eolian: APIs to check auto/empty on a function

This commit is contained in:
Daniel Kolesa 2014-09-03 14:25:50 +01:00
parent 3e8ddb1bfb
commit 5827486c3d
4 changed files with 96 additions and 14 deletions

View File

@ -734,6 +734,28 @@ EAPI Eina_Stringshare *eolian_function_description_get(const Eolian_Function *fu
*/
EAPI Eina_Bool eolian_function_is_virtual_pure(const Eolian_Function *function_id, Eolian_Function_Type f_type);
/*
* @brief Indicates if a function is auto.
*
* @param[in] function_id Id of the function
* @param[in] f_type The function type, for property get/set distinction.
* @return EINA_TRUE if auto, EINA_FALSE othrewise.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_function_is_auto(const Eolian_Function *function_id, Eolian_Function_Type f_type);
/*
* @brief Indicates if a function is empty.
*
* @param[in] function_id Id of the function
* @param[in] f_type The function type, for property get/set distinction.
* @return EINA_TRUE if empty, EINA_FALSE othrewise.
*
* @ingroup Eolian
*/
EAPI Eina_Bool eolian_function_is_empty(const Eolian_Function *function_id, Eolian_Function_Type f_type);
/*
* @brief Indicates if a function is legacy only.
*

View File

@ -224,31 +224,34 @@ _db_fill_methods(Eolian_Class *cl, Eo_Class_Def *kls)
return EINA_TRUE;
}
static int
_func_error(Eolian_Class *cl, Eolian_Implement *impl)
{
ERR("Error - %s%s not known in class %s", impl->full_name,
eolian_class_name_get(cl), (impl->is_prop_get ? ".get"
: (impl->is_prop_set ? ".set" : "")));
return -1;
}
static int
_db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
{
const char *impl_name = impl->full_name;
Eolian_Function_Type ftype = EOLIAN_UNRESOLVED;
if (impl->is_prop_get)
ftype = EOLIAN_PROP_GET;
else if (impl->is_prop_set)
ftype = EOLIAN_PROP_SET;
if (impl->is_virtual)
{
Eolian_Function_Type ftype = EOLIAN_UNRESOLVED;
if (impl->is_prop_get)
ftype = EOLIAN_PROP_GET;
else if (impl->is_prop_set)
ftype = EOLIAN_PROP_SET;
Eolian_Function *foo_id = (Eolian_Function*)
eolian_class_function_get_by_name(cl,
impl_name,
ftype);
if (!foo_id)
{
ERR("Error - %s%s not known in class %s", impl_name,
eolian_class_name_get(cl), (impl->is_prop_get ? ".get"
: (impl->is_prop_set ? ".set" : "")));
return -1;
}
if (!foo_id) return _func_error(cl, impl);
if (impl->is_prop_set)
foo_id->set_virtual_pure = EINA_TRUE;
@ -257,6 +260,34 @@ _db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
return 1;
}
else if (impl->is_auto)
{
const char *inm = impl_name;
if (inm[0] == '.') ++inm;
if (strchr(inm, '.')) goto pasttags;
Eolian_Function *foo_id = (Eolian_Function*)
eolian_class_function_get_by_name(cl, inm,
ftype);
if (!foo_id) return _func_error(cl, impl);
if (impl->is_auto)
foo_id->set_auto = EINA_TRUE;
else
foo_id->get_auto = EINA_TRUE;
}
else if (impl->is_empty)
{
const char *inm = impl_name;
if (inm[0] == '.') ++inm;
if (strchr(inm, '.')) goto pasttags;
Eolian_Function *foo_id = (Eolian_Function*)
eolian_class_function_get_by_name(cl, inm,
ftype);
if (!foo_id) return _func_error(cl, impl);
if (impl->is_auto)
foo_id->set_empty = EINA_TRUE;
else
foo_id->get_empty = EINA_TRUE;
}
else if (impl->is_class_ctor)
{
cl->class_ctor_enable = EINA_TRUE;
@ -268,6 +299,7 @@ _db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
return 1;
}
pasttags:
if (impl_name[0] == '.')
{
impl->full_name = eina_stringshare_printf("%s%s", cl->full_name,

View File

@ -92,6 +92,30 @@ eolian_function_is_virtual_pure(const Eolian_Function *fid, Eolian_Function_Type
}
}
EAPI Eina_Bool
eolian_function_is_auto(const Eolian_Function *fid, Eolian_Function_Type ftype)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
switch (ftype)
{
case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_auto; break;
case EOLIAN_PROP_SET: return fid->set_auto; break;
default: return EINA_FALSE;
}
}
EAPI Eina_Bool
eolian_function_is_empty(const Eolian_Function *fid, Eolian_Function_Type ftype)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(fid, EINA_FALSE);
switch (ftype)
{
case EOLIAN_UNRESOLVED: case EOLIAN_METHOD: case EOLIAN_PROPERTY: case EOLIAN_PROP_GET: return fid->get_empty; break;
case EOLIAN_PROP_SET: return fid->set_empty; break;
default: return EINA_FALSE;
}
}
EAPI Eina_Bool
eolian_function_is_legacy_only(const Eolian_Function *fid, Eolian_Function_Type ftype)
{

View File

@ -106,6 +106,10 @@ struct _Eolian_Function
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 set_virtual_pure :1;
Eina_Bool get_auto :1;
Eina_Bool set_auto :1;
Eina_Bool get_empty :1;
Eina_Bool set_empty :1;
Eina_Bool get_return_warn_unused :1; /* also used for methods */
Eina_Bool set_return_warn_unused :1;
Eina_Bool get_only_legacy: 1;