forked from enlightenment/efl
eolian: lift restriction on namespace/class name conflicts in library
This will allow us to name classes the same as namespaces.
This commit is contained in:
parent
4a1733f5c8
commit
8df2686d90
|
@ -12,25 +12,12 @@ eolian_constructor_full_name_get(const Eolian_Constructor *ctor)
|
|||
return ctor->full_name;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_fill_class(Eolian_Constructor *ctor)
|
||||
{
|
||||
const Eolian_Class *class = NULL;
|
||||
if (ctor->klass)
|
||||
return EINA_TRUE;
|
||||
if (!database_class_name_validate(ctor->full_name, &class) || !class)
|
||||
return EINA_FALSE;
|
||||
ctor->klass = class;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI const Eolian_Class *
|
||||
eolian_constructor_class_get(const Eolian_Constructor *ctor)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ctor, NULL);
|
||||
if (!_fill_class((Eolian_Constructor*)ctor))
|
||||
return NULL;
|
||||
return ctor->klass;
|
||||
Eolian_Constructor *mctor = (Eolian_Constructor *)ctor;
|
||||
return database_object_class_fill(ctor->full_name, &mctor->klass);
|
||||
}
|
||||
|
||||
EAPI const Eolian_Function *
|
||||
|
|
|
@ -12,25 +12,12 @@ eolian_implement_full_name_get(const Eolian_Implement *impl)
|
|||
return impl->full_name;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_fill_class(Eolian_Implement *impl)
|
||||
{
|
||||
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;
|
||||
Eolian_Implement *mimpl = (Eolian_Implement *)impl;
|
||||
return database_object_class_fill(impl->full_name, &mimpl->klass);
|
||||
}
|
||||
|
||||
EAPI const Eolian_Function *
|
||||
|
|
|
@ -275,42 +275,17 @@ database_class_to_filename(const char *cname)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* ret false -> clash, class = NULL
|
||||
* ret true && class -> only one class corresponding
|
||||
* ret true && !class -> no class corresponding
|
||||
*/
|
||||
Eina_Bool
|
||||
database_class_name_validate(const char *class_name, const Eolian_Class **cl)
|
||||
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 *colon = name + 1;
|
||||
const Eolian_Class *found_class = NULL;
|
||||
const Eolian_Class *candidate;
|
||||
if (cl) *cl = NULL;
|
||||
do
|
||||
{
|
||||
colon = strchr(colon, '.');
|
||||
if (colon) *colon = '\0';
|
||||
candidate = eolian_class_get_by_name(name);
|
||||
if (candidate)
|
||||
{
|
||||
if (found_class)
|
||||
{
|
||||
fprintf(stderr, "eolian: name clash between classes '%s' and '%s'\n",
|
||||
candidate->full_name,
|
||||
found_class->full_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 EINA_FALSE; // Names clash
|
||||
}
|
||||
found_class = candidate;
|
||||
}
|
||||
if (colon) *colon++ = '.';
|
||||
}
|
||||
while(colon);
|
||||
if (cl) *cl = found_class;
|
||||
free(name);
|
||||
return EINA_TRUE;
|
||||
return found;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
|
|
|
@ -284,7 +284,7 @@ int database_shutdown(void);
|
|||
|
||||
char *database_class_to_filename(const char *cname);
|
||||
Eina_Bool database_validate(Eina_Bool silent_types);
|
||||
Eina_Bool database_class_name_validate(const char *class_name, const Eolian_Class **cl);
|
||||
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