forked from enlightenment/efl
Eolian/Lexer: support of complex types
Complex types are now supported in .eo files: Eina_List * @own <Eo *> The parser is in charge of creating a list of formatted basic types.
This commit is contained in:
parent
08484aa646
commit
7aab226a81
|
@ -44,6 +44,12 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
typedef struct _Function_Id* Eolian_Function;
|
typedef struct _Function_Id* Eolian_Function;
|
||||||
|
|
||||||
|
/* Parameter/return type.
|
||||||
|
*
|
||||||
|
* @ingroup Eolian
|
||||||
|
*/
|
||||||
|
typedef Eina_Inlist* Eolian_Type;
|
||||||
|
|
||||||
/* Class function parameter information
|
/* Class function parameter information
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
|
@ -403,7 +409,21 @@ EAPI const Eina_List *eolian_parameters_list_get(Eolian_Function function_id);
|
||||||
*
|
*
|
||||||
* @ingroup Eolian
|
* @ingroup Eolian
|
||||||
*/
|
*/
|
||||||
EAPI void eolian_parameter_information_get(Eolian_Function_Parameter param_desc, Eolian_Parameter_Dir *param_dir, const char **type, const char **name, const char **description);
|
EAPI void eolian_parameter_information_get(const Eolian_Function_Parameter param_desc, Eolian_Parameter_Dir *param_dir, const char **type, const char **name, const char **description);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Get information on given type.
|
||||||
|
*
|
||||||
|
* An Eolian type is an inlist of basic C types. For example:
|
||||||
|
* Eina_List * <Eo *> contains two basic types.
|
||||||
|
* The first Eolian type of the list stores Eina_List *, the next one Eo *.
|
||||||
|
*
|
||||||
|
* @param[in] etype Eolian type
|
||||||
|
* @param[out] type C type
|
||||||
|
* @param[out] own indicates if the ownership has to pass to the caller/callee.
|
||||||
|
* @return the next type of the list.
|
||||||
|
*/
|
||||||
|
EAPI Eolian_Type eolian_type_information_get(Eolian_Type etype, const char **type, Eina_Bool *own);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get type of a parameter
|
* @brief Get type of a parameter
|
||||||
|
@ -415,6 +435,16 @@ EAPI void eolian_parameter_information_get(Eolian_Function_Parameter param_desc,
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Stringshare *eolian_parameter_type_get(const Eolian_Function_Parameter param);
|
EAPI Eina_Stringshare *eolian_parameter_type_get(const Eolian_Function_Parameter param);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Get a list of all the types of a parameter
|
||||||
|
*
|
||||||
|
* @param[in] param_desc parameter handle
|
||||||
|
* @return the types of the parameter
|
||||||
|
*
|
||||||
|
* @ingroup Eolian
|
||||||
|
*/
|
||||||
|
EAPI Eolian_Type eolian_parameter_types_list_get(const Eolian_Function_Parameter param);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get name of a parameter
|
* @brief Get name of a parameter
|
||||||
*
|
*
|
||||||
|
@ -449,16 +479,6 @@ EAPI Eina_Bool eolian_parameter_const_attribute_get(Eolian_Function_Parameter pa
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool eolian_parameter_is_nonull(Eolian_Function_Parameter param_desc);
|
EAPI Eina_Bool eolian_parameter_is_nonull(Eolian_Function_Parameter param_desc);
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Indicates if the ownership of tha parameter passes to the caller/callee..
|
|
||||||
*
|
|
||||||
* @param[in] param_desc parameter handle
|
|
||||||
* @return EINA_TRUE if cannot be NULL, EINA_FALSE otherwise
|
|
||||||
*
|
|
||||||
* @ingroup Eolian
|
|
||||||
*/
|
|
||||||
EAPI Eina_Bool eolian_parameter_is_own(Eolian_Function_Parameter param_desc);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get the return type of a function.
|
* @brief Get the return type of a function.
|
||||||
*
|
*
|
||||||
|
@ -473,6 +493,18 @@ EAPI Eina_Bool eolian_parameter_is_own(Eolian_Function_Parameter param_desc);
|
||||||
*/
|
*/
|
||||||
EAPI const char *eolian_function_return_type_get(Eolian_Function function_id, Eolian_Function_Type ftype);
|
EAPI const char *eolian_function_return_type_get(Eolian_Function function_id, Eolian_Function_Type ftype);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Get a list of all the types of a function return
|
||||||
|
*
|
||||||
|
* @param[in] foo_id Function Id
|
||||||
|
* @param[in] ftype Function Type
|
||||||
|
* @return the types of the function return
|
||||||
|
*
|
||||||
|
* @ingroup Eolian
|
||||||
|
*/
|
||||||
|
EAPI Eolian_Type
|
||||||
|
eolian_function_return_types_list_get(Eolian_Function foo_id, Eolian_Function_Type ftype);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Get the return default value of a function.
|
* @brief Get the return default value of a function.
|
||||||
*
|
*
|
||||||
|
@ -518,21 +550,6 @@ eolian_function_return_comment_get(Eolian_Function foo_id, Eolian_Function_Type
|
||||||
*/
|
*/
|
||||||
EAPI Eina_Bool eolian_function_return_is_warn_unused(Eolian_Function foo_id, Eolian_Function_Type ftype);
|
EAPI Eina_Bool eolian_function_return_is_warn_unused(Eolian_Function foo_id, Eolian_Function_Type ftype);
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief returns the own flag of a function
|
|
||||||
*
|
|
||||||
* @param[in] function_id id of the function
|
|
||||||
* @param[in] ftype type of the function
|
|
||||||
* @return the own flag.
|
|
||||||
*
|
|
||||||
* The type of the function is needed because a given function can represent a
|
|
||||||
* property, that can be set and get functions.
|
|
||||||
*
|
|
||||||
* @ingroup Eolian
|
|
||||||
*/
|
|
||||||
EAPI Eina_Bool
|
|
||||||
eolian_function_return_own_get(Eolian_Function foo_id, Eolian_Function_Type ftype);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Indicates if a function object is const.
|
* @brief Indicates if a function object is const.
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,7 +12,6 @@ typedef struct _eo_ret_def
|
||||||
const char *comment;
|
const char *comment;
|
||||||
char *dflt_ret_val;
|
char *dflt_ret_val;
|
||||||
Eina_Bool warn_unused:1;
|
Eina_Bool warn_unused:1;
|
||||||
Eina_Bool own:1;
|
|
||||||
} Eo_Ret_Def;
|
} Eo_Ret_Def;
|
||||||
|
|
||||||
/* PARAM */
|
/* PARAM */
|
||||||
|
@ -32,7 +31,6 @@ typedef struct _eo_param_def
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *comment;
|
const char *comment;
|
||||||
Eina_Bool nonull:1;
|
Eina_Bool nonull:1;
|
||||||
Eina_Bool own:1;
|
|
||||||
} Eo_Param_Def;
|
} Eo_Param_Def;
|
||||||
|
|
||||||
/* ACCESSOR */
|
/* ACCESSOR */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -222,12 +222,6 @@ _eo_tokenizer_param_get(Eo_Tokenizer *toknz, char *p)
|
||||||
param->nonull = EINA_TRUE;
|
param->nonull = EINA_TRUE;
|
||||||
memset(s, ' ', 7);
|
memset(s, ' ', 7);
|
||||||
}
|
}
|
||||||
s = strstr(toknz->saved.tok, "@own");
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
param->own = EINA_TRUE;
|
|
||||||
memset(s, ' ', 4);
|
|
||||||
}
|
|
||||||
*p = ';';
|
*p = ';';
|
||||||
s = p - 1; /* Don't look at the character ';' */
|
s = p - 1; /* Don't look at the character ';' */
|
||||||
/* Remove any space between the param name and ';'/@nonull
|
/* Remove any space between the param name and ';'/@nonull
|
||||||
|
@ -284,12 +278,6 @@ _eo_tokenizer_return_get(Eo_Tokenizer *toknz, char *p)
|
||||||
ret->warn_unused = EINA_TRUE;
|
ret->warn_unused = EINA_TRUE;
|
||||||
memset(s, ' ', 12);
|
memset(s, ' ', 12);
|
||||||
}
|
}
|
||||||
s = strstr(toknz->saved.tok, "@own");
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
ret->own = EINA_TRUE;
|
|
||||||
memset(s, ' ', 4);
|
|
||||||
}
|
|
||||||
s = strchr(toknz->saved.tok, '(');
|
s = strchr(toknz->saved.tok, '(');
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
@ -450,7 +438,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
|
||||||
colon = ':';
|
colon = ':';
|
||||||
|
|
||||||
# chars allowed on the return line.
|
# chars allowed on the return line.
|
||||||
return_char = (alnum_u | '*' | ws | '@' | '(' | ')' | '.' | '-');
|
return_char = (alnum_u | '*' | ws | '@' | '(' | ')' | '.' | '-' | '<' | '>');
|
||||||
func_name = (alnum >save_fpc (alnum | '_')+ (ws (alnum | '_')+)?);
|
func_name = (alnum >save_fpc (alnum | '_')+ (ws (alnum | '_')+)?);
|
||||||
}%%
|
}%%
|
||||||
|
|
||||||
|
@ -563,7 +551,7 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
param_comment = ws* eo_comment %end_param_comment;
|
param_comment = ws* eo_comment %end_param_comment;
|
||||||
param = ('@'|alpha+) >save_fpc (alnum_u | '*' | '@' | ws )+ %end_param end_statement param_comment?;
|
param = ('@'|alpha+) >save_fpc (alnum_u | '*' | '@' | '<' | '>' | ws )+ %end_param end_statement param_comment?;
|
||||||
|
|
||||||
tokenize_params := |*
|
tokenize_params := |*
|
||||||
ignore+; #=> show_ignore;
|
ignore+; #=> show_ignore;
|
||||||
|
@ -1287,6 +1275,108 @@ eo_tokenizer_dump(Eo_Tokenizer *toknz)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Inlist *
|
||||||
|
_types_extract(const char *buf, int len)
|
||||||
|
{
|
||||||
|
const char *save_buf = buf;
|
||||||
|
Eolian_Type types = NULL;
|
||||||
|
long depth = 0;
|
||||||
|
char *tmp_type = malloc(2 * len + 1);
|
||||||
|
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
char *d = tmp_type;
|
||||||
|
Eina_Bool end_type = EINA_FALSE;
|
||||||
|
Eina_Bool is_own = EINA_FALSE;
|
||||||
|
char c;
|
||||||
|
Eina_Bool in_spaces = EINA_TRUE, in_stars = EINA_FALSE;
|
||||||
|
while (len > 0 && !end_type)
|
||||||
|
{
|
||||||
|
switch (c = *buf++)
|
||||||
|
{
|
||||||
|
/* @own */
|
||||||
|
case '@':
|
||||||
|
{
|
||||||
|
if (!strncmp(buf, "own", 3))
|
||||||
|
{
|
||||||
|
is_own = EINA_TRUE;
|
||||||
|
buf += 3; len -= 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* if '*', we have to add a space. We set in_spaces to true in
|
||||||
|
* case spaces are between stars, to be sure we remove them.
|
||||||
|
*/
|
||||||
|
case '*':
|
||||||
|
{
|
||||||
|
if (!in_stars && !in_spaces)
|
||||||
|
{
|
||||||
|
*d++ = ' ';
|
||||||
|
in_stars = EINA_TRUE;
|
||||||
|
in_spaces = EINA_TRUE;
|
||||||
|
}
|
||||||
|
*d++ = c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Only the first space is inserted. */
|
||||||
|
case ' ':
|
||||||
|
{
|
||||||
|
if (!in_spaces) *d++ = c;
|
||||||
|
in_spaces = EINA_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case '<':
|
||||||
|
{
|
||||||
|
if (depth < 0)
|
||||||
|
{
|
||||||
|
ERR("%s: Cannot reopen < after >", save_buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
depth++;
|
||||||
|
end_type = EINA_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case '>':
|
||||||
|
{
|
||||||
|
if (depth == 0)
|
||||||
|
{
|
||||||
|
ERR("%s: Too much >", save_buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (d == tmp_type)
|
||||||
|
{
|
||||||
|
ERR("%s: empty type inside <>", save_buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (depth > 0) depth *= -1;
|
||||||
|
depth++;
|
||||||
|
end_type = EINA_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
*d++ = c;
|
||||||
|
in_spaces = EINA_FALSE;
|
||||||
|
in_stars = EINA_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
if (d != tmp_type)
|
||||||
|
{
|
||||||
|
*d = '\0';
|
||||||
|
types = database_type_append(types, tmp_type, is_own);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (depth)
|
||||||
|
{
|
||||||
|
types = NULL;
|
||||||
|
ERR("%s: < and > are not well used.", save_buf);
|
||||||
|
}
|
||||||
|
free(tmp_type);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
eo_tokenizer_database_fill(const char *filename)
|
eo_tokenizer_database_fill(const char *filename)
|
||||||
{
|
{
|
||||||
|
@ -1378,7 +1468,8 @@ eo_tokenizer_database_fill(const char *filename)
|
||||||
database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
|
database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
|
||||||
EINA_LIST_FOREACH(meth->params, m, param)
|
EINA_LIST_FOREACH(meth->params, m, param)
|
||||||
{
|
{
|
||||||
database_method_parameter_add(foo_id, (Eolian_Parameter_Dir)param->way, param->type, param->name, param->comment);
|
Eolian_Type type = _types_extract(param->type, strlen(param->type));
|
||||||
|
database_method_parameter_add(foo_id, (Eolian_Parameter_Dir)param->way, type, param->name, param->comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1390,7 +1481,8 @@ eo_tokenizer_database_fill(const char *filename)
|
||||||
database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
|
database_function_data_set(foo_id, EOLIAN_LEGACY, meth->legacy);
|
||||||
EINA_LIST_FOREACH(meth->params, m, param)
|
EINA_LIST_FOREACH(meth->params, m, param)
|
||||||
{
|
{
|
||||||
database_method_parameter_add(foo_id, (Eolian_Parameter_Dir)param->way, param->type, param->name, param->comment);
|
Eolian_Type type = _types_extract(param->type, strlen(param->type));
|
||||||
|
database_method_parameter_add(foo_id, (Eolian_Parameter_Dir)param->way, type, param->name, param->comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1400,17 +1492,17 @@ eo_tokenizer_database_fill(const char *filename)
|
||||||
database_function_scope_set(foo_id, prop->scope);
|
database_function_scope_set(foo_id, prop->scope);
|
||||||
EINA_LIST_FOREACH(prop->keys, m, param)
|
EINA_LIST_FOREACH(prop->keys, m, param)
|
||||||
{
|
{
|
||||||
|
Eolian_Type type = _types_extract(param->type, strlen(param->type));
|
||||||
Eolian_Function_Parameter p = database_property_key_add(
|
Eolian_Function_Parameter p = database_property_key_add(
|
||||||
foo_id, param->type, param->name, param->comment);
|
foo_id, type, param->name, param->comment);
|
||||||
database_parameter_nonull_set(p, param->nonull);
|
database_parameter_nonull_set(p, param->nonull);
|
||||||
database_parameter_own_set(p, param->own);
|
|
||||||
}
|
}
|
||||||
EINA_LIST_FOREACH(prop->values, m, param)
|
EINA_LIST_FOREACH(prop->values, m, param)
|
||||||
{
|
{
|
||||||
|
Eolian_Type type = _types_extract(param->type, strlen(param->type));
|
||||||
Eolian_Function_Parameter p = database_property_value_add(
|
Eolian_Function_Parameter p = database_property_value_add(
|
||||||
foo_id, param->type, param->name, param->comment);
|
foo_id, type, param->name, param->comment);
|
||||||
database_parameter_nonull_set(p, param->nonull);
|
database_parameter_nonull_set(p, param->nonull);
|
||||||
database_parameter_own_set(p, param->own);
|
|
||||||
}
|
}
|
||||||
EINA_LIST_FOREACH(prop->accessors, m, accessor)
|
EINA_LIST_FOREACH(prop->accessors, m, accessor)
|
||||||
{
|
{
|
||||||
|
@ -1419,14 +1511,12 @@ eo_tokenizer_database_fill(const char *filename)
|
||||||
{
|
{
|
||||||
Eolian_Function_Type ftype =
|
Eolian_Function_Type ftype =
|
||||||
accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET;
|
accessor->type == SETTER?EOLIAN_PROP_SET:EOLIAN_PROP_GET;
|
||||||
database_function_return_type_set(foo_id,
|
Eolian_Type types = _types_extract(accessor->ret->type, strlen(accessor->ret->type));
|
||||||
ftype, accessor->ret->type);
|
database_function_return_type_set(foo_id, ftype, types);
|
||||||
database_function_return_comment_set(foo_id,
|
database_function_return_comment_set(foo_id,
|
||||||
ftype, accessor->ret->comment);
|
ftype, accessor->ret->comment);
|
||||||
database_function_return_flag_set_as_warn_unused(foo_id,
|
database_function_return_flag_set_as_warn_unused(foo_id,
|
||||||
ftype, accessor->ret->warn_unused);
|
ftype, accessor->ret->warn_unused);
|
||||||
database_function_return_flag_set_own(foo_id,
|
|
||||||
ftype, accessor->ret->own);
|
|
||||||
database_function_return_dflt_val_set(foo_id,
|
database_function_return_dflt_val_set(foo_id,
|
||||||
ftype, accessor->ret->dflt_ret_val);
|
ftype, accessor->ret->dflt_ret_val);
|
||||||
}
|
}
|
||||||
|
@ -1465,11 +1555,11 @@ eo_tokenizer_database_fill(const char *filename)
|
||||||
database_class_function_add(kls->name, foo_id);
|
database_class_function_add(kls->name, foo_id);
|
||||||
if (meth->ret)
|
if (meth->ret)
|
||||||
{
|
{
|
||||||
database_function_return_type_set(foo_id, EOLIAN_METHOD, meth->ret->type);
|
Eolian_Type types = _types_extract(meth->ret->type, strlen(meth->ret->type));
|
||||||
|
database_function_return_type_set(foo_id, EOLIAN_METHOD, types);
|
||||||
database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
|
database_function_return_comment_set(foo_id, EOLIAN_METHOD, meth->ret->comment);
|
||||||
database_function_return_flag_set_as_warn_unused(foo_id,
|
database_function_return_flag_set_as_warn_unused(foo_id,
|
||||||
EOLIAN_METHOD, meth->ret->warn_unused);
|
EOLIAN_METHOD, meth->ret->warn_unused);
|
||||||
database_function_return_flag_set_own(foo_id, EOLIAN_METHOD, meth->ret->own);
|
|
||||||
database_function_return_dflt_val_set(foo_id,
|
database_function_return_dflt_val_set(foo_id,
|
||||||
EOLIAN_METHOD, meth->ret->dflt_ret_val);
|
EOLIAN_METHOD, meth->ret->dflt_ret_val);
|
||||||
}
|
}
|
||||||
|
@ -1478,10 +1568,10 @@ eo_tokenizer_database_fill(const char *filename)
|
||||||
database_function_object_set_as_const(foo_id, meth->obj_const);
|
database_function_object_set_as_const(foo_id, meth->obj_const);
|
||||||
EINA_LIST_FOREACH(meth->params, m, param)
|
EINA_LIST_FOREACH(meth->params, m, param)
|
||||||
{
|
{
|
||||||
|
Eolian_Type type = _types_extract(param->type, strlen(param->type));
|
||||||
Eolian_Function_Parameter p = database_method_parameter_add(foo_id,
|
Eolian_Function_Parameter p = database_method_parameter_add(foo_id,
|
||||||
(Eolian_Parameter_Dir)param->way, param->type, param->name, param->comment);
|
(Eolian_Parameter_Dir)param->way, type, param->name, param->comment);
|
||||||
database_parameter_nonull_set(p, param->nonull);
|
database_parameter_nonull_set(p, param->nonull);
|
||||||
database_parameter_own_set(p, param->own);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,28 +45,34 @@ typedef struct
|
||||||
Eina_List *params; /* list of _Parameter_Desc */
|
Eina_List *params; /* list of _Parameter_Desc */
|
||||||
Eolian_Function_Type type;
|
Eolian_Function_Type type;
|
||||||
Eolian_Function_Scope scope;
|
Eolian_Function_Scope scope;
|
||||||
|
Eolian_Type get_ret_type;
|
||||||
|
Eolian_Type set_ret_type;
|
||||||
Eina_Hash *data;
|
Eina_Hash *data;
|
||||||
Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */
|
Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */
|
||||||
Eina_Bool get_virtual_pure :1;
|
Eina_Bool get_virtual_pure :1;
|
||||||
Eina_Bool set_virtual_pure :1;
|
Eina_Bool set_virtual_pure :1;
|
||||||
Eina_Bool get_return_warn_unused :1; /* also used for methods */
|
Eina_Bool get_return_warn_unused :1; /* also used for methods */
|
||||||
Eina_Bool set_return_warn_unused :1;
|
Eina_Bool set_return_warn_unused :1;
|
||||||
Eina_Bool get_return_own :1; /* also used for methods */
|
|
||||||
Eina_Bool set_return_own :1;
|
|
||||||
} _Function_Id;
|
} _Function_Id;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Eina_Stringshare *name;
|
Eina_Stringshare *name;
|
||||||
Eina_Stringshare *type;
|
Eolian_Type type;
|
||||||
Eina_Stringshare *description;
|
Eina_Stringshare *description;
|
||||||
Eolian_Parameter_Dir param_dir;
|
Eolian_Parameter_Dir param_dir;
|
||||||
Eina_Bool is_const_on_get :1; /* True if const in this the get property */
|
Eina_Bool is_const_on_get :1; /* True if const in this the get property */
|
||||||
Eina_Bool is_const_on_set :1; /* True if const in this the set property */
|
Eina_Bool is_const_on_set :1; /* True if const in this the set property */
|
||||||
Eina_Bool nonull :1; /* True if this argument cannot be NULL */
|
Eina_Bool nonull :1; /* True if this argument cannot be NULL */
|
||||||
Eina_Bool own :1; /* True if the ownership of this argument passes to the caller/callee */
|
|
||||||
} _Parameter_Desc;
|
} _Parameter_Desc;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
EINA_INLIST;
|
||||||
|
Eina_Stringshare *name;
|
||||||
|
Eina_Bool is_own :1; /* True if the ownership of this argument passes to the caller/callee */
|
||||||
|
} _Parameter_Type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Eina_Stringshare *eo_param;
|
Eina_Stringshare *eo_param;
|
||||||
|
@ -101,7 +107,13 @@ static void
|
||||||
_param_del(_Parameter_Desc *pdesc)
|
_param_del(_Parameter_Desc *pdesc)
|
||||||
{
|
{
|
||||||
eina_stringshare_del(pdesc->name);
|
eina_stringshare_del(pdesc->name);
|
||||||
eina_stringshare_del(pdesc->type);
|
|
||||||
|
while (pdesc->type)
|
||||||
|
{
|
||||||
|
_Parameter_Type *type = (_Parameter_Type *) pdesc->type;
|
||||||
|
eina_stringshare_del(type->name);
|
||||||
|
pdesc->type = eina_inlist_remove(pdesc->type, EINA_INLIST_GET(type));
|
||||||
|
}
|
||||||
eina_stringshare_del(pdesc->description);
|
eina_stringshare_del(pdesc->description);
|
||||||
free(pdesc);
|
free(pdesc);
|
||||||
}
|
}
|
||||||
|
@ -711,18 +723,18 @@ eolian_function_data_get(Eolian_Function function_id, const char *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
static _Parameter_Desc *
|
static _Parameter_Desc *
|
||||||
_parameter_new(const char *type, const char *name, const char *description)
|
_parameter_new(Eolian_Type type, const char *name, const char *description)
|
||||||
{
|
{
|
||||||
_Parameter_Desc *param = NULL;
|
_Parameter_Desc *param = NULL;
|
||||||
param = calloc(1, sizeof(*param));
|
param = calloc(1, sizeof(*param));
|
||||||
param->name = eina_stringshare_add(name);
|
param->name = eina_stringshare_add(name);
|
||||||
param->type = eina_stringshare_add(type);
|
param->type = type;
|
||||||
param->description = eina_stringshare_add(description);
|
param->description = eina_stringshare_add(description);
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
|
|
||||||
Eolian_Function_Parameter
|
Eolian_Function_Parameter
|
||||||
database_property_key_add(Eolian_Function foo_id, const char *type, const char *name, const char *description)
|
database_property_key_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description)
|
||||||
{
|
{
|
||||||
_Function_Id *fid = (_Function_Id *)foo_id;
|
_Function_Id *fid = (_Function_Id *)foo_id;
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
||||||
|
@ -732,7 +744,7 @@ database_property_key_add(Eolian_Function foo_id, const char *type, const char *
|
||||||
}
|
}
|
||||||
|
|
||||||
Eolian_Function_Parameter
|
Eolian_Function_Parameter
|
||||||
database_property_value_add(Eolian_Function foo_id, const char *type, const char *name, const char *description)
|
database_property_value_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description)
|
||||||
{
|
{
|
||||||
_Function_Id *fid = (_Function_Id *)foo_id;
|
_Function_Id *fid = (_Function_Id *)foo_id;
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
||||||
|
@ -742,7 +754,7 @@ database_property_value_add(Eolian_Function foo_id, const char *type, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
Eolian_Function_Parameter
|
Eolian_Function_Parameter
|
||||||
database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, const char *type, const char *name, const char *description)
|
database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type type, const char *name, const char *description)
|
||||||
{
|
{
|
||||||
_Function_Id *fid = (_Function_Id *)foo_id;
|
_Function_Id *fid = (_Function_Id *)foo_id;
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, NULL);
|
||||||
|
@ -766,15 +778,16 @@ eolian_function_parameter_get(const Eolian_Function foo_id, const char *param_na
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Stringshare*
|
EAPI Eina_Stringshare *
|
||||||
eolian_parameter_type_get(const Eolian_Function_Parameter param)
|
eolian_parameter_type_get(const Eolian_Function_Parameter param)
|
||||||
{
|
{
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL);
|
||||||
eina_stringshare_ref(((_Parameter_Desc*)param)->type);
|
_Parameter_Type *type = (_Parameter_Type *)((_Parameter_Desc *)param)->type;
|
||||||
return ((_Parameter_Desc*)param)->type;
|
eina_stringshare_ref(type->name);
|
||||||
|
return type->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI Eina_Stringshare*
|
EAPI Eina_Stringshare *
|
||||||
eolian_parameter_name_get(const Eolian_Function_Parameter param)
|
eolian_parameter_name_get(const Eolian_Function_Parameter param)
|
||||||
{
|
{
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL);
|
||||||
|
@ -806,12 +819,13 @@ eolian_parameters_list_get(Eolian_Function foo_id)
|
||||||
|
|
||||||
/* Get parameter information */
|
/* Get parameter information */
|
||||||
EAPI void
|
EAPI void
|
||||||
eolian_parameter_information_get(Eolian_Function_Parameter param_desc, Eolian_Parameter_Dir *param_dir, const char **type, const char **name, const char **description)
|
eolian_parameter_information_get(const Eolian_Function_Parameter param_desc, Eolian_Parameter_Dir *param_dir, const char **type, const char **name, const char **description)
|
||||||
{
|
{
|
||||||
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
||||||
EINA_SAFETY_ON_NULL_RETURN(param);
|
EINA_SAFETY_ON_NULL_RETURN(param);
|
||||||
|
_Parameter_Type *ptype = (_Parameter_Type *)((_Parameter_Desc *)param)->type;
|
||||||
if (param_dir) *param_dir = param->param_dir;
|
if (param_dir) *param_dir = param->param_dir;
|
||||||
if (type) *type = param->type;
|
if (type) *type = ptype->name;
|
||||||
if (name) *name = param->name;
|
if (name) *name = param->name;
|
||||||
if (description) *description = param->description;
|
if (description) *description = param->description;
|
||||||
}
|
}
|
||||||
|
@ -827,6 +841,43 @@ database_parameter_const_attribute_set(Eolian_Function_Parameter param_desc, Ein
|
||||||
param->is_const_on_set = is_const;
|
param->is_const_on_set = is_const;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Eolian_Type
|
||||||
|
eolian_parameter_types_list_get(const Eolian_Function_Parameter param_desc)
|
||||||
|
{
|
||||||
|
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL);
|
||||||
|
return param->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eolian_Type
|
||||||
|
eolian_type_information_get(Eolian_Type list, const char **name, Eina_Bool *own)
|
||||||
|
{
|
||||||
|
_Parameter_Type *type = (_Parameter_Type *)list;
|
||||||
|
if (name) *name = type->name;
|
||||||
|
if (own) *own = type->is_own;
|
||||||
|
return list->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
Eolian_Type
|
||||||
|
database_type_append(Eolian_Type types, const char *name, Eina_Bool own)
|
||||||
|
{
|
||||||
|
_Parameter_Type *type = calloc(1, sizeof(*type));
|
||||||
|
type->name = eina_stringshare_add(name);
|
||||||
|
type->is_own = own;
|
||||||
|
if (types)
|
||||||
|
return eina_inlist_append(types, EINA_INLIST_GET(type));
|
||||||
|
else
|
||||||
|
return EINA_INLIST_GET(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
database_parameter_type_set(Eolian_Function_Parameter param_desc, Eolian_Type types)
|
||||||
|
{
|
||||||
|
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(param);
|
||||||
|
param->type = types;
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Eina_Bool
|
EAPI Eina_Bool
|
||||||
eolian_parameter_const_attribute_get(Eolian_Function_Parameter param_desc, Eina_Bool is_get)
|
eolian_parameter_const_attribute_get(Eolian_Function_Parameter param_desc, Eina_Bool is_get)
|
||||||
{
|
{
|
||||||
|
@ -854,47 +905,36 @@ eolian_parameter_is_nonull(Eolian_Function_Parameter param_desc)
|
||||||
return param->nonull;
|
return param->nonull;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, Eolian_Type ret_type)
|
||||||
database_parameter_own_set(Eolian_Function_Parameter param_desc, Eina_Bool own)
|
|
||||||
{
|
{
|
||||||
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
_Function_Id *fid = (_Function_Id *)foo_id;
|
||||||
EINA_SAFETY_ON_NULL_RETURN(param);
|
|
||||||
param->own = own;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI Eina_Bool
|
|
||||||
eolian_parameter_is_own(Eolian_Function_Parameter param_desc)
|
|
||||||
{
|
|
||||||
_Parameter_Desc *param = (_Parameter_Desc *)param_desc;
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(param, EINA_FALSE);
|
|
||||||
return param->own;
|
|
||||||
}
|
|
||||||
|
|
||||||
void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_type)
|
|
||||||
{
|
|
||||||
const char *key = NULL;
|
|
||||||
switch (ftype)
|
switch (ftype)
|
||||||
{
|
{
|
||||||
case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_TYPE; break;
|
case EOLIAN_PROP_SET: fid->set_ret_type = ret_type; break;
|
||||||
case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_TYPE; break;
|
case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROP_GET: fid->get_ret_type = ret_type; break;
|
||||||
case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_TYPE; break;
|
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
database_function_data_set(foo_id, key, ret_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI const char *
|
EAPI const char *
|
||||||
eolian_function_return_type_get(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
eolian_function_return_type_get(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
||||||
{
|
{
|
||||||
const char *key = NULL;
|
Eolian_Type types = eolian_function_return_types_list_get(foo_id, ftype);
|
||||||
|
_Parameter_Type *type = (_Parameter_Type *)types;
|
||||||
|
if (type) return type->name;
|
||||||
|
else return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eolian_Type
|
||||||
|
eolian_function_return_types_list_get(Eolian_Function foo_id, Eolian_Function_Type ftype)
|
||||||
|
{
|
||||||
|
_Function_Id *fid = (_Function_Id *)foo_id;
|
||||||
switch (ftype)
|
switch (ftype)
|
||||||
{
|
{
|
||||||
case EOLIAN_PROP_SET: key = EOLIAN_PROP_SET_RETURN_TYPE; break;
|
case EOLIAN_PROP_SET: return fid->set_ret_type;
|
||||||
case EOLIAN_PROP_GET: key = EOLIAN_PROP_GET_RETURN_TYPE; break;
|
case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROP_GET: return fid->get_ret_type;
|
||||||
case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: key = EOLIAN_METHOD_RETURN_TYPE; break;
|
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
return eolian_function_data_get(foo_id, key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void database_function_return_dflt_val_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_dflt_value)
|
void database_function_return_dflt_val_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_dflt_value)
|
||||||
|
@ -978,33 +1018,6 @@ eolian_function_return_is_warn_unused(Eolian_Function foo_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void database_function_return_flag_set_own(Eolian_Function foo_id,
|
|
||||||
Eolian_Function_Type ftype, Eina_Bool own)
|
|
||||||
{
|
|
||||||
_Function_Id *fid = (_Function_Id *)foo_id;
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN(fid);
|
|
||||||
switch (ftype)
|
|
||||||
{
|
|
||||||
case EOLIAN_METHOD: case EOLIAN_PROP_GET: fid->get_return_own = own; break;
|
|
||||||
case EOLIAN_PROP_SET: fid->set_return_own = own; break;
|
|
||||||
default: return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI Eina_Bool
|
|
||||||
eolian_function_return_own_get(Eolian_Function foo_id,
|
|
||||||
Eolian_Function_Type ftype)
|
|
||||||
{
|
|
||||||
_Function_Id *fid = (_Function_Id *)foo_id;
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
|
|
||||||
switch (ftype)
|
|
||||||
{
|
|
||||||
case EOLIAN_METHOD: case EOLIAN_PROP_GET: return fid->get_return_own;
|
|
||||||
case EOLIAN_PROP_SET: return fid->set_return_own;
|
|
||||||
default: return EINA_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
database_function_object_set_as_const(Eolian_Function foo_id, Eina_Bool is_const)
|
database_function_object_set_as_const(Eolian_Function foo_id, Eina_Bool is_const)
|
||||||
{
|
{
|
||||||
|
@ -1249,7 +1262,22 @@ static Eina_Bool _function_print(const _Function_Id *fid, int nb_spaces)
|
||||||
param_dir = "INOUT";
|
param_dir = "INOUT";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("%*s%s <%s> <%s> <%s>\n", nb_spaces + 5, "", param_dir, param->name, param->type, (param->description?param->description:""));
|
Eina_Strbuf *type_buf = eina_strbuf_new();
|
||||||
|
Eolian_Type type = param->type;
|
||||||
|
while (type)
|
||||||
|
{
|
||||||
|
const char *type_str = NULL;
|
||||||
|
Eina_Bool is_own = EINA_FALSE;
|
||||||
|
type = eolian_type_information_get(type, &type_str, &is_own);
|
||||||
|
eina_strbuf_append_printf(type_buf, "%s%s%s",
|
||||||
|
eina_strbuf_length_get(type_buf)?"/":"",
|
||||||
|
type_str, is_own?"@own":"");
|
||||||
|
}
|
||||||
|
printf("%*s%s <%s> <%s> <%s>\n", nb_spaces + 5, "",
|
||||||
|
param_dir, param->name,
|
||||||
|
eina_strbuf_string_get(type_buf),
|
||||||
|
param->description?param->description:"");
|
||||||
|
eina_strbuf_free(type_buf);
|
||||||
}
|
}
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,21 +78,21 @@ void database_function_data_set(Eolian_Function function_id, const char *key, co
|
||||||
#define database_function_description_set(foo_id, key, desc) database_function_data_set((foo_id), (key), (desc))
|
#define database_function_description_set(foo_id, key, desc) database_function_data_set((foo_id), (key), (desc))
|
||||||
|
|
||||||
/* Add a key to a property */
|
/* Add a key to a property */
|
||||||
Eolian_Function_Parameter database_property_key_add(Eolian_Function foo_id, const char *type, const char *name, const char *description);
|
Eolian_Function_Parameter database_property_key_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description);
|
||||||
|
|
||||||
/* Add a value to a property */
|
/* Add a value to a property */
|
||||||
Eolian_Function_Parameter database_property_value_add(Eolian_Function foo_id, const char *type, const char *name, const char *description);
|
Eolian_Function_Parameter database_property_value_add(Eolian_Function foo_id, Eolian_Type type, const char *name, const char *description);
|
||||||
|
|
||||||
/* Add a parameter to a method */
|
/* Add a parameter to a method */
|
||||||
Eolian_Function_Parameter database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, const char *type, const char *name, const char *description);
|
Eolian_Function_Parameter database_method_parameter_add(Eolian_Function foo_id, Eolian_Parameter_Dir param_dir, Eolian_Type type, const char *name, const char *description);
|
||||||
|
|
||||||
|
Eolian_Type database_type_append(Eolian_Type types, const char *name, Eina_Bool own);
|
||||||
|
|
||||||
void database_parameter_const_attribute_set(Eolian_Function_Parameter param_desc, Eina_Bool is_get, Eina_Bool is_const);
|
void database_parameter_const_attribute_set(Eolian_Function_Parameter param_desc, Eina_Bool is_get, Eina_Bool is_const);
|
||||||
|
|
||||||
void database_parameter_nonull_set(Eolian_Function_Parameter, Eina_Bool nonull);
|
void database_parameter_nonull_set(Eolian_Function_Parameter, Eina_Bool nonull);
|
||||||
|
|
||||||
void database_parameter_own_set(Eolian_Function_Parameter, Eina_Bool own);
|
void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, Eolian_Type ret_type);
|
||||||
|
|
||||||
void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_type);
|
|
||||||
|
|
||||||
void database_function_return_comment_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_comment);
|
void database_function_return_comment_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_comment);
|
||||||
|
|
||||||
|
@ -101,9 +101,6 @@ void database_function_return_dflt_val_set(Eolian_Function foo_id, Eolian_Functi
|
||||||
void database_function_return_flag_set_as_warn_unused(Eolian_Function foo_id,
|
void database_function_return_flag_set_as_warn_unused(Eolian_Function foo_id,
|
||||||
Eolian_Function_Type ftype, Eina_Bool warn_unused);
|
Eolian_Function_Type ftype, Eina_Bool warn_unused);
|
||||||
|
|
||||||
void database_function_return_flag_set_own(Eolian_Function foo_id,
|
|
||||||
Eolian_Function_Type ftype, Eina_Bool own);
|
|
||||||
|
|
||||||
void database_function_object_set_as_const(Eolian_Function foo_id, Eina_Bool is_const);
|
void database_function_object_set_as_const(Eolian_Function foo_id, Eina_Bool is_const);
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
|
|
Loading…
Reference in New Issue