feat: convert Stat from Wren class with list fields to foreign class with native C accessors
Replace the Wren-implemented Stat class that stored stat fields in a list with a foreign class backed by the raw uv_fs_stat struct, enabling direct C-level access to stat data for future methods like isDirectory() using S_ISDIR().
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