meta: -4, method:-3, getter: -2, setter: -1
(Type type, RealStatePtr L, ObjectTranslator translator, int meta_count, int method_count, int getter_count, int setter_count, int type_id = -1)
| 973 | |
| 974 | //meta: -4, method:-3, getter: -2, setter: -1 |
| 975 | public static void BeginObjectRegister(Type type, RealStatePtr L, ObjectTranslator translator, int meta_count, int method_count, int getter_count, |
| 976 | int setter_count, int type_id = -1) |
| 977 | { |
| 978 | if (type == null) |
| 979 | { |
| 980 | if (type_id == -1) throw new Exception("Fatal: must provide a type of type_id"); |
| 981 | LuaAPI.xlua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, type_id); |
| 982 | } |
| 983 | else |
| 984 | { |
| 985 | LuaAPI.luaL_getmetatable(L, type.FullName); |
| 986 | if (LuaAPI.lua_isnil(L, -1)) |
| 987 | { |
| 988 | LuaAPI.lua_pop(L, 1); |
| 989 | LuaAPI.luaL_newmetatable(L, type.FullName); |
| 990 | } |
| 991 | } |
| 992 | LuaAPI.lua_pushlightuserdata(L, LuaAPI.xlua_tag()); |
| 993 | LuaAPI.lua_pushnumber(L, 1); |
| 994 | LuaAPI.lua_rawset(L, -3); |
| 995 | |
| 996 | if ((type == null || !translator.HasCustomOp(type)) && type != typeof(decimal)) |
| 997 | { |
| 998 | LuaAPI.xlua_pushasciistring(L, "__gc"); |
| 999 | LuaAPI.lua_pushstdcallcfunction(L, translator.metaFunctions.GcMeta); |
| 1000 | LuaAPI.lua_rawset(L, -3); |
| 1001 | } |
| 1002 | |
| 1003 | LuaAPI.xlua_pushasciistring(L, "__tostring"); |
| 1004 | LuaAPI.lua_pushstdcallcfunction(L, translator.metaFunctions.ToStringMeta); |
| 1005 | LuaAPI.lua_rawset(L, -3); |
| 1006 | |
| 1007 | if (method_count == 0) |
| 1008 | { |
| 1009 | LuaAPI.lua_pushnil(L); |
| 1010 | } |
| 1011 | else |
| 1012 | { |
| 1013 | LuaAPI.lua_createtable(L, 0, method_count); |
| 1014 | } |
| 1015 | |
| 1016 | if (getter_count == 0) |
| 1017 | { |
| 1018 | LuaAPI.lua_pushnil(L); |
| 1019 | } |
| 1020 | else |
| 1021 | { |
| 1022 | LuaAPI.lua_createtable(L, 0, getter_count); |
| 1023 | } |
| 1024 | |
| 1025 | if (setter_count == 0) |
| 1026 | { |
| 1027 | LuaAPI.lua_pushnil(L); |
| 1028 | } |
| 1029 | else |
| 1030 | { |
| 1031 | LuaAPI.lua_createtable(L, 0, setter_count); |
| 1032 | } |
no test coverage detected