I have C++ project and I'm using duktape JS library. I need to register global function in JS and save pointer to object as closure data with this function, so I can access this pointer when function is called.
I know how to do this in lua c api:
lua_pushlightuserdata(L, this);
lua_pushcclosure(L, &someFunction, 1);
lua_setglobal(L, "someFunction");
First I'm pushing pointer as closure data, then pointer to function. I need same functionality in duktape api.
Can you show me some code with closure registration and accessing it?