| 41 | } |
| 42 | |
| 43 | int create_cpp_class_metatable(lua_State* L) |
| 44 | { |
| 45 | lua_newtable(L); |
| 46 | |
| 47 | // mark the table with our (hopefully) unique tag |
| 48 | // that says that the user data that has this |
| 49 | // metatable is a class_rep |
| 50 | lua_pushstring(L, "__luabind_classrep"); |
| 51 | lua_pushboolean(L, 1); |
| 52 | lua_rawset(L, -3); |
| 53 | |
| 54 | lua_pushstring(L, "__gc"); |
| 55 | lua_pushcclosure( |
| 56 | L |
| 57 | , &garbage_collector_s< |
| 58 | detail::class_rep |
| 59 | >::apply |
| 60 | , 0); |
| 61 | |
| 62 | lua_rawset(L, -3); |
| 63 | |
| 64 | lua_pushstring(L, "__call"); |
| 65 | lua_pushcclosure(L, &class_rep::constructor_dispatcher, 0); |
| 66 | lua_rawset(L, -3); |
| 67 | |
| 68 | lua_pushstring(L, "__index"); |
| 69 | lua_pushcclosure(L, &class_rep::static_class_gettable, 0); |
| 70 | lua_rawset(L, -3); |
| 71 | |
| 72 | lua_pushstring(L, "__newindex"); |
| 73 | lua_pushcclosure(L, &class_rep::lua_settable_dispatcher, 0); |
| 74 | lua_rawset(L, -3); |
| 75 | |
| 76 | return detail::ref(L); |
| 77 | } |
| 78 | |
| 79 | int create_cpp_instance_metatable(lua_State* L) |
| 80 | { |
no test coverage detected