use version as an actual version and bring back macros for setting up

class header for those using const item class structs.



SVN revision: 68770
This commit is contained in:
Carsten Haitzler 2012-03-06 05:02:36 +00:00
parent f1ef54cc87
commit c233923591
4 changed files with 19 additions and 10 deletions

View File

@ -4,6 +4,9 @@
#include "els_scroller.h"
#include "elm_gen_common.h"
// internally allocated
#define CLASS_ALLOCATED 0x3a70f00f
/* --
* TODO:
* Handle non-homogeneous objects too.
@ -2770,7 +2773,7 @@ elm_gengrid_item_class_new(void)
itc = calloc(1, sizeof(Elm_Gengrid_Item_Class));
if (!itc)
return NULL;
itc->version = ELM_GENGRID_ITEM_CLASS_VERSION;
itc->version = CLASS_ALLOCATED;
itc->refcount = 1;
itc->delete_me = EINA_FALSE;
@ -2780,7 +2783,7 @@ elm_gengrid_item_class_new(void)
EAPI void
elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
{
if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
if (itc && (itc->version == CLASS_ALLOCATED))
{
if (!itc->delete_me) itc->delete_me = EINA_TRUE;
if (itc->refcount > 0) elm_gengrid_item_class_unref(itc);
@ -2795,7 +2798,7 @@ elm_gengrid_item_class_free(Elm_Gengrid_Item_Class *itc)
EAPI void
elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
{
if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
if (itc && (itc->version == CLASS_ALLOCATED))
{
itc->refcount++;
if (itc->refcount == 0) itc->refcount--;
@ -2805,7 +2808,7 @@ elm_gengrid_item_class_ref(Elm_Gengrid_Item_Class *itc)
EAPI void
elm_gengrid_item_class_unref(Elm_Gengrid_Item_Class *itc)
{
if (itc && (itc->version == ELM_GENGRID_ITEM_CLASS_VERSION))
if (itc && (itc->version == CLASS_ALLOCATED))
{
if (itc->refcount > 0) itc->refcount--;
if (itc->delete_me && (!itc->refcount))

View File

@ -838,6 +838,7 @@ EAPI const Elm_Gengrid_Item_Class *elm_gengrid_item_item_class_get(const Elm_Obj
//EAPI unsigned int elm_gengrid_items_count(const Evas_Object *obj);
#define ELM_GENGRID_ITEM_CLASS_VERSION 2 /* current version number */
#define ELM_GENGRID_ITEM_CLASS_HEADER ELM_GENGRID_ITEM_CLASS_VERSION, 0, 0
/**
* Add a new gengrid item class in a given gengrid widget.

View File

@ -6,6 +6,9 @@
#include "els_scroller.h"
#include "elm_gen_common.h"
// internally allocated
#define CLASS_ALLOCATED 0x3a70f11f
#define MAX_ITEMS_PER_BLOCK 32
#define REORDER_EFFECT_TIME 0.5
@ -29,9 +32,10 @@
ERR("Genlist_Item_Class(itc) is NULL"); \
return; \
} \
if (itc->version != ELM_GENLIST_ITEM_CLASS_VERSION) \
if ((itc->version != ELM_GENLIST_ITEM_CLASS_VERSION) && \
(itc->version != CLASS_ALLOCATED)) \
{ \
ERR("Genlist_Item_Class version mismatched! required = (%d), current = (%d)", itc->version, ELM_GENLIST_ITEM_CLASS_VERSION); \
ERR("Genlist_Item_Class version mismatched! current = (%d), required = (%d) or (%d)", itc->version, ELM_GENLIST_ITEM_CLASS_VERSION, CLASS_ALLOCATED); \
return; \
} \
} \
@ -5666,7 +5670,7 @@ elm_genlist_item_class_new(void)
itc = calloc(1, sizeof(Elm_Genlist_Item_Class));
if (!itc)
return NULL;
itc->version = ELM_GENLIST_ITEM_CLASS_VERSION;
itc->version = CLASS_ALLOCATED;
itc->refcount = 1;
itc->delete_me = EINA_FALSE;
@ -5676,7 +5680,7 @@ elm_genlist_item_class_new(void)
EAPI void
elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
{
if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
if (itc && (itc->version == CLASS_ALLOCATED))
{
if (!itc->delete_me) itc->delete_me = EINA_TRUE;
if (itc->refcount > 0) elm_genlist_item_class_unref(itc);
@ -5691,7 +5695,7 @@ elm_genlist_item_class_free(Elm_Genlist_Item_Class *itc)
EAPI void
elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
{
if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
if (itc && (itc->version == CLASS_ALLOCATED))
{
itc->refcount++;
if (itc->refcount == 0) itc->refcount--;
@ -5701,7 +5705,7 @@ elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc)
EAPI void
elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc)
{
if (itc && (itc->version == ELM_GENLIST_ITEM_CLASS_VERSION))
if (itc && (itc->version == CLASS_ALLOCATED))
{
if (itc->refcount > 0) itc->refcount--;
if (itc->delete_me && (!itc->refcount))

View File

@ -1122,6 +1122,7 @@ EAPI void elm_genlist_realized_items_update(Evas_Object
EAPI unsigned int elm_genlist_items_count(const Evas_Object *obj);
#define ELM_GENLIST_ITEM_CLASS_VERSION 2 /* current version number */
#define ELM_GENLIST_ITEM_CLASS_HEADER ELM_GENLIST_ITEM_CLASS_VERSION, 0, 0
/**
* Add a new genlist item class in a given genlist widget.