| 108 | } |
| 109 | |
| 110 | LUABIND_API void open(lua_State* L) |
| 111 | { |
| 112 | bool is_main_thread = lua_pushthread(L) == 1; |
| 113 | lua_pop(L, 1); |
| 114 | |
| 115 | if (!is_main_thread) |
| 116 | { |
| 117 | throw std::runtime_error( |
| 118 | "luabind::open() must be called with the main thread " |
| 119 | "lua_State*" |
| 120 | ); |
| 121 | } |
| 122 | |
| 123 | push_gc_udata<detail::class_registry>(L, &detail::classes_tag, L); |
| 124 | push_gc_udata<detail::class_id_map>(L, &detail::classid_map_tag); |
| 125 | push_gc_udata<detail::cast_graph>(L, &detail::cast_graph_tag); |
| 126 | push_gc_udata<detail::class_map>(L, &detail::class_map_tag); |
| 127 | |
| 128 | // add functions (class, cast etc...) |
| 129 | lua_pushcfunction(L, detail::create_class::stage1); |
| 130 | lua_setglobal(L, "class"); |
| 131 | |
| 132 | lua_pushcfunction(L, &make_property); |
| 133 | lua_setglobal(L, "property"); |
| 134 | |
| 135 | lua_pushlightuserdata(L, &main_thread_tag); |
| 136 | lua_pushlightuserdata(L, L); |
| 137 | lua_rawset(L, LUA_REGISTRYINDEX); |
| 138 | |
| 139 | lua_pushcfunction(L, &deprecated_super); |
| 140 | lua_setglobal(L, "super"); |
| 141 | } |
| 142 | |
| 143 | } // namespace luabind |
no test coverage detected