cpp2ffi.lua: remove explicit keyword, get template_type from parser.templates instead of string substitution (solves issues #140 and #141)

This commit is contained in:
Victor Bombi
2020-06-30 09:39:48 +02:00
parent 92a029f678
commit 4645c082fa

View File

@@ -430,6 +430,7 @@ local function parseFunction(self,stname,lineorig,namespace,locat)
line = line:gsub("static","") line = line:gsub("static","")
line = line:gsub("inline","") line = line:gsub("inline","")
line = line:gsub("mutable","") line = line:gsub("mutable","")
line = line:gsub("explicit","")
--skip operator --skip operator
if line:match("operator") then return end if line:match("operator") then return end
--skip template --skip template
@@ -1075,19 +1076,22 @@ function M.Parser()
else else
--split type name1,name2; in several lines --split type name1,name2; in several lines
local typen,rest = line:match("%s*([^,]+)%s(%S+[,;])") local typen,rest = line:match("%s*([^,]+)%s(%S+[,;])")
--local template_type = typen:match("/%*<(.+)>%*/")
--if template_type then typen = typen:match("(.+)/%*") end
if not typen then -- Lets try Type*name if not typen then -- Lets try Type*name
typen,rest = line:match("([^,]+%*)(%S+[,;])") typen,rest = line:match("([^,]+%*)(%S+[,;])")
end end
local template_type local template_type
for k,v in pairs(self.templates) do for k,v in pairs(self.templates) do
template_type = typen:match(k.."_(.+)") local template_type2 = typen:match(k.."_(.+)")
if template_type then break end if template_type2 then
end for k1,k2 in pairs(v) do
if template_type then if template_type2==k2 then
template_type = template_type:gsub("_"," ") template_type=k1
template_type = template_type:gsub("Ptr","%*") break
end
end
assert(template_type)
break
end
end end
for name in rest:gmatch("([^%s,;]+)%s?[,;]") do for name in rest:gmatch("([^%s,;]+)%s?[,;]") do
--unnamed unions --unnamed unions