eolian: add support for class functions

This commit is contained in:
Daniel Kolesa 2014-07-24 12:05:12 +01:00
parent 805d746910
commit a5ad792780
8 changed files with 49 additions and 6 deletions

View File

@ -505,6 +505,16 @@ EAPI Eina_Stringshare *eolian_function_data_get(const Eolian_Function *function_
*/
EAPI Eina_Bool eolian_function_is_virtual_pure(const Eolian_Function *function_id, Eolian_Function_Type f_type);
/*
* @brief Get whether a function is a class method/property.
*
* @param[in] function_id Id of the function
* @return EINA_TRUE and EINA_FALSE respectively
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_function_is_class(const Eolian_Function *function_id);
/*
* @brief Returns a specific description for a function.
*

View File

@ -201,6 +201,7 @@ _db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop)
EOLIAN_UNRESOLVED);
database_function_scope_set(foo_id, prop->scope);
database_function_set_as_class(foo_id, prop->is_class);
if (!_db_fill_keys (foo_id, prop)) goto failure;
if (!_db_fill_values (foo_id, prop)) goto failure;
@ -259,6 +260,7 @@ _db_fill_method(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Method_Def *meth)
database_function_description_set(foo_id, EOLIAN_COMMENT, meth->comment);
database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
database_function_object_set_as_const(foo_id, meth->obj_const);
database_function_set_as_class(foo_id, meth->is_class);
_db_fill_params(foo_id, meth);

View File

@ -63,6 +63,13 @@ database_function_set_as_virtual_pure(Eolian_Function *fid, Eolian_Function_Type
return EINA_TRUE;
}
void
database_function_set_as_class(Eolian_Function *fid, Eina_Bool is_class)
{
EINA_SAFETY_ON_NULL_RETURN(fid);
fid->is_class = is_class;
}
void
database_function_data_set(Eolian_Function *fid, const char *key, const char *data)
{

View File

@ -68,6 +68,13 @@ eolian_function_is_virtual_pure(const Eolian_Function *fid, Eolian_Function_Type
}
}
EAPI Eina_Bool
eolian_function_is_class(const Eolian_Function *fid)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
return fid->is_class;
}
EAPI Eina_Stringshare *
eolian_function_data_get(const Eolian_Function *fid, const char *key)
{

View File

@ -59,6 +59,7 @@ typedef struct _Eo_Property_Def
Eina_List *values;
Eina_List *accessors;
int scope;
Eina_Bool is_class:1;
} Eo_Property_Def;
/* METHOD */
@ -72,6 +73,7 @@ typedef struct _Eo_Method_Def
Eina_Stringshare *legacy;
Eina_Bool obj_const;
int scope;
Eina_Bool is_class:1;
} Eo_Method_Def;
/* CLASS */

View File

@ -25,8 +25,8 @@ enum Tokens
KW(destructor), KW(eo_prefix), KW(events), KW(func), KW(get), \
KW(implements), KW(interface), KW(keys), KW(legacy), KW(legacy_prefix), \
KW(methods), KW(mixin), KW(own), KW(params), KW(properties), KW(set), \
KW(type), KW(values), KWAT(const), KWAT(extern), KWAT(in), KWAT(inout), \
KWAT(nonull), KWAT(out), KWAT(protected), KWAT(warn_unused), \
KW(type), KW(values), KWAT(class), KWAT(const), KWAT(extern), KWAT(in), \
KWAT(inout), KWAT(nonull), KWAT(out), KWAT(protected), KWAT(warn_unused), \
\
KW(byte), KW(ubyte), KW(char), KW(short), KW(ushort), KW(int), KW(uint), \
KW(long), KW(ulong), KW(llong), KW(ullong), \

View File

@ -716,18 +716,28 @@ parse_property(Eo_Lexer *ls)
{
int line, col;
Eo_Property_Def *prop = NULL;
Eina_Bool has_get = EINA_FALSE, has_set = EINA_FALSE,
has_keys = EINA_FALSE, has_values = EINA_FALSE;
Eina_Bool has_get = EINA_FALSE, has_set = EINA_FALSE,
has_keys = EINA_FALSE, has_values = EINA_FALSE,
has_protected = EINA_FALSE, has_class = EINA_FALSE;
prop = calloc(1, sizeof(Eo_Property_Def));
ls->tmp.prop = prop;
check(ls, TOK_VALUE);
prop->name = eina_stringshare_ref(ls->t.value);
eo_lexer_get(ls);
if (ls->t.kw == KW_at_protected)
for (;;) switch (ls->t.kw)
{
case KW_at_protected:
CASE_LOCK(ls, protected, "protected qualifier")
prop->scope = EOLIAN_SCOPE_PROTECTED;
eo_lexer_get(ls);
break;
case KW_at_class:
CASE_LOCK(ls, class, "class qualifier");
prop->is_class = EINA_TRUE;
default:
goto body;
}
body:
line = ls->line_number;
col = ls->column;
check_next(ls, '{');
@ -773,7 +783,7 @@ parse_method(Eo_Lexer *ls, Eina_Bool ctor)
Eo_Method_Def *meth = NULL;
Eina_Bool has_const = EINA_FALSE, has_params = EINA_FALSE,
has_return = EINA_FALSE, has_legacy = EINA_FALSE,
has_protected = EINA_FALSE;
has_protected = EINA_FALSE, has_class = EINA_FALSE;
meth = calloc(1, sizeof(Eo_Method_Def));
ls->tmp.meth = meth;
if (ctor)
@ -800,6 +810,9 @@ parse_method(Eo_Lexer *ls, Eina_Bool ctor)
meth->obj_const = EINA_TRUE;
eo_lexer_get(ls);
break;
case KW_at_class:
CASE_LOCK(ls, class, "class qualifier");
meth->is_class = EINA_TRUE;
default:
goto body;
}

View File

@ -83,6 +83,7 @@ struct _Eolian_Function
Eina_Bool set_virtual_pure :1;
Eina_Bool get_return_warn_unused :1; /* also used for methods */
Eina_Bool set_return_warn_unused :1;
Eina_Bool is_class :1;
};
struct _Eolian_Function_Parameter
@ -191,6 +192,7 @@ void database_function_return_default_val_set(Eolian_Function *foo_id, Eolian_Fu
void database_function_return_flag_set_as_warn_unused(Eolian_Function *foo_id, Eolian_Function_Type ftype, Eina_Bool warn_unused);
void database_function_object_set_as_const(Eolian_Function *foo_id, Eina_Bool is_const);
void database_function_set_as_class(Eolian_Function *foo_id, Eina_Bool is_class);
Eina_Bool database_function_set_as_virtual_pure(Eolian_Function *function_id, Eolian_Function_Type type);
void database_function_scope_set(Eolian_Function *function_id, Eolian_Function_Scope scope);