meta refactorings
This commit is contained in:
@@ -3,7 +3,7 @@ void mt_app(ma_arena_t *arena) {
|
||||
sb8_t *c = sb8_serial_begin(arena);
|
||||
|
||||
|
||||
ast_t *keys = parse_table(arena, __FILE__, S8_CODE(
|
||||
ast_t *keys = mt_table_parse(arena, __FILE__, S8_CODE(
|
||||
// javascript filter out
|
||||
| name | js1 | js2 | jf | windows1 | windows2 |
|
||||
| null | XXX | XXX | 1 | XXX | XXX |
|
||||
@@ -76,14 +76,14 @@ void mt_app(ma_arena_t *arena) {
|
||||
| page_up | PageUp | XXX | 1 | VK_INSERT | XXX |
|
||||
| page_down | PageDown | XXX | 1 | VK_PRIOR | XXX |
|
||||
));
|
||||
sb8_serial_table_enum(c, h, keys, s8_lit("app_key"));
|
||||
mt_table_serial(c, h, keys, s8_lit("app_key"));
|
||||
|
||||
// Javascript
|
||||
{
|
||||
i32 name_idx = row_findi(keys->first, "name");
|
||||
i32 js1_idx = row_findi(keys->first, "js1");
|
||||
i32 js2_idx = row_findi(keys->first, "js2");
|
||||
i32 filter_out_idx = row_findi(keys->first, "jf");
|
||||
i32 name_idx = mt_table_find_rowi(keys->first, "name");
|
||||
i32 js1_idx = mt_table_find_rowi(keys->first, "js1");
|
||||
i32 js2_idx = mt_table_find_rowi(keys->first, "js2");
|
||||
i32 filter_out_idx = mt_table_find_rowi(keys->first, "jf");
|
||||
|
||||
|
||||
sb8_stmtf(c, "\n#if PLATFORM_WASM");
|
||||
@@ -92,11 +92,11 @@ void mt_app(ma_arena_t *arena) {
|
||||
c->indent += 1;
|
||||
sb8_stmtf(c, "if (0) {}");
|
||||
for (ast_t *row = keys->first->next; row; row = row->next) {
|
||||
s8_t name = row_geti(row, name_idx)->string;
|
||||
i64 filter_out = row_geti(row, filter_out_idx)->integer;
|
||||
s8_t name = mt_table_get_rowi(row, name_idx)->string;
|
||||
i64 filter_out = mt_table_get_rowi(row, filter_out_idx)->integer;
|
||||
assert(filter_out == 0 || filter_out == 1);
|
||||
|
||||
s8_t js[] = {row_geti(row, js1_idx)->string, row_geti(row, js2_idx)->string};
|
||||
s8_t js[] = {mt_table_get_rowi(row, js1_idx)->string, mt_table_get_rowi(row, js2_idx)->string};
|
||||
for (i32 i = 0; i < lengthof(js); i += 1) {
|
||||
if (s8_are_equal(js[i], s8_lit("XXX"))) continue;
|
||||
sb8_stmtf(c, "else if (s8_are_equal_ex(key, s8_lit(\"%S\"), s8_ignore_case)) return (wasm_key_map_t){app_key_%S, %d};", js[i], name, (i32)filter_out);
|
||||
@@ -110,9 +110,9 @@ void mt_app(ma_arena_t *arena) {
|
||||
|
||||
// Windows
|
||||
{
|
||||
i32 name_idx = row_findi(keys->first, "name");
|
||||
i32 w1i = row_findi(keys->first, "windows1");
|
||||
i32 w2i = row_findi(keys->first, "windows2");
|
||||
i32 name_idx = mt_table_find_rowi(keys->first, "name");
|
||||
i32 w1i = mt_table_find_rowi(keys->first, "windows1");
|
||||
i32 w2i = mt_table_find_rowi(keys->first, "windows2");
|
||||
|
||||
sb8_stmtf(c, "\n#if PLATFORM_WINDOWS");
|
||||
sb8_stmtf(c, "app_key_t w32_map_wparam_to_app_key(WPARAM wparam) {");
|
||||
@@ -120,8 +120,8 @@ void mt_app(ma_arena_t *arena) {
|
||||
sb8_stmtf(c, "switch(wparam) {");
|
||||
c->indent += 1;
|
||||
for (ast_t *row = keys->first->next; row; row = row->next) {
|
||||
s8_t name = row_geti(row, name_idx)->string;
|
||||
s8_t w[] = {row_geti(row, w1i)->string, row_geti(row, w2i)->string};
|
||||
s8_t name = mt_table_get_rowi(row, name_idx)->string;
|
||||
s8_t w[] = {mt_table_get_rowi(row, w1i)->string, mt_table_get_rowi(row, w2i)->string};
|
||||
for (i32 i = 0; i < lengthof(w); i += 1) {
|
||||
if (s8_are_equal(w[i], s8_lit("XXX"))) continue;
|
||||
sb8_stmtf(c, "case %S: return app_key_%S; break;", w[i], name);
|
||||
@@ -136,7 +136,7 @@ void mt_app(ma_arena_t *arena) {
|
||||
}
|
||||
|
||||
{
|
||||
ast_t *decls = parse_decls(arena, __FILE__, S8_CODE(
|
||||
ast_t *decls = mt_parse_decls(arena, __FILE__, S8_CODE(
|
||||
typedef enum {
|
||||
app_mouse_button_null,
|
||||
app_mouse_button_left,
|
||||
@@ -195,10 +195,10 @@ void mt_app(ma_arena_t *arena) {
|
||||
};
|
||||
));
|
||||
|
||||
sb8_serial_ast_to_code(h, decls);
|
||||
sb8_serial_ast_to_type_info(c, decls);
|
||||
mt_serialb_ast_to_code(h, decls);
|
||||
mt_serialb_ast_to_type_info(c, decls);
|
||||
}
|
||||
|
||||
os_write_file(cg_cpath(arena), sb8_serial_end(arena, c));
|
||||
os_write_file(cg_hpath(arena), sb8_serial_end(arena, h));
|
||||
os_write_file(mt_cpath(arena), sb8_serial_end(arena, c));
|
||||
os_write_file(mt_hpath(arena), sb8_serial_end(arena, h));
|
||||
}
|
||||
Reference in New Issue
Block a user