summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono/eolian/mono/klass.hh
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-02-01 14:03:02 -0500
committerChristopher Michael <cp.michael@samsung.com>2019-02-01 14:03:02 -0500
commit0223bb29dfc4c1621ace044395196064c82b98de (patch)
treefc42c91c0461472391960afd14f232f941911f02 /src/bin/eolian_mono/eolian/mono/klass.hh
parente4144504048ff2c9a3c1787b82c73a54e8d209a7 (diff)
eolian-mono: Provide constructor parameters based on the constructors
section of the Eo files. Reviewers: woohyun, segfaultxavi, bu5hm4n, felipealmeida Reviewed By: segfaultxavi Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7789
Diffstat (limited to 'src/bin/eolian_mono/eolian/mono/klass.hh')
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh63
1 files changed, 27 insertions, 36 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 6a2c818..d8f2e7e 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -220,15 +220,16 @@ struct klass
220 if (!generate_fields(sink, cls, concrete_cxt)) 220 if (!generate_fields(sink, cls, concrete_cxt))
221 return false; 221 return false;
222 222
223 bool root = !helpers::has_regular_ancestor(cls);
223 if (!as_generator 224 if (!as_generator
224 ( 225 (
225 scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename) 226 scope_tab << "[System.Runtime.InteropServices.DllImport(" << context_find_tag<library_context>(concrete_cxt).actual_library_name(cls.filename)
226 << ")] internal static extern System.IntPtr\n" 227 << ")] internal static extern System.IntPtr\n"
227 << scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n" 228 << scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
228 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n" 229 << scope_tab << "///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>\n"
229 << scope_tab << "public " << concrete_name << "(System.IntPtr raw)\n" 230 << scope_tab << "public " << concrete_name << "(System.IntPtr raw)" << (root ? "" : " : base(raw)") << "\n"
230 << scope_tab << "{\n" 231 << scope_tab << "{\n"
231 << scope_tab << scope_tab << "handle = raw;\n" 232 << scope_tab << scope_tab << (root ? "handle = raw;\n" : "")
232 << scope_tab << scope_tab << "register_event_proxies();\n" 233 << scope_tab << scope_tab << "register_event_proxies();\n"
233 << scope_tab << "}\n" 234 << scope_tab << "}\n"
234 ) 235 )
@@ -503,48 +504,44 @@ struct klass
503 ).generate(sink, attributes::unused, context)) 504 ).generate(sink, attributes::unused, context))
504 return false; 505 return false;
505 506
507 auto constructors = helpers::reorder_constructors(cls.get_all_constructors());
506 508
507 if (!root) 509 // Public (API) constructors
508 { 510 if (!as_generator(
509 return as_generator(
510 scope_tab << "///<summary>Creates a new instance.</summary>\n" 511 scope_tab << "///<summary>Creates a new instance.</summary>\n"
511 << scope_tab << "///<param name=\"parent\">Parent instance.</param>\n" 512 << scope_tab << "///<param name=\"parent\">Parent instance.</param>\n"
512 << scope_tab << "///<param name=\"init_cb\">Delegate to call constructing methods that should be run inside the constructor.</param>\n" 513 << *(documentation)
513 << scope_tab << "public " << inherit_name << "(Efl.Object parent = null, ConstructingMethod init_cb=null) : " 514 // For constructors with arguments, the parent is also required, as optional parameters can't come before non-optional paramenters.
514 "base(\"" << inherit_name << "\", " << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent)\n" 515 << scope_tab << "public " << inherit_name << "(Efl.Object parent" << ((constructors.size() > 0) ? "" : "= null") << "\n"
516 << scope_tab << scope_tab << scope_tab << *(", " << constructor_param ) << ") :\n"
517 << scope_tab << scope_tab << (root ? "this" : "base") << "(\"" << inherit_name << "\", " << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent)\n"
515 << scope_tab << "{\n" 518 << scope_tab << "{\n"
516 << scope_tab << scope_tab << "if (init_cb != null) {\n" 519 << *(scope_tab << scope_tab << constructor_invocation << "\n" )
517 << scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
518 << scope_tab << scope_tab << "}\n"
519 << scope_tab << scope_tab << "FinishInstantiation();\n" 520 << scope_tab << scope_tab << "FinishInstantiation();\n"
520 << scope_tab << "}\n" 521 << scope_tab << "}\n"
521 522 << scope_tab << "///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>\n"
522 << scope_tab << "///<summary>Internal constructor to forward the wrapper initialization to the root class.</summary>\n"
523 << scope_tab << "protected " << inherit_name << "(String klass_name, IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(klass_name, base_klass, managed_type, parent) {}\n"
524
525 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
526 << scope_tab << "public " << inherit_name << "(System.IntPtr raw)" << (root ? "" : " : base(raw)") << "\n" 523 << scope_tab << "public " << inherit_name << "(System.IntPtr raw)" << (root ? "" : " : base(raw)") << "\n"
527 << scope_tab << "{\n" 524 << scope_tab << "{\n"
528 << scope_tab << scope_tab << (root ? "handle = raw;\n" : "") 525 << scope_tab << scope_tab << (root ? "handle = raw;\n" : "")
529 << scope_tab << scope_tab << "register_event_proxies();\n" 526 << scope_tab << scope_tab << "register_event_proxies();\n"
530 << scope_tab << "}\n" 527 << scope_tab << "}\n"
528 ).generate(sink, std::make_tuple(constructors, constructors, constructors), context))
529 return false;
530
531 // Internal constructors
532 if (!root)
533 {
534 return as_generator(
535 scope_tab << "///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>\n"
536 << scope_tab << "protected " << inherit_name << "(String klass_name, IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(klass_name, base_klass, managed_type, parent) {}\n"
531 ).generate(sink, attributes::unused, context); 537 ).generate(sink, attributes::unused, context);
532 } 538
539 }
533 540
534 // Detailed constructors go only in root classes. 541 // Detailed constructors go only in root classes.
535 return as_generator( 542 return as_generator(
536 scope_tab << "///<summary>Creates a new instance.</summary>\n" 543 /// Actual root costructor that creates class and instantiates
537 << scope_tab << "///<param name=\"parent\">Parent instance.</param>\n" 544 scope_tab << "protected " << inherit_name << "(String klass_name, IntPtr base_klass, System.Type managed_type, Efl.Object parent)\n"
538 << scope_tab << "///<param name=\"init_cb\">Delegate to call constructing methods that should be run inside the constructor.</param>\n"
539 << scope_tab << "public " << inherit_name << "(Efl.Object parent = null, ConstructingMethod init_cb=null) : this(\"" << inherit_name << "\", " << name_helpers::klass_get_name(cls) << "(), typeof(" << inherit_name << "), parent)\n"
540 << scope_tab << "{\n"
541 << scope_tab << scope_tab << "if (init_cb != null) {\n"
542 << scope_tab << scope_tab << scope_tab << "init_cb(this);\n"
543 << scope_tab << scope_tab << "}\n"
544 << scope_tab << scope_tab << "FinishInstantiation();\n"
545 << scope_tab << "}\n"
546
547 << scope_tab << "protected " << inherit_name << "(String klass_name, IntPtr base_klass, System.Type managed_type, Efl.Object parent)\n"
548 << scope_tab << "{\n" 545 << scope_tab << "{\n"
549 << scope_tab << scope_tab << "inherited = ((object)this).GetType() != managed_type;\n" 546 << scope_tab << scope_tab << "inherited = ((object)this).GetType() != managed_type;\n"
550 << scope_tab << scope_tab << "IntPtr actual_klass = base_klass;\n" 547 << scope_tab << scope_tab << "IntPtr actual_klass = base_klass;\n"
@@ -574,12 +571,6 @@ struct klass
574 << scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n" 571 << scope_tab << scope_tab << "Eina.Error.RaiseIfUnhandledException();\n"
575 << scope_tab << "}\n" 572 << scope_tab << "}\n"
576 573
577 << scope_tab << "///<summary>Constructs an instance from a native pointer.</summary>\n"
578 << scope_tab << "public " << inherit_name << "(System.IntPtr raw)\n"
579 << scope_tab << "{\n"
580 << scope_tab << scope_tab << "handle = raw;\n"
581 << scope_tab << scope_tab << "register_event_proxies();\n"
582 << scope_tab << "}\n"
583 ).generate(sink, attributes::unused, context); 574 ).generate(sink, attributes::unused, context);
584 } 575 }
585 576