Merge pull request 'Properly name the functions record parameters (#56)' (#71) from feat/#56 into master

Reviewed-on: #71
This commit is contained in:
Aire-One 2023-01-08 18:00:15 +01:00
commit 00fa0dce30
1 changed files with 18 additions and 0 deletions

View File

@ -1,6 +1,8 @@
local List = require "pl.List" local List = require "pl.List"
local Map = require "pl.Map"
local Type_Info = require "entity.Type_Info" local Type_Info = require "entity.Type_Info"
local Variable_Info = require "entity.Variable_Info" local Variable_Info = require "entity.Variable_Info"
local utils = require "utils"
local record Function_Info local record Function_Info
metamethod __call: function( metamethod __call: function(
@ -28,6 +30,21 @@ local function fixup_parameters(self: Function_Info)
end end
end end
local function fixup_record_parameter(self: Function_Info)
for p in self.parameters:iter() do
for t in p.types:iter() do
if t.record_entries and
(t.record_entries as Map<string, any>):len() > 0 then
t.name = string.format(
"%s_%s",
utils.capitalize(self.name),
utils.capitalize(t.name)
)
end
end
end
end
local function fixup_return_types(self: Function_Info) local function fixup_return_types(self: Function_Info)
for r in self.return_types:iter() do for r in self.return_types:iter() do
r:fixup() r:fixup()
@ -65,6 +82,7 @@ local __Function_Info: metatable<Function_Info> = {
fixup = function(self: Function_Info) fixup = function(self: Function_Info)
fixup_parameters(self) fixup_parameters(self)
fixup_record_parameter(self)
fixup_return_types(self) fixup_return_types(self)
fixup_signal_type(self) fixup_signal_type(self)
end, end,