forked from enlightenment/efl
eolian: API refactoring
Remove eolian_implement_information_get. Also, fix some nasty lookup problems.
This commit is contained in:
parent
057e01d67f
commit
ad3dbe834b
|
@ -667,8 +667,9 @@ eo_source_end_generate(const Eolian_Class *class, Eina_Strbuf *buf)
|
|||
const char *rets;
|
||||
char *tp = implname;
|
||||
|
||||
if (eolian_implement_information_get(impl_desc, &impl_class, &fnid, &ftype))
|
||||
if ((impl_class = eolian_implement_class_get(impl_desc)))
|
||||
{
|
||||
fnid = eolian_implement_function_get(impl_desc, &ftype);
|
||||
_class_env_create(impl_class, NULL, &impl_env);
|
||||
funcname = eolian_function_name_get(fnid);
|
||||
|
||||
|
|
|
@ -131,11 +131,7 @@ _prototype_generate(const Eolian_Function *foo, Eolian_Function_Type ftype, Eina
|
|||
super_invok = eina_strbuf_new();
|
||||
if (impl_desc)
|
||||
{
|
||||
const Eolian_Class *impl_class;
|
||||
eolian_implement_information_get(impl_desc, &impl_class, NULL, NULL);
|
||||
|
||||
_class_env_create(impl_class, NULL, &impl_env);
|
||||
|
||||
_class_env_create(eolian_implement_class_get(impl_desc), NULL, &impl_env);
|
||||
char *tmp = impl_name;
|
||||
sprintf(impl_name, "%s_%s", class_env.full_classname, impl_env.full_classname);
|
||||
eina_str_tolower(&tmp);
|
||||
|
@ -303,12 +299,8 @@ impl_source_generate(const Eolian_Class *class, Eina_Strbuf *buffer)
|
|||
Eolian_Implement *impl_desc;
|
||||
EINA_ITERATOR_FOREACH(itr, impl_desc)
|
||||
{
|
||||
const Eolian_Class *impl_class = NULL;
|
||||
Eolian_Function_Type ftype;
|
||||
|
||||
foo = NULL;
|
||||
eolian_implement_information_get(impl_desc, &impl_class, &foo, &ftype);
|
||||
if (!foo)
|
||||
if (!(foo = eolian_implement_function_get(impl_desc, &ftype)))
|
||||
{
|
||||
ERR ("Failed to generate implementation of %s - missing form super class",
|
||||
eolian_implement_full_name_get(impl_desc));
|
||||
|
|
|
@ -209,11 +209,9 @@ convert_eolian_implements(efl::eolian::eo_class& cls, Eolian_Class const& klass)
|
|||
EINA_ITERATOR_FOREACH(itr, impl_desc_)
|
||||
{
|
||||
const Eolian_Implement *impl_desc = static_cast<Eolian_Implement*>(impl_desc_);
|
||||
const Eolian_Class *impl_class;
|
||||
const Eolian_Function *impl_func;
|
||||
const Eolian_Class *impl_class = eolian_implement_class_get(impl_desc);
|
||||
Eolian_Function_Type impl_type;
|
||||
eolian_implement_information_get
|
||||
(impl_desc, &impl_class, &impl_func, &impl_type);
|
||||
const Eolian_Function *impl_func = eolian_implement_function_get(impl_desc, &impl_type);
|
||||
if (impl_type == EOLIAN_CTOR)
|
||||
{
|
||||
efl::eolian::eo_constructor constructor;
|
||||
|
|
|
@ -837,20 +837,28 @@ EAPI Eina_Bool eolian_function_object_is_const(const Eolian_Function *function_i
|
|||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Stringshare * eolian_implement_full_name_get(const Eolian_Implement *impl);
|
||||
EAPI Eina_Stringshare *eolian_implement_full_name_get(const Eolian_Implement *impl);
|
||||
|
||||
/*
|
||||
* @brief Get information about an overriding function (implement).
|
||||
* @brief Get the class of an overriding function (implement).
|
||||
*
|
||||
* @param[in] impl handle of the implement
|
||||
* @param[out] class overridden class
|
||||
* @param[out] func overridden function
|
||||
* @param[out] type type of the overridden function
|
||||
* @return EINA_TRUE on success, EINA_FALSE otherwise.
|
||||
* @return the class handle or NULL.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eina_Bool eolian_implement_information_get(const Eolian_Implement *impl, const Eolian_Class **klass, const Eolian_Function **function, Eolian_Function_Type *type);
|
||||
EAPI const Eolian_Class *eolian_implement_class_get(const Eolian_Implement *impl);
|
||||
|
||||
/*
|
||||
* @brief Get the function of an implement.
|
||||
*
|
||||
* @param[in] impl handle of the implement
|
||||
* @param[out] func_type the function type.
|
||||
* @return the function handle or NULL.
|
||||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI const Eolian_Function *eolian_implement_function_get(const Eolian_Implement *impl, Eolian_Function_Type *func_type);
|
||||
|
||||
/*
|
||||
* @brief Get an iterator to the overriding functions defined in a class.
|
||||
|
@ -890,7 +898,7 @@ EAPI Eina_Stringshare *eolian_event_name_get(const Eolian_Event *event);
|
|||
*
|
||||
* @ingroup Eolian
|
||||
*/
|
||||
EAPI Eolian_Type *eolian_event_type_get(const Eolian_Event *event);
|
||||
EAPI const Eolian_Type *eolian_event_type_get(const Eolian_Event *event);
|
||||
|
||||
/*
|
||||
* @brief Get the description of an event.
|
||||
|
|
|
@ -8,7 +8,7 @@ eolian_event_name_get(const Eolian_Event *event)
|
|||
return event->name;
|
||||
}
|
||||
|
||||
EAPI Eolian_Type *
|
||||
EAPI const Eolian_Type *
|
||||
eolian_event_type_get(const Eolian_Event *event)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(event, NULL);
|
||||
|
|
|
@ -8,29 +8,58 @@ eolian_implement_full_name_get(const Eolian_Implement *impl)
|
|||
return impl->full_name;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
eolian_implement_information_get(const Eolian_Implement *impl, const Eolian_Class **class_out, const Eolian_Function **func_out, Eolian_Function_Type *type_out)
|
||||
static Eina_Bool
|
||||
_fill_class(Eolian_Implement *impl)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(impl, EINA_FALSE);
|
||||
const Eolian_Class *class;
|
||||
if (!database_class_name_validate(impl->full_name, &class) || !class) return EINA_FALSE;
|
||||
const char *class_name = class->full_name;
|
||||
if (class_out) *class_out = class;
|
||||
|
||||
char *func_name = strdup(impl->full_name + strlen(class_name) + 1);
|
||||
char *colon = strchr(func_name, '.');
|
||||
Eolian_Function_Type type = EOLIAN_UNRESOLVED;
|
||||
if (colon)
|
||||
{
|
||||
*colon = '\0';
|
||||
if (!strcmp(colon+1, "set")) type = EOLIAN_PROP_SET;
|
||||
else if (!strcmp(colon+1, "get")) type = EOLIAN_PROP_GET;
|
||||
}
|
||||
|
||||
const Eolian_Function *fid = eolian_class_function_get_by_name(class, func_name, type);
|
||||
if (func_out) *func_out = fid;
|
||||
if (type == EOLIAN_UNRESOLVED) type = eolian_function_type_get(fid);
|
||||
if (type_out) *type_out = type;
|
||||
free(func_name);
|
||||
const Eolian_Class *class = NULL;
|
||||
if (impl->klass)
|
||||
return EINA_TRUE;
|
||||
if (!database_class_name_validate(impl->full_name, &class) || !class)
|
||||
return EINA_FALSE;
|
||||
impl->klass = class;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Class *
|
||||
eolian_implement_class_get(const Eolian_Implement *impl)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(impl, NULL);
|
||||
if (!_fill_class((Eolian_Implement*)impl))
|
||||
return NULL;
|
||||
return impl->klass;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Function *
|
||||
eolian_implement_function_get(const Eolian_Implement *impl,
|
||||
Eolian_Function_Type *func_type)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(impl, NULL);
|
||||
const Eolian_Class *klass = eolian_implement_class_get(impl);
|
||||
if (!klass)
|
||||
return NULL;
|
||||
|
||||
char *func_name = strdup(impl->full_name + strlen(klass->full_name) + 1);
|
||||
char *dot = strchr(func_name, '.');
|
||||
|
||||
Eolian_Function_Type tp = EOLIAN_UNRESOLVED;
|
||||
if (dot)
|
||||
{
|
||||
*dot = '\0';
|
||||
if (!strcmp(dot + 1, "set")) tp = EOLIAN_PROP_SET;
|
||||
else if (!strcmp(dot + 1, "get")) tp = EOLIAN_PROP_GET;
|
||||
}
|
||||
|
||||
const Eolian_Function *fid = eolian_class_function_get_by_name(klass,
|
||||
func_name,
|
||||
tp);
|
||||
free(func_name);
|
||||
|
||||
if (func_type)
|
||||
{
|
||||
if (tp == EOLIAN_UNRESOLVED)
|
||||
*func_type = eolian_function_type_get(fid);
|
||||
else
|
||||
*func_type = tp;
|
||||
}
|
||||
return fid;
|
||||
}
|
||||
|
|
|
@ -4,12 +4,10 @@
|
|||
static void
|
||||
_implements_print(Eolian_Implement *impl, int nb_spaces)
|
||||
{
|
||||
const Eolian_Class *class;
|
||||
const Eolian_Function *func;
|
||||
const char *t;
|
||||
Eolian_Function_Type ft;
|
||||
const char *t;
|
||||
|
||||
eolian_implement_information_get(impl, &class, &func, &ft);
|
||||
eolian_implement_function_get(impl, &ft);
|
||||
switch (ft)
|
||||
{
|
||||
case EOLIAN_PROP_SET: t = "SET"; break;
|
||||
|
|
|
@ -195,10 +195,8 @@ eolian_eo_file_parse(const char *filepath)
|
|||
itr = eolian_class_implements_get(class);
|
||||
EINA_ITERATOR_FOREACH(itr, impl)
|
||||
{
|
||||
const Eolian_Class *impl_class;
|
||||
const Eolian_Function *impl_func;
|
||||
Eolian_Function_Type impl_type = EOLIAN_UNRESOLVED;
|
||||
eolian_implement_information_get(impl, &impl_class, &impl_func, &impl_type);
|
||||
const Eolian_Function *impl_func = eolian_implement_function_get(impl, &impl_type);
|
||||
if (!impl_func)
|
||||
{
|
||||
ERR("Unable to find function %s", eolian_implement_full_name_get(impl));
|
||||
|
|
|
@ -143,6 +143,7 @@ struct _Eolian_Type
|
|||
struct _Eolian_Implement
|
||||
{
|
||||
Eolian_Object base;
|
||||
const Eolian_Class *klass;
|
||||
Eina_Stringshare *full_name;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ class nmsp1.class1 (nmsp1.nmsp11.class2, nmsp2.class1, no_nmsp)
|
|||
{
|
||||
implements {
|
||||
nmsp1.nmsp11.class2.a.set;
|
||||
nmsp1.bad_class.a.set;
|
||||
no_nmsp.foo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,18 +71,15 @@ START_TEST(eolian_namespaces)
|
|||
/* Implements */
|
||||
fail_if(!(iter = eolian_class_implements_get(class11)));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
||||
fail_if(!eolian_implement_information_get(impl,
|
||||
&impl_class, &fid, &func_type));
|
||||
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
||||
fail_if(!(fid = eolian_implement_function_get(impl, &func_type)));
|
||||
fail_if(impl_class != class112);
|
||||
fail_if(strcmp(eolian_function_name_get(fid), "a"));
|
||||
fail_if(func_type != EOLIAN_PROP_SET);
|
||||
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
||||
fail_if(eolian_implement_information_get(impl,
|
||||
&impl_class, &fid, &func_type));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
||||
fail_if(!eolian_implement_information_get(impl,
|
||||
&impl_class, &fid, &func_type));
|
||||
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
||||
fail_if(!(fid = eolian_implement_function_get(impl, &func_type)));
|
||||
fail_if(impl_class != class_no);
|
||||
fail_if(strcmp(eolian_function_name_get(fid), "foo"));
|
||||
fail_if(func_type != EOLIAN_METHOD);
|
||||
|
@ -117,19 +114,20 @@ START_TEST(eolian_events)
|
|||
fail_if(!(iter = eolian_class_events_get(class)));
|
||||
/* Clicked */
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&ev)));
|
||||
fail_if(!eolian_class_event_information_get(ev, &name, &type, &comment));
|
||||
fail_if(!(name = eolian_event_name_get(ev)));
|
||||
fail_if(eolian_event_type_get(ev));
|
||||
fail_if(!(comment = eolian_event_description_get(ev)));
|
||||
fail_if(strcmp(name, "clicked"));
|
||||
fail_if(type);
|
||||
fail_if(strcmp(comment, "Comment for clicked"));
|
||||
/* Clicked,double */
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&ev)));
|
||||
fail_if(!eolian_class_event_information_get(ev, &name, &type, &comment));
|
||||
fail_if(!(name = eolian_event_name_get(ev)));
|
||||
fail_if(!(type = eolian_event_type_get(ev)));
|
||||
fail_if(comment = eolian_event_description_get(ev));
|
||||
fail_if(strcmp(name, "clicked,double"));
|
||||
fail_if(!type);
|
||||
type_name = eolian_type_name_get(type);
|
||||
fail_if(strcmp(type_name, "Evas_Event_Clicked_Double_Info"));
|
||||
eina_stringshare_del(type_name);
|
||||
fail_if(comment);
|
||||
fail_if(eina_iterator_next(iter, &dummy));
|
||||
eina_iterator_free(iter);
|
||||
|
||||
|
@ -160,7 +158,8 @@ START_TEST(eolian_override)
|
|||
fail_if(!eolian_function_is_virtual_pure(fid, EOLIAN_UNRESOLVED));
|
||||
fail_if(!(iter = eolian_class_implements_get(class)));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
||||
fail_if(!eolian_implement_information_get(impl, &impl_class, &impl_func, NULL));
|
||||
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
||||
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
||||
fail_if(impl_class != base);
|
||||
fail_if(strcmp(eolian_function_name_get(impl_func), "constructor"));
|
||||
eina_iterator_free(iter);
|
||||
|
@ -226,11 +225,13 @@ START_TEST(eolian_ctor_dtor)
|
|||
/* Base ctor/dtor */
|
||||
fail_if(!(iter = eolian_class_implements_get(class)));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
||||
fail_if(!eolian_implement_information_get(impl, &impl_class, &impl_func, NULL));
|
||||
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
||||
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
||||
fail_if(impl_class != base);
|
||||
fail_if(strcmp(eolian_function_name_get(impl_func), "constructor"));
|
||||
fail_if(!(eina_iterator_next(iter, (void**)&impl)));
|
||||
fail_if(!eolian_implement_information_get(impl, &impl_class, &impl_func, NULL));
|
||||
fail_if(!(impl_class = eolian_implement_class_get(impl)));
|
||||
fail_if(!(impl_func = eolian_implement_function_get(impl, NULL)));
|
||||
fail_if(impl_class != base);
|
||||
fail_if(strcmp(eolian_function_name_get(impl_func), "destructor"));
|
||||
fail_if(eina_iterator_next(iter, &dummy));
|
||||
|
|
Loading…
Reference in New Issue