q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=10ea6e9f0ff6589736fcceca92fd3889d9963c41
commit 10ea6e9f0ff6589736fcceca92fd3889d9963c41 Author: Daniel Kolesa <[email protected]> Date: Mon Jul 14 16:08:31 2014 +0100 elua: use the type API in lualian (but only basics of it) --- src/bin/elua/modules/lualian.lua | 40 +++++++++++++++------------------------- src/bindings/luajit/eolian.lua | 10 ++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/bin/elua/modules/lualian.lua b/src/bin/elua/modules/lualian.lua index fa0505a..371111d 100644 --- a/src/bin/elua/modules/lualian.lua +++ b/src/bin/elua/modules/lualian.lua @@ -36,7 +36,7 @@ local known_out = { } local known_in = { - ["Eina_Bool" ] = function(expr) return expr end, + ["bool"] = function(expr) return expr end, ["Evas_Coord"] = function(expr) return expr end } @@ -58,16 +58,17 @@ local build_calln = function(tps, expr, isin) } end -local typeconv_in = function(tps, tp, expr, isconst, isptr) - if isptr then - local passtp = (isconst and "const " or "") .. tp - local f = known_ptr_in[passtp] +local typeconv_in = function(tps, expr) + if tps:type_get() == eolian.type_type.POINTER then + local base = tps:base_type_get() + local f = known_ptr_in[base:c_type_get()] if f then return f(expr) end return build_calln(tps, expr, true) end - if isnum[tp] then - return expr - end + + local tp = tps:name_get() + + if isnum[tp] then return expr end local f = known_in[tp] if f then @@ -78,34 +79,23 @@ local typeconv_in = function(tps, tp, expr, isconst, isptr) end local typeconv = function(tps, expr, isin) - local tp = tps:c_type_get() - -- strip away type qualifiers - local isconst, tpr = tp:match("^(const)[ ]+(.+)$") - isconst = not not isconst - if tpr then tp = tpr end - - -- check if it's a pointer - local basetype = (tp:match("(.+)[ ]+%*$")) - - -- out val if isin then - return typeconv_in(tps, basetype or tp, expr, isconst, not not basetype) + return typeconv_in(tps, expr) end - -- pointer type - if basetype then - local passtp = (isconst and "const " or "") .. basetype - local f = known_ptr_out[passtp] + if tps:type_get() == eolian.type_type.POINTER then + local base = tps:base_type_get() + local f = known_ptr_out[base:c_type_get()] if f then return f(expr) end return build_calln(tps, expr, false) end - -- number? + local tp = tps:name_get() + if isnum[tp] then return ("tonumber(%s)"):format(expr) end - -- known primitive EFL type? local f = known_out[tp] if f then return f(expr) diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua index f666eb6..adf6e3a 100644 --- a/src/bindings/luajit/eolian.lua +++ b/src/bindings/luajit/eolian.lua @@ -195,6 +195,16 @@ M.show_all = function() eolian.eolian_show_all() end +M.type_type = { + UNKNOWN = 0, + VOID = 1, + REGULAR = 2, + REGULAR_STRUCT = 3, + POINTER = 4, + FUNCTION = 5, + STRUCT = 6 +} + M.Type = ffi.metatype("Eolian_Type", { __index = { type_get = function(self) --
