forked from enlightenment/efl
eolian: support for default param values where applicable + API
This commit is contained in:
parent
a941d9c2fd
commit
b13bafabba
|
@ -778,6 +778,16 @@ EAPI Eolian_Parameter_Dir eolian_parameter_direction_get(const Eolian_Function_P
|
|||
*/
|
||||
EAPI const Eolian_Type *eolian_parameter_type_get(const Eolian_Function_Parameter *param);
|
||||
|
||||
/*
|
||||
* @brief Get the default value of a parameter
|
||||
*
|
||||
* @param[in] param_desc parameter handle
|
||||
* @return the value or NULL
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI const Eolian_Expression *eolian_parameter_default_value_get(const Eolian_Function_Parameter *param);
|
||||
|
||||
/*
|
||||
* @brief Get name of a parameter
|
||||
*
|
||||
|
|
|
@ -4,6 +4,7 @@ static Eina_Bool
|
|||
_db_fill_param(Eina_List **plist, Eo_Param_Def *param)
|
||||
{
|
||||
Eolian_Function_Parameter *p = database_parameter_add(param->type,
|
||||
param->value,
|
||||
param->name,
|
||||
param->comment);
|
||||
p->param_dir = param->way;
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
#include "eolian_database.h"
|
||||
|
||||
Eolian_Function_Parameter *
|
||||
database_parameter_add(Eolian_Type *type, const char *name, const char *description)
|
||||
database_parameter_add(Eolian_Type *type, Eolian_Expression *value,
|
||||
const char *name, const char *description)
|
||||
{
|
||||
Eolian_Function_Parameter *param = NULL;
|
||||
param = calloc(1, sizeof(*param));
|
||||
param->name = eina_stringshare_add(name);
|
||||
param->type = type;
|
||||
param->value = value;
|
||||
param->description = eina_stringshare_add(description);
|
||||
return param;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,13 @@ eolian_parameter_type_get(const Eolian_Function_Parameter *param)
|
|||
return param->type;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Expression *
|
||||
eolian_parameter_default_value_get(const Eolian_Function_Parameter *param)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(param, NULL);
|
||||
return param->value;
|
||||
}
|
||||
|
||||
EAPI Eina_Stringshare *
|
||||
eolian_parameter_name_get(const Eolian_Function_Parameter *param)
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ typedef struct _Eo_Param_Def
|
|||
Eolian_Object base;
|
||||
Eolian_Parameter_Dir way;
|
||||
Eolian_Type *type;
|
||||
Eolian_Expression *value;
|
||||
Eina_Stringshare *name;
|
||||
Eina_Stringshare *comment;
|
||||
Eina_Bool nonull:1;
|
||||
|
|
|
@ -1124,7 +1124,7 @@ parse_return(Eo_Lexer *ls, Eina_Bool allow_void)
|
|||
}
|
||||
|
||||
static void
|
||||
parse_param(Eo_Lexer *ls, Eina_Bool allow_inout)
|
||||
parse_param(Eo_Lexer *ls, Eina_Bool allow_inout, Eina_Bool is_vals)
|
||||
{
|
||||
Eo_Param_Def *par = calloc(1, sizeof(Eo_Param_Def));
|
||||
par->base.file = eina_stringshare_ref(ls->filename);
|
||||
|
@ -1159,6 +1159,16 @@ parse_param(Eo_Lexer *ls, Eina_Bool allow_inout)
|
|||
check(ls, TOK_VALUE);
|
||||
par->name = eina_stringshare_ref(ls->t.value.s);
|
||||
eo_lexer_get(ls);
|
||||
if ((is_vals || (par->way == EOLIAN_OUT_PARAM)) && (ls->t.token == '('))
|
||||
{
|
||||
int line = ls->line_number, col = ls->column;
|
||||
ls->expr_mode = EINA_TRUE;
|
||||
eo_lexer_get(ls);
|
||||
par->value = parse_expr(ls);
|
||||
ls->expr_mode = EINA_FALSE;
|
||||
pop_expr(ls);
|
||||
check_match(ls, ')', '(', line, col);
|
||||
}
|
||||
if (ls->t.kw == KW_at_nonull)
|
||||
{
|
||||
par->nonull = EINA_TRUE;
|
||||
|
@ -1278,11 +1288,11 @@ end:
|
|||
}
|
||||
|
||||
static void
|
||||
parse_params(Eo_Lexer *ls, Eina_Bool allow_inout)
|
||||
parse_params(Eo_Lexer *ls, Eina_Bool allow_inout, Eina_Bool is_vals)
|
||||
{
|
||||
PARSE_SECTION
|
||||
{
|
||||
parse_param(ls, allow_inout);
|
||||
parse_param(ls, allow_inout, is_vals);
|
||||
ls->tmp.params = eina_list_append(ls->tmp.params, ls->tmp.param);
|
||||
ls->tmp.param = NULL;
|
||||
}
|
||||
|
@ -1347,13 +1357,13 @@ body:
|
|||
break;
|
||||
case KW_keys:
|
||||
CASE_LOCK(ls, keys, "keys definition")
|
||||
parse_params(ls, EINA_FALSE);
|
||||
parse_params(ls, EINA_FALSE, EINA_FALSE);
|
||||
prop->keys = ls->tmp.params;
|
||||
ls->tmp.params = NULL;
|
||||
break;
|
||||
case KW_values:
|
||||
CASE_LOCK(ls, values, "values definition")
|
||||
parse_params(ls, EINA_FALSE);
|
||||
parse_params(ls, EINA_FALSE, EINA_TRUE);
|
||||
prop->values = ls->tmp.params;
|
||||
ls->tmp.params = NULL;
|
||||
break;
|
||||
|
@ -1454,7 +1464,7 @@ body:
|
|||
break;
|
||||
case KW_params:
|
||||
CASE_LOCK(ls, params, "params definition")
|
||||
parse_params(ls, EINA_TRUE);
|
||||
parse_params(ls, EINA_TRUE, EINA_FALSE);
|
||||
meth->params = ls->tmp.params;
|
||||
ls->tmp.params = NULL;
|
||||
break;
|
||||
|
|
|
@ -118,6 +118,7 @@ struct _Eolian_Function_Parameter
|
|||
Eolian_Object base;
|
||||
Eina_Stringshare *name;
|
||||
Eolian_Type *type;
|
||||
Eolian_Expression *value;
|
||||
Eina_Stringshare *description;
|
||||
Eolian_Parameter_Dir param_dir;
|
||||
Eina_Bool is_const_on_get :1; /* True if const in this the get property */
|
||||
|
@ -313,7 +314,7 @@ void database_function_del(Eolian_Function *fid);
|
|||
|
||||
/* func parameters */
|
||||
|
||||
Eolian_Function_Parameter *database_parameter_add(Eolian_Type *type, const char *name, const char *description);
|
||||
Eolian_Function_Parameter *database_parameter_add(Eolian_Type *type, Eolian_Expression *value, const char *name, const char *description);
|
||||
void database_parameter_del(Eolian_Function_Parameter *pdesc);
|
||||
|
||||
/* implements */
|
||||
|
|
Loading…
Reference in New Issue