MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / register_

Method register_

ogsr_engine/Luabind/src/class.cpp:90–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 }
89
90 void class_registration::register_(lua_State* L) const
91 {
92 LUABIND_CHECK_STACK(L);
93
94 assert(lua_type(L, -1) == LUA_TTABLE);
95
96 lua_pushstring(L, m_name);
97
98 detail::class_rep* crep;
99
100 detail::class_registry* r = detail::class_registry::get_registry(L);
101 // create a class_rep structure for this class.
102 // allocate it within lua to let lua collect it on
103 // lua_close(). This is better than allocating it
104 // as a static, since it will then be destructed
105 // when the program exits instead.
106 // warning: we assume that lua will not
107 // move the userdata memory.
108 lua_newuserdata(L, sizeof(detail::class_rep));
109 crep = reinterpret_cast<detail::class_rep*>(lua_touserdata(L, -1));
110
111 new(crep) detail::class_rep(
112 m_type
113 , m_name
114 , L
115 , m_destructor
116 , m_const_holder_destructor
117 , m_holder_type
118 , m_const_holder_type
119 , m_extractor
120 , m_const_extractor
121 , m_const_converter
122 , m_construct_holder
123 , m_construct_const_holder
124 , m_default_construct_holder
125 , m_default_construct_const_holder
126 , m_adopt_fun
127 , m_holder_size
128 , m_holder_alignment);
129
130 // register this new type in the class registry
131 r->add_class(m_type, crep);
132 if (!(LUABIND_TYPE_INFO_EQUAL(m_holder_type, LUABIND_INVALID_TYPE_INFO)))
133 {
134 // if we have a held type
135 // we have to register it in the class-table
136 // but only for the base class, if it already
137 // exists, we don't have to register it
138 detail::class_rep* c = r->find_class(m_holder_type);
139 if (c == nullptr)
140 {
141 r->add_class(m_holder_type, crep);
142 r->add_class(m_const_holder_type, crep);
143 }
144 }
145
146 // constructors
147 m_constructor.swap(crep->m_constructor);

Callers

nothing calls this directly

Calls 15

get_registryFunction · 0.85
add_classMethod · 0.80
find_classMethod · 0.80
add_base_classMethod · 0.80
register_methodsMethod · 0.80
lua_typeFunction · 0.50
lua_pushstringFunction · 0.50
lua_newuserdataFunction · 0.50
lua_touserdataFunction · 0.50
lua_pushnilFunction · 0.50
lua_nextFunction · 0.50
lua_pushvalueFunction · 0.50

Tested by

no test coverage detected