Skip to content

Commit 1e23fd8

Browse files
committed
Make boolean arguments optional
1 parent 015fd1c commit 1e23fd8

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

lib/cpp.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CPP
3131
'ulong' => 'number',
3232
'ptr-string' => 'DFPointer<string>',
3333
'static-string' => 'string',
34-
'stl-string' => 'string',
34+
'stl-string' => 'string'
3535
# 'stl-bit-vector' => 'boolean',
3636
# 'df-flagarray' => 'boolean',
3737
# 'stl-function' => 'function',
@@ -45,7 +45,9 @@ class CPP
4545
class << self
4646
def parse_type(string)
4747
return TYPE_MAP[string] if TYPE_MAP[string]
48-
return string.gsub(/df::/, '') if string =~ /df::/
48+
49+
string = string.gsub(/df::/, '') if string
50+
string = string.gsub(/std::vector/, 'DFVector') if string
4951

5052
string
5153
end

lib/generate.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ def parse_cpp_modules(files)
6161
type, name = argument.split(' ')
6262
type = DFHackLuaDefinitions::CPP.parse_type(type)
6363

64-
{
65-
name: DFHackLuaDefinitions::LuaLS.safe_name(DFHackLuaDefinitions::CPP.sanitize(name)),
66-
type: type == 'boolean' ? 'boolean|nil' : type
67-
}
68-
end
64+
if name == 'out'
65+
nil
66+
else
67+
{
68+
name: DFHackLuaDefinitions::LuaLS.safe_name(DFHackLuaDefinitions::CPP.sanitize(name)),
69+
type: type == 'boolean' ? 'boolean|nil' : type
70+
}
71+
end
72+
end&.compact
6973

7074
arguments&.each do |argument|
71-
output << "---@param #{argument[:name]} #{argument[:type]} \n"
75+
output << "---@param #{argument[:name]} #{argument[:type]}\n"
7276
end
7377
output << "---@return #{return_type.gsub(/const|[*&]/, '')}\n" if return_type
7478
output << "function #{prefix}#{module_name}.#{function_name}("

0 commit comments

Comments
 (0)