Make Stat a foreign class.
Instead of copying the uv_fs_stat struct to a list of Wren numbers, we store it directly in the Stat object. This is important because we'll need to implement later methods like isDirectory() in C so we can use S_ISDIR(). For that, we need to have access to the original stat data.
This commit is contained in:
+9
-8
@@ -612,18 +612,19 @@ static void bindForeignClass(WrenVM* vm, ObjClass* classObj, ObjModule* module)
|
||||
|
||||
Method method;
|
||||
method.type = METHOD_FOREIGN;
|
||||
method.fn.foreign = methods.allocate;
|
||||
|
||||
ASSERT(method.fn.foreign != NULL,
|
||||
"A foreign class must provide an allocate function.");
|
||||
|
||||
int symbol = wrenSymbolTableEnsure(vm, &vm->methodNames, "<allocate>", 10);
|
||||
wrenBindMethod(vm, classObj, symbol, method);
|
||||
|
||||
// Add the symbol even if there is no finalizer so we can ensure that the
|
||||
// symbol itself is always in the symbol table.
|
||||
int symbol = wrenSymbolTableEnsure(vm, &vm->methodNames, "<allocate>", 10);
|
||||
if (methods.allocate != NULL)
|
||||
{
|
||||
method.fn.foreign = methods.allocate;
|
||||
wrenBindMethod(vm, classObj, symbol, method);
|
||||
}
|
||||
|
||||
// Add the symbol even if there is no finalizer so we can ensure that the
|
||||
// symbol itself is always in the symbol table.
|
||||
symbol = wrenSymbolTableEnsure(vm, &vm->methodNames, "<finalize>", 10);
|
||||
|
||||
if (methods.finalize != NULL)
|
||||
{
|
||||
method.fn.foreign = (WrenForeignMethodFn)methods.finalize;
|
||||
|
||||
Reference in New Issue
Block a user