From 30e8d8a735aacd10b72e26b2f5535b6521a1c241 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 14 Jul 2014 15:37:32 +0100 Subject: [PATCH] elua: make the lua generator generate things again - type stuff will need re-work --- src/bin/elua/apps/lualian.lua | 3 +++ src/bin/elua/modules/lualian.lua | 42 +++++++++++++++----------------- src/bindings/luajit/eolian.lua | 22 +++++++++-------- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/bin/elua/apps/lualian.lua b/src/bin/elua/apps/lualian.lua index 3419b74f99..ea1743287d 100644 --- a/src/bin/elua/apps/lualian.lua +++ b/src/bin/elua/apps/lualian.lua @@ -57,6 +57,9 @@ getopt.parse { for i, v in ipairs(opts["I"] or {}) do lualian.include_dir(v) end + if os.getenv("EFL_RUN_IN_TREE") then + lualian.system_directory_scan() + end lualian.load_eot_files() for i, fname in ipairs(args) do gen_file(opts, i, fname) diff --git a/src/bin/elua/modules/lualian.lua b/src/bin/elua/modules/lualian.lua index c2d0cb170b..fa0505a547 100644 --- a/src/bin/elua/modules/lualian.lua +++ b/src/bin/elua/modules/lualian.lua @@ -51,18 +51,10 @@ local known_ptr_in = { local convfuncs = {} local build_calln = function(tps, expr, isin) - local nm, own - local buf = { "__convert", isin and "IN" or "OUT" } - local owns = {} - while tps do - tps, nm, own = tps:information_get() - owns[#owns + 1] = own and "true" or "false" - buf[#buf + 1] = nm:gsub("%s", "_"):gsub("%*", "_ptr"):gsub("__+", "_") - end - local funcn = table.concat(buf, "_") + local funcn = "__convert_type_wip" convfuncs[funcn] = true return table.concat { - funcn, "(", expr, ", ", table.concat(owns, ", "), ")" + funcn, "(", expr, ")" } end @@ -86,7 +78,7 @@ local typeconv_in = function(tps, tp, expr, isconst, isptr) end local typeconv = function(tps, expr, isin) - local tp = select(2, tps:information_get()) + local tp = tps:c_type_get() -- strip away type qualifiers local isconst, tpr = tp:match("^(const)[ ]+(.+)$") isconst = not not isconst @@ -157,12 +149,12 @@ local Method = Node:clone { local meth = self.method local pars = meth:parameters_list_get() - local rett = meth:return_types_list_get(eolian.function_type.METHOD) + local rett = meth:return_type_get(eolian.function_type.METHOD) local proto = { name = meth:name_get() } - proto.ret_type = rett and (select(2, rett:information_get())) or "void" + proto.ret_type = rett and rett:c_type_get() or "void" local args, cargs, vargs = { "self" }, {}, {} proto.args, proto.cargs, proto.vargs = args, cargs, vargs local rets = {} @@ -182,8 +174,8 @@ local Method = Node:clone { if #pars > 0 then for i, v in ipairs(pars) do - local dir, tp, nm = v:information_get() - local tps = v:types_list_get() + local dir, tps, nm = v:information_get() + local tp = tps:c_type_get() if dir == dirs.OUT or dir == dirs.INOUT then if dir == dirs.INOUT then args[#args + 1] = nm @@ -276,8 +268,8 @@ local Property = Method:clone { local argn = (#keys > 1) and "keys" or "key" for i, v in ipairs(keys) do local nm = v:name_get() - local tps = v:types_list_get() - local tp = select(2, tps:information_get()) + local tps = v:type_get() + local tp = tps:c_type_get() cargs [#cargs + 1] = tp .. " " .. nm vargs [#vargs + 1] = typeconv(tps, argn .. "[" .. i .. "]", true) @@ -289,13 +281,13 @@ local Property = Method:clone { if #vals > 0 then if self.isget then if #vals == 1 and not rett then - local tps = vals[1]:types_list_get() - proto.ret_type = (select(2, tps:information_get())) + local tps = vals[1]:type_get() + proto.ret_type = tps:c_type_get() rets[#rets + 1] = typeconv(tps, "v", false) else for i, v in ipairs(vals) do - local dir, tp, nm = v:information_get() - local tps = v:types_list_get() + local dir, tps, nm = v:information_get() + local tp = v:c_type_get() cargs [#cargs + 1] = tp .. " *" .. nm vargs [#vargs + 1] = nm allocs[#allocs + 1] = { tp, nm } @@ -306,8 +298,8 @@ local Property = Method:clone { local argn = (#keys > 1) and "vals" or "val" args[#args + 1] = argn for i, v in ipairs(vals) do - local dir, tp, nm = v:information_get() - local tps = v:types_list_get() + local dir, tps, nm = v:information_get() + local tp = tps:c_type_get() cargs[#cargs + 1] = tp .. " " .. nm vargs[#vargs + 1] = typeconv(tps, argn .. "[" .. i .. "]", true) @@ -681,6 +673,10 @@ M.load_eot_files = function() return eolian.all_eot_files_parse() end +M.system_directory_scan = function() + return eolian.system_directory_scan() +end + M.generate = function(fname, modname, libname, fstream) if not eolian.eo_file_parse(fname) then error("Failed parsing file: " .. fname) diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua index 45f87e9d19..f666eb6a2c 100644 --- a/src/bindings/luajit/eolian.lua +++ b/src/bindings/luajit/eolian.lua @@ -6,6 +6,7 @@ local ffi = require("ffi") ffi.cdef [[ typedef unsigned char Eina_Bool; typedef struct _Eina_List Eina_List; + typedef struct _Eina_Iterator Eina_Iterator; typedef struct _Eolian_Class Eolian_Class; typedef struct _Eolian_Function Eolian_Function; @@ -86,7 +87,7 @@ ffi.cdef [[ Eolian_Function_Type eolian_function_type_get(const Eolian_Function *function_id); Eolian_Function_Scope eolian_function_scope_get(const Eolian_Function *function_id); const char *eolian_function_name_get(const Eolian_Function *function_id); - const char *eolian_function_full_c_name_get(const Eolian_Function function_id, const char *prefix); + const char *eolian_function_full_c_name_get(const Eolian_Function *function_id, const char *prefix); const Eolian_Function *eolian_class_function_find_by_name(const Eolian_Class *klass, const char *func_name, Eolian_Function_Type f_type); const char *eolian_function_data_get(const Eolian_Function *function_id, const char *key); Eina_Bool eolian_function_is_virtual_pure(const Eolian_Function *function_id, Eolian_Function_Type f_type); @@ -118,15 +119,15 @@ ffi.cdef [[ Eina_Iterator *eolian_type_subtypes_list_get(const Eolian_Type *tp); Eina_Iterator *eolian_type_struct_field_names_list_get(const Eolian_Type *tp); const Eolian_Type *eolian_type_struct_field_get(const Eolian_Type *tp, const char *field); - Eina_Stringshare *eolian_type_struct_field_description_get(const Eolian_Type *tp, const char *field); - Eina_Stringshare *eolian_type_struct_description_get(const Eolian_Type *tp); + const char *eolian_type_struct_field_description_get(const Eolian_Type *tp, const char *field); + const char *eolian_type_struct_description_get(const Eolian_Type *tp); const Eolian_Type *eolian_type_return_type_get(const Eolian_Type *tp); const Eolian_Type *eolian_type_base_type_get(const Eolian_Type *tp); Eina_Bool eolian_type_is_own(const Eolian_Type *tp); Eina_Bool eolian_type_is_const(const Eolian_Type *tp); - Eina_Stringshare *eolian_type_c_type_named_get(const Eolian_Type *tp, const char *name); - Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp); - Eina_Stringshare *eolian_type_name_get(const Eolian_Type *tp); + const char *eolian_type_c_type_named_get(const Eolian_Type *tp, const char *name); + const char *eolian_type_c_type_get(const Eolian_Type *tp); + const char *eolian_type_name_get(const Eolian_Type *tp); ]] local cutil = require("cutil") @@ -160,6 +161,7 @@ end M.system_directory_scan = function() return eolian.eolian_system_directory_scan() ~= 0 +end M.all_eo_files_parse = function() return eolian.eolian_all_eo_files_parse() ~= 0 @@ -302,8 +304,8 @@ M.Function = ffi.metatype("Eolian_Function", { return ffi.string(v) end, - full_c_name_get = function(self) - local v = eolian.eolian_function_full_c_name_get(self) + full_c_name_get = function(self, prefix) + local v = eolian.eolian_function_full_c_name_get(self, prefix) if v == nil then return nil end return ffi.string(v) end, @@ -423,8 +425,8 @@ ffi.metatype("Eolian_Implement", { end, information_get = function(self) - local cl = ffi.new("Eolian_Class[1]") - local fn = ffi.new("Eolian_Function[1]") + local cl = ffi.new("const Eolian_Class*[1]") + local fn = ffi.new("const Eolian_Function*[1]") local tp = ffi.new("Eolian_Function_Type[1]") eolian.eolian_implement_information_get(self, cl, fn, tp) return cl[0], fn[0], tp[0]