Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern(C) int methodWrapper(T, Class)(lua_State* L)
- {
- ParameterTypeTuple!T args;
- //Check arguments
- int top = lua_gettop(L);
- if(top < args.length + 1)
- argsError(L, top, args.length + 1);
- //Assemble method
- T func;
- func.ptr = *cast(void**)luaL_checkudata(L, 1, toStringz(Class.mangleof));
- func.funcptr = cast(typeof(func.funcptr))lua_touserdata(L, lua_upvalueindex(1));
- //Assemble arguments
- foreach(i, arg; args)
- {
- //stack indexes start at 1, index 1 is the 'this' reference
- args[i] = getValue!(typeof(arg), typeMismatch)(L, i + 2);
- }
- return callFunction!T(L, func, args);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement