]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/lua/location.h
lua: Add a Network object
[people/ms/libloc.git] / src / lua / location.h
index 6eef1a6769c5aea59350a7d6338d66646fc824a2..cc261e61e53c924eadb9b808c979d85b174b9327 100644 (file)
@@ -25,4 +25,19 @@ extern struct loc_ctx* ctx;
 
 int luaopen_location(lua_State* L);
 
+static inline int register_class(lua_State* L,
+               const char* name, const struct luaL_Reg* functions) {
+       // Create a new metatable
+       luaL_newmetatable(L, name);
+
+       // Set functions
+       luaL_setfuncs(L, functions, 0);
+
+       // Configure metatable
+       lua_pushvalue(L, -1);
+       lua_setfield(L, -2, "__index");
+
+       return 1;
+}
+
 #endif /* LUA_LOCATION_LOCATION_H */