q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8df2686d9023cac7420fbad0f1d0db105c344d85

commit 8df2686d9023cac7420fbad0f1d0db105c344d85
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Fri May 6 12:56:16 2016 +0100

    eolian: lift restriction on namespace/class name conflicts in library
    
    This will allow us to name classes the same as namespaces.
---
 src/lib/eolian/database_constructor_api.c | 17 ++-----------
 src/lib/eolian/database_implement_api.c   | 17 ++-----------
 src/lib/eolian/eolian_database.c          | 41 ++++++-------------------------
 src/lib/eolian/eolian_database.h          |  2 +-
 4 files changed, 13 insertions(+), 64 deletions(-)

diff --git a/src/lib/eolian/database_constructor_api.c 
b/src/lib/eolian/database_constructor_api.c
index 9e44e75..6eedefd 100644
--- a/src/lib/eolian/database_constructor_api.c
+++ b/src/lib/eolian/database_constructor_api.c
@@ -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 *
diff --git a/src/lib/eolian/database_implement_api.c 
b/src/lib/eolian/database_implement_api.c
index 7d3fd2c..8f628c4 100644
--- a/src/lib/eolian/database_implement_api.c
+++ b/src/lib/eolian/database_implement_api.c
@@ -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 *
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 67f056e..8520ca4 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -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);
-                  free(name);
-                  return EINA_FALSE; // Names clash
-               }
-             found_class = candidate;
-          }
-        if (colon) *colon++ = '.';
-     }
-   while(colon);
-   if (cl) *cl = found_class;
+   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_TRUE;
+   return found;
 }
 
 EAPI Eina_Bool
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index d57ea30..a232ff6 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -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);

-- 


Reply via email to