summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-09-07 18:02:43 +0900
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-09-08 11:47:29 +0900
commit48b3c127f7c4e7ffc7dbf66013c3ec2812ae9a5f (patch)
tree30f2a04e2b8ae4fa69e700bc1103a8ea4aaba31b /src/lib/eolian_cxx
parentff96e30c7239118b349883f8b1b882e9c64d10c5 (diff)
eo-cxx: Require instantiate keyword for constructors calling efl_add to avoid ambiguity
Diffstat (limited to 'src/lib/eolian_cxx')
-rw-r--r--src/lib/eolian_cxx/grammar/class_declaration.hpp12
-rw-r--r--src/lib/eolian_cxx/grammar/class_definition.hpp37
2 files changed, 41 insertions, 8 deletions
diff --git a/src/lib/eolian_cxx/grammar/class_declaration.hpp b/src/lib/eolian_cxx/grammar/class_declaration.hpp
index bed1a5696f..7c9957f07d 100644
--- a/src/lib/eolian_cxx/grammar/class_declaration.hpp
+++ b/src/lib/eolian_cxx/grammar/class_declaration.hpp
@@ -37,7 +37,17 @@ struct class_declaration_generator
37 ( 37 (
38 "namespace efl { namespace eo { template<> struct is_eolian_object< " 38 "namespace efl { namespace eo { template<> struct is_eolian_object< "
39 "::" << *(lower_case[string] << "::") << string << "> : ::std::true_type {}; } }\n" 39 "::" << *(lower_case[string] << "::") << string << "> : ::std::true_type {}; } }\n"
40 ).generate(sink, std::make_tuple(cpp_namespaces, cls.cxx_name), context)) return false; 40 "namespace efl { namespace eo { template<> struct is_eolian_object< "
41 "::" << *(lower_case[string] << "::") << string << "&> : ::std::true_type {}; } }\n"
42 "namespace efl { namespace eo { template<> struct is_eolian_object< "
43 "::" << *(lower_case[string] << "::") << string << " const> : ::std::true_type {}; } }\n"
44 "namespace efl { namespace eo { template<> struct is_eolian_object< "
45 "::" << *(lower_case[string] << "::") << string << " const&> : ::std::true_type {}; } }\n"
46 ).generate(sink, std::make_tuple
47 (
48 cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name
49 , cpp_namespaces, cls.cxx_name, cpp_namespaces, cls.cxx_name
50 ), context)) return false;
41 51
42 52
43 return true; 53 return true;
diff --git a/src/lib/eolian_cxx/grammar/class_definition.hpp b/src/lib/eolian_cxx/grammar/class_definition.hpp
index c05ea6d0bf..2e53b6e6a7 100644
--- a/src/lib/eolian_cxx/grammar/class_definition.hpp
+++ b/src/lib/eolian_cxx/grammar/class_definition.hpp
@@ -29,7 +29,7 @@ struct class_definition_generator
29 29
30 if(!as_generator 30 if(!as_generator
31 ( 31 (
32 "struct " << string << " : ::efl::eo::concrete" 32 "struct " << string << " : private ::efl::eo::concrete"
33 ) 33 )
34 .generate(sink, cls.cxx_name, context)) 34 .generate(sink, cls.cxx_name, context))
35 return false; 35 return false;
@@ -46,25 +46,34 @@ struct class_definition_generator
46 ( 46 (
47 scope_tab << "explicit " << string << "( ::Eo* eo)\n" 47 scope_tab << "explicit " << string << "( ::Eo* eo)\n"
48 << scope_tab << scope_tab << ": ::efl::eo::concrete(eo) {}\n" 48 << scope_tab << scope_tab << ": ::efl::eo::concrete(eo) {}\n"
49 << scope_tab << "explicit " << string << "(std::nullptr_t)\n" 49 << scope_tab << string << "(std::nullptr_t)\n"
50 << scope_tab << scope_tab << ": ::efl::eo::concrete(nullptr) {}\n" 50 << scope_tab << scope_tab << ": ::efl::eo::concrete(nullptr) {}\n"
51 << scope_tab << "explicit " << string << "() = default;\n"
51 << scope_tab << string << "(" << string << " const& other) = default;\n" 52 << scope_tab << string << "(" << string << " const& other) = default;\n"
52 << scope_tab << string << "(" << string << "&& other) = default;\n" 53 << scope_tab << string << "(" << string << "&& other) = default;\n"
53 << scope_tab << string << "& operator=(" << string << " const& other) = default;\n" 54 << scope_tab << string << "& operator=(" << string << " const& other) = default;\n"
54 << scope_tab << string << "& operator=(" << string << "&& other) = default;\n" 55 << scope_tab << string << "& operator=(" << string << "&& other) = default;\n"
55 << scope_tab << string << "()\n" 56 << scope_tab << "template <typename Derived>\n"
57 << scope_tab << string << "(Derived&& derived\n"
58 << scope_tab << scope_tab << ", typename std::enable_if<\n"
59 << scope_tab << scope_tab << scope_tab << "::efl::eo::is_eolian_object<Derived>::value\n"
60 << scope_tab << scope_tab << scope_tab << " && std::is_base_of< " << string << ", Derived>::value"
61 << scope_tab << scope_tab << scope_tab << ">::type* = 0) : ::efl::eo::concrete(derived._eo_ptr())\n"
62 << scope_tab << "{}\n"
63 << scope_tab << string << "( ::efl::eo::instantiate_t)\n"
56 << scope_tab << "{\n" 64 << scope_tab << "{\n"
57 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, ::efl::eo::concrete{nullptr}, _eo_class());\n" 65 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, ::efl::eo::concrete{nullptr}, _eo_class());\n"
58 << scope_tab << "}\n" 66 << scope_tab << "}\n"
59 << scope_tab << string << "( ::efl::eo::concrete parent)\n" 67 << scope_tab << "template <typename T>\n"
68 << scope_tab << "explicit " << string << "( ::efl::eo::instantiate_t, T&& parent, typename std::enable_if< ::efl::eo::is_eolian_object<T>::value>::type* = 0)\n"
60 << scope_tab << "{\n" 69 << scope_tab << "{\n"
61 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, parent, _eo_class());\n" 70 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, parent, _eo_class());\n"
62 << scope_tab << "}\n" 71 << scope_tab << "}\n"
63 << scope_tab << "template <typename F> " << string << "(F f, typename ::std::enable_if< ::efl::eolian::is_callable<F>::value>::type* = 0)\n" 72 << scope_tab << "template <typename F> " << string << "( ::efl::eo::instantiate_t, F f, typename ::std::enable_if< ::efl::eolian::is_callable<F>::value>::type* = 0)\n"
64 << scope_tab << "{\n" 73 << scope_tab << "{\n"
65 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, ::efl::eo::concrete{nullptr}, _eo_class(), f);\n" 74 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, ::efl::eo::concrete{nullptr}, _eo_class(), f);\n"
66 << scope_tab << "}\n" 75 << scope_tab << "}\n"
67 << scope_tab << "template <typename F> " << string << "( ::efl::eo::concrete parent, F f, typename ::std::enable_if< ::efl::eolian::is_callable<F>::value>::type* = 0)\n" 76 << scope_tab << "template <typename F> " << string << "( ::efl::eo::instantiate_t, ::efl::eo::concrete parent, F f, typename ::std::enable_if< ::efl::eolian::is_callable<F>::value>::type* = 0)\n"
68 << scope_tab << "{\n" 77 << scope_tab << "{\n"
69 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, parent, _eo_class(), f);\n" 78 << scope_tab << scope_tab << "::efl::eolian::do_eo_add( ::efl::eo::concrete::_eo_raw, parent, _eo_class(), f);\n"
70 << scope_tab << "}\n" 79 << scope_tab << "}\n"
@@ -161,8 +170,22 @@ struct class_definition_generator
161 // /// @endcond 170 // /// @endcond
162 if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false; 171 if(!as_generator(scope_tab << "/// @endcond\n").generate(sink, attributes::unused, context)) return false;
163 172
164 if(!as_generator("};\n").generate(sink, attributes::unused, context)) return false; 173 if(!as_generator( scope_tab << "::efl::eo::concrete const& _get_concrete() const { return *this; }\n"
174 << scope_tab << "::efl::eo::concrete& _get_concrete() { return *this; }\n"
175 ).generate(sink, attributes::unused, context)) return false;
176
177 if(!as_generator( scope_tab << "using ::efl::eo::concrete::_eo_ptr;\n"
178 << scope_tab << "using ::efl::eo::concrete::_release;\n"
179 << scope_tab << "using ::efl::eo::concrete::_reset;\n"
180 << scope_tab << "using ::efl::eo::concrete::operator bool;\n"
181 ).generate(sink, attributes::unused, context)) return false;
165 182
183 if(!as_generator( scope_tab << "friend bool operator==(" << string << " const& lhs, " << string << " const& rhs)\n"
184 << scope_tab << "{ return lhs._get_concrete() == rhs._get_concrete(); }\n"
185 << scope_tab << "friend bool operator!=(" << string << " const& lhs, " << string << " const& rhs)\n"
186 << scope_tab << "{ return !(lhs == rhs); }\n"
187 << "};\n").generate(sink, attributes::make_infinite_tuple(cls.cxx_name), context)) return false;
188
166 // static asserts 189 // static asserts
167 if(!as_generator("static_assert(sizeof(" << string << ") == sizeof(Eo*), \"\");\n") 190 if(!as_generator("static_assert(sizeof(" << string << ") == sizeof(Eo*), \"\");\n")
168 .generate(sink, cls.cxx_name, context)) return false; 191 .generate(sink, cls.cxx_name, context)) return false;