summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/class_declaration.hpp
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-01-18 22:25:02 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-01-18 22:47:04 -0200
commita1f2db255b22052050baf0c04bb72146b22a6e99 (patch)
tree8499c057a7a0054f75fe3ab4719b2cc3659949d5 /src/lib/eolian_cxx/grammar/class_declaration.hpp
parent7f148feea8275d4ae3a366e5aead8170498089a6 (diff)
cxx: Modify how to generate C++ headers and allow cyclic dependencies
Allow cyclic dependencies in generated C++ headers by changing order of includes and creating forward declarations.
Diffstat (limited to 'src/lib/eolian_cxx/grammar/class_declaration.hpp')
-rw-r--r--src/lib/eolian_cxx/grammar/class_declaration.hpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/eolian_cxx/grammar/class_declaration.hpp b/src/lib/eolian_cxx/grammar/class_declaration.hpp
index 6f23641e4d..bed1a5696f 100644
--- a/src/lib/eolian_cxx/grammar/class_declaration.hpp
+++ b/src/lib/eolian_cxx/grammar/class_declaration.hpp
@@ -15,6 +15,8 @@ namespace efl { namespace eolian { namespace grammar {
15 15
16struct class_declaration_generator 16struct class_declaration_generator
17{ 17{
18 bool type_traits;
19
18 template <typename OutputIterator, typename Context> 20 template <typename OutputIterator, typename Context>
19 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
20 { 22 {
@@ -30,11 +32,12 @@ struct class_declaration_generator
30 auto close_namespace = *(lit("} ")) << "\n"; 32 auto close_namespace = *(lit("} ")) << "\n";
31 if(!as_generator(close_namespace).generate(sink, cpp_namespaces, context)) return false; 33 if(!as_generator(close_namespace).generate(sink, cpp_namespaces, context)) return false;
32 34
33 if(!as_generator 35 if(type_traits)
34 ( 36 if(!as_generator
35 "namespace efl { namespace eo { template<> struct is_eolian_object< " 37 (
36 "::" << *(lower_case[string] << "::") << string << "> : ::std::true_type {}; } }\n" 38 "namespace efl { namespace eo { template<> struct is_eolian_object< "
37 ).generate(sink, std::make_tuple(cpp_namespaces, cls.cxx_name), context)) return false; 39 "::" << *(lower_case[string] << "::") << string << "> : ::std::true_type {}; } }\n"
40 ).generate(sink, std::make_tuple(cpp_namespaces, cls.cxx_name), context)) return false;
38 41
39 42
40 return true; 43 return true;
@@ -49,7 +52,8 @@ template <>
49struct attributes_needed<class_declaration_generator> : std::integral_constant<int, 1> {}; 52struct attributes_needed<class_declaration_generator> : std::integral_constant<int, 1> {};
50} 53}
51 54
52class_declaration_generator const class_declaration = {}; 55class_declaration_generator const class_declaration = {true};
56class_declaration_generator const class_forward_declaration = {false};
53 57
54} } } 58} } }
55 59