From bb24b606380747e795aec3f468833bde3327dab1 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Fri, 1 Aug 2014 15:11:28 +0100 Subject: [PATCH] eolian: generate implicit typedef for each class And use these typedefs instead of just Eo in API. --- src/bin/eolian/main.c | 18 ++++++++++++++++++ src/bin/eolian/types_generator.c | 14 ++++++++++++++ src/bin/eolian/types_generator.h | 2 ++ src/lib/ecore/Ecore_Common.h | 14 ++++++++++++++ src/lib/edje/edje_edit.c | 2 ++ src/lib/eo/Eo.h | 1 + src/lib/eolian/database_type.c | 4 +--- src/lib/evas/Evas_Common.h | 4 ++++ src/lib/evas/Evas_Eo.h | 16 ++++++++++++++++ 9 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c index 0b288d1..bcd13fc 100644 --- a/src/bin/eolian/main.c +++ b/src/bin/eolian/main.c @@ -126,6 +126,15 @@ _generate_eo_header_file(char *filename, const char *eo_filename) buffer = _include_guard_enclose(eo_filename, "TYPES", buffer); } + Eina_Strbuf *ctbuf = eina_strbuf_new(); + if (types_class_typedef_generate(eo_filename, ctbuf)) + { + ctbuf = _include_guard_enclose(eo_filename, "CLASS_TYPE", ctbuf); + eina_strbuf_append_char(ctbuf, '\n'); + eina_strbuf_prepend(buffer, eina_strbuf_string_get(ctbuf)); + } + eina_strbuf_free(ctbuf); + const Eolian_Class *class = eolian_class_get_by_file(eo_filename); if (class) { @@ -218,6 +227,15 @@ _generate_legacy_header_file(char *filename, const char *eo_filename) goto end; } + Eina_Strbuf *ctbuf = eina_strbuf_new(); + if (types_class_typedef_generate(eo_filename, ctbuf)) + { + ctbuf = _include_guard_enclose(eo_filename, "CLASS_TYPE", ctbuf); + eina_strbuf_append_char(ctbuf, '\n'); + eina_strbuf_prepend(buffer, eina_strbuf_string_get(ctbuf)); + } + eina_strbuf_free(ctbuf); + const Eolian_Class *class = eolian_class_get_by_file(eo_filename); if (class) { diff --git a/src/bin/eolian/types_generator.c b/src/bin/eolian/types_generator.c index f5adcce..7f42362 100644 --- a/src/bin/eolian/types_generator.c +++ b/src/bin/eolian/types_generator.c @@ -132,3 +132,17 @@ types_header_generate(const char *eo_filename, Eina_Strbuf *buf) eina_iterator_free(itr); return EINA_TRUE; } + +Eina_Bool +types_class_typedef_generate(const char *eo_filename, Eina_Strbuf *buf) +{ + const Eolian_Class *class = eolian_class_get_by_file(eo_filename); + if (!class) + return EINA_FALSE; + + static _eolian_class_vars class_env; + _class_env_create(class, NULL, &class_env); + + eina_strbuf_append_printf(buf, "typedef Eo %s;\n", class_env.full_classname); + return EINA_TRUE; +} diff --git a/src/bin/eolian/types_generator.h b/src/bin/eolian/types_generator.h index 6738b02..2e07b20 100644 --- a/src/bin/eolian/types_generator.h +++ b/src/bin/eolian/types_generator.h @@ -14,5 +14,7 @@ */ Eina_Bool types_header_generate(const char *eo_filename, Eina_Strbuf *buf); +Eina_Bool types_class_typedef_generate(const char *eo_filename, Eina_Strbuf *buf); + #endif diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h index ffd2ff4..e3d0ad0 100644 --- a/src/lib/ecore/Ecore_Common.h +++ b/src/lib/ecore/Ecore_Common.h @@ -2525,6 +2525,8 @@ typedef enum _Ecore_Poller_Type Ecore_Poller_Type; typedef Eo Ecore_Poller; /**< A handle for pollers */ +#define _ECORE_POLLER_EO_CLASS_TYPE + /** * @brief Sets the time(in seconds) between ticks for the given poller type. * @param type The poller type to adjust. @@ -2627,6 +2629,8 @@ typedef Eina_Bool (*Ecore_Timeline_Cb)(void *data, double pos); */ typedef Eo Ecore_Animator; /**< A handle for animators */ +#define _ECORE_ANIMATOR_EO_CLASS_TYPE + /** * @brief Set the animator call interval in seconds. * @@ -2901,6 +2905,8 @@ EAPI void ecore_animator_custom_tick(void); */ typedef Eo Ecore_Timer; /**< A handle for timers */ +#define _ECORE_TIMER_EO_CLASS_TYPE + /** * Retrieves the current precision used by timer infrastructure. * @return Current precision. @@ -3009,16 +3015,22 @@ EAPI char *ecore_timer_dump(void); */ typedef Eo Ecore_Idler; /**< A handle for idlers */ +#define _ECORE_IDLER_EO_CLASS_TYPE + /* * @since 1.8 */ typedef Eo Ecore_Idle_Enterer; /**< A handle for idle enterers */ +#define _ECORE_IDLE_ENTERER_EO_CLASS_TYPE + /* * @since 1.8 */ typedef Eo Ecore_Idle_Exiter; /**< A handle for idle exiters */ +#define _ECORE_IDLE_EXITER_EO_CLASS_TYPE + /** * @} */ @@ -3051,6 +3063,8 @@ typedef Eo Ecore_Idle_Exiter; /**< A handle for idle exiters */ * @since 1.8 */ typedef Eo Ecore_Job; /**< A job handle */ + +#define _ECORE_JOB_EO_CLASS_TYPE /** * @} */ diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index f67813a..4a25447 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -7,6 +7,8 @@ * */ +#define _EDJE_EDIT_EO_CLASS_TYPE + #include "edje_private.h" #define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index 14728cb..eaf673e 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1109,6 +1109,7 @@ struct _Eo_Callback_Array_Item * @} */ +#define _EO_BASE_EO_CLASS_TYPE #include "eo_base.eo.h" #define EO_CLASS EO_BASE_CLASS diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c index d3d2037..cfb8bc7 100644 --- a/src/lib/eolian/database_type.c +++ b/src/lib/eolian/database_type.c @@ -155,7 +155,7 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name) { eina_strbuf_append(buf, "const "); } - if (tp->type == EOLIAN_TYPE_REGULAR) + if (tp->type == EOLIAN_TYPE_REGULAR || tp->type == EOLIAN_TYPE_CLASS) { Eina_List *l; const char *sp; @@ -173,8 +173,6 @@ database_type_to_str(const Eolian_Type *tp, Eina_Strbuf *buf, const char *name) } else if (tp->type == EOLIAN_TYPE_VOID) eina_strbuf_append(buf, "void"); - else if (tp->type == EOLIAN_TYPE_CLASS) - eina_strbuf_append(buf, "Eo"); else { Eolian_Type *btp = tp->base_type; diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index e9abd73..adafbdd 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -276,6 +276,8 @@ typedef struct _Evas_Public_Data Evas_Public_Data; */ typedef Eo Evas_Object; +#define _EVAS_OBJECT_EO_CLASS_TYPE + typedef void Evas_Performance; /**< An Evas Performance handle */ typedef struct _Evas_Modifier Evas_Modifier; /**< An opaque type containing information on which modifier keys are registered in an Evas canvas */ typedef struct _Evas_Lock Evas_Lock; /**< An opaque type containing information on which lock keys are registered in an Evas canvas */ @@ -5241,6 +5243,8 @@ EAPI Eina_Bool evas_key_lock_is_set(const Evas_Lock *l, const char *k typedef Eo Evas_Out; +#define _EVAS_OUT_EO_CLASS_TYPE + /** * @ingroup Evas_Font_Group * diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 5f20e3f..5f578cf 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -344,6 +344,8 @@ typedef double Evas_Real; */ typedef Eo Evas_3D_Object; +#define _EVAS_3D_OBJECT_EO_CLASS_TYPE + /** * @typedef Evas_3D_Scene * @@ -354,6 +356,8 @@ typedef Eo Evas_3D_Object; */ typedef Eo Evas_3D_Scene; +#define _EVAS_3D_SCENE_EO_CLASS_TYPE + /** * @typedef Evas_3D_Node * @@ -364,6 +368,8 @@ typedef Eo Evas_3D_Scene; */ typedef Eo Evas_3D_Node; +#define _EVAS_3D_NODE_EO_CLASS_TYPE + /** * @typedef Evas_3D_Camera * @@ -374,6 +380,8 @@ typedef Eo Evas_3D_Node; */ typedef Eo Evas_3D_Camera; +#define _EVAS_3D_CAMERA_EO_CLASS_TYPE + /** * @typedef Evas_3D_Light * @@ -384,6 +392,8 @@ typedef Eo Evas_3D_Camera; */ typedef Eo Evas_3D_Light; +#define _EVAS_3D_LIGHT_EO_CLASS_TYPE + /** * @typedef Evas_3D_Mesh * @@ -394,6 +404,8 @@ typedef Eo Evas_3D_Light; */ typedef Eo Evas_3D_Mesh; +#define _EVAS_3D_MESH_EO_CLASS_TYPE + /** * @typedef Evas_3D_Texture * @@ -404,6 +416,8 @@ typedef Eo Evas_3D_Mesh; */ typedef Eo Evas_3D_Texture; +#define _EVAS_3D_TEXTURE_EO_CLASS_TYPE + /** * @typedef Evas_3D_Material * @@ -414,6 +428,8 @@ typedef Eo Evas_3D_Texture; */ typedef Eo Evas_3D_Material; +#define _EVAS_3D_MATERIAL_EO_CLASS_TYPE + /** * Type of 3D Object * -- 2.7.4