diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/legacy2luatest.pl | 16 | ||||
-rw-r--r-- | scripts/msgpack-gen.lua | 15 |
2 files changed, 17 insertions, 14 deletions
diff --git a/scripts/legacy2luatest.pl b/scripts/legacy2luatest.pl index 51997c037b..1a3f54146e 100755 --- a/scripts/legacy2luatest.pl +++ b/scripts/legacy2luatest.pl @@ -42,15 +42,8 @@ sub read_in_file { my $command_lines = $_[1]; my $test_body_lines = $_[2]; - # Only keep first input line if it is not empty. - my $first_input_line = shift @{$input_lines}; - if ($first_input_line =~ /^$/) { - unshift @{$input_lines}, $first_input_line; - } - - # If there are input lines left, wrap them with - # `insert` command and add before the previous command - # block. + # If there are input lines, wrap with an `insert` + # command and add before the previous command block. if (@{$input_lines}) { my $last_input_line = pop @{$input_lines}; unshift @{$command_lines}, ''; @@ -168,7 +161,10 @@ sub read_in_file { return EMIT_COMMAND; } - push @input_lines, ' ' . $_; + # Skip initial lines if they are empty. + if (@input_lines or !/^$/) { + push @input_lines, ' ' . $_; + } return EMIT_INPUT; }, ); diff --git a/scripts/msgpack-gen.lua b/scripts/msgpack-gen.lua index 9ff9b4cf6f..bb37ae94da 100644 --- a/scripts/msgpack-gen.lua +++ b/scripts/msgpack-gen.lua @@ -183,13 +183,20 @@ for i = 1, #functions do local converted, convert_arg, param, arg param = fn.parameters[j] converted = 'arg_'..j - if real_type(param[1]) ~= 'Object' then - output:write('\n if (args.items['..(j - 1)..'].type != kObjectType'..real_type(param[1])..') {') + local rt = real_type(param[1]) + if rt ~= 'Object' then + output:write('\n if (args.items['..(j - 1)..'].type == kObjectType'..rt..') {') + output:write('\n '..converted..' = args.items['..(j - 1)..'].data.'..rt:lower()..';') + if rt:match('^Buffer$') or rt:match('^Window$') or rt:match('^Tabpage$') or rt:match('^Boolean$') then + -- accept positive integers for Buffers, Windows and Tabpages + output:write('\n } else if (args.items['..(j - 1)..'].type == kObjectTypeInteger && args.items['..(j - 1)..'].data.integer > 0) {') + output:write('\n '..converted..' = (unsigned)args.items['..(j - 1)..'].data.integer;') + end + output:write('\n } else {') output:write('\n snprintf(error->msg, sizeof(error->msg), "Wrong type for argument '..j..', expecting '..param[1]..'");') output:write('\n error->set = true;') output:write('\n goto cleanup;') - output:write('\n }') - output:write('\n '..converted..' = args.items['..(j - 1)..'].data.'..real_type(param[1]):lower()..';\n') + output:write('\n }\n') else output:write('\n '..converted..' = args.items['..(j - 1)..'];\n') end |