refactor(ui): use "ui_client" instead of "redraw" as general prefix

This commit is contained in:
bfredl
2022-03-13 14:57:57 +01:00
parent 534edce3c4
commit ca23f2ed30
6 changed files with 40 additions and 44 deletions

View File

@@ -10,9 +10,9 @@ local call_output = io.open(arg[4], 'wb')
local remote_output = io.open(arg[5], 'wb')
local bridge_output = io.open(arg[6], 'wb')
local metadata_output = io.open(arg[7], 'wb')
local redraw_output = io.open(arg[8], 'wb')
local client_output = io.open(arg[8], 'wb')
c_grammar = require('generators.c_grammar')
local c_grammar = require('generators.c_grammar')
local events = c_grammar.grammar:match(input:read('*all'))
local function write_signature(output, ev, prefix, notype)
@@ -51,7 +51,7 @@ local function write_arglist(output, ev, need_copy)
end
end
function extract_and_write_arglist(output, ev)
local function extract_and_write_arglist(output, ev)
local hlattrs_args_count = 0
for j = 1, #ev.parameters do
local param = ev.parameters[j]
@@ -59,7 +59,7 @@ function extract_and_write_arglist(output, ev)
output:write(' '..kind..' arg_'..j..' = ')
if kind == 'HlAttrs' then
-- The first HlAttrs argument is rgb_attrs and second is cterm_attrs
output:write('redraw_dict2hlattrs(args.items['..(j-1)..'].data.dictionary, '..(hlattrs_args_count == 0 and 'true' or 'false')..');\n')
output:write('ui_client_dict2hlattrs(args.items['..(j-1)..'].data.dictionary, '..(hlattrs_args_count == 0 and 'true' or 'false')..');\n')
hlattrs_args_count = hlattrs_args_count + 1
elseif kind == 'Object' then
output:write('args.items['..(j-1)..'];\n')
@@ -69,7 +69,7 @@ function extract_and_write_arglist(output, ev)
end
end
function call_ui_event_method(output, ev)
local function call_ui_event_method(output, ev)
output:write(' ui_call_'..ev.name..'(')
for j = 1, #ev.parameters do
output:write('arg_'..j)
@@ -192,16 +192,16 @@ for i = 1, #events do
end
if (not ev.remote_only) and (not ev.noexport) and (not ev.client_impl) then
redraw_output:write('void ui_redraw_event_'..ev.name..'(Array args)\n{\n')
extract_and_write_arglist(redraw_output, ev)
call_ui_event_method(redraw_output, ev)
redraw_output:write('}\n\n')
client_output:write('void ui_client_event_'..ev.name..'(Array args)\n{\n')
extract_and_write_arglist(client_output, ev)
call_ui_event_method(client_output, ev)
client_output:write('}\n\n')
end
end
-- Generate the map_init method for redraw handlers
redraw_output:write([[
void redraw_methods_table_init(void)
-- Generate the map_init method for client handlers
client_output:write([[
void ui_client_methods_table_init(void)
{
]])
@@ -209,19 +209,19 @@ void redraw_methods_table_init(void)
for i = 1, #events do
local fn = events[i]
if (not fn.noexport) and ((not fn.remote_only) or fn.client_impl) then
redraw_output:write(' add_redraw_event_handler('..
client_output:write(' add_ui_client_event_handler('..
'(String) {.data = "'..fn.name..'", '..
'.size = sizeof("'..fn.name..'") - 1}, '..
'(ApiRedrawWrapper) ui_redraw_event_'..fn.name..');\n')
'(UIClientHandler) ui_client_event_'..fn.name..');\n')
end
end
redraw_output:write('\n}\n\n')
client_output:write('\n}\n\n')
proto_output:close()
call_output:close()
remote_output:close()
redraw_output:close()
client_output:close()
-- don't expose internal attributes like "impl_name" in public metadata
local exported_attributes = {'name', 'parameters',