forked from enlightenment/efl
eolian: fill ctor class early on
This commit is contained in:
parent
bd21080c82
commit
3dc9d28279
|
@ -16,8 +16,7 @@ EAPI const Eolian_Class *
|
|||
eolian_constructor_class_get(const Eolian_Constructor *ctor)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ctor, NULL);
|
||||
Eolian_Constructor *mctor = (Eolian_Constructor *)ctor;
|
||||
return database_object_class_fill(ctor->full_name, &mctor->klass);
|
||||
return ctor->klass;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Function *
|
||||
|
|
|
@ -203,12 +203,47 @@ _db_fill_implements(Eolian_Class *cl)
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_db_fill_ctors(Eolian_Class *cl)
|
||||
{
|
||||
Eolian_Constructor *ctor;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FOREACH(cl->constructors, l, ctor)
|
||||
{
|
||||
const char *ldot = strrchr(ctor->full_name, '.');
|
||||
if (!ldot)
|
||||
return EINA_FALSE;
|
||||
char *cnbuf = alloca(ldot - ctor->full_name + 1);
|
||||
memcpy(cnbuf, ctor->full_name, ldot - ctor->full_name);
|
||||
cnbuf[ldot - ctor->full_name] = '\0';
|
||||
const Eolian_Class *tcl = NULL;
|
||||
/* referencing self */
|
||||
if (!strcmp(cnbuf, cl->full_name))
|
||||
tcl = cl;
|
||||
else
|
||||
tcl = eolian_class_get_by_name(cnbuf);
|
||||
if (!tcl)
|
||||
{
|
||||
fprintf(stderr, "eolian:%s:%d:%d: class not found for ctor '%s'\n",
|
||||
ctor->base.file, ctor->base.line, ctor->base.column, ctor->full_name);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
ctor->klass = tcl;
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_db_fill_class(Eolian_Class *cl)
|
||||
{
|
||||
if (!_db_fill_implements(cl))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!_db_fill_ctors(cl))
|
||||
return EINA_FALSE;
|
||||
|
||||
eina_hash_set(_classes, cl->full_name, cl);
|
||||
eina_hash_set(_classesf, cl->base.file, cl);
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ EAPI const Eolian_Class *
|
|||
eolian_implement_class_get(const Eolian_Implement *impl)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(impl, NULL);
|
||||
Eolian_Implement *mimpl = (Eolian_Implement *)impl;
|
||||
return database_object_class_fill(impl->full_name, &mimpl->klass);
|
||||
return impl->klass;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Function *
|
||||
|
|
|
@ -655,19 +655,6 @@ database_class_to_filename(const char *cname)
|
|||
return ret;
|
||||
}
|
||||
|
||||
const Eolian_Class *
|
||||
database_object_class_fill(const char *class_name, const Eolian_Class **cl)
|
||||
{
|
||||
if (*cl) return *cl;
|
||||
char *name = strdup(class_name);
|
||||
char *ldot = strrchr(name + 1, '.');
|
||||
if (ldot) *ldot = '\0';
|
||||
const Eolian_Class *found = eolian_class_get_by_name(name);
|
||||
*cl = found;
|
||||
free(name);
|
||||
return found;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_eolian_file_parse_nodep(const char *filepath)
|
||||
{
|
||||
|
|
|
@ -288,7 +288,6 @@ int database_shutdown(void);
|
|||
|
||||
char *database_class_to_filename(const char *cname);
|
||||
Eina_Bool database_validate();
|
||||
const Eolian_Class *database_object_class_fill(const char *class_name, const Eolian_Class **cl);
|
||||
|
||||
void database_decl_add(Eina_Stringshare *name, Eolian_Declaration_Type type,
|
||||
Eina_Stringshare *file, void *ptr);
|
||||
|
|
Loading…
Reference in New Issue