From d355bf56d8be4905aaa0f5a247c58f8141dfd09e Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Mon, 12 Mar 2018 16:10:32 +0100 Subject: [PATCH] eolian: make more name APIs into inline helpers --- src/lib/eolian/Eolian.h | 130 +++++++++++++---------- src/lib/eolian/database_constructor_api.c | 7 -- src/lib/eolian/database_event_api.c | 7 -- src/lib/eolian/database_function_api.c | 7 -- src/lib/eolian/database_function_parameter_api.c | 7 -- src/lib/eolian/database_implement_api.c | 7 -- src/lib/eolian/database_part_api.c | 7 -- src/lib/eolian/database_type_api.c | 14 --- 8 files changed, 74 insertions(+), 112 deletions(-) diff --git a/src/lib/eolian/Eolian.h b/src/lib/eolian/Eolian.h index 6932909..8ecd254 100644 --- a/src/lib/eolian/Eolian.h +++ b/src/lib/eolian/Eolian.h @@ -1180,13 +1180,9 @@ EAPI Eina_Iterator *eolian_unit_structs_get(const Eolian_Unit *unit); EAPI Eina_Iterator *eolian_unit_enums_get(const Eolian_Unit *unit); /* - * @brief Returns the full name of the given class. + * @brief A helper function to get the full name of a class. * - * @param[in] class the class. - * @return the full name of the class on success or NULL otherwise. - * - * The full name and the name of a class will be different if namespaces - * are used. + * @see eolian_object_name_get * * @ingroup Eolian */ @@ -1197,10 +1193,9 @@ eolian_class_name_get(const Eolian_Class *klass) } /* - * @brief Returns the name of the given class. + * @brief A helper function to get the short name of a class. * - * @param[in] class the class. - * @return the name of the class on success or NULL otherwise. + * @see eolian_object_short_name_get * * @ingroup Eolian */ @@ -1211,10 +1206,9 @@ eolian_class_short_name_get(const Eolian_Class *klass) } /* - * @brief Returns an iterator to the namespaces of the given class. + * @brief A helper function to get the namespaces of a class. * - * @param[in] class the class. - * @return the iterator on success or NULL otherwise. + * @see eolian_object_namespaces_get * * @ingroup Eolian */ @@ -1331,14 +1325,17 @@ EAPI Eolian_Function_Type eolian_function_type_get(const Eolian_Function *functi EAPI Eolian_Object_Scope eolian_function_scope_get(const Eolian_Function *function_id, Eolian_Function_Type ftype); /* - * @brief Returns the name of a function + * @brief A helper function to get the name of a function. * - * @param[in] function_id Id of the function - * @return the function name + * @see eolian_object_name_get * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_function_name_get(const Eolian_Function *function_id); +static inline const char * +eolian_function_name_get(const Eolian_Function *fid) +{ + return eolian_object_name_get(EOLIAN_OBJECT(fid)); +} /* * @brief Returns the full C name of a function. @@ -1522,14 +1519,17 @@ EAPI const Eolian_Type *eolian_parameter_type_get(const Eolian_Function_Paramete EAPI const Eolian_Expression *eolian_parameter_default_value_get(const Eolian_Function_Parameter *param); /* - * @brief Get name of a parameter + * @brief A helper function to get the name of a function parameter. * - * @param[in] param_desc parameter handle - * @return the name of the parameter + * @see eolian_object_name_get * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_parameter_name_get(const Eolian_Function_Parameter *param); +static inline const char * +eolian_parameter_name_get(const Eolian_Function_Parameter *param) +{ + return eolian_object_name_get(EOLIAN_OBJECT(param)); +} /* * @brief Get documentation of a parameter @@ -1658,14 +1658,17 @@ EAPI Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_i EAPI const Eolian_Class *eolian_function_class_get(const Eolian_Function *function_id); /* - * @brief Get full string of an overriding function (implement). + * @brief A helper function to get the full name of an implement. * - * @param[in] impl the handle of the implement - * @return the full string. + * @see eolian_object_name_get * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_implement_full_name_get(const Eolian_Implement *impl); +static inline const char * +eolian_implement_name_get(const Eolian_Implement *impl) +{ + return eolian_object_name_get(EOLIAN_OBJECT(impl)); +} /* * @brief Get the class of an overriding function (implement). @@ -1776,14 +1779,17 @@ EAPI Eina_Bool eolian_implement_is_prop_set(const Eolian_Implement *impl); EAPI Eina_Iterator *eolian_class_implements_get(const Eolian_Class *klass); /* - * @brief Get full string of a constructing function. + * @brief A helper function to get the full name of a constructor. * - * @param[in] ctor the handle of the constructor - * @return the full string. + * @see eolian_object_name_get * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_constructor_full_name_get(const Eolian_Constructor *ctor); +static inline const char * +eolian_constructor_name_get(const Eolian_Constructor *ctor) +{ + return eolian_object_name_get(EOLIAN_OBJECT(ctor)); +} /* * @brief Get the class of a constructing function. @@ -1836,14 +1842,17 @@ EAPI Eina_Iterator *eolian_class_constructors_get(const Eolian_Class *klass); EAPI Eina_Iterator *eolian_class_events_get(const Eolian_Class *klass); /* - * @brief Get the name of an event. + * @brief A helper function to get the name of an event. * - * @param[in] event the event handle - * @return the name or NULL + * @see eolian_object_name_get * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_event_name_get(const Eolian_Event *event); +static inline const char * +eolian_event_name_get(const Eolian_Event *event) +{ + return eolian_object_name_get(EOLIAN_OBJECT(event)); +} /* * @brief Get the type of an event. @@ -1920,14 +1929,29 @@ EAPI Eina_Bool eolian_event_is_restart(const Eolian_Event *event); EAPI Eina_Iterator *eolian_class_parts_get(const Eolian_Class *klass); /* - * @brief Get the name of a part. + * @brief Returns the C name of an event * - * @param[in] part the part handle - * @return the name or NULL + * @param[in] event the event handle + * @return the event C name + * + * You're responsible for deleting the stringshare. * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_part_name_get(const Eolian_Part *part); +EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event); + +/* + * @brief A helper function to get the name of a part. + * + * @see eolian_object_name_get + * + * @ingroup Eolian + */ +static inline const char * +eolian_part_name_get(const Eolian_Part *part) +{ + return eolian_object_name_get(EOLIAN_OBJECT(part)); +} /* * @brief Get the type of a part. @@ -1950,18 +1974,6 @@ EAPI const Eolian_Class *eolian_part_class_get(const Eolian_Part *part); EAPI const Eolian_Documentation *eolian_part_documentation_get(const Eolian_Part *part); /* - * @brief Returns the C name of an event - * - * @param[in] event the event handle - * @return the event C name - * - * You're responsible for deleting the stringshare. - * - * @ingroup Eolian - */ -EAPI Eina_Stringshare *eolian_event_c_name_get(const Eolian_Event *event); - -/* * @brief Get an event in a class by its name * * @param[in] klass the class @@ -2075,14 +2087,17 @@ EAPI Eina_Iterator *eolian_typedecl_struct_fields_get(const Eolian_Typedecl *tp) EAPI const Eolian_Struct_Type_Field *eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field); /* - * @brief Get the name of a field of a struct type. + * @brief A helper function to get the name of a struct field. * - * @param[in] fl the field. - * @return the name. + * @see eolian_object_name_get * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl); +static inline const char * +eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *field) +{ + return eolian_object_name_get(EOLIAN_OBJECT(field)); +} /* * @brief Get the documentation of a field of a struct type. @@ -2130,14 +2145,17 @@ EAPI Eina_Iterator *eolian_typedecl_enum_fields_get(const Eolian_Typedecl *tp); EAPI const Eolian_Enum_Type_Field *eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field); /* - * @brief Get the name of a field of an enum type. + * @brief A helper function to get the name of an enum field. * - * @param[in] fl the field. - * @return the name. + * @see eolian_object_name_get * * @ingroup Eolian */ -EAPI Eina_Stringshare *eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl); +static inline const char * +eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *field) +{ + return eolian_object_name_get(EOLIAN_OBJECT(field)); +} /* * @brief Get the C name of a field of an enum type. diff --git a/src/lib/eolian/database_constructor_api.c b/src/lib/eolian/database_constructor_api.c index da2cbc4..adb4191 100644 --- a/src/lib/eolian/database_constructor_api.c +++ b/src/lib/eolian/database_constructor_api.c @@ -5,13 +5,6 @@ #include #include "eolian_database.h" -EAPI Eina_Stringshare * -eolian_constructor_full_name_get(const Eolian_Constructor *ctor) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(ctor, NULL); - return ctor->base.name; -} - EAPI const Eolian_Class * eolian_constructor_class_get(const Eolian_Constructor *ctor) { diff --git a/src/lib/eolian/database_event_api.c b/src/lib/eolian/database_event_api.c index 728c87e..8b7cf7f 100644 --- a/src/lib/eolian/database_event_api.c +++ b/src/lib/eolian/database_event_api.c @@ -5,13 +5,6 @@ #include #include "eolian_database.h" -EAPI Eina_Stringshare * -eolian_event_name_get(const Eolian_Event *event) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(event, NULL); - return event->base.name; -} - EAPI const Eolian_Type * eolian_event_type_get(const Eolian_Event *event) { diff --git a/src/lib/eolian/database_function_api.c b/src/lib/eolian/database_function_api.c index a5c1d7b..05e7bf9 100644 --- a/src/lib/eolian/database_function_api.c +++ b/src/lib/eolian/database_function_api.c @@ -37,13 +37,6 @@ eolian_function_type_get(const Eolian_Function *fid) return fid->type; } -EAPI Eina_Stringshare * -eolian_function_name_get(const Eolian_Function *fid) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL); - return fid->base.name; -} - static const char * _get_eo_prefix(const Eolian_Function *foo_id, char *buf, Eina_Bool use_legacy) { diff --git a/src/lib/eolian/database_function_parameter_api.c b/src/lib/eolian/database_function_parameter_api.c index 36fa981..87f1ed3 100644 --- a/src/lib/eolian/database_function_parameter_api.c +++ b/src/lib/eolian/database_function_parameter_api.c @@ -26,13 +26,6 @@ eolian_parameter_default_value_get(const Eolian_Function_Parameter *param) return param->value; } -EAPI Eina_Stringshare * -eolian_parameter_name_get(const Eolian_Function_Parameter *param) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL); - return param->base.name; -} - EAPI const Eolian_Documentation * eolian_parameter_documentation_get(const Eolian_Function_Parameter *param) { diff --git a/src/lib/eolian/database_implement_api.c b/src/lib/eolian/database_implement_api.c index 21d5456..ff83c9e 100644 --- a/src/lib/eolian/database_implement_api.c +++ b/src/lib/eolian/database_implement_api.c @@ -5,13 +5,6 @@ #include #include "eolian_database.h" -EAPI Eina_Stringshare * -eolian_implement_full_name_get(const Eolian_Implement *impl) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(impl, NULL); - return impl->base.name; -} - EAPI const Eolian_Class * eolian_implement_class_get(const Eolian_Implement *impl) { diff --git a/src/lib/eolian/database_part_api.c b/src/lib/eolian/database_part_api.c index 71166f1..4fcd7c6 100644 --- a/src/lib/eolian/database_part_api.c +++ b/src/lib/eolian/database_part_api.c @@ -5,13 +5,6 @@ #include #include "eolian_database.h" -EAPI Eina_Stringshare * -eolian_part_name_get(const Eolian_Part *part) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL); - return part->base.name; -} - EAPI const Eolian_Class * eolian_part_class_get(const Eolian_Part *part) { diff --git a/src/lib/eolian/database_type_api.c b/src/lib/eolian/database_type_api.c index 4a01707..d3efa88 100644 --- a/src/lib/eolian/database_type_api.c +++ b/src/lib/eolian/database_type_api.c @@ -49,13 +49,6 @@ eolian_typedecl_struct_field_get(const Eolian_Typedecl *tp, const char *field) return sf; } -EAPI Eina_Stringshare * -eolian_typedecl_struct_field_name_get(const Eolian_Struct_Type_Field *fl) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL); - return fl->base.name; -} - EAPI const Eolian_Documentation * eolian_typedecl_struct_field_documentation_get(const Eolian_Struct_Type_Field *fl) { @@ -93,13 +86,6 @@ eolian_typedecl_enum_field_get(const Eolian_Typedecl *tp, const char *field) } EAPI Eina_Stringshare * -eolian_typedecl_enum_field_name_get(const Eolian_Enum_Type_Field *fl) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(fl, NULL); - return fl->base.name; -} - -EAPI Eina_Stringshare * eolian_typedecl_enum_field_c_name_get(const Eolian_Enum_Type_Field *fl) { Eina_Stringshare *ret; -- 2.7.4