Page MenuHomePhabricator

Add a little reflection API
Closed, ResolvedPublic

Description

Add code generator support for generating a tuple list of "name of propertz" - setter-func-pointer - getter-func-pointer.

This list should be accessable from eo API to search for keys, so perperties can be linked.

bu5hm4n created this task.Feb 1 2019, 8:01 AM

The whole idea would be something like this:

Addition to Eo.h:

typedef struct {

const char *property_name;
Eina_Value type_type;
Setter setter; /* function pointer */
Getter getter; /* function pointer */

} Reflection_Line;

The getter has to have the type that is passed in as type of the return type.
The setter has to have the type that is passed in as the second argument of the function

void efl_reflection_table_set(const Reflection_Line *line);

void efl_reflection_set(const Eo *obj, const char *name, Eina_Value *value);
void efl_reflection_get(const Eo *obj, const char *name, Eina_Value **value);

The table however needs to be generated by some magically unicorns that can write code.

Eina_Value generic_string_get(Eo *obj, void *(*str_get)(Eo *obj))
{

const char *s = str_get(obj);
return eina_value_string_init(s);

}

void generic_string_set(Eo *obj, Eina_Value s, voir (*str_set)(Eo *obj, void *str))
{

char *s = eina_value_string_convert(&s);
str_set(obj, s);
free(s);

}

{ "file", generic_string_get, generic_string_set } = efl_property_reflection_get("file");

bu5hm4n moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Feb 4 2019, 6:04 AM
bu5hm4n removed q66 as the assignee of this task.Feb 4 2019, 1:13 PM
bu5hm4n edited projects, added efl: language bindings; removed Restricted Project.
bu5hm4n added subscribers: cedric, q66.
bu5hm4n closed this task as Resolved.Mar 18 2019, 7:46 AM
bu5hm4n claimed this task.