}
static Eina_Bool
-eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, _eolian_class_vars *impl_env)
+eo_bind_func_generate(const Eolian_Class *class, const Eolian_Function *funcid, Eolian_Function_Type ftype, Eina_Strbuf *buf, Eolian_Implement *impl, _eolian_class_vars *impl_env)
{
_eolian_class_func_vars func_env;
const char *suffix = "";
Eina_Iterator *itr;
void *data, *data2;
const Eolian_Expression *default_ret_val = NULL;
+ Eina_Bool is_empty = impl ? eolian_implement_is_empty(impl) : eolian_function_is_empty(funcid, ftype);
+ Eina_Bool is_auto = impl ? eolian_implement_is_auto(impl) : eolian_function_is_auto(funcid, ftype);
+ if (ftype != EOLIAN_PROP_GET && ftype != EOLIAN_PROP_SET) ftype = eolian_function_type_get(funcid);
Eina_Bool need_implementation = EINA_TRUE;
if (!impl_env && eolian_function_is_virtual_pure(funcid, ftype)) need_implementation = EINA_FALSE;
rettypet = eolian_function_return_type_get(funcid, ftype);
if (rettypet)
- default_ret_val = eolian_function_return_default_value_get(funcid, ftype);
+ {
+ is_auto = EINA_FALSE; /* We block auto when the function has to return something */
+ default_ret_val = eolian_function_return_default_value_get(funcid, ftype);
+ }
if (ftype == EOLIAN_PROP_GET)
{
suffix = "_get";
Eina_Bool is_const = eolian_parameter_const_attribute_get(data, ftype == EOLIAN_PROP_GET);
if (eina_strbuf_length_get(params)) eina_strbuf_append(params, ", ");
eina_strbuf_append_printf(params, "%s", pname);
- eina_strbuf_append_printf(full_params, ", %s%s %s",
+ eina_strbuf_append_printf(full_params, ", %s%s %s%s",
is_const?"const ":"",
- ptype, pname);
+ ptype, pname, is_empty || is_auto?" EINA_UNUSED":"");
eina_stringshare_del(ptype);
}
eina_iterator_free(itr);
EINA_ITERATOR_FOREACH(itr, data)
{
Eolian_Function_Parameter *param = data;
+ const Eolian_Expression *dflt_value = eolian_parameter_default_value_get(param);
const Eolian_Type *ptypet = eolian_parameter_type_get(param);
const char *pname = eolian_parameter_name_get(param);
const char *ptype = eolian_type_c_type_get(ptypet);
if (ftype == EOLIAN_UNRESOLVED || ftype == EOLIAN_METHOD) add_star = (pdir == EOLIAN_OUT_PARAM || pdir == EOLIAN_INOUT_PARAM);
if (eina_strbuf_length_get(params)) eina_strbuf_append(params, ", ");
eina_strbuf_append_printf(params, "%s", pname);
- eina_strbuf_append_printf(full_params, ", %s%s%s%s%s",
+ eina_strbuf_append_printf(full_params, ", %s%s%s%s%s%s",
is_const?"const ":"",
- ptype, had_star?"":" ", add_star?"*":"", pname);
- if (ftype != EOLIAN_PROP_SET)
+ ptype, had_star?"":" ", add_star?"*":"", pname, is_empty && !dflt_value ?" EINA_UNUSED":"");
+ if (is_auto)
{
- const Eolian_Expression *dflt_value = eolian_parameter_default_value_get(param);
- if (dflt_value)
+ if (ftype == EOLIAN_PROP_SET)
{
- const char *val_str = NULL;
- Eolian_Value val = eolian_expression_eval
- (dflt_value, EOLIAN_MASK_ALL);
- if (val.type)
+ eina_strbuf_append_printf(params_init,
+ " %s = pd->%s;\n", pname, pname);
+ }
+ else
+ {
+ eina_strbuf_append_printf(params_init,
+ " if (%s) *%s = pd->%s;\n", pname, pname, pname);
+ }
+ }
+ else {
+ if (ftype != EOLIAN_PROP_SET)
+ {
+ if (dflt_value)
{
- val_str = eolian_expression_value_to_literal(&val);
- eina_strbuf_append_printf(params_init,
- " if (%s) *%s = %s;",
- pname, pname, val_str);
- if (eolian_expression_type_get(dflt_value) == EOLIAN_EXPR_ENUM)
+ const char *val_str = NULL;
+ Eolian_Value val = eolian_expression_eval
+ (dflt_value, EOLIAN_MASK_ALL);
+ if (val.type)
{
- Eina_Stringshare *string = eolian_expression_serialize(dflt_value);
- eina_strbuf_append_printf(params_init, " /* %s */", string);
- eina_stringshare_del(string);
+ val_str = eolian_expression_value_to_literal(&val);
+ eina_strbuf_append_printf(params_init,
+ " if (%s) *%s = %s;",
+ pname, pname, val_str);
+ if (eolian_expression_type_get(dflt_value) == EOLIAN_EXPR_ENUM)
+ {
+ Eina_Stringshare *string = eolian_expression_serialize(dflt_value);
+ eina_strbuf_append_printf(params_init, " /* %s */", string);
+ eina_stringshare_del(string);
+ }
+ eina_strbuf_append_printf(params_init, "\n");
}
- eina_strbuf_append_printf(params_init, "\n");
}
}
}
{
Eina_Strbuf *ret_param = eina_strbuf_new();
eina_strbuf_append_printf(fbody, "\n");
- eina_strbuf_append_printf(fbody, "%s%s _%s%s%s_%s%s(Eo *obj, @#Datatype_Data *pd@#full_params);\n\n",
- ret_const?"const ":"", rettype?rettype:"void",
- class_env.lower_classname,
- impl_env?"_":"",
- impl_env?impl_env->lower_classname:"",
- eolian_function_name_get(funcid), suffix);
+ /* Generation of the user function prototype declaration - not needed when @auto and @empty are indicated */
+ if (!is_empty && !is_auto)
+ {
+ eina_strbuf_append_printf(fbody, "%s%s _%s%s%s_%s%s(Eo *obj, @#Datatype_Data *pd%s);\n\n",
+ ret_const?"const ":"", rettype?rettype:"void",
+ class_env.lower_classname,
+ impl_env?"_":"",
+ impl_env?impl_env->lower_classname:"",
+ eolian_function_name_get(funcid), suffix,
+ eina_strbuf_string_get(full_params));
+ }
- if (eina_strbuf_length_get(params_init))
+ if (is_empty || is_auto || eina_strbuf_length_get(params_init))
{
+ /* We need to give the internal function name to Eo. We use this hash table as indication */
eina_hash_add(_funcs_params_init,
- eina_stringshare_add(eolian_function_name_get(funcid)), funcid);
- eina_strbuf_append_printf(fbody, "static %s%s __eolian_%s%s%s_%s%s(Eo *obj, @#Datatype_Data *pd@#full_params)\n{\n%s\n",
+ eina_stringshare_add(eolian_function_name_get(funcid)), (void *)ftype);
+ /* Generation of the intermediate function __eolian_... */
+ eina_strbuf_append_printf(fbody, "static %s%s __eolian_%s%s%s_%s%s(Eo *obj%s, @#Datatype_Data *pd%s%s)\n{\n",
ret_const?"const ":"", rettype?rettype:"void",
class_env.lower_classname,
impl_env?"_":"",
impl_env?impl_env->lower_classname:"",
eolian_function_name_get(funcid), suffix,
- eina_strbuf_string_get(params_init));
- eina_strbuf_append_printf(fbody, " %s_%s%s%s_%s%s(obj, pd, %s);\n}\n\n",
+ is_empty || is_auto?" EINA_UNUSED":"",
+ is_empty || (is_auto && !eina_strbuf_length_get(params_init))?" EINA_UNUSED":"",
+ eina_strbuf_string_get(full_params));
+ }
+ if (eina_strbuf_length_get(params_init))
+ {
+ eina_strbuf_append_printf(fbody, "%s", eina_strbuf_string_get(params_init));
+ }
+ if (is_auto || is_empty)
+ {
+ if (rettype)
+ {
+ /* return for auto and empty */
+ const char *val_str = NULL;
+ if (default_ret_val)
+ {
+ Eolian_Value val = eolian_expression_eval
+ (default_ret_val, EOLIAN_MASK_ALL);
+ if (val.type)
+ val_str = eolian_expression_value_to_literal(&val);
+ }
+ eina_strbuf_append_printf(fbody, " return %s;\n", val_str?val_str:"0");
+ }
+ eina_strbuf_append_printf(fbody, "}\n\n");
+ }
+ else if (eina_strbuf_length_get(params_init))
+ {
+ /* Generation of the user function invocation, e.g return _user_foo(obj, pd, ...) */
+ eina_strbuf_append_printf(fbody, " %s_%s%s%s_%s%s(obj, pd, %s);\n}\n\n",
rettype?"return ":"",
class_env.lower_classname,
impl_env?"_":"",
}
if (has_params)
{
+ eina_strbuf_replace_all(full_params, " EINA_UNUSED", "");
eina_strbuf_append_printf(eo_func_decl, ", EO_FUNC_CALL(%s)%s",
eina_strbuf_string_get(params),
eina_strbuf_string_get(full_params));
if (need_implementation)
{
Eina_Bool is_cf = eolian_function_is_class(funcid);
- eina_strbuf_replace_all(fbody, "@#full_params", eina_strbuf_string_get(full_params));
const char *data_type = eolian_class_data_type_get(class);
if (is_cf || (data_type && !strcmp(data_type, "null")))
eina_strbuf_replace_all(fbody, "@#Datatype_Data", "void");
eina_strbuf_append_printf(buf, "\n EO_OP_%sFUNC(%s, ", class_str, func_env.lower_eo_func);
if (!is_virtual_pure)
{
+ Eolian_Function_Type ftype2 = (Eolian_Function_Type) eina_hash_find(_funcs_params_init, funcname);
eina_strbuf_append_printf(buf, "%s_%s_%s%s, \"%s\"),",
- eina_hash_find(_funcs_params_init, funcname)
- && ftype != EOLIAN_PROP_SET?"__eolian":"",
+ ftype == ftype2?"__eolian":"",
class_env.lower_classname, funcname, suffix, desc);
}
else
const Eolian_Function *fnid = NULL;
const char *funcname = NULL;
const char *rets;
- char *tp = implname;
const char *names[] = { "", "getter ", "setter " };
- if ((impl_class = eolian_implement_class_get(impl_desc)))
+ impl_class = eolian_implement_class_get(impl_desc);
+
+ if (impl_class)
{
+ char *tp = implname;
if (impl_class == class)
continue;
fnid = eolian_implement_function_get(impl_desc, &ftype);
_class_env_create(impl_class, NULL, &impl_env);
funcname = eolian_function_name_get(fnid);
- sprintf(implname, "%s_%s", class_env.full_classname, impl_env.full_classname);
+ sprintf(implname, "%s_%s_%s",
+ eolian_implement_is_auto(impl_desc) || eolian_implement_is_empty(impl_desc)?
+ "__eolian":"",
+ class_env.full_classname, impl_env.full_classname);
eina_str_tolower(&tp);
}
case EOLIAN_PROP_SET: case EOLIAN_PROP_GET: case EOLIAN_PROPERTY:
if (ftype != EOLIAN_PROP_GET)
{
- eina_strbuf_append_printf(str_op, "\n EO_OP_%sFUNC_OVERRIDE(%s_set, _%s_%s_set),",
+ eina_strbuf_append_printf(str_op, "\n EO_OP_%sFUNC_OVERRIDE(%s_set, %s_%s_set),",
class_str, rets, implname, funcname);
- eo_bind_func_generate(class, fnid, EOLIAN_PROP_SET, str_bodyf, &impl_env);
+ eo_bind_func_generate(class, fnid, EOLIAN_PROP_SET, str_bodyf, impl_desc, &impl_env);
}
if (ftype != EOLIAN_PROP_SET)
{
- eina_strbuf_append_printf(str_op, "\n EO_OP_%sFUNC_OVERRIDE(%s_get, _%s_%s_get),",
+ eina_strbuf_append_printf(str_op, "\n EO_OP_%sFUNC_OVERRIDE(%s_get, %s_%s_get),",
class_str, rets, implname, funcname);
- eo_bind_func_generate(class, fnid, EOLIAN_PROP_GET, str_bodyf, &impl_env);
+ eo_bind_func_generate(class, fnid, EOLIAN_PROP_GET, str_bodyf, impl_desc, &impl_env);
}
break;
default:
- eina_strbuf_append_printf(str_op, "\n EO_OP_%sFUNC_OVERRIDE(%s, _%s_%s),",
+ eina_strbuf_append_printf(str_op, "\n EO_OP_%sFUNC_OVERRIDE(%s, %s_%s),",
class_str, rets, implname, funcname);
- eo_bind_func_generate(class, fnid, ftype, str_bodyf, &impl_env);
+ eo_bind_func_generate(class, fnid, ftype, str_bodyf, impl_desc, &impl_env);
break;
}
eina_stringshare_del(rets);
switch (ftype)
{
case EOLIAN_PROP_GET: case EOLIAN_PROP_SET:
- if (!eo_bind_func_generate(class, fid, ftype, str_bodyf, NULL))
+ if (!eo_bind_func_generate(class, fid, ftype, str_bodyf, NULL, NULL))
goto end;
break;
case EOLIAN_PROPERTY:
- if (!eo_bind_func_generate(class, fid, EOLIAN_PROP_SET, str_bodyf, NULL))
+ if (!eo_bind_func_generate(class, fid, EOLIAN_PROP_SET, str_bodyf, NULL, NULL))
goto end;
- if (!eo_bind_func_generate(class, fid, EOLIAN_PROP_GET, str_bodyf, NULL))
+ if (!eo_bind_func_generate(class, fid, EOLIAN_PROP_GET, str_bodyf, NULL, NULL))
goto end;
break;
default:
- if (!eo_bind_func_generate(class, fid, EOLIAN_UNRESOLVED, str_bodyf, NULL))
+ if (!eo_bind_func_generate(class, fid, EOLIAN_UNRESOLVED, str_bodyf, NULL, NULL))
goto end;
break;
}
--- /dev/null
+EOAPI EO_VOID_FUNC_BODY(override_a_set);
+EOAPI EO_VOID_FUNC_BODY(override_foo);
+
+static void __eolian_override_b_set(Eo *obj EINA_UNUSED, Override_Data *pd, int idx EINA_UNUSED, float a, char b, int c)
+{
+ a = pd->a;
+ b = pd->b;
+ c = pd->c;
+}
+
+EOAPI EO_VOID_FUNC_BODYV(override_b_set, EO_FUNC_CALL(idx, a, b, c), int idx, float a, char b, int c);
+
+static void __eolian_override_bar(Eo *obj EINA_UNUSED, Override_Data *pd EINA_UNUSED, int idx EINA_UNUSED, int *a, char **str)
+{
+ if (a) *a = 250;
+ if (str) *str = NULL;
+}
+
+EOAPI EO_VOID_FUNC_BODYV(override_bar, EO_FUNC_CALL(idx, a, str), int idx, int *a, char **str);
+
+static int __eolian_override_c_get(Eo *obj EINA_UNUSED, Override_Data *pd EINA_UNUSED, int idx EINA_UNUSED)
+{
+ return 50;
+}
+
+EOAPI EO_FUNC_BODYV(override_c_get, int, 50, EO_FUNC_CALL(idx), int idx);
+
+void _override_a_get(Eo *obj, Override_Data *pd);
+
+EOAPI EO_VOID_FUNC_BODY(override_a_get);
+
+void _override_b_get(Eo *obj, Override_Data *pd, int idx, float *a, char *b, int *c);
+
+EOAPI EO_VOID_FUNC_BODYV(override_b_get, EO_FUNC_CALL(idx, a, b, c), int idx, float *a, char *b, int *c);
+
+void _override_c_set(Eo *obj, Override_Data *pd, int idx, int c);
+
+EOAPI EO_VOID_FUNC_BODYV(override_c_set, EO_FUNC_CALL(idx, c), int idx, int c);
+
+void _override_base_constructor(Eo *obj, Override_Data *pd);
+
+
+static void __eolian_override_base_z_get(Eo *obj EINA_UNUSED, Override_Data *pd, int *a, char *b, float *c)
+{
+ if (a) *a = pd->a;
+ if (b) *b = pd->b;
+ if (c) *c = pd->c;
+}
+
+
+static void __eolian_override_base_z_set(Eo *obj EINA_UNUSED, Override_Data *pd EINA_UNUSED, int a EINA_UNUSED, char b EINA_UNUSED, float c EINA_UNUSED)
+{
+}
+
+
+static Eo_Op_Description _override_op_desc[] = {
+ EO_OP_FUNC_OVERRIDE(base_constructor, _override_base_constructor),
+ EO_OP_FUNC_OVERRIDE(base_z_get, __eolian_override_base_z_get),
+ EO_OP_FUNC_OVERRIDE(base_z_set, __eolian_override_base_z_set),
+ EO_OP_FUNC(override_a_set, NULL, ""),
+ EO_OP_FUNC(override_foo, NULL, ""),
+ EO_OP_FUNC(override_b_set, __eolian_override_b_set, ""),
+ EO_OP_FUNC(override_bar, __eolian_override_bar, ""),
+ EO_OP_FUNC(override_c_get, __eolian_override_c_get, ""),
+ EO_OP_FUNC(override_a_get, _override_a_get, ""),
+ EO_OP_FUNC(override_b_get, _override_b_get, ""),
+ EO_OP_FUNC(override_c_set, _override_c_set, ""),
+ EO_OP_SENTINEL
+};
+
+static const Eo_Class_Description _override_class_desc = {
+ EO_VERSION,
+ "Override",
+ EO_CLASS_TYPE_REGULAR,
+ EO_CLASS_DESCRIPTION_OPS(_override_op_desc),
+ NULL,
+ sizeof(Override_Data),
+ NULL,
+ NULL
+};
+
+EO_DEFINE_CLASS(override_class_get, &_override_class_desc, BASE_CLASS, NULL);
\ No newline at end of file