sonoro1234 / LuaJIT-ImGui

LuaJIT ffi binding for imgui, backends and extension widgets
MIT License
213 stars 29 forks source link

Some generic version failures #19

Open sonoro1234 opened 4 years ago

sonoro1234 commented 4 years ago

Generic version is still experimental Its purpose is to detect the overloaded version from arguments Here are some failing cases

from implot

M.PushPlotStyleVarFloat = lib.igPushPlotStyleVarFloat
M.PushPlotStyleVarInt = lib.igPushPlotStyleVarInt
function M.PushPlotStyleVar(a1,a2) -- generic version
    if (ffi.istype('float',a2) or type(a2)=='number') then return M.PushPlotStyleVarFloat(a1,a2) end
    if (ffi.istype('int',a2) or type(a2)=='number') then return M.PushPlotStyleVarInt(a1,a2) end
    print(a1,a2)
    error'M.PushPlotStyleVar could not find overloaded'
end

It is imposible to discriminate float from int when it is a Lua number. In this cases generic version cannot be used and overloaded name should be used.

Trying to work a solution, suggestions are welcome.

sonoro1234 commented 2 years ago

In order to avoid using overloaded name solution can be giving second argument as CDATA