c++ - How I get the cdata out in c function with variable arguments using luajit? -
here code. aim print messages. in printc, e...but arrives cdata. how can unpack or circumvent that?
extern "c" { static int printc ( lua_state *l ) { // not work cdata //executor* e = ( executor* ) lual_checkudata(l, 1, "cdata"); n //lual_checkudata(l, 1, "void *"); if ( e->writelog ) { int no = lua_gettop ( l ) ; ( int = 2; <= no; i++ ) { cout << lua_tostring (l,i); } } return 1; } }
// initialised lua_pushcfunction ( l, printc ); lua_setglobal ( l, "printc" ); lua_pushinteger ( l, ( long ) ); // in class executor lua_setglobal ( l, "p" );
p= ffi.cast("void *",p) function print() return printc(p) end
you can't. lua c api , luajit ffi deliberately separated , cannot interact.
rewrite printc
in lua using ffi, or write lua c api bindings library you're using p
with. i.e. use 1 or other.
Comments
Post a Comment