summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-01-19 10:30:00 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2018-01-25 15:27:05 -0300
commit4cd760c9a7f806614f929cf435f99bc2436527fa (patch)
treeebbae473fe8225acfa2288e03c44fdf9baf21461 /src/bin/eolian_mono
parentb56a02602ab8bc1b06b2b10c9b1a14b1b189b20e (diff)
eolian_mono: Fix visibility of generated events
Protected members do not make sense in sealed classes like the Concrete ones. Also document the placeholder field in extern structures.
Diffstat (limited to 'src/bin/eolian_mono')
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh19
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh2
2 files changed, 15 insertions, 6 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 119cd73d12..8657faf573 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -72,6 +72,13 @@ get_function_count(grammar::attributes::klass_def const& cls)
72 }); 72 });
73} 73}
74 74
75template<typename Context>
76static bool
77is_inherit_context(Context const& context)
78{
79 return context_find_tag<class_context>(context).current_wrapper_kind == class_context::inherit;
80}
81
75struct get_csharp_type_visitor 82struct get_csharp_type_visitor
76{ 83{
77 typedef get_csharp_type_visitor visitor_type; 84 typedef get_csharp_type_visitor visitor_type;
@@ -281,7 +288,7 @@ struct klass
281 << scope_tab << scope_tab << "Dispose(false);\n" 288 << scope_tab << scope_tab << "Dispose(false);\n"
282 << scope_tab << "}\n" 289 << scope_tab << "}\n"
283 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n" 290 << scope_tab << "///<summary>Releases the underlying native instance.</summary>\n"
284 << scope_tab << "protected void Dispose(bool disposing)\n" 291 << scope_tab << "internal void Dispose(bool disposing)\n"
285 << scope_tab << "{\n" 292 << scope_tab << "{\n"
286 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n" 293 << scope_tab << scope_tab << "if (handle != System.IntPtr.Zero) {\n"
287 << scope_tab << scope_tab << scope_tab << "efl.eo.Globals.efl_unref(handle);\n" 294 << scope_tab << scope_tab << scope_tab << "efl.eo.Globals.efl_unref(handle);\n"
@@ -550,6 +557,8 @@ struct klass
550 if (!has_events(cls)) 557 if (!has_events(cls))
551 return true; 558 return true;
552 559
560 std::string visibility = is_inherit_context(context) ? "protected" : "private";
561
553 if (!as_generator(scope_tab << "private readonly object eventLock = new object();\n" 562 if (!as_generator(scope_tab << "private readonly object eventLock = new object();\n"
554 << scope_tab << "private Dictionary<string, int> event_cb_count = new Dictionary<string, int>();\n") 563 << scope_tab << "private Dictionary<string, int> event_cb_count = new Dictionary<string, int>();\n")
555 .generate(sink, NULL, context)) 564 .generate(sink, NULL, context))
@@ -627,9 +636,9 @@ struct klass
627 return false; 636 return false;
628 637
629 if(!as_generator( 638 if(!as_generator(
630 scope_tab << "protected event EventHandler" << wrapper_args_template << " " << upper_name << ";\n" 639 scope_tab << visibility << " event EventHandler" << wrapper_args_template << " " << upper_name << ";\n"
631 << scope_tab << "///<summary>Method to raise event "<< event_name << ".</summary>\n" 640 << scope_tab << "///<summary>Method to raise event "<< event_name << ".</summary>\n"
632 << scope_tab << "protected void On_" << event_name << "(" << wrapper_args_type << " e)\n" 641 << scope_tab << visibility << " void On_" << event_name << "(" << wrapper_args_type << " e)\n"
633 << scope_tab << "{\n" 642 << scope_tab << "{\n"
634 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n" 643 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n"
635 << scope_tab << scope_tab << "lock (eventLock) {\n" 644 << scope_tab << scope_tab << "lock (eventLock) {\n"
@@ -717,9 +726,9 @@ struct klass
717 return false; 726 return false;
718 727
719 if (!as_generator( 728 if (!as_generator(
720 scope_tab << "protected event EventHandler" << wrapper_args_template << " " << wrapper_evt_name << ";\n" 729 scope_tab << visibility << " event EventHandler" << wrapper_args_template << " " << wrapper_evt_name << ";\n"
721 << scope_tab << "///<summary>Method to raise event "<< wrapper_evt_name << ".</summary>\n" 730 << scope_tab << "///<summary>Method to raise event "<< wrapper_evt_name << ".</summary>\n"
722 << scope_tab << "protected void On_" << wrapper_evt_name << "(" << wrapper_args_type.str() << " e)\n" 731 << scope_tab << visibility << " void On_" << wrapper_evt_name << "(" << wrapper_args_type.str() << " e)\n"
723 << scope_tab << "{\n" 732 << scope_tab << "{\n"
724 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n" 733 << scope_tab << scope_tab << "EventHandler" << wrapper_args_template << " evt;\n"
725 << scope_tab << scope_tab << "lock (eventLock) {\n" 734 << scope_tab << scope_tab << "lock (eventLock) {\n"
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index 5db84e0a9b..324e787748 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -67,7 +67,7 @@ struct struct_definition_generator
67 // those 'mini-amd64.c condition fields not met' crashes. 67 // those 'mini-amd64.c condition fields not met' crashes.
68 if (struct_.fields.size() == 0) 68 if (struct_.fields.size() == 0)
69 { 69 {
70 if (!as_generator("public IntPtr field;\n").generate(sink, nullptr, context)) 70 if (!as_generator("///<summary>Placeholder field</summary>\npublic IntPtr field;\n").generate(sink, nullptr, context))
71 return false; 71 return false;
72 } 72 }
73 73