Compare commits

..

4 Commits

Author SHA1 Message Date
sonoro1234
354f316b89 CIMGUI_DEFINE_ENUMS_AND_STRUCTS in README.md 2018-10-21 13:18:36 +02:00
sonoro1234
f6fdec9d98 do check of bad overloading 2018-10-21 11:39:23 +02:00
sonoro1234
3da4350671 readme hard coded overloaded names 2018-10-20 19:42:33 +02:00
sonoro1234
fe1d9d081b more readme update 2018-10-20 19:36:46 +02:00
3 changed files with 37 additions and 26 deletions

View File

@@ -2,7 +2,7 @@
This is a thin c-api wrapper programmatically generated for the excellent C++ immediate mode gui [Dear ImGui](https://github.com/ocornut/imgui).
All functions are programmatically wrapped except constructors, destructors and `ImVector`. (Unless someone find a use case for them)
All functions are programmatically wrapped except `ImVector` constructors and destructors. (Unless someone find a use case for them)(Now they exist for `ImVector_ImWchar`)
Generated files are: `cimgui.cpp`, `cimgui.h` for C compilation. Also for helping in bindings creation, `definitions.lua` with function definition information and `structs_and_enums.lua`.
This library is intended as a intermediate layer to be able to use Dear ImGui from other languages that can interface with C (like D - see [D-binding](https://github.com/Extrawurst/DerelictImgui))
@@ -12,7 +12,7 @@ Initially cimgui was developed by Stephan Dilly as hand-written code but lately
Notes:
* currently this wrapper is based on version [1.65 of Dear ImGui]
* overloaded function names try to be the most compatible with traditional cimgui names. So all naming is algorithmic except for those names that were in conflict with widely used cimgui names and were thus coded in a table (https://github.com/cimgui/cimgui/blob/master/generator/generator.lua#L40). Current overloaded function names can be found in (https://github.com/cimgui/cimgui/blob/master/generator/output/overloads.txt)
* overloaded function names try to be the most compatible with traditional cimgui names. So all naming is algorithmic except for those names that were in conflict with widely used cimgui names and were thus coded in a table (https://github.com/cimgui/cimgui/blob/master/generator/generator.lua#L58). Current overloaded function names can be found in (https://github.com/cimgui/cimgui/blob/master/generator/output/overloads.txt)
# compilation
@@ -32,6 +32,7 @@ Notes:
* as a result some files are generated: `cimgui.cpp` and `cimgui.h` for compiling and some lua/json files with information about the binding: `definitions.json` with function info, `structs_and_enums.json` with struct and enum info, `impl_definitions.json` with functions from the implementations info.
# generate binding
* C interface is exposed by cimgui.h when you define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
* with your prefered language you can use the lua or json files generated as in:
* https://github.com/sonoro1234/LuaJIT-ImGui/blob/master_auto_implementations/lua/build.bat (with lua code generation in https://github.com/sonoro1234/LuaJIT-ImGui/blob/master_auto_implementations/lua/class_gen.lua)
* https://github.com/mellinoe/ImGui.NET/tree/autogen/src/CodeGenerator

View File

@@ -10,7 +10,7 @@
:: impl_definitions.lua for implementation function definitions
:: set your PATH if necessary for LuaJIT or Lua5.1 or luajit with: (for example)
set PATH=%PATH%;C:\luaGL;C:\mingw32\bin;
:: set PATH=%PATH%;C:\luaGL;C:\mingw32\bin;
:: set PATH=%PATH%;C:\luaGL;C:\i686-7.2.0-release-posix-dwarf-rt_v5-rev1\mingw32\bin;
:: set PATH=%PATH%;C:\luaGL\sources\luajit-master\luajit-master\bin\mingw32;C:\mingw32\bin;
::process files

View File

@@ -307,18 +307,18 @@ local function serializeTable(name, value, saved)
for k,v in pairs(value) do
table.insert(ordered_keys,k)
end
local function sorter(a,b)
if type(a)==type(b) then
return a<b
elseif type(a)=="number" then
return true
else
assert(type(b)=="number")
return false
end
end
local function sorter(a,b)
if type(a)==type(b) then
return a<b
elseif type(a)=="number" then
return true
else
assert(type(b)=="number")
return false
end
end
table.sort(ordered_keys,sorter)
for _,k in ipairs(ordered_keys) do
for _,k in ipairs(ordered_keys) do
local v = value[k]
--]]
-- for k,v in pairs(value) do -- save its fields
@@ -779,6 +779,16 @@ local function func_parser()
table.insert(strt,string.format("%d\t%s\t%s %s",i,t.ret,t.ov_cimguiname,t.signature))
--prtable(typesc[i])
end
--check not two names are equal (produced by bad cimguiname_overload)
for i=1,#v-1 do
for j=i+1,#v-1 do
if v[i].ov_cimguiname == v[j].ov_cimguiname then
local t,tj = v[i],v[j]
print("Error caused by Bad overloading "..t.ov_cimguiname.." of function ",t.funcname,t.signature,"conflicts with ",tj.funcname,tj.signature)
error("Bad overloading:"..t.ov_cimguiname)
end
end
end
end
end
--print(numoverloaded, "overloaded")
@@ -1449,18 +1459,18 @@ local function DefsByStruct(FP)
FP.defsBystruct = struct
end
local function AdjustArguments(FP)
for fun,defs in pairs(FP.defsT) do
--struct function but no constructors
if defs[1].stname~="ImGui" and defs[1].stname~="" and defs[1].ret then
--print("adjusting",fun)
for i,def in ipairs(defs) do
local empty = def.args:match("^%(%)") --no args
--local ptret = def.retref and "&" or ""
def.args = def.args:gsub("^%(","("..def.stname.."* self"..(empty and "" or ","))
table.insert(def.argsT,1,{type=def.stname.."*",name="self"})
end
end
end
for fun,defs in pairs(FP.defsT) do
--struct function but no constructors
if defs[1].stname~="ImGui" and defs[1].stname~="" and defs[1].ret then
--print("adjusting",fun)
for i,def in ipairs(defs) do
local empty = def.args:match("^%(%)") --no args
--local ptret = def.retref and "&" or ""
def.args = def.args:gsub("^%(","("..def.stname.."* self"..(empty and "" or ","))
table.insert(def.argsT,1,{type=def.stname.."*",name="self"})
end
end
end
end
--generate cimgui.cpp cimgui.h and auto versions depending on postfix
local function cimgui_generation(postfix,STP,FP)