mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
cpp2ffi.lua, generator ... :get manual funcs args and ret
This commit is contained in:
2
cimgui.h
2
cimgui.h
@@ -4989,7 +4989,7 @@ CIMGUI_API void igImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[2
|
|||||||
|
|
||||||
/////////////////////////hand written functions
|
/////////////////////////hand written functions
|
||||||
//no LogTextV
|
//no LogTextV
|
||||||
CIMGUI_API void igLogText(CONST char *fmt, ...);
|
CIMGUI_API void igLogText(const char *fmt, ...);
|
||||||
//no appendfV
|
//no appendfV
|
||||||
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...);
|
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...);
|
||||||
//for getting FLT_MAX in bindings
|
//for getting FLT_MAX in bindings
|
||||||
|
@@ -47,7 +47,7 @@ typedef union SDL_Event SDL_Event;
|
|||||||
|
|
||||||
/////////////////////////hand written functions
|
/////////////////////////hand written functions
|
||||||
//no LogTextV
|
//no LogTextV
|
||||||
CIMGUI_API void igLogText(CONST char *fmt, ...);
|
CIMGUI_API void igLogText(const char *fmt, ...);
|
||||||
//no appendfV
|
//no appendfV
|
||||||
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...);
|
CIMGUI_API void ImGuiTextBuffer_appendf(struct ImGuiTextBuffer *buffer, const char *fmt, ...);
|
||||||
//for getting FLT_MAX in bindings
|
//for getting FLT_MAX in bindings
|
||||||
|
@@ -673,14 +673,18 @@ local function CleanImU32(def)
|
|||||||
for i=1,#bb do res = res + bb[i] end
|
for i=1,#bb do res = res + bb[i] end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
local function moveptr(line)
|
||||||
|
line = line:gsub("%s*%*","%*")
|
||||||
|
line = line:gsub("%*([%w_])","%* %1")
|
||||||
|
line = line:gsub("(%(%*)%s","%1")
|
||||||
|
return line
|
||||||
|
end
|
||||||
local function parseFunction(self,stname,itt,namespace,locat)
|
local function parseFunction(self,stname,itt,namespace,locat)
|
||||||
|
|
||||||
local lineorig,comment = split_comment(itt.item)
|
local lineorig,comment = split_comment(itt.item)
|
||||||
line = clean_spaces(lineorig)
|
line = clean_spaces(lineorig)
|
||||||
--move *
|
--move *
|
||||||
line = line:gsub("%s*%*","%*")
|
line = moveptr(line)
|
||||||
line = line:gsub("%*([%w_])","%* %1")
|
|
||||||
line = line:gsub("(%(%*)%s","%1")
|
|
||||||
|
|
||||||
--print(line)
|
--print(line)
|
||||||
--clean implemetation
|
--clean implemetation
|
||||||
@@ -719,6 +723,21 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
|||||||
error"parseFunction not getting args"
|
error"parseFunction not getting args"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--get manuals args and ret
|
||||||
|
local cname = self.getCname(stname,funcname, namespace) --cimguiname
|
||||||
|
local manpars = self.manuals[cname]
|
||||||
|
local ismanual
|
||||||
|
if manpars then
|
||||||
|
if type(manpars) == "boolean" then
|
||||||
|
print("warning: unable to get args and ret from "..cname)
|
||||||
|
print("did you forgot to use set_manuals? ")
|
||||||
|
else
|
||||||
|
ismanual = true
|
||||||
|
args, ret = manpars.args, manpars.ret
|
||||||
|
args = moveptr(args)
|
||||||
|
ret = moveptr(ret)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local argsp = args:sub(2,-2)..","
|
local argsp = args:sub(2,-2)..","
|
||||||
local argsTa = {}
|
local argsTa = {}
|
||||||
@@ -734,6 +753,8 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
|||||||
argsTa[#argsTa+1] = tynam
|
argsTa[#argsTa+1] = tynam
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- templates in args
|
--- templates in args
|
||||||
for i,ar in ipairs(argsTa) do
|
for i,ar in ipairs(argsTa) do
|
||||||
--TODO several diferent templates
|
--TODO several diferent templates
|
||||||
@@ -747,7 +768,7 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
|||||||
end
|
end
|
||||||
argsTa[i] = te and code2 or ar --ar:gsub("<([%w_%*%s]+)>",te) --ImVector
|
argsTa[i] = te and code2 or ar --ar:gsub("<([%w_%*%s]+)>",te) --ImVector
|
||||||
end
|
end
|
||||||
|
|
||||||
--get typ, name and defaults
|
--get typ, name and defaults
|
||||||
local functype_re = "^%s*[%w%s%*]+%(%*%s*[%w_]+%)%([^%(%)]*%)"
|
local functype_re = "^%s*[%w%s%*]+%(%*%s*[%w_]+%)%([^%(%)]*%)"
|
||||||
local functype_reex = "^(%s*[%w%s%*]+)%(%*%s*([%w_]+)%)(%([^%(%)]*%))"
|
local functype_reex = "^(%s*[%w%s%*]+)%(%*%s*([%w_]+)%)(%([^%(%)]*%))"
|
||||||
@@ -807,6 +828,7 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local argsArr = argsTa2
|
local argsArr = argsTa2
|
||||||
|
|
||||||
--recreate argscsinpars, call_args and signature from argsArr
|
--recreate argscsinpars, call_args and signature from argsArr
|
||||||
@@ -838,7 +860,7 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
|||||||
caar = "()"
|
caar = "()"
|
||||||
signat = "()" .. (extraconst or "")
|
signat = "()" .. (extraconst or "")
|
||||||
end
|
end
|
||||||
|
--if ismanual then print("manual",asp, caar, signat) end
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
if not ret and stname then --must be constructors
|
if not ret and stname then --must be constructors
|
||||||
@@ -871,6 +893,9 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
|||||||
ar.default = nil
|
ar.default = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--if ismanual then M.prtable(argsArr) end
|
||||||
|
|
||||||
defT.templated = self.typenames[stname] and true
|
defT.templated = self.typenames[stname] and true
|
||||||
defT.namespace = namespace
|
defT.namespace = namespace
|
||||||
defT.cimguiname = cimguiname
|
defT.cimguiname = cimguiname
|
||||||
@@ -901,6 +926,7 @@ local function parseFunction(self,stname,itt,namespace,locat)
|
|||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
defsT[cimguiname][signat] = defT
|
defsT[cimguiname][signat] = defT
|
||||||
|
|
||||||
end
|
end
|
||||||
local function itemsCount(items)
|
local function itemsCount(items)
|
||||||
print"------------items"
|
print"------------items"
|
||||||
@@ -913,8 +939,8 @@ end
|
|||||||
|
|
||||||
local function AdjustArguments(FP)
|
local function AdjustArguments(FP)
|
||||||
for fun,defs in pairs(FP.defsT) do
|
for fun,defs in pairs(FP.defsT) do
|
||||||
--struct function but no constructors or static functions
|
--struct function but no constructors or static functions or manuals
|
||||||
if defs[1].stname~="" and defs[1].ret and not defs[1].is_static_function then
|
if defs[1].stname~="" and defs[1].ret and not defs[1].is_static_function and not defs[1].manual then
|
||||||
--print("adjusting",fun)
|
--print("adjusting",fun)
|
||||||
for i,def in ipairs(defs) do
|
for i,def in ipairs(defs) do
|
||||||
local empty = def.args:match("^%(%)") --no args
|
local empty = def.args:match("^%(%)") --no args
|
||||||
@@ -1408,6 +1434,20 @@ function M.Parser()
|
|||||||
function par:printItems()
|
function par:printItems()
|
||||||
printItems(items)
|
printItems(items)
|
||||||
end
|
end
|
||||||
|
function par:set_manuals(manuals, modulen, erase)
|
||||||
|
erase = erase or {"CIMGUI_API"}
|
||||||
|
local moddata = read_data("./"..modulen.."_template.h")
|
||||||
|
for k,v in pairs(manuals) do
|
||||||
|
local ret = moddata:match("([^%(%):,\n;]+[%*%s])%s?~?"..k.."%b()")
|
||||||
|
for i,ww in ipairs(erase) do
|
||||||
|
ret = ret:gsub(ww,"")
|
||||||
|
end
|
||||||
|
local args = moddata:match(k.."%s*(%b())")
|
||||||
|
manuals[k] = {args = args, ret = ret}
|
||||||
|
--print(k,args,ret)
|
||||||
|
end
|
||||||
|
self.manuals = manuals
|
||||||
|
end
|
||||||
par.parseFunction = parseFunction
|
par.parseFunction = parseFunction
|
||||||
local uniques = {}
|
local uniques = {}
|
||||||
local function check_unique_typedefs(l,uniques)
|
local function check_unique_typedefs(l,uniques)
|
||||||
|
@@ -318,7 +318,8 @@ local function parseImGuiHeader(header,names)
|
|||||||
return pre..funcname
|
return pre..funcname
|
||||||
end
|
end
|
||||||
parser.cname_overloads = cimgui_overloads
|
parser.cname_overloads = cimgui_overloads
|
||||||
parser.manuals = cimgui_manuals
|
--parser.manuals = cimgui_manuals
|
||||||
|
parser:set_manuals(cimgui_manuals, "cimgui")
|
||||||
parser.skipped = cimgui_skipped
|
parser.skipped = cimgui_skipped
|
||||||
parser.UDTs = {"ImVec2","ImVec4","ImColor","ImRect"}
|
parser.UDTs = {"ImVec2","ImVec4","ImColor","ImRect"}
|
||||||
--parser.gen_template_typedef = gen_template_typedef --use auto
|
--parser.gen_template_typedef = gen_template_typedef --use auto
|
||||||
|
@@ -9773,23 +9773,23 @@
|
|||||||
],
|
],
|
||||||
"ImGuiTextBuffer_appendf": [
|
"ImGuiTextBuffer_appendf": [
|
||||||
{
|
{
|
||||||
"args": "(ImGuiTextBuffer* self,const char* fmt,...)",
|
"args": "(struct ImGuiTextBuffer* buffer, const char* fmt,...)",
|
||||||
"argsT": [
|
"argsT": [
|
||||||
{
|
{
|
||||||
"name": "self",
|
"name": "buffer",
|
||||||
"type": "ImGuiTextBuffer*"
|
"type": "struct ImGuiTextBuffer*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fmt",
|
"name": "fmt",
|
||||||
"type": "const char*"
|
"type": " const char*"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "...",
|
"name": "...",
|
||||||
"type": "..."
|
"type": "..."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"argsoriginal": "(const char* fmt,...)",
|
"argsoriginal": "(struct ImGuiTextBuffer* buffer, const char* fmt, ...)",
|
||||||
"call_args": "(fmt,...)",
|
"call_args": "(buffer,fmt,...)",
|
||||||
"cimguiname": "ImGuiTextBuffer_appendf",
|
"cimguiname": "ImGuiTextBuffer_appendf",
|
||||||
"defaults": {},
|
"defaults": {},
|
||||||
"funcname": "appendf",
|
"funcname": "appendf",
|
||||||
@@ -9798,7 +9798,7 @@
|
|||||||
"manual": true,
|
"manual": true,
|
||||||
"ov_cimguiname": "ImGuiTextBuffer_appendf",
|
"ov_cimguiname": "ImGuiTextBuffer_appendf",
|
||||||
"ret": "void",
|
"ret": "void",
|
||||||
"signature": "(const char*,...)",
|
"signature": "(struct ImGuiTextBuffer*, const char*,...)",
|
||||||
"stname": "ImGuiTextBuffer"
|
"stname": "ImGuiTextBuffer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -28904,7 +28904,7 @@
|
|||||||
"type": "..."
|
"type": "..."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"argsoriginal": "(const char* fmt,...)",
|
"argsoriginal": "(const char* fmt, ...)",
|
||||||
"call_args": "(fmt,...)",
|
"call_args": "(fmt,...)",
|
||||||
"cimguiname": "igLogText",
|
"cimguiname": "igLogText",
|
||||||
"defaults": {},
|
"defaults": {},
|
||||||
|
@@ -8225,19 +8225,19 @@ defs["ImGuiTextBuffer_append"][1]["stname"] = "ImGuiTextBuffer"
|
|||||||
defs["ImGuiTextBuffer_append"]["(const char*,const char*)"] = defs["ImGuiTextBuffer_append"][1]
|
defs["ImGuiTextBuffer_append"]["(const char*,const char*)"] = defs["ImGuiTextBuffer_append"][1]
|
||||||
defs["ImGuiTextBuffer_appendf"] = {}
|
defs["ImGuiTextBuffer_appendf"] = {}
|
||||||
defs["ImGuiTextBuffer_appendf"][1] = {}
|
defs["ImGuiTextBuffer_appendf"][1] = {}
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["args"] = "(ImGuiTextBuffer* self,const char* fmt,...)"
|
defs["ImGuiTextBuffer_appendf"][1]["args"] = "(struct ImGuiTextBuffer* buffer, const char* fmt,...)"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"] = {}
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"] = {}
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][1] = {}
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][1] = {}
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][1]["name"] = "self"
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][1]["name"] = "buffer"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][1]["type"] = "ImGuiTextBuffer*"
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][1]["type"] = "struct ImGuiTextBuffer*"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][2] = {}
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][2] = {}
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][2]["name"] = "fmt"
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][2]["name"] = "fmt"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][2]["type"] = "const char*"
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][2]["type"] = " const char*"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][3] = {}
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][3] = {}
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][3]["name"] = "..."
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][3]["name"] = "..."
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsT"][3]["type"] = "..."
|
defs["ImGuiTextBuffer_appendf"][1]["argsT"][3]["type"] = "..."
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["argsoriginal"] = "(const char* fmt,...)"
|
defs["ImGuiTextBuffer_appendf"][1]["argsoriginal"] = "(struct ImGuiTextBuffer* buffer, const char* fmt, ...)"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["call_args"] = "(fmt,...)"
|
defs["ImGuiTextBuffer_appendf"][1]["call_args"] = "(buffer,fmt,...)"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["cimguiname"] = "ImGuiTextBuffer_appendf"
|
defs["ImGuiTextBuffer_appendf"][1]["cimguiname"] = "ImGuiTextBuffer_appendf"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["defaults"] = {}
|
defs["ImGuiTextBuffer_appendf"][1]["defaults"] = {}
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["funcname"] = "appendf"
|
defs["ImGuiTextBuffer_appendf"][1]["funcname"] = "appendf"
|
||||||
@@ -8246,9 +8246,9 @@ defs["ImGuiTextBuffer_appendf"][1]["location"] = "imgui:2709"
|
|||||||
defs["ImGuiTextBuffer_appendf"][1]["manual"] = true
|
defs["ImGuiTextBuffer_appendf"][1]["manual"] = true
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["ov_cimguiname"] = "ImGuiTextBuffer_appendf"
|
defs["ImGuiTextBuffer_appendf"][1]["ov_cimguiname"] = "ImGuiTextBuffer_appendf"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["ret"] = "void"
|
defs["ImGuiTextBuffer_appendf"][1]["ret"] = "void"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["signature"] = "(const char*,...)"
|
defs["ImGuiTextBuffer_appendf"][1]["signature"] = "(struct ImGuiTextBuffer*, const char*,...)"
|
||||||
defs["ImGuiTextBuffer_appendf"][1]["stname"] = "ImGuiTextBuffer"
|
defs["ImGuiTextBuffer_appendf"][1]["stname"] = "ImGuiTextBuffer"
|
||||||
defs["ImGuiTextBuffer_appendf"]["(const char*,...)"] = defs["ImGuiTextBuffer_appendf"][1]
|
defs["ImGuiTextBuffer_appendf"]["(struct ImGuiTextBuffer*, const char*,...)"] = defs["ImGuiTextBuffer_appendf"][1]
|
||||||
defs["ImGuiTextBuffer_appendfv"] = {}
|
defs["ImGuiTextBuffer_appendfv"] = {}
|
||||||
defs["ImGuiTextBuffer_appendfv"][1] = {}
|
defs["ImGuiTextBuffer_appendfv"][1] = {}
|
||||||
defs["ImGuiTextBuffer_appendfv"][1]["args"] = "(ImGuiTextBuffer* self,const char* fmt,va_list args)"
|
defs["ImGuiTextBuffer_appendfv"][1]["args"] = "(ImGuiTextBuffer* self,const char* fmt,va_list args)"
|
||||||
@@ -24514,7 +24514,7 @@ defs["igLogText"][1]["argsT"][1]["type"] = "const char*"
|
|||||||
defs["igLogText"][1]["argsT"][2] = {}
|
defs["igLogText"][1]["argsT"][2] = {}
|
||||||
defs["igLogText"][1]["argsT"][2]["name"] = "..."
|
defs["igLogText"][1]["argsT"][2]["name"] = "..."
|
||||||
defs["igLogText"][1]["argsT"][2]["type"] = "..."
|
defs["igLogText"][1]["argsT"][2]["type"] = "..."
|
||||||
defs["igLogText"][1]["argsoriginal"] = "(const char* fmt,...)"
|
defs["igLogText"][1]["argsoriginal"] = "(const char* fmt, ...)"
|
||||||
defs["igLogText"][1]["call_args"] = "(fmt,...)"
|
defs["igLogText"][1]["call_args"] = "(fmt,...)"
|
||||||
defs["igLogText"][1]["cimguiname"] = "igLogText"
|
defs["igLogText"][1]["cimguiname"] = "igLogText"
|
||||||
defs["igLogText"][1]["defaults"] = {}
|
defs["igLogText"][1]["defaults"] = {}
|
||||||
|
Reference in New Issue
Block a user