MCPcopy Create free account
hub / github.com/SOUI2/soui / class_add

Function class_add

components/ScriptModule-LUA/lua_tinker/lua_tinker.h:785–810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

783 // class init
784 template<typename T>
785 void class_add(lua_State* L, const char* name)
786 {
787 // 通过类名设置类table
788 // 如果该类没有注册,在lua中是获取不到类信息的
789 class_name<T>::name(name);
790
791 lua_newtable(L);
792
793 lua_pushstring(L, "__name");
794 lua_pushstring(L, name);
795 lua_rawset(L, -3);
796
797 lua_pushstring(L, "__index");
798 lua_pushcclosure(L, meta_get, 0);
799 lua_rawset(L, -3);
800
801 lua_pushstring(L, "__newindex");
802 lua_pushcclosure(L, meta_set, 0);
803 lua_rawset(L, -3);
804
805 lua_pushstring(L, "__gc");
806 lua_pushcclosure(L, destroyer<T>, 0);
807 lua_rawset(L, -3);
808
809 lua_setglobal(L, name);
810 }
811
812 // Tinker Class Inheritence
813 template<typename T, typename P>

Callers

nothing calls this directly

Calls 5

nameFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawsetFunction · 0.85
lua_pushcclosureFunction · 0.85
lua_setglobalFunction · 0.85

Tested by

no test coverage detected