forked from enlightenment/efl
Eolian: support warn_unused variables.
This commit is contained in:
parent
2db3cdb5e3
commit
10d7bffc4a
|
@ -15,7 +15,7 @@ tmpl_eapi_funcdef[] = "\n\
|
|||
*\n\
|
||||
@#list_desc_param\
|
||||
*/\n\
|
||||
EAPI @#type_return @#class_@#func(@#is_constEvas_Object *obj@#params);\n\
|
||||
EAPI @#type_return @#class_@#func(@#is_constEvas_Object *obj@#params);@#flags\n\
|
||||
";
|
||||
|
||||
/*@#CLASS_CHECK(obj) @#check_ret;\n\*/
|
||||
|
@ -127,6 +127,7 @@ _eapi_decl_func_generate(const char *classname, Eolian_Function funcid, Eolian_F
|
|||
eina_strbuf_replace_all(fbody, "@#list_desc_param", eina_strbuf_string_get(descparam));
|
||||
eina_strbuf_replace_all(fbody, "@#type_return", (rettype) ? rettype : "void");
|
||||
eina_strbuf_replace_all(fbody, "@#is_const", (ftype == GET || eolian_function_object_is_const(funcid)) ? "const " : "");
|
||||
eina_strbuf_replace_all(fbody, "@#flags", (eolian_function_return_is_warn_unused(funcid, ftype)) ? " EINA_WARN_UNUSED_RESULT" : "");
|
||||
eina_strbuf_append(buf, eina_strbuf_string_get(fbody));
|
||||
|
||||
eina_strbuf_free(fbody);
|
||||
|
@ -288,7 +289,7 @@ legacy_header_generate(const char *classname, int eo_version, Eina_Strbuf *buf)
|
|||
|
||||
if (!prop_read && !prop_write)
|
||||
{
|
||||
_eapi_decl_func_generate(classname, (Eolian_Function)data, UNRESOLVED, buf);
|
||||
_eapi_decl_func_generate(classname, (Eolian_Function)data, METHOD_FUNC, buf);
|
||||
}
|
||||
if (prop_read)
|
||||
{
|
||||
|
|
|
@ -50,7 +50,9 @@ typedef struct _Event_Desc* Eolian_Event;
|
|||
#define EOLIAN_METHOD_RETURN_TYPE "method_return_type"
|
||||
#define EOLIAN_PROP_GET_RETURN_TYPE "property_get_return_type"
|
||||
#define EOLIAN_PROP_SET_RETURN_TYPE "property_set_return_type"
|
||||
#define EOLIAN_RETURN_COMMENT "return_comment"
|
||||
#define EOLIAN_RETURN_COMMENT "method_return_comment"
|
||||
#define EOLIAN_PROP_GET_RETURN_COMMENT "property_get_return_comment"
|
||||
#define EOLIAN_PROP_SET_RETURN_COMMENT "property_set_return_comment"
|
||||
#define EOLIAN_LEGACY "legacy"
|
||||
#define EOLIAN_LEGACY_GET "legacy_get"
|
||||
#define EOLIAN_LEGACY_SET "legacy_set"
|
||||
|
@ -395,6 +397,20 @@ EAPI Eina_Bool eolian_parameter_get_const_attribute_get(Eolian_Function_Paramete
|
|||
*/
|
||||
EAPI const char *eolian_function_return_type_get(Eolian_Function function_id, Eolian_Function_Type ftype);
|
||||
|
||||
/*
|
||||
* @brief Indicates if a function return is warn-unused.
|
||||
*
|
||||
* @param[in] function_id id of the function
|
||||
* @param[in] ftype type of the function
|
||||
* @return EINA_TRUE is warn-unused, EINA_FALSE otherwise.
|
||||
*
|
||||
* 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_is_warn_unused(Eolian_Function foo_id, Eolian_Function_Type ftype);
|
||||
|
||||
/*
|
||||
* @brief Indicates if a function object is const.
|
||||
*
|
||||
|
@ -451,8 +467,26 @@ EAPI const Eina_List *eolian_class_events_list_get(const char *class_name);
|
|||
*/
|
||||
EAPI Eina_Bool eolian_class_event_information_get(Eolian_Event event, const char **event_name, const char **event_desc);
|
||||
|
||||
/*
|
||||
* @brief Indicates if the class constructor has to invoke
|
||||
* a non-generated class constructor function.
|
||||
*
|
||||
* @param[in] class_name name of the class.
|
||||
* @return EINA_TRUE if the invocation is needed, EINA_FALSE otherwise.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Bool eolian_class_ctor_enable_get(const char *class_name);
|
||||
|
||||
/*
|
||||
* @brief Indicates if the class destructor has to invoke
|
||||
* a non-generated class destructor function.
|
||||
*
|
||||
* @param[in] class_name name of the class.
|
||||
* @return EINA_TRUE if the invocation is needed, EINA_FALSE otherwise.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Bool eolian_class_dtor_enable_get(const char *class_name);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,7 @@ typedef struct _eo_ret_def
|
|||
{
|
||||
const char *type;
|
||||
const char *comment;
|
||||
Eina_Bool warn_unused:1;
|
||||
} Eo_Ret_Def;
|
||||
|
||||
/* PARAM */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -370,6 +370,11 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
|
|||
INF(" %s", toknz->tmp.accessor->ret.comment);
|
||||
}
|
||||
|
||||
action end_accessor_rettype_unused_flag {
|
||||
toknz->tmp.accessor->ret.warn_unused = EINA_TRUE;
|
||||
INF(" WARN_UNUSED");
|
||||
}
|
||||
|
||||
action end_accessor_legacy {
|
||||
toknz->tmp.accessor->legacy = _eo_tokenizer_token_get(toknz, fpc);
|
||||
}
|
||||
|
@ -393,8 +398,9 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
|
|||
toknz->tmp.accessor_param = NULL;
|
||||
}
|
||||
|
||||
rettype_flag = "@warn_unused" %end_accessor_rettype_unused_flag;
|
||||
rettype_comment = ws* eo_comment %end_accessor_rettype_comment;
|
||||
rettype = 'return' ws+ alpha+ >save_fpc (alnum_u | '*' | ws )+ %end_accessor_rettype end_statement rettype_comment?;
|
||||
rettype = 'return' ws+ alpha+ >save_fpc (alnum_u | '*' | ws )+ %end_accessor_rettype rettype_flag? end_statement rettype_comment?;
|
||||
|
||||
legacy = 'legacy' ws+ ident %end_accessor_legacy end_statement;
|
||||
|
||||
|
@ -571,6 +577,11 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
|
|||
INF(" %s", toknz->tmp.meth->ret.comment);
|
||||
}
|
||||
|
||||
action end_method_rettype_unused_flag{
|
||||
toknz->tmp.meth->ret.warn_unused = EINA_TRUE;
|
||||
INF(" WARN_UNUSED");
|
||||
}
|
||||
|
||||
action end_method_legacy {
|
||||
toknz->tmp.meth->legacy = _eo_tokenizer_token_get(toknz, fpc);
|
||||
}
|
||||
|
@ -605,10 +616,14 @@ _eo_tokenizer_implement_get(Eo_Tokenizer *toknz, char *p)
|
|||
fgoto tokenize_methods;
|
||||
}
|
||||
|
||||
|
||||
meth_params = 'params' ignore* begin_def;
|
||||
meth_legacy = 'legacy' ws+ ident %end_method_legacy end_statement;
|
||||
|
||||
meth_rettype_flag = "@warn_unused" %end_method_rettype_unused_flag;
|
||||
meth_rettype_comment = ws* eo_comment %end_method_rettype_comment;
|
||||
meth_rettype = 'return' ws+ alpha+ >save_fpc (alnum_u | '*' | ws )+ %end_method_rettype end_statement meth_rettype_comment?;
|
||||
meth_rettype = 'return' ws+ alpha+ >save_fpc (alnum_u | '*' | ws )+ %end_method_rettype meth_rettype_flag? end_statement meth_rettype_comment?;
|
||||
|
||||
meth_obj_const = 'const' %end_method_obj_const end_statement;
|
||||
|
||||
tokenize_method := |*
|
||||
|
@ -885,6 +900,7 @@ eo_tokenizer_walk(Eo_Tokenizer *toknz, const char *source)
|
|||
toknz->source = eina_stringshare_add(source);
|
||||
|
||||
FILE *stream;
|
||||
Eina_Bool ret = EINA_TRUE;
|
||||
|
||||
int done = 0;
|
||||
int have = 0;
|
||||
|
@ -927,7 +943,8 @@ eo_tokenizer_walk(Eo_Tokenizer *toknz, const char *source)
|
|||
|
||||
if ( toknz->cs == %%{ write error; }%% )
|
||||
{
|
||||
ERR("wrong termination");
|
||||
ERR("%s: wrong termination", source);
|
||||
ret = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -957,7 +974,7 @@ eo_tokenizer_walk(Eo_Tokenizer *toknz, const char *source)
|
|||
|
||||
fclose(stream);
|
||||
|
||||
return EINA_TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Eo_Tokenizer*
|
||||
|
@ -1107,7 +1124,7 @@ eo_tokenizer_database_fill(const char *filename)
|
|||
ERR("error accessing file %s : %s", filename, strerror(errno));
|
||||
return EINA_FALSE;
|
||||
}
|
||||
eo_tokenizer_walk(toknz, filename);
|
||||
if (!eo_tokenizer_walk(toknz, filename)) return EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(toknz->classes, k, kls)
|
||||
{
|
||||
|
@ -1158,9 +1175,15 @@ eo_tokenizer_database_fill(const char *filename)
|
|||
{
|
||||
database_function_type_set(foo_id, (accessor->type == SETTER?SET:GET));
|
||||
if (accessor->ret.type)
|
||||
database_function_data_set(foo_id,
|
||||
(accessor->type == SETTER?EOLIAN_PROP_SET_RETURN_TYPE:EOLIAN_PROP_GET_RETURN_TYPE),
|
||||
accessor->ret.type);
|
||||
{
|
||||
database_function_return_type_set(foo_id,
|
||||
accessor->type == SETTER?SET:GET, accessor->ret.type);
|
||||
database_function_data_set(foo_id,
|
||||
(accessor->type == SETTER?EOLIAN_PROP_SET_RETURN_COMMENT:EOLIAN_PROP_GET_RETURN_COMMENT),
|
||||
accessor->ret.comment);
|
||||
database_function_return_flag_set_as_warn_unused(foo_id,
|
||||
accessor->type == SETTER?SET:GET, accessor->ret.warn_unused);
|
||||
}
|
||||
database_function_description_set(foo_id,
|
||||
(accessor->type == SETTER?EOLIAN_COMMENT_SET:EOLIAN_COMMENT_GET),
|
||||
accessor->comment);
|
||||
|
@ -1193,6 +1216,7 @@ eo_tokenizer_database_fill(const char *filename)
|
|||
database_class_function_add(kls->name, foo_id);
|
||||
database_function_data_set(foo_id, EOLIAN_METHOD_RETURN_TYPE, meth->ret.type);
|
||||
database_function_description_set(foo_id, EOLIAN_RETURN_COMMENT, meth->ret.comment);
|
||||
database_function_return_flag_set_as_warn_unused(foo_id, METHOD_FUNC, meth->ret.warn_unused);
|
||||
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);
|
||||
|
|
|
@ -33,6 +33,8 @@ typedef struct
|
|||
Eina_Hash *data;
|
||||
Eina_Bool obj_is_const :1; /* True if the object has to be const. Useful for a few methods. */
|
||||
Eina_Bool virtual_pure :1;
|
||||
Eina_Bool get_return_warn_unused :1; /* also used for methods */
|
||||
Eina_Bool set_return_warn_unused :1;
|
||||
} _Function_Id;
|
||||
|
||||
typedef struct
|
||||
|
@ -752,7 +754,7 @@ void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_T
|
|||
const char *key = NULL;
|
||||
switch (ftype)
|
||||
{
|
||||
case SET: key= EOLIAN_PROP_SET_RETURN_TYPE; break;
|
||||
case SET: key = EOLIAN_PROP_SET_RETURN_TYPE; break;
|
||||
case GET: key = EOLIAN_PROP_GET_RETURN_TYPE; break;
|
||||
case METHOD_FUNC: key = EOLIAN_METHOD_RETURN_TYPE; break;
|
||||
default: return;
|
||||
|
@ -765,7 +767,7 @@ EAPI const char *eolian_function_return_type_get(Eolian_Function foo_id, Eolian_
|
|||
const char *key = NULL;
|
||||
switch (ftype)
|
||||
{
|
||||
case SET: key= EOLIAN_PROP_SET_RETURN_TYPE; break;
|
||||
case SET: key = EOLIAN_PROP_SET_RETURN_TYPE; break;
|
||||
case GET: key = EOLIAN_PROP_GET_RETURN_TYPE; break;
|
||||
case UNRESOLVED: case METHOD_FUNC: key = EOLIAN_METHOD_RETURN_TYPE; break;
|
||||
default: return NULL;
|
||||
|
@ -775,6 +777,32 @@ EAPI const char *eolian_function_return_type_get(Eolian_Function foo_id, Eolian_
|
|||
return ret;
|
||||
}
|
||||
|
||||
void database_function_return_flag_set_as_warn_unused(Eolian_Function foo_id,
|
||||
Eolian_Function_Type ftype, Eina_Bool warn_unused)
|
||||
{
|
||||
_Function_Id *fid = (_Function_Id *)foo_id;
|
||||
EINA_SAFETY_ON_NULL_RETURN(fid);
|
||||
switch (ftype)
|
||||
{
|
||||
case METHOD_FUNC: case GET: fid->get_return_warn_unused = warn_unused; break;
|
||||
case SET: fid->set_return_warn_unused = warn_unused; break;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Eina_Bool eolian_function_return_is_warn_unused(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 METHOD_FUNC: case GET: return fid->get_return_warn_unused;
|
||||
case SET: return fid->set_return_warn_unused;
|
||||
default: return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
database_function_object_set_as_const(Eolian_Function foo_id, Eina_Bool is_const)
|
||||
{
|
||||
|
|
|
@ -82,6 +82,9 @@ void database_parameter_get_const_attribute_set(Eolian_Function_Parameter param_
|
|||
|
||||
void database_function_return_type_set(Eolian_Function foo_id, Eolian_Function_Type ftype, const char *ret_type);
|
||||
|
||||
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);
|
||||
|
||||
Eina_Bool
|
||||
|
|
Loading…
Reference in New Issue