summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-12-14 15:06:12 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-01-17 21:36:27 +0900
commit7b342e8fddaff50dd62354f357a3d249afc77498 (patch)
treedde704c04fdbd8a3f6906518949a6c54a764e544 /src/bin/eolian_mono
parent92aab7830cbc3e8697d56440972835b6d8c67aba (diff)
eolian_mono: fix inheriting from efl types not considering additional interfaces
Reviewers: segfaultxavi, bu5hm4n, Jaehyun_Cho, lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7635
Diffstat (limited to 'src/bin/eolian_mono')
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh17
-rw-r--r--src/bin/eolian_mono/eolian/mono/name_helpers.hh31
2 files changed, 38 insertions, 10 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index a22a5a0..5dc22f5 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -128,6 +128,11 @@ struct klass
128 if(!as_generator(documentation).generate(sink, cls, iface_cxt)) 128 if(!as_generator(documentation).generate(sink, cls, iface_cxt))
129 return false; 129 return false;
130 130
131 // Mark the interface with the proper native Efl_Class* getter
132 if(!as_generator(lit("[") << name_helpers::interface_native_getter_attr_name(cls) << "]\n")
133 .generate(sink, attributes::unused, iface_cxt))
134 return false;
135
131 if(!as_generator 136 if(!as_generator
132 ( 137 (
133 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : " 138 "public " /*<< class_type*/ "interface" /*<<*/ " " << string << " : "
@@ -272,6 +277,16 @@ struct klass
272 277
273 if(!as_generator("}\n").generate(sink, attributes::unused, concrete_cxt)) return false; 278 if(!as_generator("}\n").generate(sink, attributes::unused, concrete_cxt)) return false;
274 279
280 // Attribute getter of the native 'Efl_Class *' handle (for proper inheritance from additional explicit interfaces)
281 if(!as_generator(lit("public class ") << name_helpers::interface_native_getter_attr_name(cls) << " : Efl.Eo.NativeGetterAttr\n"
282 << "{\n"
283 << scope_tab << "public override IntPtr GetEflClass()\n"
284 << scope_tab << "{\n"
285 << scope_tab << scope_tab << "return " << name_helpers::klass_get_full_name(cls) << "();\n"
286 << scope_tab << "}\n"
287 << "}\n")
288 .generate(sink, attributes::unused, concrete_cxt))
289 return false;
275 } 290 }
276 291
277 // Inheritable class 292 // Inheritable class
@@ -560,7 +575,7 @@ struct klass
560 << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n" 575 << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n"
561 << scope_tab << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n" 576 << scope_tab << scope_tab << scope_tab << scope_tab << "lock (klassAllocLock) {\n"
562 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n" 577 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n"
563 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "target_klass = Efl.Eo.Globals.register_class(class_initializer, klass_name, base_klass);\n" 578 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "target_klass = Efl.Eo.Globals.register_class(class_initializer, klass_name, base_klass, this.GetType());\n"
564 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n" 579 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "if (target_klass == System.IntPtr.Zero) {\n"
565 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "throw new System.InvalidOperationException(\"Failed to initialize class '" << inherit_name << "'\");\n" 580 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "throw new System.InvalidOperationException(\"Failed to initialize class '" << inherit_name << "'\");\n"
566 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "}\n" 581 << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << scope_tab << "}\n"
diff --git a/src/bin/eolian_mono/eolian/mono/name_helpers.hh b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
index 801d721..a5cf5c0 100644
--- a/src/bin/eolian_mono/eolian/mono/name_helpers.hh
+++ b/src/bin/eolian_mono/eolian/mono/name_helpers.hh
@@ -274,14 +274,14 @@ struct klass_interface_name_generator
274 { 274 {
275 return utils::remove_all(klass.eolian_name, '_'); 275 return utils::remove_all(klass.eolian_name, '_');
276 } 276 }
277 277
278 template <typename OutputIterator, typename Attr, typename Context> 278 template <typename OutputIterator, typename Attr, typename Context>
279 bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const 279 bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const
280 { 280 {
281 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context); 281 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
282 } 282 }
283} klass_interface_name; 283} const klass_interface_name;
284 284
285struct klass_full_interface_name_generator 285struct klass_full_interface_name_generator
286{ 286{
287 template <typename T> 287 template <typename T>
@@ -289,13 +289,13 @@ struct klass_full_interface_name_generator
289 { 289 {
290 return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_interface_name(klass); 290 return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_interface_name(klass);
291 } 291 }
292 292
293 template <typename OutputIterator, typename Attr, typename Context> 293 template <typename OutputIterator, typename Attr, typename Context>
294 bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const 294 bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const
295 { 295 {
296 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context); 296 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
297 } 297 }
298} klass_full_interface_name; 298} const klass_full_interface_name;
299 299
300template<typename T> 300template<typename T>
301inline std::string klass_concrete_name(T const& klass) 301inline std::string klass_concrete_name(T const& klass)
@@ -313,13 +313,13 @@ struct klass_full_concrete_name_generator
313 { 313 {
314 return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_concrete_name(klass); 314 return join_namespaces(klass.namespaces, '.', managed_namespace) + klass_concrete_name(klass);
315 } 315 }
316 316
317 template <typename OutputIterator, typename Attr, typename Context> 317 template <typename OutputIterator, typename Attr, typename Context>
318 bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const 318 bool generate(OutputIterator sink, Attr const& attribute, Context const& context) const
319 { 319 {
320 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context); 320 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
321 } 321 }
322} klass_full_concrete_name; 322} const klass_full_concrete_name;
323 323
324struct klass_full_concrete_or_interface_name_generator 324struct klass_full_concrete_or_interface_name_generator
325{ 325{
@@ -347,7 +347,7 @@ struct klass_full_concrete_or_interface_name_generator
347 { 347 {
348 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context); 348 return as_generator((*this).operator()<Attr>(attribute)).generate(sink, attributes::unused, context);
349 } 349 }
350} klass_full_concrete_or_interface_name; 350} const klass_full_concrete_or_interface_name;
351 351
352template<typename T> 352template<typename T>
353inline std::string klass_inherit_name(T const& klass) 353inline std::string klass_inherit_name(T const& klass)
@@ -373,11 +373,24 @@ inline std::string klass_get_name(T const& clsname)
373 return clsname.klass_get_name; 373 return clsname.klass_get_name;
374} 374}
375 375
376inline std::string klass_get_full_name(attributes::klass_name const& clsname) 376template<typename T>
377inline std::string klass_get_full_name(T const& clsname)
377{ 378{
378 return klass_full_concrete_name(clsname) + "." + klass_get_name(clsname); 379 return klass_full_concrete_name(clsname) + "." + klass_get_name(clsname);
379} 380}
380 381
382template<typename T>
383inline std::string interface_native_getter_attr_name(T const& clsname)
384{
385 return klass_interface_name(clsname) + "NativeGetterAttr";
386}
387
388template<typename T>
389inline std::string interface_native_getter_attr_full_name(T const& clsname)
390{
391 return klass_full_interface_name(clsname) + "NativeGetterAttr";
392}
393
381// Events 394// Events
382inline std::string managed_event_name(std::string const& name) 395inline std::string managed_event_name(std::string const& name)
383{ 396{