+/* Taking that definition from lua 5.1 source */
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502
+int luaL_typerror(lua_State *L, int narg, const char *tname)
+{
+ const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, luaL_typename(L, narg));
+ return luaL_argerror(L, narg, msg);
+}
+
+# define LUA_register_meta(L, meta) luaL_setfuncs(L, meta, 0);
+# define LUA_register_global(L, string, func) \
+ lua_newtable(L); \
+ luaL_setfuncs(L, func, 0); \
+ lua_pushvalue(L, -1); \
+ lua_setglobal(L, string)
+#else
+# define LUA_register_meta(L, meta) luaL_register(L, NULL, meta)
+# define LUA_register_global(L, string, func) luaL_register(L, string, func)
+#endif
+