Evas: Mark type as legacy and protected

Only set() is allowed for EO, and it's a constructor,
protected function. Unfortunately, this means a lot
of #define EVAS_OBJECT_PROTECTED
This commit is contained in:
Jean-Philippe Andre 2016-06-16 16:05:00 +09:00
parent 76d2778177
commit d4b96d33d6
9 changed files with 54 additions and 36 deletions

View File

@ -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 */

View File

@ -39,6 +39,8 @@
# include <Evil.h>
#endif
#define EVAS_OBJECT_PROTECTED
#include <Eina.h>
#include <Eet.h>
#include <Eo.h>

View File

@ -8,4 +8,4 @@
*/
#define ELM_CONFIG_ICON_THEME_ELEMENTARY "_Elementary_Icon_Theme"
#define EVAS_OBJECT_PROTECTED

View File

@ -2,6 +2,8 @@
# include "config.h"
#endif
#define EVAS_OBJECT_PROTECTED
#include <Evas.h>
#include <Ecore.h>

View File

@ -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.

View File

@ -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;

View File

@ -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)
{

View File

@ -54,6 +54,11 @@
#ifdef BUILD_LOADER_EET
# include <Eet.h>
#endif
#ifndef EVAS_OBJECT_PROTECTED
# define EVAS_OBJECT_PROTECTED
#endif
#include "Evas.h"
#ifdef EAPI

View File

@ -5,6 +5,10 @@
# include <config.h>
#endif
#ifndef EVAS_OBJECT_PROTECTED
# define EVAS_OBJECT_PROTECTED
#endif
#include "Evas.h"
#include "Eet.h"