From: Daniel Z. <dan...@sa...> - 2014-10-02 10:13:31
|
Hi D5, Didn't we speak about having automatic tests to be sure it works as expected? And don't tell me Lua checks it ;-) D2 On 10/02/14 13:02, Daniel Kolesa wrote: > q66 pushed a commit to branch master. > > http://git.enlightenment.org/core/efl.git/commit/?id=a2bde0bf96a2c7f61f12983df78e0d9d2c17f4a5 > > commit a2bde0bf96a2c7f61f12983df78e0d9d2c17f4a5 > Author: Daniel Kolesa <d.k...@sa...> > Date: Thu Oct 2 11:00:06 2014 +0100 > > eolian: new API: eolian_class_c_get_function_name_get > > This allows bindings to easily retrieve name of the C function used to > retrieve the Eo_Class. Also, update the Lua Eolian bindings and generator. > --- > src/bin/elua/modules/lualian.lua | 7 ++----- > src/bindings/luajit/eolian.lua | 7 +++++++ > src/lib/eolian/Eolian.h | 12 ++++++++++++ > src/lib/eolian/database_class_api.c | 28 ++++++++++++++++++++++++++++ > 4 files changed, 49 insertions(+), 5 deletions(-) > > diff --git a/src/bin/elua/modules/lualian.lua b/src/bin/elua/modules/lualian.lua > index 745c228..d74cb02 100644 > --- a/src/bin/elua/modules/lualian.lua > +++ b/src/bin/elua/modules/lualian.lua > @@ -364,7 +364,6 @@ end > local Mixin = Node:clone { > __ctor = function(self, klass, iface, ch, evs) > self.klass = klass > - self.prefix = klass:eo_prefix_get() > self.children = ch > self.events = evs > self.is_iface = iface > @@ -386,9 +385,8 @@ local Mixin = Node:clone { > end, > > gen_ffi = function(self, s) > - local prefix = self.is_iface and "interface" or "mixin" > - s:write(" const Eo_Class *", self.prefix, "_", prefix, > - "_get(void);\n") > + s:write(" const Eo_Class *", self.klass:c_get_function_name_get(), > + "(void);\n") > for i, v in ipairs(self.children) do > v.parent_node = self > v:gen_ffi(s) > @@ -415,7 +413,6 @@ local Class = Node:clone { > self.parent = parent > self.interfaces = interfaces > self.mixins = mixins > - self.prefix = klass:eo_prefix_get() > self.children = ch > self.events = evs > end, > diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua > index 5931741..3e43750 100644 > --- a/src/bindings/luajit/eolian.lua > +++ b/src/bindings/luajit/eolian.lua > @@ -249,6 +249,7 @@ ffi.cdef [[ > const char *eolian_event_c_name_get(const Eolian_Event *event); > Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass); > Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass); > + const char *eolian_class_c_get_function_name_get(const Eolian_Class *klass); > const Eolian_Type *eolian_type_alias_get_by_name(const char *name); > const Eolian_Type *eolian_type_struct_get_by_name(const char *name); > const Eolian_Type *eolian_type_enum_get_by_name(const char *name); > @@ -960,6 +961,12 @@ M.Class = ffi.metatype("Eolian_Class", { > > dtor_enable_get = function(self) > return eolian.eolian_class_dtor_enable_get(self) ~= 0 > + end, > + > + c_get_function_name_get = function(self) > + local v = eolian.eolian_class_c_get_function_name_get(self) > + if v == nil then return nil end > + return ffi_stringshare(v) > end > } > }) > diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h > index 0fcecd8..4463862 100644 > --- a/src/lib/eolian/Eolian.h > +++ b/src/lib/eolian/Eolian.h > @@ -1245,6 +1245,18 @@ EAPI Eina_Bool eolian_class_ctor_enable_get(const Eolian_Class *klass); > EAPI Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass); > > /* > + * @brief Returns the name of the C function used to get the Eo_Class pointer. > + * > + * @param[in] klass the class. > + * @return a stringshare containing the func name or NULL on error. > + * > + * You have to delete the stringshare manually. > + * > + * @ingroup Eolian > + */ > +EAPI Eina_Stringshare *eolian_class_c_get_function_name_get(const Eolian_Class *klass); > + > +/* > * @brief Get an alias type by name. Supports namespaces. > * > * @param[in] name the name of the alias > diff --git a/src/lib/eolian/database_class_api.c b/src/lib/eolian/database_class_api.c > index c6f9262..8de2fae 100644 > --- a/src/lib/eolian/database_class_api.c > +++ b/src/lib/eolian/database_class_api.c > @@ -174,3 +174,31 @@ eolian_class_dtor_enable_get(const Eolian_Class *cl) > EINA_SAFETY_ON_NULL_RETURN_VAL(cl, EINA_FALSE); > return cl->class_dtor_enable; > } > + > +EAPI Eina_Stringshare * > +eolian_class_c_get_function_name_get(const Eolian_Class *cl) > +{ > + EINA_SAFETY_ON_NULL_RETURN_VAL(cl, NULL); > + Eina_Stringshare *ret; > + Eina_Strbuf *buf = eina_strbuf_new(); > + char *bufp; > + eina_strbuf_append(buf, cl->full_name); > + switch (cl->type) > + { > + case EOLIAN_CLASS_INTERFACE: > + eina_strbuf_append(buf, "_interface_get"); > + break; > + case EOLIAN_CLASS_MIXIN: > + eina_strbuf_append(buf, "_mixin_get"); > + break; > + default: > + eina_strbuf_append(buf, "_class_get"); > + break; > + } > + eina_strbuf_replace_all(buf, ".", "_"); > + bufp = eina_strbuf_string_steal(buf); > + eina_str_tolower(&bufp); > + ret = eina_stringshare_add(bufp); > + free(bufp); > + return ret; > +} > |