jpeg pushed a commit to branch master.

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

commit c6dfdeb0c8d0122c848e959cfb73d529c44d5176
Author: Jean-Philippe Andre <[email protected]>
Date:   Tue Jun 14 16:20:51 2016 +0900

    cxx: Add support for protected and beta events
    
    The code is horrible, pardon my C++.
    
    Note: I guess @protected should also change the scope from
    public: to protected: but that's another problem. Here I'm only
    trying to fix the build while still introducing @beta and
    @protected flags.
---
 src/lib/eolian_cxx/grammar/class_definition.hpp | 53 ++++++++++++++++++-------
 src/lib/eolian_cxx/grammar/klass_def.hpp        |  9 +++--
 2 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp 
b/src/lib/eolian_cxx/grammar/class_definition.hpp
index cbf45ad..8c451bc 100644
--- a/src/lib/eolian_cxx/grammar/class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/class_definition.hpp
@@ -110,21 +110,44 @@ struct class_definition_generator
          scope_tab << "Eo* _eo_ptr() const { return *(Eo**)this; }\n"
         ).generate(sink, attributes::unused, context)) return false;
      
-     if(!as_generator
-        (
-         *attribute_reorder<1, 2, 0, 1>
-         ((scope_tab << "static struct " << string_replace(',', '_') << 
"_event\n"
-           << scope_tab << "{\n"
-           << scope_tab << scope_tab << "static Eo_Event_Description const* 
description()\n"
-           << scope_tab << scope_tab << "{ return " << string << "; }\n"
-           << scope_tab << scope_tab << "typedef "
-           << (attribute_conditional([] (eina::optional<attributes::type_def> 
t) { return !!t; })
-               [attribute_replace([] (eina::optional<attributes::type_def> t) 
{ return *t; }) [type]]
-               | "void")
-           << " parameter_type;\n"
-           << scope_tab << "} const " << string_replace(',', '_') << 
"_event;\n"
-        ))).generate(sink, cls.events, context))
-       return false;
+     for (auto&& e : cls.events)
+       {
+          if (e.beta)
+            {
+               suffix = "BETA";
+               if(!as_generator
+                     ("#ifdef " << *(string << "_") << string << "_" << string 
<< "\n")
+                     .generate(sink, std::make_tuple(cls.namespaces, 
cls.eolian_name, suffix), add_upper_case_context(context)))
+                 return false;
+            }
+          if (e.protect)
+            {
+               suffix = "PROTECTED";
+               if(!as_generator
+                     ("#ifdef " << *(string << "_") << string << "_" << string 
<< "\n")
+                     .generate(sink, std::make_tuple(cls.namespaces, 
cls.eolian_name, suffix), add_upper_case_context(context)))
+                 return false;
+            }
+          if(!as_generator
+             (
+              *attribute_reorder<1, 2, 0, 1>
+              ((scope_tab << "static struct " << string_replace(',', '_') << 
"_event\n"
+                << scope_tab << "{\n"
+                << scope_tab << scope_tab << "static Eo_Event_Description 
const* description()\n"
+                << scope_tab << scope_tab << "{ return " << string << "; }\n"
+                << scope_tab << scope_tab << "typedef "
+                << (attribute_conditional([] 
(eina::optional<attributes::type_def> t) { return !!t; })
+                    [attribute_replace([] 
(eina::optional<attributes::type_def> t) { return *t; }) [type]]
+                    | "void")
+                << " parameter_type;\n"
+                << scope_tab << "} const " << string_replace(',', '_') << 
"_event;\n"
+             ))).generate(sink, std::vector<attributes::event_def>{e}, 
context))
+            return false;
+          if (e.beta && !as_generator("#endif\n").generate(sink, 
attributes::unused, context))
+            return false;
+          if (e.protect && !as_generator("#endif\n").generate(sink, 
attributes::unused, context))
+            return false;
+       }
      
      // /// @cond LOCAL
      if(!as_generator(scope_tab << "/// @cond LOCAL\n").generate(sink, 
attributes::unused, context)) return false;
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp 
b/src/lib/eolian_cxx/grammar/klass_def.hpp
index 56d408f..b42d6f2 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -532,13 +532,16 @@ struct event_def
 {
   eina::optional<type_def> type;
   std::string name, c_name;
+  bool beta, protect;
 
-  event_def(type_def type, std::string name, std::string c_name)
-    : type(type), name(name), c_name(c_name) {}
+  event_def(type_def type, std::string name, std::string c_name, bool beta, 
bool protect)
+    : type(type), name(name), c_name(c_name), beta(beta), protect(protect) {}
   event_def(Eolian_Event const* event)
     : type( ::eolian_event_type_get(event) ? ::eolian_event_type_get(event) : 
eina::optional<type_def>{})
     , name( ::eolian_event_name_get(event))
-    , c_name( ::eolian_event_c_name_get(event)) {}
+    , c_name( ::eolian_event_c_name_get(event))
+    , beta( ::eolian_event_is_beta(event))
+    , protect( ::eolian_event_scope_get(event) == EOLIAN_SCOPE_PROTECTED){}
 };
 
 template <>

-- 


Reply via email to