q66 pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=accdd50f50e18e5d2b3880f8ea49f2ebc123b7d8
commit accdd50f50e18e5d2b3880f8ea49f2ebc123b7d8 Author: Daniel Kolesa <[email protected]> Date: Wed Jul 9 17:18:02 2014 +0100 eolian: refactoring step five Move from all instances of Eolian_Type to Eolian_Type*. --- src/bin/eolian/eo_generator.c | 12 +- src/bin/eolian/impl_generator.c | 6 +- src/bin/eolian/legacy_generator.c | 12 +- src/bin/eolian_cxx/convert_comments.cc | 2 +- src/bin/eolian_cxx/type_lookup.hh | 2 +- src/lib/eolian/Eolian.h | 40 +++---- src/lib/eolian/eo_parser.c | 34 +++--- src/lib/eolian/eolian_database.c | 195 ++++++++++++++++----------------- src/lib/eolian/eolian_database.h | 16 +-- src/tests/eolian/eolian_parsing.c | 8 +- 10 files changed, 158 insertions(+), 169 deletions(-) diff --git a/src/bin/eolian/eo_generator.c b/src/bin/eolian/eo_generator.c index 29be0cd..397af3f 100644 --- a/src/bin/eolian/eo_generator.c +++ b/src/bin/eolian/eo_generator.c @@ -89,7 +89,7 @@ eo_fundef_generate(const Eolian_Class *class, Eolian_Function func, Eolian_Funct char descname[0xFF]; char *tmpstr = malloc(0x1FF); Eina_Bool var_as_ret = EINA_FALSE; - Eolian_Type rettypet = NULL; + Eolian_Type *rettypet = NULL; const char *rettype = NULL; Eina_Bool ret_const = EINA_FALSE; Eolian_Function_Scope scope = eolian_function_scope_get(func); @@ -152,7 +152,7 @@ eo_fundef_generate(const Eolian_Class *class, Eolian_Function func, Eolian_Funct EINA_LIST_FOREACH(eolian_property_keys_list_get(func), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; const char *pdesc = NULL; @@ -171,7 +171,7 @@ eo_fundef_generate(const Eolian_Class *class, Eolian_Function func, Eolian_Funct { EINA_LIST_FOREACH(eolian_parameters_list_get(func), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; const char *pdesc; @@ -331,7 +331,7 @@ eo_bind_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eolian_ _eolian_class_func_vars func_env; const char *suffix = ""; Eina_Bool var_as_ret = EINA_FALSE; - Eolian_Type rettypet = NULL; + Eolian_Type *rettypet = NULL; const char *rettype = NULL; const char *retname = NULL; Eina_Bool ret_const = EINA_FALSE; @@ -373,7 +373,7 @@ eo_bind_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eolian_ EINA_LIST_FOREACH(eolian_property_keys_list_get(funcid), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; eolian_parameter_information_get((Eolian_Function_Parameter*)data, NULL, &ptypet, &pname, NULL); @@ -392,7 +392,7 @@ eo_bind_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eolian_ { EINA_LIST_FOREACH(eolian_parameters_list_get(funcid), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; Eolian_Parameter_Dir pdir; diff --git a/src/bin/eolian/impl_generator.c b/src/bin/eolian/impl_generator.c index 06b7649..673de7c 100644 --- a/src/bin/eolian/impl_generator.c +++ b/src/bin/eolian/impl_generator.c @@ -16,7 +16,7 @@ _params_generate(Eolian_Function foo, Eolian_Function_Type ftype, Eina_Bool var_ eina_strbuf_reset(short_params); EINA_LIST_FOREACH(eolian_property_keys_list_get(foo), itr, param) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; eolian_parameter_information_get(param, NULL, &ptypet, &pname, NULL); @@ -40,7 +40,7 @@ _params_generate(Eolian_Function foo, Eolian_Function_Type ftype, Eina_Bool var_ Eina_Bool add_star = (ftype == EOLIAN_PROP_GET); EINA_LIST_FOREACH(eolian_parameters_list_get(foo), itr, param) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; Eolian_Parameter_Dir pdir; @@ -142,7 +142,7 @@ _prototype_generate(Eolian_Function foo, Eolian_Function_Type ftype, Eina_Strbuf if (_function_exists(func_name, buffer)) goto end; printf("Generation of function %s\n", func_name); - Eolian_Type rettypet = eolian_function_return_type_get(foo, ftype); + Eolian_Type *rettypet = eolian_function_return_type_get(foo, ftype); if (ftype == EOLIAN_PROP_GET && !rettypet) { const Eina_List *l = eolian_parameters_list_get(foo); diff --git a/src/bin/eolian/legacy_generator.c b/src/bin/eolian/legacy_generator.c index 1f9bf5f..7e30fac 100644 --- a/src/bin/eolian/legacy_generator.c +++ b/src/bin/eolian/legacy_generator.c @@ -47,7 +47,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eoli _eolian_class_func_vars func_env; const char *funcname = eolian_function_name_get(funcid); const char *suffix = ""; - Eolian_Type rettypet = NULL; + Eolian_Type *rettypet = NULL; const char *rettype = NULL; Eina_Bool var_as_ret = EINA_FALSE; Eina_Bool add_star = EINA_FALSE; @@ -106,7 +106,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eoli EINA_LIST_FOREACH(eolian_property_keys_list_get(funcid), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *pdesc; const char *ptype; @@ -133,7 +133,7 @@ _eapi_decl_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eoli { EINA_LIST_FOREACH(eolian_parameters_list_get(funcid), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *pdesc; const char *ptype; @@ -203,7 +203,7 @@ _eapi_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eolian_Fu _eolian_class_func_vars func_env; char tmpstr[0xFF]; Eina_Bool var_as_ret = EINA_FALSE; - Eolian_Type rettypet = NULL; + Eolian_Type *rettypet = NULL; const char *rettype = NULL; const char *retname = NULL; Eina_Bool ret_const = EINA_FALSE; @@ -254,7 +254,7 @@ _eapi_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eolian_Fu EINA_LIST_FOREACH(eolian_property_keys_list_get(funcid), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; eolian_parameter_information_get((Eolian_Function_Parameter*)data, NULL, &ptypet, &pname, NULL); @@ -270,7 +270,7 @@ _eapi_func_generate(const Eolian_Class *class, Eolian_Function funcid, Eolian_Fu { EINA_LIST_FOREACH(eolian_parameters_list_get(funcid), l, data) { - Eolian_Type ptypet; + Eolian_Type *ptypet; const char *pname; const char *ptype; Eolian_Parameter_Dir pdir; diff --git a/src/bin/eolian_cxx/convert_comments.cc b/src/bin/eolian_cxx/convert_comments.cc index 5331b3c..70f7e72 100644 --- a/src/bin/eolian_cxx/convert_comments.cc +++ b/src/bin/eolian_cxx/convert_comments.cc @@ -62,7 +62,7 @@ static std::string _comment_return(Eolian_Function function, Eolian_Function_Type rettype) { - Eolian_Type rettypet = eolian_function_return_type_get(function, rettype); + Eolian_Type *rettypet = eolian_function_return_type_get(function, rettype); const char *rettypes = NULL; if (rettypet) rettypes = eolian_type_c_type_get(rettypet); std::string doc = ""; diff --git a/src/bin/eolian_cxx/type_lookup.hh b/src/bin/eolian_cxx/type_lookup.hh index e185cd0..945586c 100644 --- a/src/bin/eolian_cxx/type_lookup.hh +++ b/src/bin/eolian_cxx/type_lookup.hh @@ -20,7 +20,7 @@ namespace eolian_cxx { inline std::string -type_lookup(Eolian_Type type) +type_lookup(Eolian_Type *type) { if (type == NULL) return "void"; diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 899bd95..3bb82a8 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -54,7 +54,7 @@ typedef struct _Eolian_Function* Eolian_Function; * * @ingroup Eolian */ -typedef struct _Eolian_Type* Eolian_Type; +typedef struct _Eolian_Type Eolian_Type; /* Class function parameter information * @@ -515,7 +515,7 @@ EAPI const Eina_List *eolian_parameters_list_get(Eolian_Function function_id); * * @ingroup Eolian */ -EAPI void eolian_parameter_information_get(const Eolian_Function_Parameter *param_desc, Eolian_Parameter_Dir *param_dir, Eolian_Type *type, const char **name, const char **description); +EAPI void eolian_parameter_information_get(const Eolian_Function_Parameter *param_desc, Eolian_Parameter_Dir *param_dir, Eolian_Type **type, const char **name, const char **description); /* * @brief Get type of a parameter @@ -525,7 +525,7 @@ EAPI void eolian_parameter_information_get(const Eolian_Function_Parameter *para * * @ingroup Eolian */ -EAPI Eolian_Type eolian_parameter_type_get(const Eolian_Function_Parameter *param); +EAPI Eolian_Type *eolian_parameter_type_get(const Eolian_Function_Parameter *param); /* * @brief Get name of a parameter @@ -573,7 +573,7 @@ EAPI Eina_Bool eolian_parameter_is_nonull(const Eolian_Function_Parameter *param * * @ingroup Eolian */ -EAPI Eolian_Type eolian_function_return_type_get(Eolian_Function function_id, Eolian_Function_Type ftype); +EAPI Eolian_Type *eolian_function_return_type_get(Eolian_Function function_id, Eolian_Function_Type ftype); /* * @brief Get the return default value of a function. @@ -716,7 +716,7 @@ EAPI Eina_Bool eolian_class_dtor_enable_get(const Eolian_Class *klass); * * @ingroup Eolian */ -EAPI Eolian_Type eolian_type_find_by_alias(const char *alias); +EAPI Eolian_Type *eolian_type_find_by_alias(const char *alias); /* * @brief Find a struct by name @@ -726,7 +726,7 @@ EAPI Eolian_Type eolian_type_find_by_alias(const char *alias); * * @ingroup Eolian */ -EAPI Eolian_Type eolian_type_struct_find_by_name(const char *name); +EAPI Eolian_Type *eolian_type_struct_find_by_name(const char *name); /* * @brief Get the type of a type (regular, function, pointer) @@ -737,7 +737,7 @@ EAPI Eolian_Type eolian_type_struct_find_by_name(const char *name); * * @ingroup Eolian */ -EAPI Eolian_Type_Type eolian_type_type_get(Eolian_Type tp); +EAPI Eolian_Type_Type eolian_type_type_get(Eolian_Type *tp); /* * @brief Get an iterator to all arguments of a function type. @@ -747,7 +747,7 @@ EAPI Eolian_Type_Type eolian_type_type_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eina_Iterator *eolian_type_arguments_list_get(Eolian_Type tp); +EAPI Eina_Iterator *eolian_type_arguments_list_get(Eolian_Type *tp); /* * @brief Get an iterator to all subtypes of a type. @@ -758,7 +758,7 @@ EAPI Eina_Iterator *eolian_type_arguments_list_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eina_Iterator *eolian_type_subtypes_list_get(Eolian_Type tp); +EAPI Eina_Iterator *eolian_type_subtypes_list_get(Eolian_Type *tp); /* * @brief Get an iterator to all field names of a struct type. @@ -768,7 +768,7 @@ EAPI Eina_Iterator *eolian_type_subtypes_list_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eina_Iterator *eolian_type_struct_field_names_list_get(Eolian_Type tp); +EAPI Eina_Iterator *eolian_type_struct_field_names_list_get(Eolian_Type *tp); /* * @brief Get a field of a struct type. @@ -780,7 +780,7 @@ EAPI Eina_Iterator *eolian_type_struct_field_names_list_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eolian_Type eolian_type_struct_field_get(Eolian_Type tp, const char *field); +EAPI Eolian_Type *eolian_type_struct_field_get(Eolian_Type *tp, const char *field); /* * @brief Get the description of a field of a struct type. @@ -792,7 +792,7 @@ EAPI Eolian_Type eolian_type_struct_field_get(Eolian_Type tp, const char *field) * * @ingroup Eolian */ -EAPI const char *eolian_type_struct_field_description_get(Eolian_Type tp, const char *field); +EAPI const char *eolian_type_struct_field_description_get(Eolian_Type *tp, const char *field); /* * @brief Get the description of a struct type. @@ -802,7 +802,7 @@ EAPI const char *eolian_type_struct_field_description_get(Eolian_Type tp, const * * @ingroup Eolian */ -EAPI const char *eolian_type_struct_description_get(Eolian_Type tp); +EAPI const char *eolian_type_struct_description_get(Eolian_Type *tp); /* * @brief Get the return type of a function type. @@ -812,7 +812,7 @@ EAPI const char *eolian_type_struct_description_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eolian_Type eolian_type_return_type_get(Eolian_Type tp); +EAPI Eolian_Type *eolian_type_return_type_get(Eolian_Type *tp); /* * @brief Get the base type of a function type. @@ -822,7 +822,7 @@ EAPI Eolian_Type eolian_type_return_type_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eolian_Type eolian_type_base_type_get(Eolian_Type tp); +EAPI Eolian_Type *eolian_type_base_type_get(Eolian_Type *tp); /* * @brief Get whether the given type is @own. @@ -833,7 +833,7 @@ EAPI Eolian_Type eolian_type_base_type_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eina_Bool eolian_type_is_own(Eolian_Type tp); +EAPI Eina_Bool eolian_type_is_own(Eolian_Type *tp); /* * @brief Get whether the given type is const. @@ -844,7 +844,7 @@ EAPI Eina_Bool eolian_type_is_own(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eina_Bool eolian_type_is_const(Eolian_Type tp); +EAPI Eina_Bool eolian_type_is_const(Eolian_Type *tp); /* * @brief Get the full C type name of the given type with a name. @@ -864,7 +864,7 @@ EAPI Eina_Bool eolian_type_is_const(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_type_c_type_named_get(Eolian_Type tp, const char *name); +EAPI Eina_Stringshare *eolian_type_c_type_named_get(Eolian_Type *tp, const char *name); /* * @brief Get the full C type name of the given type without a name. @@ -880,7 +880,7 @@ EAPI Eina_Stringshare *eolian_type_c_type_named_get(Eolian_Type tp, const char * * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_type_c_type_get(Eolian_Type tp); +EAPI Eina_Stringshare *eolian_type_c_type_get(Eolian_Type *tp); /* * @brief Get the type name of the given type. You have to manually delete @@ -892,7 +892,7 @@ EAPI Eina_Stringshare *eolian_type_c_type_get(Eolian_Type tp); * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_type_name_get(Eolian_Type tp); +EAPI Eina_Stringshare *eolian_type_name_get(Eolian_Type *tp); #endif diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index 2703c39..4e5ac72 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -1085,14 +1085,14 @@ _dump_class(Eo_Class_Def *kls) if (meth->ret) { printf(" return: "); - database_type_print((Eolian_Type)meth->ret->type); + database_type_print((Eolian_Type*)meth->ret->type); printf(" (%s)\n", meth->ret->comment); } printf(" legacy : %s\n", meth->legacy); EINA_LIST_FOREACH(meth->params, m, param) { printf(" param: %s %s : ", _param_way_str[param->way], param->name); - database_type_print((Eolian_Type)param->type); + database_type_print((Eolian_Type*)param->type); printf(" (%s)\n", param->comment); } } @@ -1103,20 +1103,20 @@ _dump_class(Eo_Class_Def *kls) EINA_LIST_FOREACH(prop->keys, m, param) { printf(" key: %s : ", param->name); - database_type_print((Eolian_Type)param->type); + database_type_print((Eolian_Type*)param->type); printf(" (%s)\n", param->comment); } EINA_LIST_FOREACH(prop->values, m, param) { printf(" value: %s : ", param->name); - database_type_print((Eolian_Type)param->type); + database_type_print((Eolian_Type*)param->type); printf(" (%s)\n", param->comment); } EINA_LIST_FOREACH(prop->accessors, m, accessor) { printf(" accessor: "); if (accessor->ret) - database_type_print((Eolian_Type)accessor->ret->type); + database_type_print((Eolian_Type*)accessor->ret->type); printf(" : %s (%s)\n", _accessor_type_str[accessor->type], accessor->comment); printf(" legacy : %s\n", accessor->legacy); } @@ -1128,7 +1128,7 @@ _dump_class(Eo_Class_Def *kls) if (meth->ret) { printf(" return: "); - database_type_print((Eolian_Type)meth->ret->type); + database_type_print((Eolian_Type*)meth->ret->type); printf(" (%s)\n", meth->ret->comment); } printf(" legacy : %s\n", meth->legacy); @@ -1136,7 +1136,7 @@ _dump_class(Eo_Class_Def *kls) EINA_LIST_FOREACH(meth->params, m, param) { printf(" param: %s %s : ", _param_way_str[param->way], param->name); - database_type_print((Eolian_Type)param->type); + database_type_print((Eolian_Type*)param->type); printf(" (%s)\n", param->comment); } } @@ -1146,14 +1146,14 @@ static void _dump_type(Eo_Typedef_Def *type) { printf("Typedef: %s ", type->alias); - database_type_print((Eolian_Type)type->type); + database_type_print((Eolian_Type*)type->type); printf("\n"); } static void _dump_struct(Eo_Type_Def *type) { - database_type_print((Eolian_Type)type); + database_type_print((Eolian_Type*)type); } void @@ -1233,7 +1233,7 @@ _db_fill_class(Eo_Class_Def *kls, const char *filename) database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy); EINA_LIST_FOREACH(meth->params, m, param) { - database_method_parameter_add(foo_id, (Eolian_Parameter_Dir)param->way, (Eolian_Type)param->type, param->name, param->comment); + database_method_parameter_add(foo_id, (Eolian_Parameter_Dir)param->way, (Eolian_Type*)param->type, param->name, param->comment); param->type = NULL; } } @@ -1245,14 +1245,14 @@ _db_fill_class(Eo_Class_Def *kls, const char *filename) EINA_LIST_FOREACH(prop->keys, m, param) { Eolian_Function_Parameter *p = database_property_key_add( - foo_id, (Eolian_Type)param->type, param->name, param->comment); + foo_id, (Eolian_Type*)param->type, param->name, param->comment); database_parameter_nonull_set(p, param->nonull); param->type = NULL; } EINA_LIST_FOREACH(prop->values, m, param) { Eolian_Function_Parameter *p = database_property_value_add( - foo_id, (Eolian_Type)param->type, param->name, param->comment); + foo_id, (Eolian_Type*)param->type, param->name, param->comment); database_parameter_nonull_set(p, param->nonull); param->type = NULL; } @@ -1263,7 +1263,7 @@ _db_fill_class(Eo_Class_Def *kls, const char *filename) accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET; if (accessor->ret && accessor->ret->type) { - database_function_return_type_set(foo_id, ftype, (Eolian_Type)accessor->ret->type); + database_function_return_type_set(foo_id, ftype, (Eolian_Type*)accessor->ret->type); database_function_return_comment_set(foo_id, ftype, accessor->ret->comment); database_function_return_flag_set_as_warn_unused(foo_id, @@ -1315,7 +1315,7 @@ _db_fill_class(Eo_Class_Def *kls, const char *filename) database_class_function_add(class, foo_id); if (meth->ret) { - database_function_return_type_set(foo_id, EOLIAN_METHOD, (Eolian_Type)meth->ret->type); + database_function_return_type_set(foo_id, EOLIAN_METHOD, (Eolian_Type*)meth->ret->type); database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment); database_function_return_flag_set_as_warn_unused(foo_id, EOLIAN_METHOD, meth->ret->warn_unused); @@ -1329,7 +1329,7 @@ _db_fill_class(Eo_Class_Def *kls, const char *filename) EINA_LIST_FOREACH(meth->params, m, param) { Eolian_Function_Parameter *p = database_method_parameter_add(foo_id, - (Eolian_Parameter_Dir)param->way, (Eolian_Type)param->type, param->name, param->comment); + (Eolian_Parameter_Dir)param->way, (Eolian_Type*)param->type, param->name, param->comment); database_parameter_nonull_set(p, param->nonull); param->type = NULL; } @@ -1392,7 +1392,7 @@ _db_fill_class(Eo_Class_Def *kls, const char *filename) static Eina_Bool _db_fill_type(Eo_Typedef_Def *type_def) { - Eina_Bool ret = database_type_add(type_def->alias, (Eolian_Type)type_def->type); + Eina_Bool ret = database_type_add(type_def->alias, (Eolian_Type*)type_def->type); type_def->type = NULL; return ret; } @@ -1400,7 +1400,7 @@ _db_fill_type(Eo_Typedef_Def *type_def) static Eina_Bool _db_fill_struct(Eo_Type_Def *struct_def) { - return database_struct_add((Eolian_Type)struct_def); + return database_struct_add((Eolian_Type*)struct_def); } Eina_Bool diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c index 34b248e..964843b 100644 --- a/src/lib/eolian/eolian_database.c +++ b/src/lib/eolian/eolian_database.c @@ -45,7 +45,7 @@ typedef struct _Eolian_Class typedef struct { Eina_Stringshare *alias; - Eolian_Type type; + Eolian_Type *type; } Type_Desc; typedef struct @@ -55,8 +55,8 @@ typedef struct Eina_List *params; /* list of Eolian_Function_Parameter */ Eolian_Function_Type type; Eolian_Function_Scope scope; - Eolian_Type get_ret_type; - Eolian_Type set_ret_type; + Eolian_Type *get_ret_type; + Eolian_Type *set_ret_type; Eina_Hash *data; Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */ Eina_Bool get_virtual_pure :1; @@ -68,7 +68,7 @@ typedef struct typedef struct _Eolian_Function_Parameter { Eina_Stringshare *name; - Eolian_Type type; + Eolian_Type *type; Eina_Stringshare *description; Eolian_Parameter_Dir param_dir; Eina_Bool is_const_on_get :1; /* True if const in this the get property */ @@ -80,22 +80,22 @@ typedef struct _Eolian_Function_Parameter typedef struct { - Eolian_Type type; + Eolian_Type *type; const char *comment; } _Struct_Field_Type; -typedef struct +typedef struct _Eolian_Type { const char *name; Eolian_Type_Type type; union { struct { Eina_List *subtypes; - Eolian_Type base_type; + Eolian_Type *base_type; }; struct { Eina_List *arguments; - Eolian_Type ret_type; + Eolian_Type *ret_type; }; struct { Eina_Hash *fields; @@ -104,7 +104,7 @@ typedef struct }; Eina_Bool is_const :1; Eina_Bool is_own :1; -} _Eolian_Type; +} Eolian_Type; typedef struct _Eolian_Implement { @@ -129,7 +129,7 @@ _param_del(Eolian_Function_Parameter *pdesc) } void -database_type_del(Eolian_Type type) +database_type_del(Eolian_Type *type) { if (!type) return; eo_definitions_type_free((Eo_Type_Def*)type); @@ -227,7 +227,7 @@ database_shutdown() } Eina_Bool -database_type_add(const char *alias, Eolian_Type type) +database_type_add(const char *alias, Eolian_Type *type) { if (_types) { @@ -240,9 +240,8 @@ database_type_add(const char *alias, Eolian_Type type) return EINA_FALSE; } -Eina_Bool database_struct_add(Eolian_Type type) +Eina_Bool database_struct_add(Eolian_Type *tp) { - _Eolian_Type *tp = (_Eolian_Type*)type; if (_structs) { eina_hash_set(_structs, tp->name, tp); @@ -251,7 +250,7 @@ Eina_Bool database_struct_add(Eolian_Type type) return EINA_FALSE; } -EAPI Eolian_Type +EAPI Eolian_Type * eolian_type_find_by_alias(const char *alias) { if (!_types) return NULL; @@ -261,12 +260,12 @@ eolian_type_find_by_alias(const char *alias) return cl?cl->type:NULL; } -EAPI Eolian_Type +EAPI Eolian_Type * eolian_type_struct_find_by_name(const char *name) { if (!_structs) return NULL; Eina_Stringshare *shr = eina_stringshare_add(name); - Eolian_Type tp = eina_hash_find(_structs, shr); + Eolian_Type *tp = eina_hash_find(_structs, shr); eina_stringshare_del(shr); return tp; } @@ -777,7 +776,7 @@ eolian_function_data_get(Eolian_Function function_id, const char *key) } static Eolian_Function_Parameter * -_parameter_new(Eolian_Type type, const char *name, const char *description) +_parameter_new(Eolian_Type *type, const char *name, const char *description) { Eolian_Function_Parameter *param = NULL; param = calloc(1, sizeof(*param)); @@ -788,7 +787,7 @@ _parameter_new(Eolian_Type type, const char *name, const char *description) } Eolian_Function_Parameter * -database_property_key_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description) +database_property_key_add(Eolian_Function foo_id, Eolian_Type *type, const char *name, const char *description) { _Eolian_Function *fid = (_Eolian_Function *)foo_id; EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL); @@ -798,7 +797,7 @@ database_property_key_add(Eolian_Function foo_id, Eolian_Type type, const char * } Eolian_Function_Parameter * -database_property_value_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description) +database_property_value_add(Eolian_Function foo_id, Eolian_Type *type, const char *name, const char *description) { _Eolian_Function *fid = (_Eolian_Function *)foo_id; EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL); @@ -808,7 +807,7 @@ database_property_value_add(Eolian_Function foo_id, Eolian_Type type, const char } Eolian_Function_Parameter * -database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type type, const char *name, const char *description) +database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type *type, const char *name, const char *description) { _Eolian_Function *fid = (_Eolian_Function *)foo_id; EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL); @@ -832,7 +831,7 @@ eolian_function_parameter_get(const Eolian_Function foo_id, const char *param_na return NULL; } -EAPI Eolian_Type +EAPI Eolian_Type * eolian_parameter_type_get(const Eolian_Function_Parameter *param) { EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL); @@ -871,7 +870,7 @@ eolian_parameters_list_get(Eolian_Function foo_id) /* Get parameter information */ EAPI void -eolian_parameter_information_get(const Eolian_Function_Parameter *param, Eolian_Parameter_Dir *param_dir, Eolian_Type *type, const char **name, const char **description) +eolian_parameter_information_get(const Eolian_Function_Parameter *param, Eolian_Parameter_Dir *param_dir, Eolian_Type **type, const char **name, const char **description) { EINA_SAFETY_ON_NULL_RETURN(param); if (param_dir) *param_dir = param->param_dir; @@ -891,7 +890,7 @@ database_parameter_const_attribute_set(Eolian_Function_Parameter *param, Eina_Bo } void -database_parameter_type_set(Eolian_Function_Parameter *param, Eolian_Type types) +database_parameter_type_set(Eolian_Function_Parameter *param, Eolian_Type *types) { EINA_SAFETY_ON_NULL_RETURN(param); param->type = types; @@ -921,7 +920,7 @@ eolian_parameter_is_nonull(const Eolian_Function_Parameter *param) return param->nonull; } -void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, Eolian_Type ret_type) +void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, Eolian_Type *ret_type) { _Eolian_Function *fid = (_Eolian_Function *)foo_id; switch (ftype) @@ -932,7 +931,7 @@ void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_T } } -EAPI Eolian_Type +EAPI Eolian_Type * eolian_function_return_type_get(Eolian_Function foo_id, Eolian_Function_Type ftype) { _Eolian_Function *fid = (_Eolian_Function *)foo_id; @@ -1117,129 +1116,122 @@ eolian_class_dtor_enable_get(const Eolian_Class *cl) } EAPI Eolian_Type_Type -eolian_type_type_get(Eolian_Type tp) +eolian_type_type_get(Eolian_Type *tp) { EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EOLIAN_TYPE_UNKNOWN_TYPE); - return ((_Eolian_Type*)tp)->type; + return tp->type; } EAPI Eina_Iterator * -eolian_type_arguments_list_get(Eolian_Type tp) +eolian_type_arguments_list_get(Eolian_Type *tp) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); EINA_SAFETY_ON_FALSE_RETURN_VAL(eolian_type_type_get(tp) == EOLIAN_TYPE_FUNCTION, NULL); - if (!tpp->arguments) return NULL; - return eina_list_iterator_new(tpp->arguments); + if (!tp->arguments) return NULL; + return eina_list_iterator_new(tp->arguments); } EAPI Eina_Iterator * -eolian_type_subtypes_list_get(Eolian_Type tp) +eolian_type_subtypes_list_get(Eolian_Type *tp) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; Eolian_Type_Type tpt; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); - tpt = tpp->type; + tpt = tp->type; EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_REGULAR || tpt == EOLIAN_TYPE_POINTER || tpt == EOLIAN_TYPE_REGULAR_STRUCT, NULL); - if (!tpp->subtypes) return NULL; - return eina_list_iterator_new(tpp->subtypes); + if (!tp->subtypes) return NULL; + return eina_list_iterator_new(tp->subtypes); } EAPI Eina_Iterator * -eolian_type_struct_field_names_list_get(Eolian_Type tp) +eolian_type_struct_field_names_list_get(Eolian_Type *tp) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); - EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL); - return eina_hash_iterator_key_new(tpp->fields); + EINA_SAFETY_ON_FALSE_RETURN_VAL(tp->type == EOLIAN_TYPE_STRUCT, NULL); + return eina_hash_iterator_key_new(tp->fields); } -EAPI Eolian_Type -eolian_type_struct_field_get(Eolian_Type tp, const char *field) +EAPI Eolian_Type * +eolian_type_struct_field_get(Eolian_Type *tp, const char *field) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; _Struct_Field_Type *sf = NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL); - EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL); - sf = eina_hash_find(tpp->fields, field); + EINA_SAFETY_ON_FALSE_RETURN_VAL(tp->type == EOLIAN_TYPE_STRUCT, NULL); + sf = eina_hash_find(tp->fields, field); if (!sf) return NULL; return sf->type; } EAPI const char * -eolian_type_struct_field_description_get(Eolian_Type tp, const char *field) +eolian_type_struct_field_description_get(Eolian_Type *tp, const char *field) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; _Struct_Field_Type *sf = NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(field, NULL); - EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL); - sf = eina_hash_find(tpp->fields, field); + EINA_SAFETY_ON_FALSE_RETURN_VAL(tp->type == EOLIAN_TYPE_STRUCT, NULL); + sf = eina_hash_find(tp->fields, field); if (!sf) return NULL; return sf->comment; } EAPI const char * -eolian_type_struct_description_get(Eolian_Type tp) +eolian_type_struct_description_get(Eolian_Type *tp) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); - EINA_SAFETY_ON_FALSE_RETURN_VAL(tpp->type == EOLIAN_TYPE_STRUCT, NULL); - return tpp->comment; + EINA_SAFETY_ON_FALSE_RETURN_VAL(tp->type == EOLIAN_TYPE_STRUCT, NULL); + return tp->comment; } -EAPI Eolian_Type -eolian_type_return_type_get(Eolian_Type tp) +EAPI Eolian_Type * +eolian_type_return_type_get(Eolian_Type *tp) { EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); EINA_SAFETY_ON_FALSE_RETURN_VAL(eolian_type_type_get(tp) == EOLIAN_TYPE_FUNCTION, NULL); - return ((_Eolian_Type*)tp)->ret_type; + return tp->ret_type; } -EAPI Eolian_Type -eolian_type_base_type_get(Eolian_Type tp) +EAPI Eolian_Type * +eolian_type_base_type_get(Eolian_Type *tp) { Eolian_Type_Type tpt; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); tpt = eolian_type_type_get(tp); EINA_SAFETY_ON_FALSE_RETURN_VAL(tpt == EOLIAN_TYPE_POINTER, NULL); - return ((_Eolian_Type*)tp)->base_type; + return tp->base_type; } EAPI Eina_Bool -eolian_type_is_own(Eolian_Type tp) +eolian_type_is_own(Eolian_Type *tp) { EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE); - return ((_Eolian_Type*)tp)->is_own; + return tp->is_own; } EAPI Eina_Bool -eolian_type_is_const(Eolian_Type tp) +eolian_type_is_const(Eolian_Type *tp) { EINA_SAFETY_ON_NULL_RETURN_VAL(tp, EINA_FALSE); - return ((_Eolian_Type*)tp)->is_const; + return tp->is_const; } -static void _type_to_str(Eolian_Type tp, Eina_Strbuf *buf, const char *name); +static void _type_to_str(Eolian_Type *tp, Eina_Strbuf *buf, const char *name); static void -_ftype_to_str(Eolian_Type tp, Eina_Strbuf *buf, const char *name) +_ftype_to_str(Eolian_Type *tp, Eina_Strbuf *buf, const char *name) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; Eina_List *l; - Eolian_Type stp; + Eolian_Type *stp; Eina_Bool first = EINA_TRUE; - if (tpp->ret_type) - _type_to_str(tpp->ret_type, buf, NULL); + if (tp->ret_type) + _type_to_str(tp->ret_type, buf, NULL); else eina_strbuf_append(buf, "void"); eina_strbuf_append(buf, " (*"); if (name) eina_strbuf_append(buf, name); eina_strbuf_append(buf, ")("); - EINA_LIST_FOREACH(tpp->arguments, l, stp) + EINA_LIST_FOREACH(tp->arguments, l, stp) { if (!first) eina_strbuf_append(buf, ", "); first = EINA_FALSE; @@ -1251,24 +1243,23 @@ static Eina_Bool _stype_field_cb(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, void *fdata) { - _type_to_str((Eolian_Type)((_Struct_Field_Type*)data)->type, + _type_to_str((Eolian_Type*)((_Struct_Field_Type*)data)->type, (Eina_Strbuf*)fdata, (const char*)key); eina_strbuf_append((Eina_Strbuf*)fdata, "; "); return EINA_TRUE; } static void -_stype_to_str(Eolian_Type tp, Eina_Strbuf *buf, const char *name) +_stype_to_str(Eolian_Type *tp, Eina_Strbuf *buf, const char *name) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; eina_strbuf_append(buf, "struct "); - if (tpp->name) + if (tp->name) { - eina_strbuf_append(buf, tpp->name); + eina_strbuf_append(buf, tp->name); eina_strbuf_append_char(buf, ' '); } eina_strbuf_append(buf, "{ "); - eina_hash_foreach(tpp->fields, _stype_field_cb, buf); + eina_hash_foreach(tp->fields, _stype_field_cb, buf); eina_strbuf_append(buf, "}"); if (name) { @@ -1278,43 +1269,42 @@ _stype_to_str(Eolian_Type tp, Eina_Strbuf *buf, const char *name) } static void -_type_to_str(Eolian_Type tp, Eina_Strbuf *buf, const char *name) +_type_to_str(Eolian_Type *tp, Eina_Strbuf *buf, const char *name) { - _Eolian_Type *tpp = (_Eolian_Type*)tp; - if (tpp->type == EOLIAN_TYPE_FUNCTION) + if (tp->type == EOLIAN_TYPE_FUNCTION) { _ftype_to_str(tp, buf, name); return; } - else if (tpp->type == EOLIAN_TYPE_STRUCT) + else if (tp->type == EOLIAN_TYPE_STRUCT) { _stype_to_str(tp, buf, name); return; } - if ((tpp->type == EOLIAN_TYPE_REGULAR - || tpp->type == EOLIAN_TYPE_REGULAR_STRUCT - || tpp->type == EOLIAN_TYPE_VOID) - && tpp->is_const) + if ((tp->type == EOLIAN_TYPE_REGULAR + || tp->type == EOLIAN_TYPE_REGULAR_STRUCT + || tp->type == EOLIAN_TYPE_VOID) + && tp->is_const) { eina_strbuf_append(buf, "const "); } - if (tpp->type == EOLIAN_TYPE_REGULAR) - eina_strbuf_append(buf, tpp->name); - else if (tpp->type == EOLIAN_TYPE_REGULAR_STRUCT) + if (tp->type == EOLIAN_TYPE_REGULAR) + eina_strbuf_append(buf, tp->name); + else if (tp->type == EOLIAN_TYPE_REGULAR_STRUCT) { eina_strbuf_append(buf, "struct "); - eina_strbuf_append(buf, tpp->name); + eina_strbuf_append(buf, tp->name); } - else if (tpp->type == EOLIAN_TYPE_VOID) + else if (tp->type == EOLIAN_TYPE_VOID) eina_strbuf_append(buf, "void"); else { - _Eolian_Type *btpp = (_Eolian_Type*)tpp->base_type; - _type_to_str(tpp->base_type, buf, NULL); - if (btpp->type != EOLIAN_TYPE_POINTER || btpp->is_const) + Eolian_Type *btp = tp->base_type; + _type_to_str(tp->base_type, buf, NULL); + if (btp->type != EOLIAN_TYPE_POINTER || btp->is_const) eina_strbuf_append_char(buf, ' '); eina_strbuf_append_char(buf, '*'); - if (tpp->is_const) eina_strbuf_append(buf, " const"); + if (tp->is_const) eina_strbuf_append(buf, " const"); } if (name) { @@ -1324,7 +1314,7 @@ _type_to_str(Eolian_Type tp, Eina_Strbuf *buf, const char *name) } EAPI Eina_Stringshare * -eolian_type_c_type_named_get(Eolian_Type tp, const char *name) +eolian_type_c_type_named_get(Eolian_Type *tp, const char *name) { Eina_Stringshare *ret; Eina_Strbuf *buf; @@ -1337,17 +1327,17 @@ eolian_type_c_type_named_get(Eolian_Type tp, const char *name) } EAPI Eina_Stringshare * -eolian_type_c_type_get(Eolian_Type tp) +eolian_type_c_type_get(Eolian_Type *tp) { return eolian_type_c_type_named_get(tp, NULL); } EAPI Eina_Stringshare * -eolian_type_name_get(Eolian_Type tp) +eolian_type_name_get(Eolian_Type *tp) { EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); - eina_stringshare_ref(((_Eolian_Type*)tp)->name); - return ((_Eolian_Type*)tp)->name; + eina_stringshare_ref(tp->name); + return tp->name; } static Eina_Bool @@ -1355,17 +1345,16 @@ _print_field(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, void *fdata EINA_UNUSED) { printf("%s: ", (const char*)key); - database_type_print((Eolian_Type)data); + database_type_print((Eolian_Type*)data); puts("; "); return EINA_TRUE; } void -database_type_print(Eolian_Type type) +database_type_print(Eolian_Type *tp) { Eina_List *l; - Eolian_Type stp; - _Eolian_Type *tp = (_Eolian_Type*)type; + Eolian_Type *stp; if (tp->is_own) puts("own("); if (tp->is_const) @@ -1537,7 +1526,7 @@ static Eina_Bool _function_print(const _Eolian_Function *fid, int nb_spaces) break; } printf("%*s%s <%s> <", nb_spaces + 5, "", param_dir, param->name); - database_type_print((Eolian_Type)param->type); + database_type_print((Eolian_Type*)param->type); printf("> <%s>\n", param->description?param->description:""); } return EINA_TRUE; diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h index f80cf3b..eca7426 100644 --- a/src/lib/eolian/eolian_database.h +++ b/src/lib/eolian/eolian_database.h @@ -35,10 +35,10 @@ int database_init(); int database_shutdown(); /* Add a type in the database */ -Eina_Bool database_type_add(const char *alias, Eolian_Type type); +Eina_Bool database_type_add(const char *alias, Eolian_Type *type); /* Add a struct in the database */ -Eina_Bool database_struct_add(Eolian_Type type); +Eina_Bool database_struct_add(Eolian_Type *type); /* Add a class in the database */ Eolian_Class *database_class_add(const char *class_name, Eolian_Class_Type type); @@ -85,21 +85,21 @@ void database_function_data_set(Eolian_Function function_id, const char *key, co #define database_function_description_set(foo_id, key, desc) database_function_data_set((foo_id), (key), (desc)) /* Add a key to a property */ -Eolian_Function_Parameter *database_property_key_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description); +Eolian_Function_Parameter *database_property_key_add(Eolian_Function foo_id, Eolian_Type *type, const char *name, const char *description); /* Add a value to a property */ -Eolian_Function_Parameter *database_property_value_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description); +Eolian_Function_Parameter *database_property_value_add(Eolian_Function foo_id, Eolian_Type *type, const char *name, const char *description); /* Add a parameter to a method */ -Eolian_Function_Parameter *database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type type, const char *name, const char *description); +Eolian_Function_Parameter *database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type *type, const char *name, const char *description); -void database_type_del(Eolian_Type type); +void database_type_del(Eolian_Type *type); void database_parameter_const_attribute_set(Eolian_Function_Parameter *param, Eina_Bool is_get, Eina_Bool is_const); void database_parameter_nonull_set(Eolian_Function_Parameter *param, Eina_Bool nonull); -void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, Eolian_Type ret_type); +void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, Eolian_Type *ret_type); void database_function_return_comment_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_comment); @@ -140,6 +140,6 @@ Eina_Bool database_class_event_add(Eolian_Class *class, Eolian_Event *event_desc); void -database_type_print(Eolian_Type type); +database_type_print(Eolian_Type *type); #endif diff --git a/src/tests/eolian/eolian_parsing.c b/src/tests/eolian/eolian_parsing.c index e6f3d9c..ac30fce 100644 --- a/src/tests/eolian/eolian_parsing.c +++ b/src/tests/eolian/eolian_parsing.c @@ -217,7 +217,7 @@ END_TEST START_TEST(eolian_typedef) { - Eolian_Type type = NULL; + Eolian_Type *type = NULL; const char *type_name = NULL; Eina_Iterator *iter = NULL; Eolian_Class *class; @@ -262,7 +262,7 @@ START_TEST(eolian_complex_type) Eolian_Function fid = NULL; Eolian_Function_Parameter *param = NULL; const Eina_List *params_list = NULL; - Eolian_Type type = NULL; + Eolian_Type *type = NULL; const char *type_name = NULL; Eina_Iterator *iter = NULL; Eolian_Class *class; @@ -373,13 +373,13 @@ END_TEST START_TEST(eolian_simple_parsing) { Eolian_Function fid = NULL; - Eolian_Type ptypep = NULL; + Eolian_Type *ptypep = NULL; const char *string = NULL, *ptype = NULL, *pname = NULL; Eolian_Parameter_Dir dir = EOLIAN_IN_PARAM; const Eina_List *list = NULL; Eolian_Function_Parameter *param = NULL; Eolian_Class *class; - Eolian_Type tp; + Eolian_Type *tp; eolian_init(); /* Parsing */ --
