diff --git a/src/examples/evas/evas-object-manipulation-eo.c b/src/examples/evas/evas-object-manipulation-eo.c index f32de7b815..be50221322 100644 --- a/src/examples/evas/evas-object-manipulation-eo.c +++ b/src/examples/evas/evas-object-manipulation-eo.c @@ -209,10 +209,8 @@ main(void) efl_gfx_position_set(d.img, 0, 0); efl_gfx_size_set(d.img, WIDTH, HEIGHT); efl_gfx_visible_set(d.img, EINA_TRUE); - - const char *type = NULL; - type = evas_obj_type_get(d.img); - fprintf(stdout, "Image object added, type is: %s\n", type); + fprintf(stdout, "Image object added, class name is: %s\n", + eo_class_name_get(d.img)); } /* border on the image's clipper, here just to emphasize its position */ diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index db75df4361..c4b16f525d 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -39,6 +39,8 @@ # include #endif +#define EVAS_OBJECT_PROTECTED + #include #include #include diff --git a/src/lib/elementary/elementary_config.h b/src/lib/elementary/elementary_config.h index ae14f49252..0e84d6ecda 100644 --- a/src/lib/elementary/elementary_config.h +++ b/src/lib/elementary/elementary_config.h @@ -8,4 +8,4 @@ */ #define ELM_CONFIG_ICON_THEME_ELEMENTARY "_Elementary_Icon_Theme" - +#define EVAS_OBJECT_PROTECTED diff --git a/src/lib/emotion/emotion_smart.c b/src/lib/emotion/emotion_smart.c index 804b865307..7bfa18a94e 100644 --- a/src/lib/emotion/emotion_smart.c +++ b/src/lib/emotion/emotion_smart.c @@ -2,6 +2,8 @@ # include "config.h" #endif +#define EVAS_OBJECT_PROTECTED + #include #include diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 7ca908065f..b7e22bc893 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -672,6 +672,24 @@ EAPI int evas_object_ref_get(const Evas_Object *obj); */ EAPI void evas_object_del(Evas_Object *obj) EINA_ARG_NONNULL(1); +/** + * @brief Retrieves the type of the given Evas object. + * + * For Evas' builtin types, the return strings will be one of "rectangle", + * "line", "polygon", "text", "textblock" or "image". + * + * For Evas smart objects (see @ref Evas_Smart_Group), the name of the smart + * class itself is returned on this call. For the built-in smart objects, these + * names are "EvasObjectSmartClipped" for the clipped smart object, + * "Evas_Object_Box" for the box object and "Evas_Object_Table for the table + * object. + * + * @return The type of the object. + * + * @ingroup Evas_Object + */ +EAPI const char *evas_object_type_get(const Evas_Object *obj); + /** * Retrieves the position and (rectangular) size of the given Evas * object. diff --git a/src/lib/evas/canvas/evas_object.eo b/src/lib/evas/canvas/evas_object.eo index 587578cb64..44c98fb438 100644 --- a/src/lib/evas/canvas/evas_object.eo +++ b/src/lib/evas/canvas/evas_object.eo @@ -11,32 +11,11 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack, legacy_ctor @protected { [[Internal function. Do not use.]] } - @property type { + @property type @protected { set { - [[Sets the type of the given Evas object.]] + [[Sets the legacy type name of this Evas object.]] legacy: null; } - get { - [[Retrieves the type of the given Evas object. - - For Evas' builtin types, the return strings will be one of - "rectangle", "line", "polygon", "text", "textblock" or "image". - - For Evas smart objects (see \@ref Evas_Smart_Group), the name - of the smart class itself is returned on this call. For the - built-in smart objects, these names are "EvasObjectSmartClipped" - for the clipped smart object, "Evas_Object_Box" for the box - object and "Evas_Object_Table for the table object. - ]] - /* FIXME-doc - Example: - @dontinclude evas-object-manipulation.c - @skip d.img = evas_object_image_filled_add(d.canvas); - @until border on the - - See the full @ref Example_Evas_Object_Manipulation "example". - */ - } values { type: string; [[The type of the object.]] } @@ -875,6 +854,9 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx, Efl.Gfx.Stack, } } } + constructors { + .type; + } implements { Eo.Base.constructor; Eo.Base.destructor; diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index a79cc5250f..b9ae7da67b 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -2071,16 +2071,14 @@ _evas_canvas_objects_in_rectangle_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, return in; } -EOLIAN static const char * -_evas_object_type_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) -{ - if (obj->delete_me) return ""; - return obj->type; -} - EOLIAN static void -_evas_object_type_set(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, const char *type) +_evas_object_type_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, const char *type) { + if (eo_finalized_get(eo_obj)) + { + ERR("This function is only allowed during construction."); + return; + } obj->type = type; // Store it as the top type of this class } @@ -2189,6 +2187,15 @@ _evas_object_legacy_ctor(Eo *eo_obj, Evas_Object_Protected_Data *obj) /* legacy */ +EAPI const char * +evas_object_type_get(const Evas_Object *eo_obj) +{ + Evas_Object_Protected_Data *obj = eo_isa(eo_obj, EVAS_OBJECT_CLASS) ? + eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS) : NULL; + if (!obj || obj->delete_me) return ""; + return obj->type; +} + EAPI void evas_object_size_hint_aspect_set(Evas_Object *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h) { diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h index 53abc4594f..c10962fca3 100644 --- a/src/lib/evas/include/evas_common_private.h +++ b/src/lib/evas/include/evas_common_private.h @@ -54,6 +54,11 @@ #ifdef BUILD_LOADER_EET # include #endif + +#ifndef EVAS_OBJECT_PROTECTED +# define EVAS_OBJECT_PROTECTED +#endif + #include "Evas.h" #ifdef EAPI diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index dc3060db84..7c9b72699d 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -5,6 +5,10 @@ # include #endif +#ifndef EVAS_OBJECT_PROTECTED +# define EVAS_OBJECT_PROTECTED +#endif + #include "Evas.h" #include "Eet.h"