其中 metatable =“Obj”,但得到了“OtherType”intcreate_table_with_object(lua_State *L){lua_newtable(L);lua_pushlightuserdata(L, (void*)0x1234);luaL_setmetatable(L,"Obj");//此类型已使用lua_newmetatable()进行注册lua_setfield(L,-2,"obj");luaL_newmetatable(...
Complex *z = (Complex*) lua_newuserdata(L,sizeof(Complex));luaL_setmetatable(L,"complex");switch(op) {caseARRAY_OP_ADD: *z = v + w;break;caseARRAY_OP_SUB: *z = v - w;break;caseARRAY_OP_MUL: *z = v * w;break;caseARRAY_OP_DIV: *z = v / w;break;caseARRAY_OP_POW: ...
Complex *z = (Complex*) lua_newuserdata(L,sizeof(Complex));luaL_setmetatable(L,"complex");switch(op) {caseARRAY_OP_ADD: *z = v + w;break;caseARRAY_OP_SUB: *z = v - w;break;caseARRAY_OP_MUL: *z = v * w;break;caseARRAY_OP_DIV: *z = v / w;break;caseARRAY_OP_POW: ...