summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx
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
parent512fb7f39b9bcbd0630bba84e5a3f794f622be06 (diff)
eolian-cxx: Fixed generation of implicit conversion operators
Diffstat (limited to 'src/lib/eolian_cxx')
-rw-r--r--src/lib/eolian_cxx/grammar/base_class_definition.hpp14
-rw-r--r--src/lib/eolian_cxx/grammar/class_implementation.hpp28
2 files changed, 27 insertions, 15 deletions
diff --git a/src/lib/eolian_cxx/grammar/base_class_definition.hpp b/src/lib/eolian_cxx/grammar/base_class_definition.hpp
index 99e7d191ce..c5a22ca1cd 100644
--- a/src/lib/eolian_cxx/grammar/base_class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/base_class_definition.hpp
@@ -13,6 +13,7 @@
13#include "grammar/namespace.hpp" 13#include "grammar/namespace.hpp"
14#include "grammar/case.hpp" 14#include "grammar/case.hpp"
15#include "grammar/address_of.hpp" 15#include "grammar/address_of.hpp"
16#include "grammar/attribute_reorder.hpp"
16 17
17namespace efl { namespace eolian { namespace grammar { 18namespace efl { namespace eolian { namespace grammar {
18 19
@@ -71,14 +72,15 @@ struct base_class_definition_generator
71 // operator ::ns::Class_Name() const; 72 // operator ::ns::Class_Name() const;
72 // operator ::ns::Class_Name&(); 73 // operator ::ns::Class_Name&();
73 // operator ::ns::Class_Name const&() const; 74 // operator ::ns::Class_Name const&() const;
75 auto class_name = *(lit("::") << lower_case[string]) << "::" << string;
74 if(!as_generator 76 if(!as_generator
75 ( 77 (
76 scope_tab << "operator " << *("::" << lower_case[string]) << "::" << string << "() const;\n" 78 attribute_reorder<0, 1, 0, 1, 0, 1, 0, 1>
77 << scope_tab << "operator " << *("::" << lower_case[string]) << "::" << string << "&();\n" 79 (
78 << scope_tab << "operator " << *("::" << lower_case[string]) << "::" << string << " const&() const;\n" 80 scope_tab << "operator " << class_name << "() const;\n"
79 ).generate(sink, std::make_tuple 81 << scope_tab << "operator " << class_name << "&();\n"
80 (cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name) 82 << scope_tab << "operator " << class_name << " const&() const;\n"
81 , context)) 83 )).generate(sink, std::make_tuple(cpp_namespaces, cls.cxx_name), context))
82 return false; 84 return false;
83 85
84 // /// @cond LOCAL 86 // /// @cond LOCAL
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