summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-28 22:03:17 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-11-28 22:20:21 +0900
commit1f36ec4d0855bdfcb8e81ed3dc9408934ed3dda4 (patch)
tree3f4406d0d21dfb1be64c51e4c4cbac5d8ddb12a2
parent0d35b848ca470f9d9fd8f83f3d0c2c9ea32d1055 (diff)
cxx: Add ability to manually define new methodsdevs/jpeg/cxx
This adds a set of macros that, if defined, will be part of the class definition and implementation: Example: ifdef EOLIAN_CXX_EFL_UI_WIN_EXTRA_DECLARATIONS EOLIAN_CXX_EFL_UI_WIN_EXTRA_DECLARATIONS endif ifdef EOLIAN_CXX_EFL_UI_WIN_EXTRA_IMPLEMENTATIONS EOLIAN_CXX_EFL_UI_WIN_EXTRA_IMPLEMENTATIONS endif This feature is disable by default. Not sure we'll need it.
-rw-r--r--src/lib/eolian_cxx/grammar/base_class_definition.hpp10
-rw-r--r--src/lib/eolian_cxx/grammar/class_declaration.hpp2
-rw-r--r--src/lib/eolian_cxx/grammar/class_definition.hpp21
-rw-r--r--src/lib/eolian_cxx/grammar/class_implementation.hpp32
-rw-r--r--src/lib/eolian_cxx/grammar/generator.hpp1
5 files changed, 52 insertions, 14 deletions
diff --git a/src/lib/eolian_cxx/grammar/base_class_definition.hpp b/src/lib/eolian_cxx/grammar/base_class_definition.hpp
index 22c2847e5f..69ed79ac74 100644
--- a/src/lib/eolian_cxx/grammar/base_class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/base_class_definition.hpp
@@ -40,6 +40,16 @@ struct base_class_definition_generator
40 if(!as_generator(*(part_declaration << ";\n")) 40 if(!as_generator(*(part_declaration << ";\n"))
41 .generate(sink, cls.parts, context)) return false; 41 .generate(sink, cls.parts, context)) return false;
42 42
43#ifdef USE_EXTRA_IMPLEMENTATIONS
44 if(!as_generator
45 ("#ifdef EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
46 << scope_tab << "EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
47 << "#endif\n")
48 .generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name,
49 cls.namespaces, cls.eolian_name), add_upper_case_context(context)))
50 return false;
51#endif
52
43 // static Efl_Class const* _eo_class(); 53 // static Efl_Class const* _eo_class();
44 std::string suffix; 54 std::string suffix;
45 switch(cls.type) 55 switch(cls.type)
diff --git a/src/lib/eolian_cxx/grammar/class_declaration.hpp b/src/lib/eolian_cxx/grammar/class_declaration.hpp
index d448c31074..7a3908b9e5 100644
--- a/src/lib/eolian_cxx/grammar/class_declaration.hpp
+++ b/src/lib/eolian_cxx/grammar/class_declaration.hpp
@@ -66,7 +66,7 @@ struct class_declaration_generator
66 .generate(sink, std::make_tuple(), context)) 66 .generate(sink, std::make_tuple(), context))
67 return false; 67 return false;
68 68
69 69
70 return true; 70 return true;
71 } 71 }
72}; 72};
diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp
index 0ed997a848..af4dd5ca92 100644
--- a/src/lib/eolian_cxx/grammar/class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/class_definition.hpp
@@ -208,15 +208,28 @@ struct class_definition_generator
208 if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false; 208 if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false;
209 209
210 // EXPERIMENTAL: Parts 210 // EXPERIMENTAL: Parts
211 if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false; 211 if (!cls.parts.empty())
212 if(!as_generator(*(scope_tab << part_declaration << ";\n")) 212 {
213 .generate(sink, cls.parts, context)) return false; 213 if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false;
214 if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false; 214 if(!as_generator(*(scope_tab << part_declaration << ";\n"))
215 .generate(sink, cls.parts, context)) return false;
216 if(!as_generator("#endif \n").generate(sink, attributes::unused, context)) return false;
217 }
215 218
216 if(!as_generator( scope_tab << "::efl::eo::wref<" << string << "> _get_wref() const { " 219 if(!as_generator( scope_tab << "::efl::eo::wref<" << string << "> _get_wref() const { "
217 "return ::efl::eo::wref<" << string << ">(*this); }\n" 220 "return ::efl::eo::wref<" << string << ">(*this); }\n"
218 ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false; 221 ).generate(sink, std::make_tuple(cls.cxx_name, cls.cxx_name), context)) return false;
219 222
223#ifdef USE_EXTRA_IMPLEMENTATIONS
224 if(!as_generator
225 ("#ifdef EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
226 << scope_tab << "EOLIAN_CXX_" << *(string << "_") << string << "_EXTRA_DECLARATIONS\n"
227 << "#endif\n")
228 .generate(sink, std::make_tuple(cls.namespaces, cls.eolian_name,
229 cls.namespaces, cls.eolian_name), add_upper_case_context(context)))
230 return false;
231#endif
232
220 // EXPERIMENTAL: wref and implicit conversion to Eo* 233 // EXPERIMENTAL: wref and implicit conversion to Eo*
221 if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false; 234 if(!as_generator("#ifdef EFL_CXXPERIMENTAL\n").generate(sink, attributes::unused, context)) return false;
222 // For easy wref, operator-> in wref needs to also return a pointer type 235 // For easy wref, operator-> in wref needs to also return a pointer type
diff --git a/src/lib/eolian_cxx/grammar/class_implementation.hpp b/src/lib/eolian_cxx/grammar/class_implementation.hpp
index e960c009df..bc6e650f4f 100644
--- a/src/lib/eolian_cxx/grammar/class_implementation.hpp
+++ b/src/lib/eolian_cxx/grammar/class_implementation.hpp
@@ -26,15 +26,15 @@ struct class_implementation_generator
26 std::vector<std::string> cpp_namespaces = attributes::cpp_namespaces(cls.namespaces); 26 std::vector<std::string> cpp_namespaces = attributes::cpp_namespaces(cls.namespaces);
27 auto base_class_name = *(lower_case[string] << "::") << string; 27 auto base_class_name = *(lower_case[string] << "::") << string;
28 auto class_name = *(lit("::") << lower_case[string]) << "::" << string; 28 auto class_name = *(lit("::") << lower_case[string]) << "::" << string;
29 std::string guard_symbol; 29 std::string class_uppercase;
30 30
31 if(!as_generator(*(string << "_") << string << "_IMPL_HH") 31 if(!as_generator(*(string << "_") << string)
32 .generate(std::back_inserter(guard_symbol) 32 .generate(std::back_inserter(class_uppercase)
33 , std::make_tuple(cpp_namespaces, cls.cxx_name), add_upper_case_context(ctx))) 33 , std::make_tuple(cpp_namespaces, cls.cxx_name), add_upper_case_context(ctx)))
34 return false; 34 return false;
35 35
36 if(!as_generator( "#ifndef " << guard_symbol << "\n" 36 if(!as_generator( "#ifndef " << class_uppercase << "_IMPL_HH\n"
37 << "#define " << guard_symbol << "\n") 37 << "#define " << class_uppercase << "_IMPL_HH\n")
38 .generate(sink, std::make_tuple(), ctx)) 38 .generate(sink, std::make_tuple(), ctx))
39 return false; 39 return false;
40 40
@@ -46,14 +46,21 @@ struct class_implementation_generator
46 if(!as_generator( 46 if(!as_generator(
47 (namespaces 47 (namespaces
48 [*function_definition(get_klass_name(cls)) 48 [*function_definition(get_klass_name(cls))
49 << *part_implementation(cls.cxx_name)] 49 << *part_implementation(cls.cxx_name)
50#ifdef USE_EXTRA_IMPLEMENTATIONS
51 << "#ifdef EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
52 << scope_tab << "EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
53 << "#endif\n"
54#endif
55 ]
50 << "\n" 56 << "\n"
51 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cls.parts), ctx)) 57 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cls.parts,
58 class_uppercase, class_uppercase), ctx))
52 return false; 59 return false;
53#endif 60#endif
54 61
55 if(!as_generator( 62 if(!as_generator(
56 attribute_reorder<0, 1, 4, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3> 63 attribute_reorder<0, 1, 4, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 5, 5>
57 ( 64 (
58 "namespace eo_cxx {\n" 65 "namespace eo_cxx {\n"
59 << namespaces 66 << namespaces
@@ -66,9 +73,16 @@ struct class_implementation_generator
66 << class_name << "*>(static_cast<void*>(this)); }\n" 73 << class_name << "*>(static_cast<void*>(this)); }\n"
67 << "inline " << base_class_name << "::operator " << class_name << " const&() const { return *static_cast< " 74 << "inline " << base_class_name << "::operator " << class_name << " const&() const { return *static_cast< "
68 << class_name << " const*>(static_cast<void const*>(this)); }\n" 75 << class_name << " const*>(static_cast<void const*>(this)); }\n"
76#ifdef USE_EXTRA_IMPLEMENTATIONS
77 << "#ifdef EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
78 << scope_tab << "EOLIAN_CXX_" << string << "_EXTRA_IMPLEMENTATIONS\n"
79 << "#endif\n"
80#endif
69 ] 81 ]
70 << "}\n" 82 << "}\n"
71 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces, cls.cxx_name, cls.parts), ctx)) 83 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces,
84 cls.cxx_name, cls.parts,
85 class_uppercase), ctx))
72 return false; 86 return false;
73 87
74 if(!as_generator("#endif\n").generate(sink, std::make_tuple(), ctx)) 88 if(!as_generator("#endif\n").generate(sink, std::make_tuple(), ctx))
diff --git a/src/lib/eolian_cxx/grammar/generator.hpp b/src/lib/eolian_cxx/grammar/generator.hpp
index c2942605d0..741dfd6c13 100644
--- a/src/lib/eolian_cxx/grammar/generator.hpp
+++ b/src/lib/eolian_cxx/grammar/generator.hpp
@@ -5,6 +5,7 @@
5 5
6// EXPERIMENTAL 6// EXPERIMENTAL
7//#define USE_EOCXX_INHERIT_ONLY 7//#define USE_EOCXX_INHERIT_ONLY
8//#define USE_EXTRA_IMPLEMENTATIONS
8 9
9namespace efl { namespace eolian { namespace grammar { 10namespace efl { namespace eolian { namespace grammar {
10 11