| 5044 | }; |
| 5045 | |
| 5046 | static void init_db_funcs(Lua L) |
| 5047 | { |
| 5048 | db_t *db = lua_newuserdata(L, sizeof(db_t)); |
| 5049 | init_new_t(db, DBTYPES_DB); |
| 5050 | |
| 5051 | luaL_newmetatable(L, dbtypes.db); |
| 5052 | |
| 5053 | lua_pushinteger(L, CDB2__ERROR_CODE__DUP_OLD); |
| 5054 | lua_setfield(L, -2, "err_dup"); |
| 5055 | |
| 5056 | lua_pushinteger(L, CDB2ERR_VERIFY_ERROR); |
| 5057 | lua_setfield(L, -2, "err_verify"); |
| 5058 | |
| 5059 | lua_pushinteger(L, CDB2ERR_FKEY_VIOLATION); |
| 5060 | lua_setfield(L, -2, "err_fkey"); |
| 5061 | |
| 5062 | lua_pushinteger(L, CDB2ERR_NULL_CONSTRAINT); |
| 5063 | lua_setfield(L, -2, "err_null_constraint"); |
| 5064 | |
| 5065 | lua_pushinteger(L, CDB2ERR_CONSTRAINTS); |
| 5066 | lua_setfield(L, -2, "err_selectv"); |
| 5067 | |
| 5068 | lua_pushinteger(L, CDB2ERR_CONV_FAIL); |
| 5069 | lua_setfield(L, -2, "err_conv"); |
| 5070 | |
| 5071 | lua_pushinteger(L, CDB2ERR_CHECK_CONSTRAINT); |
| 5072 | lua_setfield(L, -2, "err_check_constraint"); |
| 5073 | |
| 5074 | lua_pushstring(L, "__index"); |
| 5075 | lua_pushvalue(L, -2); |
| 5076 | lua_settable(L, -3); // db.metatable.__index = db.metatable |
| 5077 | luaL_openlib(L, NULL, db_funcs, 0); |
| 5078 | |
| 5079 | lua_setmetatable(L, -2); |
| 5080 | lua_setglobal(L, "db"); |
| 5081 | } |
| 5082 | |
| 5083 | static void init_dbtable_funcs(Lua L) |
| 5084 | { |
no test coverage detected