Le 19/11/2015 11:36, Milla Von Weiss a écrit :
> I have looked into *neko.mod.h*:
>
> typedef struct _neko_module {
> void *jit;
> unsigned int nglobals;
> unsigned int nfields;
> unsigned int codesize;
> value name;
> value *globals;
> value *fields;
> value loader;
> value exports;
> value dbgtbl;
> neko_debug *dbgidxs;
> int_val *code;
> value jit_gc;
> } neko_module;
>
> What are *globals* and *fields* pointers for?
> Can I expose some of my object to a Neko VM module by injecting the
> objects to the arrays pointed by globals or fields pointers just before
> calling neko_vm_execute()?
You cannot dynamicaly add globals to a neko module, since their unique
id is allocated at compilation.
You can however do the following:
config = $loader.loadprim("mylib@get_config",0)();
This will load the FFI function which can return a complete object
containing anything you need.
Best,
Nicolas