summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/class_implementation.hpp
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-15 15:47:50 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2016-06-15 15:50:04 -0300
commit3a7af71079c787828655172b442a4e480e754e4c (patch)
treeb02faf388218249de8f02bfa14afd0a47d1811fb /src/lib/eolian_cxx/grammar/class_implementation.hpp
parent512fb7f39b9bcbd0630bba84e5a3f794f622be06 (diff)
eolian-cxx: Fixed generation of implicit conversion operators
Diffstat (limited to 'src/lib/eolian_cxx/grammar/class_implementation.hpp')
-rw-r--r--src/lib/eolian_cxx/grammar/class_implementation.hpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/lib/eolian_cxx/grammar/class_implementation.hpp b/src/lib/eolian_cxx/grammar/class_implementation.hpp
index de4341fc04..093d7af8ad 100644
--- a/src/lib/eolian_cxx/grammar/class_implementation.hpp
+++ b/src/lib/eolian_cxx/grammar/class_implementation.hpp
@@ -22,22 +22,32 @@ struct class_implementation_generator
22 template <typename OutputIterator, typename Context> 22 template <typename OutputIterator, typename Context>
23 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& ctx) const 23 bool generate(OutputIterator sink, attributes::klass_def const& cls, Context const& ctx) const
24 { 24 {
25 std::vector<std::string> cpp_namespaces = attributes::cpp_namespaces(cls.namespaces);
26 auto base_class_name = *(lower_case[string] << "::") << string;
27 auto class_name = *(lit("::") << lower_case[string]) << "::" << string;
25 return as_generator 28 return as_generator
26 ( 29 (
27 (namespaces 30 (namespaces
28 [*function_definition(get_klass_name(cls))] 31 [*function_definition(get_klass_name(cls))]
29 // << "namespace eo_cxx {\n" 32 << "\n"
30 // << namespaces
31 // [*function_definition(get_klass_name(cls))]
32 // << "}\n\n"
33 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions), ctx) 33 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions), ctx)
34 && as_generator 34 && as_generator
35 ( 35 (
36 "namespace eo_cxx {\n" 36 attribute_reorder<0, 1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3>
37 << namespaces 37 (
38 [*function_definition(get_klass_name(cls))] 38 "namespace eo_cxx {\n"
39 << "}\n\n" 39 << namespaces
40 ).generate(sink, std::make_tuple(cls.namespaces, cls.functions), ctx); 40 [
41 *function_definition(get_klass_name(cls))
42 << base_class_name << "::operator " << class_name << "() const { return *static_cast< "
43 << class_name << " const*>(static_cast<void const*>(this)); }\n"
44 << base_class_name << "::operator " << class_name << "&() { return *static_cast< "
45 << class_name << "*>(static_cast<void*>(this)); }\n"
46 << base_class_name << "::operator " << class_name << " const&() const { return *static_cast< "
47 << class_name << " const*>(static_cast<void const*>(this)); }\n"
48 ]
49 << "}\n\n"
50 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces, cls.cxx_name), ctx);
41 } 51 }
42}; 52};
43 53