summaryrefslogtreecommitdiff
path: root/src/bin/eolian_mono
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-06-28 18:20:01 -0300
committerJaehyun-Cho <35288529+Jaehyun-Cho@users.noreply.github.com>2019-07-05 09:57:23 +0900
commit73df0d47ff914211ee0a0b5fe46a381f1cd30f10 (patch)
tree4c805aafe893038363f97bd1b18be7264536d08d /src/bin/eolian_mono
parenta94c72f4dec91153d45b5e98bdb169b56fe0132b (diff)
csharp: encapsulate some internal code of EoWrapper
Summary: Encapsulate some parts of EoWrapper making them less accessible to lib users. This can avoid unnecessary and risky usage of code that is only intended for internal usage. `inherited` field was made private and renamed to `generated`. Now its value can only be obtained through the `IsGeneratedBindingClass` property. `handle` field was made private. `eventLock` was renamed to `eflBindingEventLock` `ConstructingHandle` property set was made private. Constructors that are used to create new EFL# managed objects by wrapping a preexisting eo handle now receive a specific struct wrapping the handle pointer. This can avoid faulty interactions with the Reflection engine used only for generated classes that implement this constructor. Test Plan: meson test Reviewers: lauromoura, felipealmeida, YOhoho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9212
Diffstat (limited to 'src/bin/eolian_mono')
-rw-r--r--src/bin/eolian_mono/eolian/mono/events.hh4
-rw-r--r--src/bin/eolian_mono/eolian/mono/function_definition.hh5
-rw-r--r--src/bin/eolian_mono/eolian/mono/klass.hh6
3 files changed, 8 insertions, 7 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index 9b4b8c3..c1a4503 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -435,7 +435,7 @@ struct event_definition_generator
435 scope_tab << "{\n" 435 scope_tab << "{\n"
436 << scope_tab << scope_tab << "add\n" 436 << scope_tab << scope_tab << "add\n"
437 << scope_tab << scope_tab << "{\n" 437 << scope_tab << scope_tab << "{\n"
438 << scope_tab << scope_tab << scope_tab << "lock (eventLock)\n" 438 << scope_tab << scope_tab << scope_tab << "lock (eflBindingEventLock)\n"
439 << scope_tab << scope_tab << scope_tab << "{\n" 439 << scope_tab << scope_tab << scope_tab << "{\n"
440 << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>\n" 440 << scope_tab << scope_tab << scope_tab << scope_tab << "Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>\n"
441 << scope_tab << scope_tab << scope_tab << scope_tab << "{\n" 441 << scope_tab << scope_tab << scope_tab << scope_tab << "{\n"
@@ -460,7 +460,7 @@ struct event_definition_generator
460 << scope_tab << scope_tab << "}\n\n" 460 << scope_tab << scope_tab << "}\n\n"
461 << scope_tab << scope_tab << "remove\n" 461 << scope_tab << scope_tab << "remove\n"
462 << scope_tab << scope_tab << "{\n" 462 << scope_tab << scope_tab << "{\n"
463 << scope_tab << scope_tab << scope_tab << "lock (eventLock)\n" 463 << scope_tab << scope_tab << scope_tab << "lock (eflBindingEventLock)\n"
464 << scope_tab << scope_tab << scope_tab << "{\n" 464 << scope_tab << scope_tab << scope_tab << "{\n"
465 << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n" 465 << scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
466 << scope_tab << scope_tab << scope_tab << scope_tab << "RemoveNativeEventHandler(" << library_name << ", key, value);\n" 466 << scope_tab << scope_tab << scope_tab << scope_tab << "RemoveNativeEventHandler(" << library_name << ", key, value);\n"
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index f2dda1e..8c43008 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -178,9 +178,10 @@ struct function_definition_generator
178 178
179 std::string self = "this.NativeHandle"; 179 std::string self = "this.NativeHandle";
180 180
181 // inherited is set in the constructor, true if this instance is from a pure C# class (not generated). 181 // IsGeneratedBindingClass is set in the constructor, true if this
182 // instance is from a pure C# class (not generated).
182 if (do_super && !f.is_static) 183 if (do_super && !f.is_static)
183 self = "(inherited ? Efl.Eo.Globals.efl_super(" + self + ", this.NativeClass) : " + self + ")"; 184 self = "(IsGeneratedBindingClass ? " + self + " : Efl.Eo.Globals.efl_super(" + self + ", this.NativeClass))";
184 else if (f.is_static) 185 else if (f.is_static)
185 self = ""; 186 self = "";
186 187
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 8b018f6..8f99326 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -214,7 +214,7 @@ struct klass
214 << scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n" 214 << scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
215 << scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << interface_name << "\"/> class.\n" 215 << scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << interface_name << "\"/> class.\n"
216 << scope_tab << "/// Internal usage: This is used when interacting with C code and should not be used directly.</summary>\n" 216 << scope_tab << "/// Internal usage: This is used when interacting with C code and should not be used directly.</summary>\n"
217 << scope_tab << "private " << concrete_name << "(System.IntPtr raw) : base(raw)\n" 217 << scope_tab << "private " << concrete_name << "(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
218 << scope_tab << "{\n" 218 << scope_tab << "{\n"
219 << scope_tab << "}\n\n" 219 << scope_tab << "}\n\n"
220 ) 220 )
@@ -511,7 +511,7 @@ struct klass
511 << scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << inherit_name << "\"/> class.\n" 511 << scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << inherit_name << "\"/> class.\n"
512 << scope_tab << "/// 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" 512 << scope_tab << "/// 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"
513 << scope_tab << "/// <param name=\"raw\">The native pointer to be wrapped.</param>\n" 513 << scope_tab << "/// <param name=\"raw\">The native pointer to be wrapped.</param>\n"
514 << scope_tab << "protected " << inherit_name << "(System.IntPtr raw) : base(raw)\n" 514 << scope_tab << "protected " << inherit_name << "(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
515 << scope_tab << "{\n" 515 << scope_tab << "{\n"
516 << scope_tab << "}\n\n" 516 << scope_tab << "}\n\n"
517 ).generate(sink, std::make_tuple(constructors, constructors, constructors), context)) 517 ).generate(sink, std::make_tuple(constructors, constructors, constructors), context))
@@ -526,7 +526,7 @@ struct klass
526 scope_tab << "[Efl.Eo.PrivateNativeClass]\n" 526 scope_tab << "[Efl.Eo.PrivateNativeClass]\n"
527 << scope_tab << "private class " << inherit_name << "Realized : " << inherit_name << "\n" 527 << scope_tab << "private class " << inherit_name << "Realized : " << inherit_name << "\n"
528 << scope_tab << "{\n" 528 << scope_tab << "{\n"
529 << scope_tab << scope_tab << "private " << inherit_name << "Realized(IntPtr ptr) : base(ptr)\n" 529 << scope_tab << scope_tab << "private " << inherit_name << "Realized(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
530 << scope_tab << scope_tab << "{\n" 530 << scope_tab << scope_tab << "{\n"
531 << scope_tab << scope_tab << "}\n" 531 << scope_tab << scope_tab << "}\n"
532 << scope_tab << "}\n" 532 << scope_tab << "}\n"