From 267c57d0f10d4b1577181c8f7157b7bc2f8053a6 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 9 Sep 2019 18:26:49 +0200 Subject: [PATCH] eolian: remove second parameter for eolian_type_c_type_get This has been replaced by newer APIs. --- src/bin/eolian/docs.c | 2 +- src/bin/eolian/sources.c | 2 +- src/bin/eolian/types.c | 4 ++-- src/bindings/luajit/eolian.lua | 18 +++--------------- src/lib/eolian/Eolian.h | 10 +--------- src/lib/eolian/database_type_api.c | 4 ++-- src/lib/eolian/eolian_database.h | 7 +++++++ src/lib/eolian_cxx/grammar/klass_def.hpp | 8 ++++---- src/scripts/pyolian/eolian.py | 21 ++------------------- src/scripts/pyolian/eolian_lib.py | 4 ++-- src/scripts/pyolian/test_eolian.py | 12 ------------ src/tests/eolian/eolian_parsing.c | 12 ++++++------ 12 files changed, 31 insertions(+), 73 deletions(-) diff --git a/src/bin/eolian/docs.c b/src/bin/eolian/docs.c index 498278f0e1..0e0d359109 100644 --- a/src/bin/eolian/docs.c +++ b/src/bin/eolian/docs.c @@ -380,7 +380,7 @@ eo_gen_docs_event_gen(const Eolian_State *state, const Eolian_Event *ev, if (rt) { p = buf; - Eina_Stringshare *rts = eolian_type_c_type_get(rt, EOLIAN_C_TYPE_DEFAULT); + Eina_Stringshare *rts = eolian_type_c_type_get(rt); snprintf(buf, sizeof(buf), "@return %s", rts); eina_stringshare_del(rts); } diff --git a/src/bin/eolian/sources.c b/src/bin/eolian/sources.c index dea9d86011..fd0c32bb07 100644 --- a/src/bin/eolian/sources.c +++ b/src/bin/eolian/sources.c @@ -235,7 +235,7 @@ _generate_iterative_free(Eina_Strbuf **buf, const Eolian_Type *type, const Eolia eina_strbuf_append_printf(iter_param, "%s_iter", eolian_parameter_name_get(parameter)); //generate the field definition - eina_strbuf_append_printf(*buf, " %s", eolian_type_c_type_get(inner_type, EOLIAN_C_TYPE_DEFAULT)); + eina_strbuf_append_printf(*buf, " %s", eolian_type_c_type_get(inner_type)); eina_strbuf_append_buffer(*buf, iter_param); eina_strbuf_append(*buf, ";\n"); diff --git a/src/bin/eolian/types.c b/src/bin/eolian/types.c index 7fe1a85b44..75426f1220 100644 --- a/src/bin/eolian/types.c +++ b/src/bin/eolian/types.c @@ -203,7 +203,7 @@ _var_generate(const Eolian_State *state, const Eolian_Variable *vr) } else { - Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT); + Eina_Stringshare *ct = eolian_type_c_type_get(vt); eina_strbuf_append_printf(buf, "EWAPI extern %s %s;", ct, fn); eina_stringshare_del(ct); } @@ -394,7 +394,7 @@ _source_gen_var(Eina_Strbuf *buf, const Eolian_Variable *vr) eina_str_toupper(&fn); const Eolian_Type *vt = eolian_variable_base_type_get(vr); - Eina_Stringshare *ct = eolian_type_c_type_get(vt, EOLIAN_C_TYPE_DEFAULT); + Eina_Stringshare *ct = eolian_type_c_type_get(vt); eina_strbuf_append_printf(buf, "EWAPI %s %s = ", ct, fn); eina_stringshare_del(ct); free(fn); diff --git a/src/bindings/luajit/eolian.lua b/src/bindings/luajit/eolian.lua index a848d029c1..faa39a4315 100644 --- a/src/bindings/luajit/eolian.lua +++ b/src/bindings/luajit/eolian.lua @@ -172,12 +172,6 @@ ffi.cdef [[ EOLIAN_TYPE_BUILTIN_VOID_PTR } Eolian_Type_Builtin_Type; - typedef enum { - EOLIAN_C_TYPE_DEFAULT = 0, - EOLIAN_C_TYPE_PARAM, - EOLIAN_C_TYPE_RETURN - } Eolian_C_Type_Type; - typedef enum { EOLIAN_EXPR_UNKNOWN = 0, EOLIAN_EXPR_INT, @@ -453,7 +447,7 @@ ffi.cdef [[ Eina_Bool eolian_typedecl_is_extern(const Eolian_Typedecl *tp); - const char *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype); + const char *eolian_type_c_type_get(const Eolian_Type *tp); const char *eolian_typedecl_c_type_get(const Eolian_Typedecl *tp); const char *eolian_typedecl_free_func_get(const Eolian_Typedecl *tp); @@ -989,12 +983,6 @@ M.typedecl_type = { FUNCTION_POINTER = 5 } -M.c_type_type = { - DEFAULT = 0, - PARAM = 1, - RETURN = 2 -} - ffi.metatype("Eolian_Struct_Type_Field", { __index = wrap_object { documentation_get = function(self) @@ -1175,8 +1163,8 @@ M.Type = ffi.metatype("Eolian_Type", { return eolian.eolian_type_is_ptr(self) ~= 0 end, - c_type_get = function(self, ctype) - local v = eolian.eolian_type_c_type_get(self, ctype) + c_type_get = function(self) + local v = eolian.eolian_type_c_type_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 78be1ac97f..c0ec4d6a56 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -351,13 +351,6 @@ typedef enum EOLIAN_TYPE_BUILTIN_VOID_PTR } Eolian_Type_Builtin_Type; -typedef enum -{ - EOLIAN_C_TYPE_DEFAULT = 0, - EOLIAN_C_TYPE_PARAM, - EOLIAN_C_TYPE_RETURN -} Eolian_C_Type_Type; - typedef enum { EOLIAN_EXPR_UNKNOWN = 0, @@ -3000,7 +2993,6 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp); * @brief Get the full C type name of the given type. * * @param[in] tp the type. - * @param[in] ctype the context within which the C type string will be used. * @return The C type name assuming @c tp is not NULL. * * You're responsible for the stringshare. @@ -3009,7 +3001,7 @@ EAPI Eina_Bool eolian_type_is_ptr(const Eolian_Type *tp); * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype); +EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp); /* * @brief A helper function to get the full name of a type. diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index 12e787d8f8..59a149337f 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -267,13 +267,13 @@ eolian_typedecl_is_extern(const Eolian_Typedecl *tp) } EAPI Eina_Stringshare * -eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype) +eolian_type_c_type_get(const Eolian_Type *tp) { Eina_Stringshare *ret; Eina_Strbuf *buf; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); buf = eina_strbuf_new(); - database_type_to_str(tp, buf, NULL, ctype, EINA_FALSE); + database_type_to_str(tp, buf, NULL, EOLIAN_C_TYPE_DEFAULT, EINA_FALSE); ret = eina_stringshare_add(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index 8a16733780..1821642c55 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -263,6 +263,13 @@ struct _Eolian_Function_Parameter Eina_Bool move :1; }; +typedef enum +{ + EOLIAN_C_TYPE_DEFAULT = 0, + EOLIAN_C_TYPE_PARAM, + EOLIAN_C_TYPE_RETURN +} Eolian_C_Type_Type; + struct _Eolian_Type { Eolian_Object base; diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp b/src/lib/eolian_cxx/grammar/klass_def.hpp index 4de294e836..108be02f79 100644 --- a/src/lib/eolian_cxx/grammar/klass_def.hpp +++ b/src/lib/eolian_cxx/grammar/klass_def.hpp @@ -491,7 +491,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni { complex.subtypes.push_back({stp , unit - , ::eolian_type_c_type_get(stp, EOLIAN_C_TYPE_DEFAULT) + , ::eolian_type_c_type_get(stp) , eolian_type_is_move(stp) , is_by::value}); stp = eolian_type_next_type_get(stp); @@ -554,7 +554,7 @@ struct alias_def auto eolian_type = ::eolian_typedecl_base_type_get(alias_obj); base_type = type_def(eolian_type , unit - , ::eolian_type_c_type_get(eolian_type, EOLIAN_C_TYPE_DEFAULT) + , ::eolian_type_c_type_get(eolian_type) , value_ownership::unmoved , is_by::value); is_undefined = false; @@ -1029,7 +1029,7 @@ struct variable_def , full_name(::eolian_variable_name_get(variable)) , base_type(::eolian_variable_base_type_get(variable) , unit - , ::eolian_type_c_type_get(eolian_variable_base_type_get(variable), ::EOLIAN_C_TYPE_DEFAULT) + , ::eolian_type_c_type_get(eolian_variable_base_type_get(variable)) , value_ownership::unmoved , is_by::value) , documentation(::eolian_variable_documentation_get(variable)) @@ -1117,7 +1117,7 @@ struct event_def : klass(cls, {attributes::qualifier_info::is_none, std::string()}) , type( ::eolian_event_type_get(event) ? eina::optional{{::eolian_event_type_get(event) , unit - , ::eolian_type_c_type_get(::eolian_event_type_get(event), EOLIAN_C_TYPE_DEFAULT) + , ::eolian_type_c_type_get(::eolian_event_type_get(event)) , value_ownership::unmoved , is_by::value} } : eina::optional{}) diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py index 22e84e556f..e231d2b579 100644 --- a/src/scripts/pyolian/eolian.py +++ b/src/scripts/pyolian/eolian.py @@ -142,11 +142,6 @@ class Eolian_Type_Builtin_Type(IntEnum): VOID_PTR = 48 FREE_CB = 49 -class Eolian_C_Type_Type(IntEnum): - DEFAULT = 0 - PARAM = 1 - RETURN = 2 - class Eolian_Expression_Type(IntEnum): UNKNOWN = 0 INT = 1 @@ -1053,24 +1048,12 @@ class Type(Object): def builtin_type(self): return Eolian_Type_Builtin_Type(lib.eolian_type_builtin_type_get(self)) - def c_type_get(self, ctype): - s = lib.eolian_type_c_type_get(self, ctype) + def c_type_get(self): + s = lib.eolian_type_c_type_get(self) ret = _str_to_py(s) lib.eina_stringshare_del(c_void_p(s)) return ret - @cached_property - def c_type_default(self): - return self.c_type_get(Eolian_C_Type_Type.DEFAULT) - - @cached_property - def c_type_param(self): - return self.c_type_get(Eolian_C_Type_Type.PARAM) - - @cached_property - def c_type_return(self): - return self.c_type_get(Eolian_C_Type_Type.RETURN) - @cached_property def typedecl(self): c_tdecl = lib.eolian_type_typedecl_get(self) diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index b532e98197..b9ee5d39a1 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py @@ -603,8 +603,8 @@ lib.eolian_type_is_const.restype = c_bool lib.eolian_type_is_ptr.argtypes = (c_void_p,) lib.eolian_type_is_ptr.restype = c_bool -# EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp, Eolian_C_Type_Type ctype); -lib.eolian_type_c_type_get.argtypes = (c_void_p, c_int) +# EAPI Eina_Stringshare *eolian_type_c_type_get(const Eolian_Type *tp); +lib.eolian_type_c_type_get.argtypes = (c_void_p) lib.eolian_type_c_type_get.restype = c_void_p # Stringshare TO BE FREED ### Eolian_Expression ####################################################### diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py index 5313e4cbba..36c19ea1ae 100755 --- a/src/scripts/pyolian/test_eolian.py +++ b/src/scripts/pyolian/test_eolian.py @@ -582,10 +582,6 @@ class TestEolianType(unittest.TestCase): self.assertIsNone(t.class_) self.assertEqual(t, t.aliased_base) # TODO find a better test - self.assertEqual(t.c_type_default, 'double') # TODO find a better test - self.assertEqual(t.c_type_param, 'double') - self.assertEqual(t.c_type_return, 'double') - def test_type_regular(self): cls = eolian_db.class_by_name_get('Efl.Gfx.Entity') func = cls.function_by_name_get('geometry') @@ -601,10 +597,6 @@ class TestEolianType(unittest.TestCase): self.assertIsNone(t.class_) self.assertEqual(t, t.aliased_base) - self.assertEqual(t.c_type_default, 'Eina_Rect') # TODO find a better test - self.assertEqual(t.c_type_param, 'Eina_Rect') - self.assertEqual(t.c_type_return, 'Eina_Rect') - td = t.typedecl self.assertIsInstance(td, eolian.Typedecl) self.assertEqual(td.name, 'Eina.Rect') @@ -623,10 +615,6 @@ class TestEolianType(unittest.TestCase): self.assertEqual(list(t.namespaces), ['Efl', 'Gfx']) self.assertEqual(t, t.aliased_base) - self.assertEqual(t.c_type_default, 'Efl_Gfx_Entity *') # TODO find a better test - self.assertEqual(t.c_type_param, 'Efl_Gfx_Entity *') - self.assertEqual(t.c_type_return, 'Efl_Gfx_Entity *') - cls = t.class_ self.assertIsInstance(cls, eolian.Class) self.assertEqual(cls.name, 'Efl.Gfx.Entity') diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index 7ef4387e1a..cc9c79bb79 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -375,12 +375,12 @@ EFL_START_TEST(eolian_typedef) fail_if(!(type_name = eolian_typedecl_short_name_get(tdl))); fail_if(strcmp(type_name, "List_Objects")); fail_if(!(type = eolian_typedecl_base_type_get(tdl))); - fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); + fail_if(!(type_name = eolian_type_c_type_get(type))); fail_if(strcmp(type_name, "Eina_List *")); eina_stringshare_del(type_name); fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!!eolian_type_next_type_get(type)); - fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); + fail_if(!(type_name = eolian_type_c_type_get(type))); fail_if(strcmp(type_name, "Typedef *")); eina_stringshare_del(type_name); @@ -432,14 +432,14 @@ EFL_START_TEST(eolian_complex_type) eina_stringshare_del(type_name); fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!!eolian_type_next_type_get(type)); - fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); + fail_if(!(type_name = eolian_type_c_type_get(type))); fail_if(eolian_type_is_move(type)); fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_ARRAY); fail_if(strcmp(type_name, "Eina_Array *")); eina_stringshare_del(type_name); fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!!eolian_type_next_type_get(type)); - fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); + fail_if(!(type_name = eolian_type_c_type_get(type))); fail_if(!eolian_type_is_move(type)); fail_if(strcmp(type_name, "Eina_Strbuf *")); eina_stringshare_del(type_name); @@ -456,7 +456,7 @@ EFL_START_TEST(eolian_complex_type) eina_stringshare_del(type_name); fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!!eolian_type_next_type_get(type)); - fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); + fail_if(!(type_name = eolian_type_c_type_get(type))); fail_if(eolian_type_is_move(type)); fail_if(strcmp(type_name, "const char *")); eina_stringshare_del(type_name); @@ -470,7 +470,7 @@ EFL_START_TEST(eolian_complex_type) eina_stringshare_del(type_name); fail_if(!(type = eolian_type_base_type_get(type))); fail_if(!!eolian_type_next_type_get(type)); - fail_if(!(type_name = eolian_type_c_type_get(type, EOLIAN_C_TYPE_DEFAULT))); + fail_if(!(type_name = eolian_type_c_type_get(type))); fail_if(eolian_type_is_move(type)); fail_if(eolian_type_builtin_type_get(type) != EOLIAN_TYPE_BUILTIN_STRINGSHARE); fail_if(strcmp(type_name, "Eina_Stringshare *"));