Created
December 9, 2013 16:04
-
-
Save ThePhD/7874559 to your computer and use it in GitHub Desktop.
I hate lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GC table | |
void** freshuserdata = static_cast<void**>( lua_newuserdata( state( ), sizeof( userdata ) ) ); | |
*freshuserdata = userdata; | |
lua_newtable( state( ) ); /* create metatable. */ | |
stack::push( state( ), "__gc" ); /* push key '__gc' */ | |
stack::push( state( ), destroyfunc, 0 ); /* push gc method. */ | |
lua_rawset( state( ), -3 ); /* metatable['__gc'] = userdata_gc_method */ | |
lua_setmetatable( state( ), -2 ); /* set the userdata's metatable. */ | |
// Actual function call we want | |
luaL_setfuncs(state(), funcreg, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment