mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-10 20:08:31 +01:00
cpp2ffi: parse_enum_value add - operator, when not loca take parent location, templates take full template string
This commit is contained in:
@@ -170,13 +170,13 @@ local function parse_enum_value(value, allenums,dontpost)
|
|||||||
value = value:gsub("^(%()",""):gsub("(%))$","")
|
value = value:gsub("^(%()",""):gsub("(%))$","")
|
||||||
assert(not value:match("[%(%)]"),value)
|
assert(not value:match("[%(%)]"),value)
|
||||||
|
|
||||||
local several,seps = strsplit(value,"([<>&|~%+]+)")
|
local several,seps = strsplit(value,"([<>&|~%+%-]+)")
|
||||||
--M.prtable(value,several,seps)
|
--M.prtable(value,several,seps)
|
||||||
assert(#seps+1==#several)
|
assert(#seps+1==#several)
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
local ik = 1
|
local ik = 1
|
||||||
local sepk = {"~","<<",">>","&","^","|","+"}
|
local sepk = {"~","<<",">>","&","^","|","+","-"}
|
||||||
while(#seps>0) do
|
while(#seps>0) do
|
||||||
local sep = sepk[ik]
|
local sep = sepk[ik]
|
||||||
local v = seps[i]
|
local v = seps[i]
|
||||||
@@ -206,6 +206,8 @@ local function parse_enum_value(value, allenums,dontpost)
|
|||||||
several[i] = bit.bor(val1,val2)
|
several[i] = bit.bor(val1,val2)
|
||||||
elseif v=="+" then
|
elseif v=="+" then
|
||||||
several[i] = val1 + val2
|
several[i] = val1 + val2
|
||||||
|
elseif v=="-" then
|
||||||
|
several[i] = val1 - val2
|
||||||
else
|
else
|
||||||
error("unknown operator "..v)
|
error("unknown operator "..v)
|
||||||
end
|
end
|
||||||
@@ -223,7 +225,7 @@ local function parse_enum_value(value, allenums,dontpost)
|
|||||||
end
|
end
|
||||||
if #seps>0 or type(several[1])~="number" and not dontpost then
|
if #seps>0 or type(several[1])~="number" and not dontpost then
|
||||||
--M.prtable("enline",enline)
|
--M.prtable("enline",enline)
|
||||||
print("parse_enum_value WARNING",value,several[1])
|
print("parse_enum_value WARNING:",value,several[1])
|
||||||
--M.prtable(several,seps)
|
--M.prtable(several,seps)
|
||||||
--M.prtable("allenums",allenums)
|
--M.prtable("allenums",allenums)
|
||||||
end
|
end
|
||||||
@@ -324,7 +326,9 @@ local function parseItems(txt,linenumdict, itparent, dumpit)
|
|||||||
local re = res[re_name]
|
local re = res[re_name]
|
||||||
local i,e = txt:find(re,ini)
|
local i,e = txt:find(re,ini)
|
||||||
if i then
|
if i then
|
||||||
|
|
||||||
item = txt:sub(i,e)
|
item = txt:sub(i,e)
|
||||||
|
--print("re_name",re_name,item)
|
||||||
------------------
|
------------------
|
||||||
--[[
|
--[[
|
||||||
--if re~=functionD_re then --skip defined functions
|
--if re~=functionD_re then --skip defined functions
|
||||||
@@ -377,12 +381,18 @@ local function parseItems(txt,linenumdict, itparent, dumpit)
|
|||||||
end
|
end
|
||||||
if not loca then
|
if not loca then
|
||||||
print("not loca",string.format("%q , %q ",itemold,itemfirstline),#itemfirstline)
|
print("not loca",string.format("%q , %q ",itemold,itemfirstline),#itemfirstline)
|
||||||
for k,v in pairs(linenumdict) do
|
-- for k,v in pairs(linenumdict) do
|
||||||
if k:match(itemfirstline) then
|
-- if k:match(itemfirstline) then
|
||||||
print(string.format("%q",k),#k)
|
-- print(string.format("%q",k),#k)
|
||||||
end
|
-- end
|
||||||
|
-- end
|
||||||
|
--error"no entry in linenumdict"
|
||||||
|
--take locat from parent
|
||||||
|
if itparent.locat then
|
||||||
|
loca = itparent.locat
|
||||||
|
else
|
||||||
|
error"no entry in linenumdict"
|
||||||
end
|
end
|
||||||
error"no entry in linenumdict"
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error"no linenumdict"
|
error"no linenumdict"
|
||||||
@@ -1140,7 +1150,8 @@ function M.Parser()
|
|||||||
local stname = it.item:match("struct%s+(%S+)")
|
local stname = it.item:match("struct%s+(%S+)")
|
||||||
it.name = stname
|
it.name = stname
|
||||||
|
|
||||||
local templa1,templa2 = it.item:match("^%s*template%s*<%s*(%S+)%s*(%S+)%s*>")
|
--local templa1,templa2 = it.item:match("^%s*template%s*<%s*(%S+)%s*(%S+)%s*>")
|
||||||
|
local templa2 = it.item:match("^%s*template%s*<%s*([^<>]+)%s*>")
|
||||||
if templa1 or templa2 then print("template found",stname,templa1,templa2,"typename",typename) end
|
if templa1 or templa2 then print("template found",stname,templa1,templa2,"typename",typename) end
|
||||||
|
|
||||||
if typename or templa2 then -- it is a struct template
|
if typename or templa2 then -- it is a struct template
|
||||||
@@ -2088,21 +2099,20 @@ end
|
|||||||
M.func_header_generate = func_header_generate
|
M.func_header_generate = func_header_generate
|
||||||
--[=[
|
--[=[
|
||||||
-- tests
|
-- tests
|
||||||
local code = [[struct ImDrawListSharedData
|
local code = [[
|
||||||
|
template<int BITCOUNT, int OFFSET = 0>
|
||||||
|
struct IMGUI_API ImBitArray
|
||||||
{
|
{
|
||||||
ImVec2 TexUvWhitePixel;
|
ImU32 Storage[(BITCOUNT + 31) >> 5];
|
||||||
ImFont* Font;
|
ImBitArray() { ClearAllBits(); }
|
||||||
float FontSize;
|
void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); }
|
||||||
float CurveTessellationTol;
|
void SetAllBits() { memset(Storage, 255, sizeof(Storage)); }
|
||||||
float CircleSegmentMaxError;
|
bool TestBit(int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
ImVec4 ClipRectFullscreen;
|
void SetBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArraySetBit(Storage, n + OFFSET); }
|
||||||
ImDrawListFlags InitialFlags;
|
void ClearBit(int n) { IM_ASSERT(n + OFFSET < BITCOUNT); ImBitArrayClearBit(Storage, n + OFFSET); }
|
||||||
ImVec2 ArcFastVtx[12 * 1];
|
void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n + OFFSET, n2 + OFFSET); } // Works on range [n..n2)
|
||||||
ImU8 CircleSegmentCounts[64];
|
bool operator[](int n) const { IM_ASSERT(n + OFFSET < BITCOUNT); return ImBitArrayTestBit(Storage, n + OFFSET); }
|
||||||
ImDrawListSharedData();
|
};
|
||||||
void SetCircleSegmentMaxError(float max_error);
|
|
||||||
};]]
|
|
||||||
local code = [[static inline void ImQsort(void* base, size_t count, size_t size_of_element, int(__cdecl *compare_func)(void const*, void const*)) { if (count > 1) qsort(base, count, size_of_element, compare_func); }
|
|
||||||
]]
|
]]
|
||||||
local parser = M.Parser()
|
local parser = M.Parser()
|
||||||
for line in code:gmatch("[^\n]+") do
|
for line in code:gmatch("[^\n]+") do
|
||||||
|
Reference in New Issue
Block a user