summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-10-25 18:00:50 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-10-25 18:03:09 -0200
commitf05a799daa6ec5e362a4376ee5d2b9ef011cd377 (patch)
treee1d82c9654ac5a38e2263712936adb2c65f09f92 /src/lib/eolian_cxx/grammar
parenta7bb770e699ca1dadb958832b2d2131a9c63216f (diff)
eolian-cxx: Fix multiple definitions in forward declaration
Diffstat (limited to 'src/lib/eolian_cxx/grammar')
-rw-r--r--src/lib/eolian_cxx/grammar/class_declaration.hpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/eolian_cxx/grammar/class_declaration.hpp b/src/lib/eolian_cxx/grammar/class_declaration.hpp
index 7c9957f07d..d448c31074 100644
--- a/src/lib/eolian_cxx/grammar/class_declaration.hpp
+++ b/src/lib/eolian_cxx/grammar/class_declaration.hpp
@@ -21,6 +21,19 @@ struct class_declaration_generator
21 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const 21 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& context) const
22 { 22 {
23 std::vector<std::string> cpp_namespaces = attributes::cpp_namespaces(cls.namespaces); 23 std::vector<std::string> cpp_namespaces = attributes::cpp_namespaces(cls.namespaces);
24
25 std::string guard_symbol;
26
27 if(!as_generator(*(string << "_") << string << "_FWD_GUARD")
28 .generate(std::back_inserter(guard_symbol)
29 , std::make_tuple(cpp_namespaces, cls.cxx_name), add_upper_case_context(context)))
30 return false;
31
32 if(!as_generator( "#ifndef " << guard_symbol << "\n"
33 << "#define " << guard_symbol << "\n")
34 .generate(sink, std::make_tuple(), context))
35 return false;
36
24 auto open_namespace = *("namespace " << string << " { ") << "\n"; 37 auto open_namespace = *("namespace " << string << " { ") << "\n";
25 if(!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context))) return false; 38 if(!as_generator(open_namespace).generate(sink, cpp_namespaces, add_lower_case_context(context))) return false;
26 39
@@ -32,7 +45,7 @@ struct class_declaration_generator
32 auto close_namespace = *(lit("} ")) << "\n"; 45 auto close_namespace = *(lit("} ")) << "\n";
33 if(!as_generator(close_namespace).generate(sink, cpp_namespaces, context)) return false; 46 if(!as_generator(close_namespace).generate(sink, cpp_namespaces, context)) return false;
34 47
35 if(type_traits) 48 // if(type_traits)
36 if(!as_generator 49 if(!as_generator
37 ( 50 (
38 "namespace efl { namespace eo { template<> struct is_eolian_object< " 51 "namespace efl { namespace eo { template<> struct is_eolian_object< "
@@ -49,6 +62,10 @@ struct class_declaration_generator
49 , cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name 62 , cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name
50 ), context)) return false; 63 ), context)) return false;
51 64
65 if(!as_generator("#endif\n")
66 .generate(sink, std::make_tuple(), context))
67 return false;
68
52 69
53 return true; 70 return true;
54 } 71 }