From c2339235911da56ae66887079ba6d552beaaa353 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Tue, 6 Mar 2012 05:02:36 +0000 Subject: [PATCH] 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 --- legacy/elementary/src/lib/elm_gengrid.c | 11 +++++++---- legacy/elementary/src/lib/elm_gengrid.h | 1 + legacy/elementary/src/lib/elm_genlist.c | 16 ++++++++++------ legacy/elementary/src/lib/elm_genlist.h | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c index 956104d4db..4b020a051c 100644 --- a/legacy/elementary/src/lib/elm_gengrid.c +++ b/legacy/elementary/src/lib/elm_gengrid.c @@ -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)) diff --git a/legacy/elementary/src/lib/elm_gengrid.h b/legacy/elementary/src/lib/elm_gengrid.h index bb454f9057..c41add9ac4 100644 --- a/legacy/elementary/src/lib/elm_gengrid.h +++ b/legacy/elementary/src/lib/elm_gengrid.h @@ -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. diff --git a/legacy/elementary/src/lib/elm_genlist.c b/legacy/elementary/src/lib/elm_genlist.c index 29b9f4840e..fb6acae355 100644 --- a/legacy/elementary/src/lib/elm_genlist.c +++ b/legacy/elementary/src/lib/elm_genlist.c @@ -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)) diff --git a/legacy/elementary/src/lib/elm_genlist.h b/legacy/elementary/src/lib/elm_genlist.h index 35482cadf0..b9e5661762 100644 --- a/legacy/elementary/src/lib/elm_genlist.h +++ b/legacy/elementary/src/lib/elm_genlist.h @@ -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.