_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_set, _a_set),
+ EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
);
return efl_class_functions_set(klass, &ops);
custom_check_cb(void *data, const Efl_Event *event)
{
EFL_OPS_DEFINE(custom_layout_ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_pack_layout_update, _custom_layout_update));
+ EFL_OBJECT_OP_FUNC(efl_pack_layout_update, _custom_layout_update));
Eina_Bool chk = elm_check_selected_get(event->object);
Eo *obj = data;
_custom_engine_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_CLASS_FUNC_OVERRIDE(efl_pack_layout_do, _custom_engine_layout_do),
+ EFL_OBJECT_OP_CLASS_FUNC(efl_pack_layout_do, _custom_engine_layout_do),
);
return efl_class_functions_set(klass, &ops);
if (ftype != EOLIAN_PROP_GET)
{
Eina_Stringshare *rets = eolian_function_full_c_name_get(fnid, EOLIAN_PROP_SET, EINA_FALSE);
- eina_strbuf_append_printf(str_op, "\n EFL_OBJECT_OP_%sFUNC_OVERRIDE(%s, %s_%s_set),",
+ eina_strbuf_append_printf(str_op, "\n EFL_OBJECT_OP_%sFUNC(%s, %s_%s_set),",
class_str, rets, implname, funcname);
eo_bind_func_generate(class, fnid, EOLIAN_PROP_SET, str_bodyf, impl_desc, &impl_env);
eina_stringshare_del(rets);
if (ftype != EOLIAN_PROP_SET)
{
Eina_Stringshare *rets = eolian_function_full_c_name_get(fnid, EOLIAN_PROP_GET, EINA_FALSE);
- eina_strbuf_append_printf(str_op, "\n EFL_OBJECT_OP_%sFUNC_OVERRIDE(%s, %s_%s_get),",
+ eina_strbuf_append_printf(str_op, "\n EFL_OBJECT_OP_%sFUNC(%s, %s_%s_get),",
class_str, rets, implname, funcname);
eo_bind_func_generate(class, fnid, EOLIAN_PROP_GET, str_bodyf, impl_desc, &impl_env);
eina_stringshare_del(rets);
default:
{
Eina_Stringshare *rets = eolian_function_full_c_name_get(fnid, ftype, EINA_FALSE);
- eina_strbuf_append_printf(str_op, "\n EFL_OBJECT_OP_%sFUNC_OVERRIDE(%s, %s_%s),",
+ eina_strbuf_append_printf(str_op, "\n EFL_OBJECT_OP_%sFUNC(%s, %s_%s),",
class_str, rets, implname, funcname);
eo_bind_func_generate(class, fnid, ftype, str_bodyf, impl_desc, &impl_env);
eina_stringshare_del(rets);
_custom_table_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_CLASS_FUNC_OVERRIDE(efl_canvas_group_calculate, _custom_table_calc)
+ EFL_OBJECT_OP_CLASS_FUNC(efl_canvas_group_calculate, _custom_table_calc)
);
return efl_class_functions_set(klass, &ops);
EFL_OBJECT_OP_TYPE_INVALID = -1, /**< Invalid op. */
EFL_OBJECT_OP_TYPE_REGULAR = 0, /**< Regular op. */
EFL_OBJECT_OP_TYPE_CLASS, /**< Class op - a class op. Like static in Java/C++. */
- EFL_OBJECT_OP_TYPE_REGULAR_OVERRIDE, /**< Regular op override (previously defined) */
- EFL_OBJECT_OP_TYPE_CLASS_OVERRIDE, /**< Class op override (previously defined) */
};
/**
* @brief Define an array of override functions for @ref efl_object_override
* @param ops A name for the Efl_Object_Ops local variable to define
* @param ... A comma separated list of Efl_Object_Op overrides, using
- * #EFL_OBJECT_OP_FUNC_OVERRIDE or #EFL_OBJECT_OP_CLASS_FUNC_OVERRIDE
+ * #EFL_OBJECT_OP_FUNC or #EFL_OBJECT_OP_CLASS_FUNC
*
* This can be used as follows:
* @code
- * EFL_OPS_DEFINE(ops, EFL_OBJECT_OP_FUNC_OVERRIDE(public_func, _my_func));
+ * EFL_OPS_DEFINE(ops, EFL_OBJECT_OP_FUNC(public_func, _my_func));
* efl_object_override(obj, &ops);
* @endcode
*
#define EFL_OBJECT_OP_FUNC(_api, _private) { _EFL_OBJECT_OP_API_ENTRY(_api), (void*)_private, EFL_OBJECT_OP_TYPE_REGULAR }
#define EFL_OBJECT_OP_CLASS_FUNC(_api, _private) { _EFL_OBJECT_OP_API_ENTRY(_api), (void*)_private, EFL_OBJECT_OP_TYPE_CLASS }
-#define EFL_OBJECT_OP_FUNC_OVERRIDE(_api, _private) { _EFL_OBJECT_OP_API_ENTRY(_api), (void*)_private, EFL_OBJECT_OP_TYPE_REGULAR_OVERRIDE }
-#define EFL_OBJECT_OP_CLASS_FUNC_OVERRIDE(_api, _private) { _EFL_OBJECT_OP_API_ENTRY(_api), (void*)_private, EFL_OBJECT_OP_TYPE_CLASS_OVERRIDE }
// returns the OP id corresponding to the given api_func
EAPI Efl_Object_Op _efl_object_api_op_id_get(const void *api_func);
#endif
}
-EAPI Efl_Object_Op
-_efl_object_api_op_id_get(const void *api_func)
+static inline Efl_Object_Op
+_efl_object_api_op_id_get_internal(const void *api_func)
{
eina_spinlock_take(&_ops_storage_lock);
#ifndef _WIN32
#endif
eina_spinlock_release(&_ops_storage_lock);
+ return op;
+}
+
+EAPI Efl_Object_Op
+_efl_object_api_op_id_get(const void *api_func)
+{
+ Efl_Object_Op op = _efl_object_api_op_id_get_internal(api_func);
+
if (op == EFL_NOOP)
{
ERR("Unable to resolve op for api func %p", api_func);
/* klass is the klass we are working on. hierarchy_klass is the class whe should
* use when validating. */
static Eina_Bool
-_eo_class_funcs_set(Eo_Vtable *vtable, const Efl_Object_Ops *ops, const _Efl_Class *hierarchy_klass, const _Efl_Class *klass, Eina_Bool override_only)
+_eo_class_funcs_set(Eo_Vtable *vtable, const Efl_Object_Ops *ops, const _Efl_Class *hierarchy_klass, const _Efl_Class *klass, Eina_Bool override_only EINA_UNUSED)
{
unsigned int i;
int op_id;
if ((op_desc->op_type == EFL_OBJECT_OP_TYPE_REGULAR) || (op_desc->op_type == EFL_OBJECT_OP_TYPE_CLASS))
{
- if (override_only)
- {
- ERR("Creation of new functions is not allowed when overriding an object's vtable.");
- return EINA_FALSE;
- }
-
if (_eo_api_func_equal(op_desc->api_func, last_api_func))
{
ERR("Class '%s': API previously defined (%p->%p '%s').",
return EINA_FALSE;
}
- op = op_id;
- eina_spinlock_take(&_ops_storage_lock);
+ op = _efl_object_api_op_id_get_internal(op_desc->api_func);
+
+ if (op == EFL_NOOP)
+ {
+ op = op_id;
+ eina_spinlock_take(&_ops_storage_lock);
#ifndef _WIN32
- eina_hash_add(_ops_storage, &op_desc->api_func, (void *) (uintptr_t) op);
+ eina_hash_add(_ops_storage, &op_desc->api_func, (void *) (uintptr_t) op);
#else
- eina_hash_add(_ops_storage, op_desc->api_func, (void *) (uintptr_t) op);
+ eina_hash_add(_ops_storage, op_desc->api_func, (void *) (uintptr_t) op);
#endif
- eina_spinlock_release(&_ops_storage_lock);
+ eina_spinlock_release(&_ops_storage_lock);
- op_id++;
- }
- else if ((op_desc->op_type == EFL_OBJECT_OP_TYPE_REGULAR_OVERRIDE) || (op_desc->op_type == EFL_OBJECT_OP_TYPE_CLASS_OVERRIDE))
- {
- /* We allow any overrides, we don't check if in hierarchy. */
- op = _efl_object_api_op_id_get(op_desc->api_func);
+ op_id++;
+ }
}
if (op == EFL_NOOP)
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_get, _a_get),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(simple_a_get, _a_get),
);
return efl_class_functions_set(klass, &ops);
{
EFL_OPS_DEFINE(ops,
EFL_OBJECT_OP_FUNC(mixin_add_and_print, _add_and_print_set),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_finalize, _finalize),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor),
+ EFL_OBJECT_OP_FUNC(efl_finalize, _finalize),
EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
EFL_OBJECT_OP_FUNC(simple_a_get, _a_get),
EFL_OBJECT_OP_FUNC(simple_b_set, _b_set),
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
);
return efl_class_functions_set(klass, &ops);
EFL_OPS_DEFINE(ops,
EFL_OBJECT_OP_FUNC(inherit2_print, _print),
EFL_OBJECT_OP_FUNC(inherit2_print2, _print2),
- EFL_OBJECT_OP_CLASS_FUNC_OVERRIDE(simple_class_print, _class_print),
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_set, _a_set),
+ EFL_OBJECT_OP_CLASS_FUNC(simple_class_print, _class_print),
+ EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_set, _a_set),
+ EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
);
return efl_class_functions_set(klass, &ops);
EFL_OBJECT_OP_FUNC(simple_a_get, _a_get),
EFL_OBJECT_OP_FUNC(simple_b_set, _b_set),
EFL_OBJECT_OP_FUNC(simple_b_get, _b_get),
- EFL_OBJECT_OP_FUNC_OVERRIDE(interface_ab_sum_get, _ab_sum_get),
- EFL_OBJECT_OP_FUNC_OVERRIDE(interface2_ab_sum_get2, _ab_sum_get2),
+ EFL_OBJECT_OP_FUNC(interface_ab_sum_get, _ab_sum_get),
+ EFL_OBJECT_OP_FUNC(interface2_ab_sum_get2, _ab_sum_get2),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_get, _a_get),
+ EFL_OBJECT_OP_FUNC(simple_a_get, _a_get),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor),
EFL_OBJECT_OP_FUNC(mixin_ab_sum_get, _ab_sum_get),
);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor),
+ EFL_OBJECT_OP_FUNC(mixin_ab_sum_get, _ab_sum_get),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(mixin_ab_sum_get, _ab_sum_get),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor),
+ EFL_OBJECT_OP_FUNC(mixin_ab_sum_get, _ab_sum_get),
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _constructor),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _constructor),
EFL_OBJECT_OP_FUNC(simple_a_set, _a_set),
);
_destructor_unref_class_initializer(Efl_Class *klass2)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _destructor_unref),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _destructor_unref),
);
return efl_class_functions_set(klass2, &ops);
END_TEST
static Eina_Bool
-_wrong_override_class_initializer(Efl_Class *klass)
-{
- EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(null_fct, _null_fct),
- );
-
- return efl_class_functions_set(klass, &ops);
-}
-
-START_TEST(eo_wrong_override)
-{
- efl_object_init();
-
- const Efl_Class *klass;
-
- static Efl_Class_Description class_desc = {
- EO_VERSION,
- "Simple",
- EFL_CLASS_TYPE_REGULAR,
- 0,
- _wrong_override_class_initializer,
- NULL,
- NULL
- };
-
- klass = efl_class_new(&class_desc, NULL, NULL);
- fail_if(klass);
-
- efl_object_shutdown();
-}
-END_TEST
-
-static Eina_Bool
_redefined_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
_dich_func_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_set, _null_fct),
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_set, NULL),
+ EFL_OBJECT_OP_FUNC(simple_a_set, _null_fct),
+ EFL_OBJECT_OP_FUNC(simple_a_set, NULL),
);
return efl_class_functions_set(klass, &ops);
NULL
};
- TEST_EO_ERROR("_vtable_func_set", "Class '%s': Overriding already set func %p for op %d (%s) with %p.");
+ TEST_EO_ERROR("_eo_class_funcs_set", "Class '%s': API previously defined (%p->%p '%s').");
klass = efl_class_new(&class_desc, SIMPLE_CLASS, NULL);
fail_if(klass);
fail_unless(ctx.did);
/* This test is not relevant for WIN32. */
tcase_add_test(tc, eo_null_api);
#endif
- tcase_add_test(tc, eo_wrong_override);
tcase_add_test(tc, eo_api_redefined);
tcase_add_test(tc, eo_dich_func_override);
}
EFL_OBJECT_OP_FUNC(simple_recursive, _recursive),
EFL_OBJECT_OP_FUNC(simple_part_get, _part_get),
EFL_OBJECT_OP_FUNC(simple_pure_virtual, NULL),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_dbg_info_get, _dbg_info_get),
+ EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _dbg_info_get),
);
return efl_class_functions_set(klass, &ops);
_searchable_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_provider_find, _interface_get)
+ EFL_OBJECT_OP_FUNC(efl_provider_find, _interface_get)
);
return efl_class_functions_set(klass, &ops);
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _singleton_efl_constructor),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _singleton_efl_constructor),
);
return efl_class_functions_set(klass, &ops);
EFL_OPS_DEFINE(
overrides,
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_get, _simple_obj_override_a_get));
+ EFL_OBJECT_OP_FUNC(simple_a_get, _simple_obj_override_a_get));
fail_if(!efl_object_override(obj, &overrides));
ck_assert_int_eq(simple_a_get(obj), OVERRIDE_A);
/* Override again. */
EFL_OPS_DEFINE(
overrides2,
- EFL_OBJECT_OP_FUNC_OVERRIDE(simple_a_set, _simple_obj_override_a_double_set));
+ EFL_OBJECT_OP_FUNC(simple_a_set, _simple_obj_override_a_double_set));
fail_if(!efl_object_override(obj, NULL));
fail_if(!efl_object_override(obj, &overrides2));
overrides3,
EFL_OBJECT_OP_FUNC(simple2_class_beef_get, _simple_obj_override_a_double_set));
fail_if(!efl_object_override(obj, NULL));
- fail_if(efl_object_override(obj, &overrides3));
+ fail_if(!efl_object_override(obj, &overrides3));
/* Test override reset */
fail_if(!efl_object_override(obj, NULL));
_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_constructor, _man_con),
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_destructor, _man_des),
+ EFL_OBJECT_OP_FUNC(efl_constructor, _man_con),
+ EFL_OBJECT_OP_FUNC(efl_destructor, _man_des),
);
return efl_class_functions_set(klass, &ops);
_add_failures_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(efl_finalize, _efl_add_failures_finalize),
+ EFL_OBJECT_OP_FUNC(efl_finalize, _efl_add_failures_finalize),
);
return efl_class_functions_set(klass, &ops);
_override_class_initializer(Efl_Class *klass)
{
EFL_OPS_DEFINE(ops,
- EFL_OBJECT_OP_FUNC_OVERRIDE(base_constructor, _override_base_constructor),
- EFL_OBJECT_OP_FUNC_OVERRIDE(base_z_get, __eolian_override_base_z_get),
- EFL_OBJECT_OP_FUNC_OVERRIDE(base_z_set, __eolian_override_base_z_set),
+ EFL_OBJECT_OP_FUNC(base_constructor, _override_base_constructor),
+ EFL_OBJECT_OP_FUNC(base_z_get, __eolian_override_base_z_get),
+ EFL_OBJECT_OP_FUNC(base_z_set, __eolian_override_base_z_set),
EFL_OBJECT_OP_FUNC(override_b_set, __eolian_override_b_set),
EFL_OBJECT_OP_FUNC(override_bar, __eolian_override_bar),
EFL_OBJECT_OP_FUNC(override_c_get, __eolian_override_c_get),