Generate lua function table
This commit is contained in:
@@ -457,10 +457,39 @@ void GenerateConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateLuaApi() {
|
||||
MA_Scratch scratch;
|
||||
S8_String file = OS_ReadFile(scratch, "../src/text_editor/lua_api.cpp");
|
||||
S8_List list = S8_Split(scratch, file, "\n");
|
||||
|
||||
S8_List funcs = {};
|
||||
for (S8_Node *it = list.first; it; it = it->next) {
|
||||
S8_String s = S8_Trim(it->string);
|
||||
if (S8_StartsWith(s, "int Lua_")) {
|
||||
s = S8_Skip(s, 4);
|
||||
S8_Seek(s, "(", 0, &s.len);
|
||||
S8_Add(scratch, &funcs, s);
|
||||
}
|
||||
}
|
||||
|
||||
S8_List sb = {};
|
||||
S8_AddF(scratch, &sb, "luaL_Reg LuaFunctions[] = {\n");
|
||||
for (S8_Node *it = funcs.first; it; it = it->next) {
|
||||
S8_String lua_name = S8_Skip(it->string, 4);
|
||||
S8_AddF(scratch, &sb, " {\"%.*s\", %.*s},\n", S8_Expand(lua_name), S8_Expand(it->string));
|
||||
}
|
||||
S8_AddF(scratch, &sb, " {NULL, NULL},\n");
|
||||
S8_AddF(scratch, &sb, "};\n");
|
||||
|
||||
S8_String output = S8_Merge(scratch, sb);
|
||||
OS_WriteFile("../src/text_editor/lua_api_generated.cpp", output);
|
||||
}
|
||||
|
||||
int main() {
|
||||
MA_InitScratch();
|
||||
SRC_InitCache(Perm, "te.cache");
|
||||
|
||||
GenerateLuaApi();
|
||||
GenerateConfig();
|
||||
int result = CompileTextEditor();
|
||||
// int result = CompileNewPlatform();
|
||||
|
||||
Reference in New Issue
Block a user