summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortasn <tasn>2012-08-20 07:56:17 +0000
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2012-08-20 07:56:17 +0000
commit245ff54265f70874c501b77f09ed756169a3befd (patch)
tree1af1384536aba5ca31f1b3585bbe79ee601c5058 /src
parent01b3b8cffade34d781ab2effc769aa5a647f1e4f (diff)
downloadeobj-245ff54265f70874c501b77f09ed756169a3befd.tar.gz
eobj-245ff54265f70874c501b77f09ed756169a3befd.tar.bz2
eobj-245ff54265f70874c501b77f09ed756169a3befd.zip
Eo: Removed static class support.
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@75452 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
Diffstat (limited to 'src')
-rw-r--r--src/lib/Eo.h33
-rw-r--r--src/lib/eo.c37
-rw-r--r--src/lib/eo_base_class.c6
-rw-r--r--src/tests/eo_suite/eo_test_class_errors.c46
-rw-r--r--src/tests/eo_suite/eo_test_general.c57
5 files changed, 49 insertions, 130 deletions
diff --git a/src/lib/Eo.h b/src/lib/Eo.h
index b75df1c..f9de616 100644
--- a/src/lib/Eo.h
+++ b/src/lib/Eo.h
@@ -188,24 +188,6 @@ typedef struct _Eo_Event_Description Eo_Event_Description;
* You must use this macro if you want thread safety in class creation.
*/
#define EO_DEFINE_CLASS(class_get_func_name, class_desc, parent_class, ...) \
- EO_DEFINE_CLASS_STATIC(class_get_func_name, 0, class_desc, parent_class, __VA_ARGS__)
-
-/**
- * @def EO_DEFINE_CLASS_STATIC(class_get_func_name, id, class_desc, parent_class, ...)
- * *** DO NOT USE UNLESS YOU REALLY KNOW WHAT YOU ARE DOING ***
- * @param id a positive number to serve as the id of the class. 0 means dynamic. See eo_class_new() for details.
- * @param class_get_func_name the name of the wanted class_get function name.
- * @param class_desc the class description.
- * @param parent_class The parent class for the function. Look at eo_class_new() for more information.
- * @param ... List of etxensions. Look at eo_class_new() for more information.
- *
- * This macro should only be used if you know what you are doing and you want
- * to create a class with a static id.
- * Use #EO_DEFINE_CLASS instead.
- *
- * @see #EO_DEFINE_CLASS
- */
-#define EO_DEFINE_CLASS_STATIC(class_get_func_name, id, class_desc, parent_class, ...) \
EAPI const Eo_Class * \
class_get_func_name(void) \
{ \
@@ -228,7 +210,7 @@ class_get_func_name(void) \
} \
eina_lock_release(&_eo_class_creation_lock); \
(void) parent_class; \
- _my_class = eo_class_new(class_desc, id, parent_class, __VA_ARGS__); \
+ _my_class = eo_class_new(class_desc, parent_class, __VA_ARGS__); \
eina_lock_release(&_my_lock); \
\
eina_lock_take(&_eo_class_creation_lock); \
@@ -395,7 +377,6 @@ typedef struct _Eo_Class_Description Eo_Class_Description;
/**
* @brief Create a new class.
* @param desc the class description to create the class with.
- * @param id a positive number to serve as the id of the class. 0 means dynamic allocation. The number of static Ids is limited and regular users should not use static ids.
* @param parent the class to inherit from.
* @param ... A NULL terminated list of extensions (interfaces, mixins and the classes of any composite objects).
* @return The new class's handle on success, or NULL otherwise.
@@ -405,7 +386,7 @@ typedef struct _Eo_Class_Description Eo_Class_Description;
*
* @see #EO_DEFINE_CLASS
*/
-EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *parent, ...);
+EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent, ...);
/**
* @brief Check if an object "is a" klass.
@@ -789,16 +770,10 @@ EAPI const Eo_Class *eo_base_class_get(void);
typedef void (*eo_base_data_free_func)(void *);
/**
- * @def EO_BASE_CLASS_ID
- * #EO_BASE_CLASS 's class id.
- */
-#define EO_BASE_CLASS_ID 1
-
-/**
- * @def EO_BASE_BASE_ID
+ * @var EO_BASE_BASE_ID
* #EO_BASE_CLASS 's base id.
*/
-#define EO_BASE_BASE_ID EO_BASE_CLASS_ID // FIXME: Awful hack.
+extern EAPI Eo_Op EO_BASE_BASE_ID;
enum {
EO_BASE_SUB_ID_CONSTRUCTOR,
diff --git a/src/lib/eo.c b/src/lib/eo.c
index d2e8f32..5b0655c 100644
--- a/src/lib/eo.c
+++ b/src/lib/eo.c
@@ -6,7 +6,7 @@
#include "config.h"
/* The last id that should be reserved for statically allocated classes. */
-#define EO_STATIC_IDS_LAST 10
+#define EO_CLASS_IDS_FIRST 1
#define EO_OP_IDS_FIRST 1
/* Used inside the class_get functions of classes, see #EO_DEFINE_CLASS */
@@ -775,7 +775,7 @@ eo_class_free(Eo_Class *klass)
/* DEVCHECK */
static Eina_Bool
-_eo_class_check_op_descs(const Eo_Class *klass, Eo_Class_Id id)
+_eo_class_check_op_descs(const Eo_Class *klass)
{
const Eo_Class_Description *desc = klass->desc;
const Eo_Op_Description *itr;
@@ -783,7 +783,7 @@ _eo_class_check_op_descs(const Eo_Class *klass, Eo_Class_Id id)
if (desc->ops.count > 0)
{
- if (((id == 0) || (id > EO_STATIC_IDS_LAST)) && !desc->ops.base_op_id)
+ if (!desc->ops.base_op_id)
{
ERR("Class '%s' has a non-zero ops count, but base_id is NULL.",
desc->name);
@@ -832,7 +832,7 @@ _eo_class_isa_func(Eo *obj EINA_UNUSED, void *class_data EINA_UNUSED, va_list *l
}
EAPI const Eo_Class *
-eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *parent, ...)
+eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent, ...)
{
Eo_Class *klass;
va_list p_list;
@@ -843,12 +843,6 @@ eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *p
return NULL;
}
- if (id > EO_STATIC_IDS_LAST)
- {
- ERR("Tried creating a class with the static id %d while the maximum static id is %d. Aborting.", id, EO_STATIC_IDS_LAST);
- return NULL;
- }
-
va_start(p_list, parent);
EINA_SAFETY_ON_NULL_RETURN_VAL(desc, NULL);
@@ -930,7 +924,7 @@ eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *p
EO_ALIGN_SIZE(klass->parent->desc->data_size);
}
- if (!_eo_class_check_op_descs(klass, id))
+ if (!_eo_class_check_op_descs(klass))
{
goto cleanup;
}
@@ -983,24 +977,7 @@ eo_class_new(const Eo_Class_Description *desc, Eo_Class_Id id, const Eo_Class *p
eina_lock_take(&_eo_class_creation_lock);
- if (id == 0)
- {
- klass->class_id = ++_eo_classes_last_id;
- }
- else
- {
-#ifndef NDEBUG
- if (_eo_classes && _eo_classes[id - 1])
- {
- ERR("A class with id %d was already defined (%s). Aborting.", id,
- _eo_classes[id - 1]->desc->name);
- eina_lock_release(&_eo_class_creation_lock);
- goto cleanup;
- }
-#endif
- klass->class_id = id;
- }
-
+ klass->class_id = ++_eo_classes_last_id;
{
/* FIXME: Handle errors. */
@@ -1451,7 +1428,7 @@ eo_init(void)
eina_init();
_eo_classes = NULL;
- _eo_classes_last_id = EO_STATIC_IDS_LAST;
+ _eo_classes_last_id = EO_CLASS_IDS_FIRST - 1;
_eo_ops_last_id = EO_OP_IDS_FIRST;
_eo_log_dom = eina_log_domain_register(log_dom, EINA_COLOR_LIGHTBLUE);
if (_eo_log_dom < 0)
diff --git a/src/lib/eo_base_class.c b/src/lib/eo_base_class.c
index 9b5870c..acf3ac1 100644
--- a/src/lib/eo_base_class.c
+++ b/src/lib/eo_base_class.c
@@ -5,6 +5,8 @@
#include "config.h"
+EAPI Eo_Op EO_BASE_BASE_ID = 0;
+
static int event_freeze_count = 0;
typedef struct
@@ -565,12 +567,12 @@ static const Eo_Class_Description class_desc = {
EO_VERSION,
"Eo Base",
EO_CLASS_TYPE_REGULAR_NO_INSTANT,
- EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, EO_BASE_SUB_ID_LAST),
+ EO_CLASS_DESCRIPTION_OPS(&EO_BASE_BASE_ID, op_desc, EO_BASE_SUB_ID_LAST),
event_desc,
sizeof(Private_Data),
_class_constructor,
NULL
};
-EO_DEFINE_CLASS_STATIC(eo_base_class_get, EO_BASE_CLASS_ID, &class_desc, NULL, NULL)
+EO_DEFINE_CLASS(eo_base_class_get, &class_desc, NULL, NULL)
diff --git a/src/tests/eo_suite/eo_test_class_errors.c b/src/tests/eo_suite/eo_test_class_errors.c
index 983ff2c..269c87a 100644
--- a/src/tests/eo_suite/eo_test_class_errors.c
+++ b/src/tests/eo_suite/eo_test_class_errors.c
@@ -44,46 +44,46 @@ START_TEST(eo_incomplete_desc)
NULL
};
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(klass);
class_desc.ops.base_op_id = &TMP_BASE_ID;
class_desc.ops.descs = NULL;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(klass);
class_desc.ops.descs = op_desc;
class_desc.ops.count = TEST_SUB_ID_LAST + 1;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(klass);
class_desc.ops.count = 0;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(klass);
class_desc.ops.count = TEST_SUB_ID_LAST;
class_desc.ops.descs = op_desc_wrong;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(klass);
class_desc.ops.descs = op_desc;
class_desc.name = NULL;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(klass);
class_desc.name = "Simple";
- klass = eo_class_new(NULL, 0, NULL, NULL);
+ klass = eo_class_new(NULL, NULL, NULL);
fail_if(klass);
/* Should create a class. */
- klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
+ klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
fail_if(!klass);
(void) klass;
@@ -133,18 +133,18 @@ START_TEST(eo_inherit_errors)
NULL
};
- klass_mixin = eo_class_new(&class_desc_mixin, 0, NULL, NULL);
+ klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL);
fail_if(!klass_mixin);
- klass_simple = eo_class_new(&class_desc_simple, 0, EO_BASE_CLASS, NULL);
+ klass_simple = eo_class_new(&class_desc_simple, EO_BASE_CLASS, NULL);
fail_if(!klass_simple);
- klass = eo_class_new(&class_desc, 0, klass_simple, NULL);
+ klass = eo_class_new(&class_desc, klass_simple, NULL);
fail_if(klass);
class_desc.type = EO_CLASS_TYPE_REGULAR;
- klass = eo_class_new(&class_desc, 0, klass_mixin, NULL);
+ klass = eo_class_new(&class_desc, klass_mixin, NULL);
fail_if(klass);
(void) klass;
@@ -206,22 +206,22 @@ START_TEST(eo_inconsistent_mro)
NULL
};
- klass_mixin = eo_class_new(&class_desc_mixin, 0, NULL, NULL);
+ klass_mixin = eo_class_new(&class_desc_mixin, NULL, NULL);
fail_if(!klass_mixin);
- klass_mixin2 = eo_class_new(&class_desc_mixin2, 0, klass_mixin, NULL);
+ klass_mixin2 = eo_class_new(&class_desc_mixin2, klass_mixin, NULL);
fail_if(!klass_mixin2);
- klass_mixin3 = eo_class_new(&class_desc_mixin3, 0, klass_mixin, NULL);
+ klass_mixin3 = eo_class_new(&class_desc_mixin3, klass_mixin, NULL);
fail_if(!klass_mixin3);
- klass = eo_class_new(&class_desc_simple, 0, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL);
+ klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin, klass_mixin2, NULL);
fail_if(klass);
- klass = eo_class_new(&class_desc_simple, 0, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL);
+ klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin, NULL);
fail_if(!klass);
- klass = eo_class_new(&class_desc_simple, 0, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL);
+ klass = eo_class_new(&class_desc_simple, EO_BASE_CLASS, klass_mixin2, klass_mixin3, NULL);
fail_if(!klass);
eo_shutdown();
@@ -247,24 +247,24 @@ START_TEST(eo_bad_interface)
NULL
};
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(klass);
class_desc.data_size = 0;
class_desc.class_constructor = _stub_class_constructor;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(!klass);
class_desc.class_constructor = NULL;
class_desc.class_destructor = _stub_class_constructor;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(!klass);
class_desc.class_destructor = NULL;
- klass = eo_class_new(&class_desc, 0, NULL, NULL);
+ klass = eo_class_new(&class_desc, NULL, NULL);
fail_if(!klass);
eo_shutdown();
@@ -326,7 +326,7 @@ START_TEST(eo_op_types)
NULL
};
- klass = eo_class_new(&class_desc, 0, SIMPLE_CLASS, NULL);
+ klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
fail_if(!klass);
/* Add class checks here... */
diff --git a/src/tests/eo_suite/eo_test_general.c b/src/tests/eo_suite/eo_test_general.c
index 12791a0..ac395d2 100644
--- a/src/tests/eo_suite/eo_test_general.c
+++ b/src/tests/eo_suite/eo_test_general.c
@@ -41,7 +41,7 @@ START_TEST(eo_data_fetch)
NULL
};
- const Eo_Class *klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
+ const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
fail_if(!klass);
Eo *obj = eo_add(klass, NULL);
@@ -52,7 +52,7 @@ START_TEST(eo_data_fetch)
eo_unref(obj);
class_desc.data_size = 0;
- klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
+ klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
fail_if(!klass);
obj = eo_add(klass, NULL);
@@ -83,7 +83,7 @@ START_TEST(eo_isa_tests)
NULL
};
- iface = eo_class_new(&class_desc, 0, NULL, NULL);
+ iface = eo_class_new(&class_desc, NULL, NULL);
fail_if(!iface);
}
@@ -100,7 +100,7 @@ START_TEST(eo_isa_tests)
NULL
};
- mixin = eo_class_new(&class_desc, 0, NULL, NULL);
+ mixin = eo_class_new(&class_desc, NULL, NULL);
fail_if(!mixin);
}
@@ -117,7 +117,7 @@ START_TEST(eo_isa_tests)
NULL
};
- klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, iface, mixin, NULL);
+ klass = eo_class_new(&class_desc, EO_BASE_CLASS, iface, mixin, NULL);
fail_if(!klass);
}
@@ -164,40 +164,6 @@ START_TEST(eo_composite_tests)
}
END_TEST
-START_TEST(eo_static_classes)
-{
- eo_init();
-
- static const Eo_Op_Description op_desc[] = {
- EO_OP_DESCRIPTION(SIMPLE_SUB_ID_A_SET, "Set property A"),
- EO_OP_DESCRIPTION_SENTINEL
- };
-
- /* Usually should be const, not const only for the test... */
- static Eo_Class_Description class_desc = {
- EO_VERSION,
- "Simple2",
- EO_CLASS_TYPE_REGULAR,
- EO_CLASS_DESCRIPTION_OPS(NULL, op_desc, 1),
- NULL,
- 0,
- NULL,
- NULL
- };
-
- const Eo_Class *klass = eo_class_new(&class_desc, 1, EO_BASE_CLASS, NULL);
- fail_if(klass);
-
- klass = eo_class_new(&class_desc, 1000, EO_BASE_CLASS, NULL);
- fail_if(klass);
-
- klass = eo_class_new(&class_desc, 2, EO_BASE_CLASS, NULL);
- fail_if(!klass);
-
- eo_shutdown();
-}
-END_TEST
-
static Eina_Bool _man_should_con = EINA_TRUE;
static Eina_Bool _man_should_des = EINA_TRUE;
@@ -247,7 +213,7 @@ START_TEST(eo_man_free)
NULL
};
- const Eo_Class *klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
+ const Eo_Class *klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
fail_if(!klass);
Eo *obj = eo_add(klass, NULL);
@@ -260,7 +226,7 @@ START_TEST(eo_man_free)
eo_unref(obj);
_man_should_des = EINA_FALSE;
- klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
+ klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
fail_if(!klass);
obj = eo_add(klass, NULL);
@@ -275,7 +241,7 @@ START_TEST(eo_man_free)
eo_manual_free(obj);
_man_should_con = EINA_FALSE;
- klass = eo_class_new(&class_desc, 0, EO_BASE_CLASS, NULL);
+ klass = eo_class_new(&class_desc, EO_BASE_CLASS, NULL);
fail_if(!klass);
obj = eo_add(klass, NULL);
@@ -467,7 +433,7 @@ START_TEST(eo_op_errors)
NULL
};
- const Eo_Class *klass = eo_class_new(&class_desc, 0, SIMPLE_CLASS, NULL);
+ const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
fail_if(!klass);
Eo *obj = eo_add(klass, NULL);
@@ -605,7 +571,7 @@ START_TEST(eo_magic_checks)
eo_class_do((Eo_Class *) buf, NULL);
eo_class_do_super((Eo_Class *) buf, EO_NOOP);
- fail_if(eo_class_new(NULL, 0, (Eo_Class *) buf), NULL);
+ fail_if(eo_class_new(NULL, (Eo_Class *) buf), NULL);
eo_xref(obj, (Eo *) buf);
eo_xunref(obj, (Eo *) buf);
@@ -714,7 +680,7 @@ START_TEST(eo_multiple_do)
NULL
};
- const Eo_Class *klass = eo_class_new(&class_desc, 0, SIMPLE_CLASS, NULL);
+ const Eo_Class *klass = eo_class_new(&class_desc, SIMPLE_CLASS, NULL);
fail_if(!klass);
Eo *obj = eo_add(klass, NULL);
@@ -739,7 +705,6 @@ void eo_test_general(TCase *tc)
tcase_add_test(tc, eo_magic_checks);
tcase_add_test(tc, eo_data_fetch);
tcase_add_test(tc, eo_man_free);
- tcase_add_test(tc, eo_static_classes);
tcase_add_test(tc, eo_composite_tests);
tcase_add_test(tc, eo_isa_tests);
tcase_add_test(tc, eo_multiple_do);