feat: replace wrenAllocateForeign with wrenSetSlotNewForeign supporting arbitrary slot and class selection
The old wrenAllocateForeign was limited to slot 0 and the class at the top of the API stack. The new wrenSetSlotNewForeign takes explicit slot and classSlot parameters, allowing foreign objects to be created in any slot from any class. All internal and test call sites updated to use the new API.
This commit is contained in:
@@ -12,7 +12,7 @@ static void apiFinalized(WrenVM* vm)
|
||||
|
||||
static void counterAllocate(WrenVM* vm)
|
||||
{
|
||||
double* value = (double*)wrenAllocateForeign(vm, sizeof(double));
|
||||
double* value = (double*)wrenSetSlotNewForeign(vm, 0, 0, sizeof(double));
|
||||
*value = 0;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ static void counterValue(WrenVM* vm)
|
||||
|
||||
static void pointAllocate(WrenVM* vm)
|
||||
{
|
||||
double* coordinates = (double*)wrenAllocateForeign(vm, sizeof(double[3]));
|
||||
double* coordinates = (double*)wrenSetSlotNewForeign(vm, 0, 0, sizeof(double[3]));
|
||||
|
||||
// This gets called by both constructors, so sniff the slot count to see
|
||||
// which one was invoked.
|
||||
@@ -69,7 +69,7 @@ static void pointToString(WrenVM* vm)
|
||||
|
||||
static void resourceAllocate(WrenVM* vm)
|
||||
{
|
||||
int* value = (int*)wrenAllocateForeign(vm, sizeof(int));
|
||||
int* value = (int*)wrenSetSlotNewForeign(vm, 0, 0, sizeof(int));
|
||||
*value = 123;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user