forked from enlightenment/efl
Eobj: Use EINA_SAFETY when needed.
Also added a couple of EINA_UNLIKELY. SVN revision: 70411
This commit is contained in:
parent
8875c23a6c
commit
a1ed819ea2
|
@ -715,28 +715,17 @@ eobj_class_new(const Eobj_Class_Description *desc, const Eobj_Class *parent, ...
|
||||||
|
|
||||||
va_start(p_list, parent);
|
va_start(p_list, parent);
|
||||||
|
|
||||||
#define _CLS_NEW_CHECK(x) \
|
EINA_SAFETY_ON_NULL_RETURN_VAL(desc, NULL);
|
||||||
do \
|
EINA_SAFETY_ON_NULL_RETURN_VAL(desc->name, NULL);
|
||||||
{ \
|
|
||||||
if (!x) \
|
|
||||||
{ \
|
|
||||||
ERR("'%s' must not be False! Aborting.", #x); \
|
|
||||||
return NULL; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
while(0)
|
|
||||||
|
|
||||||
_CLS_NEW_CHECK(desc);
|
|
||||||
_CLS_NEW_CHECK(desc->name);
|
|
||||||
|
|
||||||
/* Check restrictions on Interface types. */
|
/* Check restrictions on Interface types. */
|
||||||
if (desc->type == EOBJ_CLASS_TYPE_INTERFACE)
|
if (desc->type == EOBJ_CLASS_TYPE_INTERFACE)
|
||||||
{
|
{
|
||||||
_CLS_NEW_CHECK(!desc->constructor);
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->constructor, NULL);
|
||||||
_CLS_NEW_CHECK(!desc->destructor);
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->destructor, NULL);
|
||||||
_CLS_NEW_CHECK(!desc->class_constructor);
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->class_constructor, NULL);
|
||||||
_CLS_NEW_CHECK(!desc->class_destructor);
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->class_destructor, NULL);
|
||||||
_CLS_NEW_CHECK(!desc->data_size);
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(!desc->data_size, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
klass = calloc(1, sizeof(Eobj_Class));
|
klass = calloc(1, sizeof(Eobj_Class));
|
||||||
|
@ -882,7 +871,6 @@ cleanup:
|
||||||
eobj_class_free(klass);
|
eobj_class_free(klass);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#undef _CLS_NEW_CHECK
|
|
||||||
|
|
||||||
EAPI Eobj *
|
EAPI Eobj *
|
||||||
eobj_add(const Eobj_Class *klass, Eobj *parent)
|
eobj_add(const Eobj_Class *klass, Eobj *parent)
|
||||||
|
@ -891,7 +879,7 @@ eobj_add(const Eobj_Class *klass, Eobj *parent)
|
||||||
|
|
||||||
if (parent) EOBJ_MAGIC_RETURN_VAL(parent, EOBJ_EINA_MAGIC, NULL);
|
if (parent) EOBJ_MAGIC_RETURN_VAL(parent, EOBJ_EINA_MAGIC, NULL);
|
||||||
|
|
||||||
if (klass->desc->type != EOBJ_CLASS_TYPE_REGULAR)
|
if (EINA_UNLIKELY(klass->desc->type != EOBJ_CLASS_TYPE_REGULAR))
|
||||||
{
|
{
|
||||||
ERR("Class '%s' is not instantiate-able. Aborting.", klass->desc->name);
|
ERR("Class '%s' is not instantiate-able. Aborting.", klass->desc->name);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -912,13 +900,13 @@ eobj_add(const Eobj_Class *klass, Eobj *parent)
|
||||||
eobj_ref(obj);
|
eobj_ref(obj);
|
||||||
_eobj_constructor(obj, klass);
|
_eobj_constructor(obj, klass);
|
||||||
|
|
||||||
if (eobj_constructor_error_get(obj))
|
if (EINA_UNLIKELY(eobj_constructor_error_get(obj)))
|
||||||
{
|
{
|
||||||
ERR("Type '%s' - One of the object constructors have failed.", klass->desc->name);
|
ERR("Type '%s' - One of the object constructors have failed.", klass->desc->name);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_eobj_kls_itr_reached_end(obj))
|
if (EINA_UNLIKELY(!_eobj_kls_itr_reached_end(obj)))
|
||||||
{
|
{
|
||||||
ERR("Type '%s' - Not all of the object constructors have been executed.", klass->desc->name);
|
ERR("Type '%s' - Not all of the object constructors have been executed.", klass->desc->name);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
Loading…
Reference in New Issue