I've been attempting to change the address of a Lua Closure and then use a wrapping function which requires the upvalue of the function be passed to it. The only issue is when I change the address of the function and try to move over the upvalue it fails as the closure has no allocated space for any upvalues. So the question is, is there a way to allocate space for an upvalue for a closure which has already been created? In coding this would look like
lua_pushnil(L);//For example
lua_pushcclosure(L, Function, 0);
lua_addupvalue(L, -1, 1);
lua_pushvalue(L, -2);
lua_setupvalue(L, -2, 1);
That's the kind of method I would like, I hope the arguments are self explanatory. If anyone has any ideas please let me know. I've been pondering this for a while now.