summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-06-14 16:20:51 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-06-14 16:27:42 +0900
commitc6dfdeb0c8d0122c848e959cfb73d529c44d5176 (patch)
treef534ffd3bf2cffe9359670cfeb8b4140a6737c9f /src/lib/eolian_cxx
parent8a0e74afa820769a4fe41a61a502cac96c9626e3 (diff)
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.
Diffstat (limited to 'src/lib/eolian_cxx')
-rw-r--r--src/lib/eolian_cxx/grammar/class_definition.hpp53
-rw-r--r--src/lib/eolian_cxx/grammar/klass_def.hpp9
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 cbf45ad92a..8c451bc9ef 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
110 scope_tab << "Eo* _eo_ptr() const { return *(Eo**)this; }\n" 110 scope_tab << "Eo* _eo_ptr() const { return *(Eo**)this; }\n"
111 ).generate(sink, attributes::unused, context)) return false; 111 ).generate(sink, attributes::unused, context)) return false;
112 112
113 if(!as_generator 113 for (auto&& e : cls.events)
114 ( 114 {
115 *attribute_reorder<1, 2, 0, 1> 115 if (e.beta)
116 ((scope_tab << "static struct " << string_replace(',', '_') << "_event\n" 116 {
117 << scope_tab << "{\n" 117 suffix = "BETA";
118 << scope_tab << scope_tab << "static Eo_Event_Description const* description()\n" 118 if(!as_generator
119 << scope_tab << scope_tab << "{ return " << string << "; }\n" 119 ("#ifdef " << *(string << "_") << string << "_" << string << "\n")
120 << scope_tab << scope_tab << "typedef " 120 .generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name, suffix), add_upper_case_context(context)))
121 << (attribute_conditional([] (eina::optional<attributes::type_def> t) { return !!t; }) 121 return false;
122 [attribute_replace([] (eina::optional<attributes::type_def> t) { return *t; }) [type]] 122 }
123 | "void") 123 if (e.protect)
124 << " parameter_type;\n" 124 {
125 << scope_tab << "} const " << string_replace(',', '_') << "_event;\n" 125 suffix = "PROTECTED";
126 ))).generate(sink, cls.events, context)) 126 if(!as_generator
127 return false; 127 ("#ifdef " << *(string << "_") << string << "_" << string << "\n")
128 .generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name, suffix), add_upper_case_context(context)))
129 return false;
130 }
131 if(!as_generator
132 (
133 *attribute_reorder<1, 2, 0, 1>
134 ((scope_tab << "static struct " << string_replace(',', '_') << "_event\n"
135 << scope_tab << "{\n"
136 << scope_tab << scope_tab << "static Eo_Event_Description const* description()\n"
137 << scope_tab << scope_tab << "{ return " << string << "; }\n"
138 << scope_tab << scope_tab << "typedef "
139 << (attribute_conditional([] (eina::optional<attributes::type_def> t) { return !!t; })
140 [attribute_replace([] (eina::optional<attributes::type_def> t) { return *t; }) [type]]
141 | "void")
142 << " parameter_type;\n"
143 << scope_tab << "} const " << string_replace(',', '_') << "_event;\n"
144 ))).generate(sink, std::vector<attributes::event_def>{e}, context))
145 return false;
146 if (e.beta && !as_generator("#endif\n").generate(sink, attributes::unused, context))
147 return false;
148 if (e.protect && !as_generator("#endif\n").generate(sink, attributes::unused, context))
149 return false;
150 }
128 151
129 // /// @cond LOCAL 152 // /// @cond LOCAL
130 if(!as_generator(scope_tab << "/// @cond LOCAL\n").generate(sink, attributes::unused, context)) return false; 153 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 56d408f306..b42d6f2d44 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
532{ 532{
533 eina::optional<type_def> type; 533 eina::optional<type_def> type;
534 std::string name, c_name; 534 std::string name, c_name;
535 bool beta, protect;
535 536
536 event_def(type_def type, std::string name, std::string c_name) 537 event_def(type_def type, std::string name, std::string c_name, bool beta, bool protect)
537 : type(type), name(name), c_name(c_name) {} 538 : type(type), name(name), c_name(c_name), beta(beta), protect(protect) {}
538 event_def(Eolian_Event const* event) 539 event_def(Eolian_Event const* event)
539 : type( ::eolian_event_type_get(event) ? ::eolian_event_type_get(event) : eina::optional<type_def>{}) 540 : type( ::eolian_event_type_get(event) ? ::eolian_event_type_get(event) : eina::optional<type_def>{})
540 , name( ::eolian_event_name_get(event)) 541 , name( ::eolian_event_name_get(event))
541 , c_name( ::eolian_event_c_name_get(event)) {} 542 , c_name( ::eolian_event_c_name_get(event))
543 , beta( ::eolian_event_is_beta(event))
544 , protect( ::eolian_event_scope_get(event) == EOLIAN_SCOPE_PROTECTED){}
542}; 545};
543 546
544template <> 547template <>