janko metelko a écrit :
I looked into how lua does this what I am seeking for in neko...
its somewhat equivalent to this (lua_register)
>>
------C
static int alert_glue(lua_State *L) { .... }
lua_register(L, "alert", alert_glue);
-----LUA
return alert(double(1))
Hi Janko,
The Neko model is a bit more abstract. Your haxe/Neko program can load C
primitives through a "loader" object ($loader in Neko,
neko.vm.Loader.current() in haXe).
The default implementation looks for the primitive by using the
[EMAIL PROTECTED] format, and load the corresponding .ndll file. You can
change this behavior by creating a custom loader in C : you just need to
create an object that have the loadprim and loadmodule methods.
That's what xCross is doing, it creates a default loader then replace
its "loadprim" implementation with its own :
value l = neko_default_loader(argv,argc);
alloc_field(l,val_id("loadprim"),alloc_function(loadprim,2,"loadprim"));
primitives needs to be allocated by using the "alloc_function" neko api
method, for example :
value p = alloc_function(my_c_function,3,"my_c_function");
Hope that helps,
Nicolas
--
Neko : One VM to run them all
(http://nekovm.org)