Skip to content
Snippets Groups Projects
Commit ace479ee authored by Luigi Scarso's avatar Luigi Scarso
Browse files

a patch for require luaharfbuzz with luajit (LS)

parent b74dbc36
Branches
Tags
No related merge requests found
......@@ -13,13 +13,19 @@ int register_class(lua_State *L, const char *name, const luaL_Reg *methods, cons
constants++;
}
}
#ifdef LuajitTeX
luaL_register(L,NULL,methods);
#else
luaL_setfuncs(L, methods, 0);
#endif
lua_pop(L, 1);
lua_newtable(L);
#ifdef LuajitTeX
luaL_register(L,NULL,functions);
#else
luaL_setfuncs(L, functions, 0);
#endif
luaL_getmetatable(L, name);
lua_setmetatable(L, -2);
return 1;
......
......@@ -97,7 +97,24 @@ int luaopen_luaharfbuzz (lua_State *L) {
register_unicode(L);
lua_setfield(L, -2, "unicode");
#ifdef LuajitTeX
/* TODO: we usually dont use require, the module */
/* is already in global space */
luaL_register(L,NULL, lib_table);
/**/
lua_pushvalue(L, -1);
lua_setglobal(L,"luaharfbuzz");
/**/
lua_getglobal(L, "package");
lua_getfield(L, -1, "loaded");
lua_remove(L, -2);
lua_pushvalue(L, -2);
lua_setfield(L, -2, "luaharfbuzz");
/**/
#else
luaL_setfuncs(L, lib_table, 0);
#endif
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment