2014-07-11 03:31:48 -07:00
|
|
|
#include "eo_parser.h"
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-08-19 03:53:50 -07:00
|
|
|
_db_fill_param(Eina_List **plist, Eo_Param_Def *param)
|
2014-07-11 03:31:48 -07:00
|
|
|
{
|
2014-08-15 05:51:41 -07:00
|
|
|
Eolian_Function_Parameter *p = database_parameter_add(param->type,
|
2014-09-02 02:47:38 -07:00
|
|
|
param->value,
|
2014-08-15 05:51:41 -07:00
|
|
|
param->name,
|
|
|
|
param->comment);
|
|
|
|
p->param_dir = param->way;
|
2014-08-19 03:53:50 -07:00
|
|
|
*plist = eina_list_append(*plist, p);
|
2014-08-15 06:14:43 -07:00
|
|
|
p->nonull = param->nonull;
|
2014-07-11 03:31:48 -07:00
|
|
|
param->type = NULL;
|
|
|
|
|
2014-08-04 06:29:13 -07:00
|
|
|
p->base = param->base;
|
2014-08-07 07:15:07 -07:00
|
|
|
param->base.file = NULL;
|
2014-08-04 06:29:13 -07:00
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-08-19 03:53:50 -07:00
|
|
|
_db_fill_params(Eina_List *oplist, Eina_List **plist)
|
2014-07-11 03:31:48 -07:00
|
|
|
{
|
|
|
|
Eo_Param_Def *param;
|
|
|
|
Eina_List *l;
|
|
|
|
|
2014-08-19 03:53:50 -07:00
|
|
|
EINA_LIST_FOREACH(oplist, l, param)
|
|
|
|
if (!_db_fill_param(plist, param)) return EINA_FALSE;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_accessor(Eolian_Function *foo_id, Eo_Class_Def *kls,
|
|
|
|
Eo_Property_Def *prop, Eo_Accessor_Def *accessor)
|
|
|
|
{
|
|
|
|
Eo_Accessor_Param *acc_param;
|
|
|
|
Eina_List *l;
|
|
|
|
|
2014-08-15 05:51:41 -07:00
|
|
|
if (accessor->type == SETTER)
|
|
|
|
foo_id->type = (foo_id->type == EOLIAN_PROP_GET) ? EOLIAN_PROPERTY
|
|
|
|
: EOLIAN_PROP_SET;
|
|
|
|
else
|
|
|
|
foo_id->type = (foo_id->type == EOLIAN_PROP_SET) ? EOLIAN_PROPERTY
|
|
|
|
: EOLIAN_PROP_GET;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
if (accessor->ret && accessor->ret->type)
|
|
|
|
{
|
2014-08-15 05:51:41 -07:00
|
|
|
if (accessor->type == SETTER)
|
|
|
|
{
|
|
|
|
foo_id->set_ret_type = accessor->ret->type;
|
|
|
|
foo_id->set_ret_val = accessor->ret->default_ret_val;
|
|
|
|
foo_id->set_return_comment = eina_stringshare_ref(accessor->ret->comment);
|
|
|
|
foo_id->set_return_warn_unused = accessor->ret->warn_unused;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foo_id->get_ret_type = accessor->ret->type;
|
|
|
|
foo_id->get_ret_val = accessor->ret->default_ret_val;
|
|
|
|
foo_id->get_return_comment = eina_stringshare_ref(accessor->ret->comment);
|
|
|
|
foo_id->get_return_warn_unused = accessor->ret->warn_unused;
|
|
|
|
}
|
2014-07-11 03:31:48 -07:00
|
|
|
accessor->ret->type = NULL;
|
2014-08-07 07:15:07 -07:00
|
|
|
accessor->ret->default_ret_val = NULL;
|
2014-07-11 03:31:48 -07:00
|
|
|
}
|
|
|
|
|
2014-08-15 05:51:41 -07:00
|
|
|
if (accessor->type == SETTER)
|
|
|
|
{
|
|
|
|
foo_id->set_description = eina_stringshare_ref(accessor->comment);
|
|
|
|
if (accessor->legacy)
|
|
|
|
foo_id->set_legacy = eina_stringshare_ref(accessor->legacy);
|
2014-08-18 06:51:03 -07:00
|
|
|
foo_id->set_only_legacy = accessor->only_legacy;
|
2014-08-15 05:51:41 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foo_id->get_description = eina_stringshare_ref(accessor->comment);
|
|
|
|
if (accessor->legacy)
|
|
|
|
foo_id->get_legacy = eina_stringshare_ref(accessor->legacy);
|
2014-08-18 06:51:03 -07:00
|
|
|
foo_id->get_only_legacy = accessor->only_legacy;
|
2014-08-15 05:51:41 -07:00
|
|
|
}
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(accessor->params, l, acc_param)
|
|
|
|
{
|
|
|
|
Eolian_Function_Parameter *desc = (Eolian_Function_Parameter*)
|
2014-07-23 06:22:25 -07:00
|
|
|
eolian_function_parameter_get_by_name(foo_id, acc_param->name);
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
if (!desc)
|
|
|
|
{
|
|
|
|
ERR("Error - %s not known as parameter of property %s\n",
|
|
|
|
acc_param->name, prop->name);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
else if (acc_param->is_const)
|
|
|
|
{
|
2014-08-15 06:14:43 -07:00
|
|
|
if (accessor->type == GETTER)
|
|
|
|
desc->is_const_on_get = EINA_TRUE;
|
|
|
|
else
|
|
|
|
desc->is_const_on_set = EINA_TRUE;
|
2014-07-11 03:31:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kls->type == EOLIAN_CLASS_INTERFACE)
|
2014-08-15 05:51:41 -07:00
|
|
|
{
|
|
|
|
if (accessor->type == SETTER)
|
|
|
|
foo_id->set_virtual_pure = EINA_TRUE;
|
|
|
|
else
|
|
|
|
foo_id->get_virtual_pure = EINA_TRUE;
|
|
|
|
}
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-08-15 05:51:41 -07:00
|
|
|
if (accessor->type == GETTER)
|
2014-08-04 06:29:13 -07:00
|
|
|
foo_id->base = accessor->base;
|
|
|
|
else
|
|
|
|
foo_id->set_base = accessor->base;
|
|
|
|
|
2014-08-07 07:15:07 -07:00
|
|
|
accessor->base.file = NULL;
|
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_accessors(Eolian_Function *foo_id, Eo_Class_Def *kls,
|
|
|
|
Eo_Property_Def *prop)
|
|
|
|
{
|
|
|
|
Eo_Accessor_Def *accessor;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(prop->accessors, l, accessor)
|
|
|
|
if (!_db_fill_accessor(foo_id, kls, prop, accessor)) return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_property(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Property_Def *prop)
|
|
|
|
{
|
|
|
|
Eolian_Function *foo_id = database_function_new(prop->name,
|
|
|
|
EOLIAN_UNRESOLVED);
|
|
|
|
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->scope = prop->scope;
|
|
|
|
foo_id->is_class = prop->is_class;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-08-19 03:53:50 -07:00
|
|
|
if (!_db_fill_params (prop->keys , &(foo_id->keys ))) goto failure;
|
|
|
|
if (!_db_fill_params (prop->values, &(foo_id->params))) goto failure;
|
2014-07-15 16:30:48 -07:00
|
|
|
if (!_db_fill_accessors(foo_id, kls, prop)) goto failure;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
if (!prop->accessors)
|
|
|
|
{
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->type = EOLIAN_PROPERTY;
|
2014-07-11 03:31:48 -07:00
|
|
|
if (kls->type == EOLIAN_CLASS_INTERFACE)
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->get_virtual_pure = foo_id->set_virtual_pure = EINA_TRUE;
|
2014-08-04 06:29:13 -07:00
|
|
|
foo_id->base = prop->base;
|
2014-08-07 07:15:07 -07:00
|
|
|
prop->base.file = NULL;
|
2014-07-11 03:31:48 -07:00
|
|
|
}
|
|
|
|
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->properties = eina_list_append(cl->properties, foo_id);
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2014-07-15 16:30:48 -07:00
|
|
|
|
|
|
|
failure:
|
|
|
|
database_function_del(foo_id);
|
|
|
|
return EINA_FALSE;
|
2014-07-11 03:31:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_properties(Eolian_Class *cl, Eo_Class_Def *kls)
|
|
|
|
{
|
|
|
|
Eo_Property_Def *prop;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(kls->properties, l, prop)
|
|
|
|
if (!_db_fill_property(cl, kls, prop)) return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_method(Eolian_Class *cl, Eo_Class_Def *kls, Eo_Method_Def *meth)
|
|
|
|
{
|
|
|
|
Eolian_Function *foo_id = database_function_new(meth->name, EOLIAN_METHOD);
|
|
|
|
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->scope = meth->scope;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->methods = eina_list_append(cl->methods, foo_id);
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
if (meth->ret)
|
|
|
|
{
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->get_ret_type = meth->ret->type;
|
|
|
|
foo_id->get_return_comment = eina_stringshare_ref(meth->ret->comment);
|
|
|
|
foo_id->get_return_warn_unused = meth->ret->warn_unused;
|
|
|
|
foo_id->get_ret_val = meth->ret->default_ret_val;
|
2014-07-11 03:31:48 -07:00
|
|
|
meth->ret->type = NULL;
|
2014-08-07 07:15:07 -07:00
|
|
|
meth->ret->default_ret_val = NULL;
|
2014-07-11 03:31:48 -07:00
|
|
|
}
|
|
|
|
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->get_description = eina_stringshare_ref(meth->comment);
|
|
|
|
foo_id->get_legacy = eina_stringshare_ref(meth->legacy);
|
|
|
|
foo_id->obj_is_const = meth->obj_const;
|
|
|
|
foo_id->is_class = meth->is_class;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-08-18 06:51:03 -07:00
|
|
|
if (meth->only_legacy)
|
|
|
|
foo_id->get_only_legacy = EINA_TRUE;
|
|
|
|
|
2014-08-19 03:53:50 -07:00
|
|
|
_db_fill_params(meth->params, &(foo_id->params));
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
if (kls->type == EOLIAN_CLASS_INTERFACE)
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->get_virtual_pure = EINA_TRUE;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-08-04 06:29:13 -07:00
|
|
|
foo_id->base = meth->base;
|
2014-08-07 07:15:07 -07:00
|
|
|
meth->base.file = NULL;
|
2014-08-04 06:29:13 -07:00
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_methods(Eolian_Class *cl, Eo_Class_Def *kls)
|
|
|
|
{
|
|
|
|
Eo_Method_Def *meth;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(kls->methods, l, meth)
|
|
|
|
if (!_db_fill_method(cl, kls, meth)) return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-09-03 06:25:50 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-09-04 03:06:41 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_get_impl_func(Eolian_Class *cl, Eolian_Implement *impl,
|
|
|
|
Eolian_Function_Type ftype, Eolian_Function **foo_id)
|
|
|
|
{
|
|
|
|
size_t cllen = strlen(cl->full_name);
|
|
|
|
size_t imlen = strlen(impl->full_name);
|
|
|
|
const char *imstr = impl->full_name;
|
|
|
|
*foo_id = NULL;
|
|
|
|
if (imstr[0] == '.')
|
|
|
|
++imstr;
|
|
|
|
else if ((imlen > (cllen + 1)) && (*(imstr + cllen) == '.')
|
|
|
|
&& !strncmp(imstr, cl->full_name, cllen))
|
|
|
|
imstr += cllen + 1;
|
|
|
|
else
|
|
|
|
return EINA_TRUE;
|
|
|
|
if (strchr(imstr, '.'))
|
|
|
|
return EINA_FALSE;
|
2014-09-04 06:29:33 -07:00
|
|
|
impl->klass = cl;
|
2014-09-04 03:06:41 -07:00
|
|
|
*foo_id = (Eolian_Function*)eolian_class_function_get_by_name(cl, imstr,
|
|
|
|
ftype);
|
2014-09-04 07:15:38 -07:00
|
|
|
impl->foo_id = *foo_id;
|
2014-09-04 03:06:41 -07:00
|
|
|
return !!*foo_id;
|
|
|
|
}
|
|
|
|
|
2014-09-05 08:04:08 -07:00
|
|
|
static void
|
|
|
|
_write_impl(Eolian_Function *fid, Eolian_Implement *impl)
|
|
|
|
{
|
|
|
|
if (impl->is_prop_set)
|
|
|
|
fid->set_impl = impl;
|
|
|
|
else if (impl->is_prop_get)
|
|
|
|
fid->get_impl = impl;
|
|
|
|
else
|
|
|
|
fid->get_impl = fid->set_impl = impl;
|
|
|
|
}
|
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
static int
|
|
|
|
_db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
|
|
|
|
{
|
|
|
|
const char *impl_name = impl->full_name;
|
|
|
|
|
2014-09-05 08:18:47 -07:00
|
|
|
Eolian_Function *foo_id;
|
2014-09-03 06:25:50 -07:00
|
|
|
Eolian_Function_Type ftype = EOLIAN_UNRESOLVED;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-09-03 06:25:50 -07:00
|
|
|
if (impl->is_prop_get)
|
|
|
|
ftype = EOLIAN_PROP_GET;
|
|
|
|
else if (impl->is_prop_set)
|
|
|
|
ftype = EOLIAN_PROP_SET;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-09-03 06:25:50 -07:00
|
|
|
if (impl->is_virtual)
|
|
|
|
{
|
2014-09-05 08:18:47 -07:00
|
|
|
foo_id = (Eolian_Function*)eolian_class_function_get_by_name(cl,
|
|
|
|
impl_name, ftype);
|
2014-09-05 08:04:08 -07:00
|
|
|
if (!foo_id)
|
|
|
|
return _func_error(cl, impl);
|
2014-08-29 03:40:29 -07:00
|
|
|
if (impl->is_prop_set)
|
2014-08-15 05:51:41 -07:00
|
|
|
foo_id->set_virtual_pure = EINA_TRUE;
|
|
|
|
else
|
|
|
|
foo_id->get_virtual_pure = EINA_TRUE;
|
2014-08-29 03:40:29 -07:00
|
|
|
|
2014-09-05 08:04:08 -07:00
|
|
|
impl->full_name = eina_stringshare_printf("%s.%s", cl->full_name,
|
|
|
|
impl_name);
|
|
|
|
eina_stringshare_del(impl_name);
|
|
|
|
impl_name = impl->full_name;
|
|
|
|
|
|
|
|
_write_impl(foo_id, impl);
|
2014-07-11 03:31:48 -07:00
|
|
|
}
|
2014-09-03 06:25:50 -07:00
|
|
|
else if (impl->is_auto)
|
|
|
|
{
|
2014-09-04 03:06:41 -07:00
|
|
|
if (!_get_impl_func(cl, impl, ftype, &foo_id))
|
|
|
|
return _func_error(cl, impl);
|
|
|
|
if (!foo_id)
|
|
|
|
goto pasttags;
|
2014-09-03 06:44:23 -07:00
|
|
|
if (impl->is_prop_set)
|
2014-09-03 06:25:50 -07:00
|
|
|
foo_id->set_auto = EINA_TRUE;
|
|
|
|
else
|
|
|
|
foo_id->get_auto = EINA_TRUE;
|
2014-09-04 06:48:39 -07:00
|
|
|
|
2014-09-05 08:04:08 -07:00
|
|
|
_write_impl(foo_id, impl);
|
2014-09-03 06:25:50 -07:00
|
|
|
}
|
|
|
|
else if (impl->is_empty)
|
|
|
|
{
|
2014-09-04 03:06:41 -07:00
|
|
|
if (!_get_impl_func(cl, impl, ftype, &foo_id))
|
|
|
|
return _func_error(cl, impl);
|
|
|
|
if (!foo_id)
|
|
|
|
goto pasttags;
|
2014-09-03 06:44:23 -07:00
|
|
|
if (impl->is_prop_set)
|
2014-09-03 06:25:50 -07:00
|
|
|
foo_id->set_empty = EINA_TRUE;
|
|
|
|
else
|
|
|
|
foo_id->get_empty = EINA_TRUE;
|
2014-09-04 06:48:39 -07:00
|
|
|
|
2014-09-05 08:04:08 -07:00
|
|
|
_write_impl(foo_id, impl);
|
2014-09-03 06:25:50 -07:00
|
|
|
}
|
2014-08-29 03:40:29 -07:00
|
|
|
else if (impl->is_class_ctor)
|
|
|
|
{
|
|
|
|
cl->class_ctor_enable = EINA_TRUE;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (impl->is_class_dtor)
|
|
|
|
{
|
|
|
|
cl->class_dtor_enable = EINA_TRUE;
|
|
|
|
return 1;
|
|
|
|
}
|
2014-09-04 06:29:33 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!_get_impl_func(cl, impl, ftype, &foo_id))
|
|
|
|
return _func_error(cl, impl);
|
|
|
|
}
|
2014-08-29 03:40:29 -07:00
|
|
|
|
2014-09-03 06:25:50 -07:00
|
|
|
pasttags:
|
2014-08-29 06:13:34 -07:00
|
|
|
if (impl_name[0] == '.')
|
|
|
|
{
|
|
|
|
impl->full_name = eina_stringshare_printf("%s%s", cl->full_name,
|
|
|
|
impl_name);
|
|
|
|
eina_stringshare_del(impl_name);
|
|
|
|
}
|
|
|
|
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->implements = eina_list_append(cl->implements, impl);
|
2014-07-11 03:31:48 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-09-04 06:48:39 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_db_build_implement(Eolian_Class *cl, Eolian_Function *foo_id)
|
|
|
|
{
|
2014-09-05 08:04:08 -07:00
|
|
|
if (foo_id->type == EOLIAN_PROP_SET)
|
|
|
|
{
|
|
|
|
if (foo_id->set_impl)
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (foo_id->type == EOLIAN_PROP_GET)
|
|
|
|
{
|
|
|
|
if (foo_id->get_impl)
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (foo_id->get_impl && foo_id->set_impl)
|
2014-09-04 06:48:39 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
Eolian_Implement *impl = calloc(1, sizeof(Eolian_Implement));
|
|
|
|
|
|
|
|
if (foo_id->type == EOLIAN_PROP_SET)
|
|
|
|
impl->base = foo_id->set_base;
|
|
|
|
else
|
|
|
|
impl->base = foo_id->base;
|
|
|
|
eina_stringshare_ref(impl->base.file);
|
|
|
|
|
|
|
|
impl->klass = cl;
|
2014-09-04 07:15:38 -07:00
|
|
|
impl->foo_id = foo_id;
|
2014-09-04 06:48:39 -07:00
|
|
|
impl->full_name = eina_stringshare_printf("%s.%s", cl->full_name,
|
|
|
|
foo_id->name);
|
|
|
|
|
2014-09-05 08:04:08 -07:00
|
|
|
if (foo_id->type == EOLIAN_PROPERTY)
|
|
|
|
{
|
|
|
|
if (foo_id->get_impl)
|
|
|
|
{
|
|
|
|
impl->is_prop_set = EINA_TRUE;
|
|
|
|
foo_id->set_impl = impl;
|
|
|
|
}
|
|
|
|
else if (foo_id->set_impl)
|
|
|
|
{
|
|
|
|
impl->is_prop_get = EINA_TRUE;
|
|
|
|
foo_id->get_impl = impl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
foo_id->get_impl = foo_id->set_impl = impl;
|
|
|
|
}
|
|
|
|
else if (foo_id->type == EOLIAN_PROP_SET)
|
2014-09-05 08:19:56 -07:00
|
|
|
{
|
|
|
|
impl->is_prop_set = EINA_TRUE;
|
|
|
|
foo_id->set_impl = impl;
|
|
|
|
}
|
2014-09-05 08:04:08 -07:00
|
|
|
else if (foo_id->type == EOLIAN_PROP_GET)
|
2014-09-05 08:19:56 -07:00
|
|
|
{
|
|
|
|
impl->is_prop_get = EINA_TRUE;
|
|
|
|
foo_id->get_impl = impl;
|
|
|
|
}
|
2014-09-05 08:04:08 -07:00
|
|
|
else
|
|
|
|
foo_id->get_impl = foo_id->set_impl = impl;
|
2014-09-04 06:48:39 -07:00
|
|
|
|
|
|
|
cl->implements = eina_list_append(cl->implements, impl);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_implements(Eolian_Class *cl, Eo_Class_Def *kls)
|
|
|
|
{
|
|
|
|
Eolian_Implement *impl;
|
2014-09-04 06:48:39 -07:00
|
|
|
Eolian_Function *foo_id;
|
2014-07-11 03:31:48 -07:00
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(kls->implements, l, impl)
|
|
|
|
{
|
|
|
|
int ret = _db_fill_implement(cl, impl);
|
|
|
|
if (ret < 0) return EINA_FALSE;
|
|
|
|
if (ret > 0) continue;
|
|
|
|
eina_list_data_set(l, NULL); /* prevent double free */
|
|
|
|
}
|
2014-09-04 06:48:39 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(cl->properties, l, foo_id)
|
|
|
|
if (!_db_build_implement(cl, foo_id))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(cl->methods, l, foo_id)
|
|
|
|
if (!_db_build_implement(cl, foo_id))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-09-01 07:35:50 -07:00
|
|
|
static void
|
|
|
|
_db_fill_constructor(Eolian_Class *cl, Eolian_Constructor *ctor)
|
|
|
|
{
|
|
|
|
const char *ctor_name = ctor->full_name;
|
|
|
|
if (ctor_name[0] == '.')
|
|
|
|
{
|
|
|
|
ctor->full_name = eina_stringshare_printf("%s%s", cl->full_name,
|
|
|
|
ctor_name);
|
|
|
|
eina_stringshare_del(ctor_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->constructors = eina_list_append(cl->constructors, ctor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_constructors(Eolian_Class *cl, Eo_Class_Def *kls)
|
|
|
|
{
|
|
|
|
Eolian_Constructor *ctor;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(kls->constructors, l, ctor)
|
|
|
|
{
|
|
|
|
_db_fill_constructor(cl, ctor);
|
|
|
|
eina_list_data_set(l, NULL); /* prevent double free */
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_events(Eolian_Class *cl, Eo_Class_Def *kls)
|
|
|
|
{
|
|
|
|
Eolian_Event *event;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(kls->events, l, event)
|
|
|
|
{
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->events = eina_list_append(cl->events, event);
|
2014-07-11 03:31:48 -07:00
|
|
|
eina_list_data_set(l, NULL); /* prevent double free */
|
|
|
|
}
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-07-23 09:15:00 -07:00
|
|
|
_db_fill_class(Eo_Class_Def *kls)
|
2014-07-11 03:31:48 -07:00
|
|
|
{
|
|
|
|
Eolian_Class *cl = database_class_add(kls->name, kls->type);
|
|
|
|
const char *s;
|
|
|
|
Eina_List *l;
|
|
|
|
|
2014-08-08 07:19:52 -07:00
|
|
|
eina_hash_set(_classesf, kls->base.file, cl);
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
if (kls->comment)
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->description = eina_stringshare_ref(kls->comment);
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(kls->inherits, l, s)
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->inherits = eina_list_append(cl->inherits, eina_stringshare_add(s));
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
if (kls->legacy_prefix)
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->legacy_prefix = eina_stringshare_ref(kls->legacy_prefix);
|
2014-07-11 03:31:48 -07:00
|
|
|
if (kls->eo_prefix)
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->eo_prefix = eina_stringshare_ref(kls->eo_prefix);
|
2014-07-11 03:31:48 -07:00
|
|
|
if (kls->data_type)
|
2014-08-15 06:14:43 -07:00
|
|
|
cl->data_type = eina_stringshare_ref(kls->data_type);
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-09-01 07:35:50 -07:00
|
|
|
if (!_db_fill_properties (cl, kls)) return EINA_FALSE;
|
|
|
|
if (!_db_fill_methods (cl, kls)) return EINA_FALSE;
|
|
|
|
if (!_db_fill_implements (cl, kls)) return EINA_FALSE;
|
|
|
|
if (!_db_fill_constructors(cl, kls)) return EINA_FALSE;
|
|
|
|
if (!_db_fill_events (cl, kls)) return EINA_FALSE;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
2014-08-04 06:29:13 -07:00
|
|
|
cl->base = kls->base;
|
2014-08-07 07:15:07 -07:00
|
|
|
kls->base.file = NULL;
|
2014-08-04 06:29:13 -07:00
|
|
|
|
2014-07-11 03:31:48 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
eo_parser_database_fill(const char *filename, Eina_Bool eot)
|
|
|
|
{
|
|
|
|
Eina_List *k;
|
|
|
|
Eo_Node *nd;
|
|
|
|
Eina_Bool has_class = EINA_FALSE;
|
|
|
|
|
|
|
|
Eo_Lexer *ls = eo_lexer_new(filename);
|
|
|
|
if (!ls)
|
|
|
|
{
|
|
|
|
ERR("unable to create lexer");
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read first token */
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
|
|
|
|
if (!eo_parser_walk(ls, eot))
|
|
|
|
{
|
|
|
|
eo_lexer_free(ls);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2014-07-21 03:42:05 -07:00
|
|
|
if (eot) goto done;
|
2014-07-11 03:31:48 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ls->nodes, k, nd) if (nd->type == NODE_CLASS)
|
|
|
|
{
|
|
|
|
has_class = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_class)
|
|
|
|
{
|
|
|
|
ERR("No classes for file %s", filename);
|
|
|
|
eo_lexer_free(ls);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(ls->nodes, k, nd)
|
|
|
|
{
|
|
|
|
switch (nd->type)
|
|
|
|
{
|
|
|
|
case NODE_CLASS:
|
2014-07-23 09:15:00 -07:00
|
|
|
if (!_db_fill_class(nd->def_class))
|
2014-07-11 03:31:48 -07:00
|
|
|
goto error;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-21 03:42:05 -07:00
|
|
|
done:
|
2014-07-11 03:31:48 -07:00
|
|
|
eo_lexer_free(ls);
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
eo_lexer_free(ls);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|