summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eo_mono
diff options
context:
space:
mode:
Diffstat (limited to 'src/bindings/mono/eo_mono')
-rw-r--r--src/bindings/mono/eo_mono/EoWrapper.cs224
-rw-r--r--src/bindings/mono/eo_mono/FunctionWrapper.cs139
-rw-r--r--src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs36
-rw-r--r--src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs26
-rw-r--r--src/bindings/mono/eo_mono/NativeModule.cs60
-rw-r--r--src/bindings/mono/eo_mono/NativeModule_Unix.cs28
-rw-r--r--src/bindings/mono/eo_mono/NativeModule_Windows.cs26
-rw-r--r--src/bindings/mono/eo_mono/WrapperSupervisor.cs34
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs704
-rw-r--r--src/bindings/mono/eo_mono/workaround.cs201
10 files changed, 1145 insertions, 333 deletions
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs
index 2f21778..99e60b1 100644
--- a/src/bindings/mono/eo_mono/EoWrapper.cs
+++ b/src/bindings/mono/eo_mono/EoWrapper.cs
@@ -1,3 +1,18 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using System.Runtime.InteropServices; 17using System.Runtime.InteropServices;
3using System.Runtime.CompilerServices; 18using System.Runtime.CompilerServices;
@@ -16,6 +31,8 @@ namespace Eo
16/// 31///
17/// Most of it is protected functionalities to serve the generated 32/// Most of it is protected functionalities to serve the generated
18/// binding classes that inherit from it. 33/// binding classes that inherit from it.
34///
35/// <para>Since EFL 1.23.</para>
19/// </summary> 36/// </summary>
20public abstract class EoWrapper : IWrapper, IDisposable 37public abstract class EoWrapper : IWrapper, IDisposable
21{ 38{
@@ -30,14 +47,17 @@ public abstract class EoWrapper : IWrapper, IDisposable
30 private Hashtable keyValueHash = null; 47 private Hashtable keyValueHash = null;
31 48
32 /// <summary>Constructor to be used when objects are expected to be constructed from native code. 49 /// <summary>Constructor to be used when objects are expected to be constructed from native code.
33 /// For a class that inherited from an EFL# class to be properly constructed from native code 50 /// <para>For a class that inherited from an EFL# class to be properly constructed from native code
34 /// one must create a constructor with this signature and calls this base constructor from it. 51 /// one must create a constructor with this signature and calls this base constructor from it.
35 /// This constructor will take care of calling base constructors of the native classes and 52 /// This constructor will take care of calling base constructors of the native classes and
36 /// perform additional setup so objects are ready to use. 53 /// perform additional setup so objects are ready to use.</para>
37 /// It is advisable to check for the <see cref="NativeHandle"/> property in the top level 54 /// <para>It is advisable to check for the <see cref="NativeHandle"/> property in the top level
38 /// constructor and signal an error when it has a value of IntPtr.Zero after this 55 /// constructor and signal an error when it has a value of IntPtr.Zero after this
39 /// constructor completion. 56 /// constructor completion.</para>
40 /// Warning: Do not use this constructor directly from a `new` statement.</summary> 57 /// <para>Warning: Do not use this constructor directly from a `new` statement.</para>
58 /// <para>Since EFL 1.23.</para>
59 /// </summary>
60 ///
41 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param> 61 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
42 protected EoWrapper(ConstructingHandle ch) 62 protected EoWrapper(ConstructingHandle ch)
43 { 63 {
@@ -56,18 +76,22 @@ public abstract class EoWrapper : IWrapper, IDisposable
56 } 76 }
57 77
58 /// <summary>Initializes a new instance of the <see cref="Object"/> class. 78 /// <summary>Initializes a new instance of the <see cref="Object"/> class.
59 /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly. 79 /// <para>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</para>
60 /// Do not implement this constructor.</summary> 80 /// <para>Do not implement this constructor.</para>
81 /// <para>Since EFL 1.23.</para>
82 /// </summary>
61 /// <param name="wh">The native pointer to be wrapped.</param> 83 /// <param name="wh">The native pointer to be wrapped.</param>
62 protected EoWrapper(Efl.Eo.Globals.WrappingHandle wh) 84 internal EoWrapper(Efl.Eo.WrappingHandle wh)
63 { 85 {
64 handle = wh.NativeHandle; 86 handle = wh.NativeHandle;
65 AddWrapperSupervisor(); 87 AddWrapperSupervisor();
66 } 88 }
67 89
68 /// <summary>Initializes a new instance of the <see cref="Object"/> class. 90 /// <summary>Initializes a new instance of the <see cref="Object"/> class.
69 /// Internal usage: Constructor to actually call the native library constructors. C# subclasses 91 /// <para>Internal usage: Constructor to actually call the native library constructors. C# subclasses
70 /// must use the public constructor only.</summary> 92 /// must use the public constructor only.</para>
93 /// <para>Since EFL 1.23.</para>
94 /// </summary>
71 /// <param name="baseKlass">The pointer to the base native Eo class.</param> 95 /// <param name="baseKlass">The pointer to the base native Eo class.</param>
72 /// <param name="parent">The Efl.Object parent of this instance.</param> 96 /// <param name="parent">The Efl.Object parent of this instance.</param>
73 /// <param name="file">Name of the file from where the constructor is called.</param> 97 /// <param name="file">Name of the file from where the constructor is called.</param>
@@ -76,7 +100,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
76 [CallerFilePath] string file = null, 100 [CallerFilePath] string file = null,
77 [CallerLineNumber] int line = 0) 101 [CallerLineNumber] int line = 0)
78 { 102 {
79 generated = Efl.Eo.BindingEntity.IsBindingEntity(((object)this).GetType()); 103 generated = Efl.Eo.BindingEntityAttribute.IsBindingEntity(((object)this).GetType());
80 IntPtr actual_klass = baseKlass; 104 IntPtr actual_klass = baseKlass;
81 if (!generated) 105 if (!generated)
82 { 106 {
@@ -114,19 +138,25 @@ public abstract class EoWrapper : IWrapper, IDisposable
114 AddWrapperSupervisor(); 138 AddWrapperSupervisor();
115 } 139 }
116 140
117 /// <summary>Destructor.</summary> 141 /// <summary>Destructor.
142 /// <para>Since EFL 1.23.</para>
143 /// </summary>
118 ~EoWrapper() 144 ~EoWrapper()
119 { 145 {
120 Dispose(false); 146 Dispose(false);
121 } 147 }
122 148
123 /// <summary>Pointer to the native instance.</summary> 149 /// <summary>Pointer to the native instance.
150 /// <para>Since EFL 1.23.</para>
151 /// </summary>
124 public System.IntPtr NativeHandle 152 public System.IntPtr NativeHandle
125 { 153 {
126 get { return handle; } 154 get { return handle; }
127 } 155 }
128 156
129 /// <summary>Pointer to the native class description.</summary> 157 /// <summary>Pointer to the native class description.
158 /// <para>Since EFL 1.23.</para>
159 /// </summary>
130 public abstract System.IntPtr NativeClass 160 public abstract System.IntPtr NativeClass
131 { 161 {
132 get; 162 get;
@@ -135,6 +165,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
135 /// <summary> 165 /// <summary>
136 /// Whether this object type is one of the generated binding classes or a custom 166 /// Whether this object type is one of the generated binding classes or a custom
137 /// class defined by the user and that inherit from one of the generated ones. 167 /// class defined by the user and that inherit from one of the generated ones.
168 /// <para>Since EFL 1.23.</para>
138 /// </summary> 169 /// </summary>
139 /// <returns> 170 /// <returns>
140 /// True if this object type is one of the generated binding classes, 171 /// True if this object type is one of the generated binding classes,
@@ -146,7 +177,9 @@ public abstract class EoWrapper : IWrapper, IDisposable
146 get { return generated; } 177 get { return generated; }
147 } 178 }
148 179
149 /// <summary>Releases the underlying native instance.</summary> 180 /// <summary>Releases the underlying native instance.
181 /// <para>Since EFL 1.23.</para>
182 /// </summary>
150 protected virtual void Dispose(bool disposing) 183 protected virtual void Dispose(bool disposing)
151 { 184 {
152 if (disposing && handle != System.IntPtr.Zero) 185 if (disposing && handle != System.IntPtr.Zero)
@@ -167,14 +200,18 @@ public abstract class EoWrapper : IWrapper, IDisposable
167 } 200 }
168 } 201 }
169 202
170 /// <summary>Turns the native pointer into a string representation.</summary> 203 /// <summary>Turns the native pointer into a string representation.
204 /// <para>Since EFL 1.23.</para>
205 /// </summary>
171 /// <returns>A string with the type and the native pointer for this object.</returns> 206 /// <returns>A string with the type and the native pointer for this object.</returns>
172 public override String ToString() 207 public override String ToString()
173 { 208 {
174 return $"{this.GetType().Name}@[0x{(UInt64)handle:x}]"; 209 return $"{this.GetType().Name}@[0x{(UInt64)handle:x}]";
175 } 210 }
176 211
177 /// <summary>Releases the underlying native instance.</summary> 212 /// <summary>Releases the underlying native instance.
213 /// <para>Since EFL 1.23.</para>
214 /// </summary>
178 public void Dispose() 215 public void Dispose()
179 { 216 {
180 Dispose(true); 217 Dispose(true);
@@ -185,6 +222,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
185 /// 222 ///
186 /// This method is a C# counterpart to the C `efl_del` function. It removes the parent of the object 223 /// This method is a C# counterpart to the C `efl_del` function. It removes the parent of the object
187 /// and releases the Eo reference it was holding. 224 /// and releases the Eo reference it was holding.
225 /// <para>Since EFL 1.23.</para>
188 /// </summary> 226 /// </summary>
189 public void Del() 227 public void Del()
190 { 228 {
@@ -194,7 +232,9 @@ public abstract class EoWrapper : IWrapper, IDisposable
194 } 232 }
195 233
196 /// <summary>Finishes instantiating this object. 234 /// <summary>Finishes instantiating this object.
197 /// Internal usage by generated code.</summary> 235 /// <para>Internal usage by generated code.</para>
236 /// <para>Since EFL 1.23.</para>
237 /// </summary>
198 protected void FinishInstantiation() 238 protected void FinishInstantiation()
199 { 239 {
200 Eina.Log.Debug("calling efl_add_internal_end"); 240 Eina.Log.Debug("calling efl_add_internal_end");
@@ -208,12 +248,15 @@ public abstract class EoWrapper : IWrapper, IDisposable
208 handle = h; 248 handle = h;
209 } 249 }
210 250
211 /// <summary>Adds a new event handler, registering it to the native event. For internal use only.</summary> 251 /// <summary>Adds a new event handler, registering it to the native event.
252 /// <para>For internal use only.</para>
253 /// <para>Since EFL 1.23.</para>
254 /// </summary>
212 /// <param name="lib">The name of the native library definining the event.</param> 255 /// <param name="lib">The name of the native library definining the event.</param>
213 /// <param name="key">The name of the native event.</param> 256 /// <param name="key">The name of the native event.</param>
214 /// <param name="evtCaller">Delegate to be called by native code on event raising.</param> 257 /// <param name="evtCaller">Delegate to be called by native code on event raising.</param>
215 /// <param name="evtDelegate">Managed delegate that will be called by evtCaller on event raising.</param> 258 /// <param name="evtDelegate">Managed delegate that will be called by evtCaller on event raising.</param>
216 protected void AddNativeEventHandler(string lib, string key, Efl.EventCb evtCaller, object evtDelegate) 259 internal void AddNativeEventHandler(string lib, string key, Efl.EventCb evtCaller, object evtDelegate)
217 { 260 {
218 lock (eflBindingEventLock) 261 lock (eflBindingEventLock)
219 { 262 {
@@ -244,11 +287,14 @@ public abstract class EoWrapper : IWrapper, IDisposable
244 } 287 }
245 } 288 }
246 289
247 /// <summary>Removes the given event handler for the given event. For internal use only.</summary> 290 /// <summary>Removes the given event handler for the given event.
291 /// <para>For internal use only.</para>
292 /// <para>Since EFL 1.23.</para>
293 /// </summary>
248 /// <param name="lib">The name of the native library definining the event.</param> 294 /// <param name="lib">The name of the native library definining the event.</param>
249 /// <param name="key">The name of the native event.</param> 295 /// <param name="key">The name of the native event.</param>
250 /// <param name="evtDelegate">The delegate to be removed.</param> 296 /// <param name="evtDelegate">The delegate to be removed.</param>
251 protected void RemoveNativeEventHandler(string lib, string key, object evtDelegate) 297 internal void RemoveNativeEventHandler(string lib, string key, object evtDelegate)
252 { 298 {
253 lock (eflBindingEventLock) 299 lock (eflBindingEventLock)
254 { 300 {
@@ -280,6 +326,63 @@ public abstract class EoWrapper : IWrapper, IDisposable
280 } 326 }
281 } 327 }
282 328
329 internal Efl.EventCb GetInternalEventCallback<T>(EventHandler<T> handler, Func<IntPtr, T> createArgsInstance) where T:EventArgs
330 {
331 return (IntPtr data, ref Efl.Event.NativeStruct evt) =>
332 {
333 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
334 if (obj != null)
335 {
336 try
337 {
338 handler?.Invoke(obj, createArgsInstance(evt.Info));
339 }
340 catch (Exception e)
341 {
342 Eina.Log.Error(e.ToString());
343 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
344 }
345 }
346 };
347 }
348
349 internal Efl.EventCb GetInternalEventCallback(EventHandler handler)
350 {
351 return (IntPtr data, ref Efl.Event.NativeStruct evt) =>
352 {
353 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
354 if (obj != null)
355 {
356 try
357 {
358 handler?.Invoke(obj, EventArgs.Empty);
359 }
360 catch (Exception e)
361 {
362 Eina.Log.Error(e.ToString());
363 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
364 }
365 }
366 };
367 }
368
369 internal void CallNativeEventCallback(string lib, string key, IntPtr eventInfo, Action<IntPtr> freeAction)
370 {
371 try
372 {
373 IntPtr desc = Efl.EventDescription.GetNative(lib, key);
374 if (desc == IntPtr.Zero)
375 throw new ArgumentException($"Failed to get native event {key}", "key");
376
377 Efl.Eo.Globals.CallEventCallback(NativeHandle, desc, eventInfo);
378 }
379 finally
380 {
381 if (freeAction != null)
382 freeAction(eventInfo);
383 }
384 }
385
283 private static void OwnershipUniqueCallback(IntPtr data, ref Efl.Event.NativeStruct evt) 386 private static void OwnershipUniqueCallback(IntPtr data, ref Efl.Event.NativeStruct evt)
284 { 387 {
285 var ws = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data); 388 var ws = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data);
@@ -316,22 +419,75 @@ public abstract class EoWrapper : IWrapper, IDisposable
316 419
317 /// <summary> 420 /// <summary>
318 /// Struct to be used when constructing objects from native code. 421 /// Struct to be used when constructing objects from native code.
319 /// Wraps the pointer handle to the native object instance. 422 /// <para>For internal use by generated code only.</para>
423 /// <para>Wraps the pointer handle to the native object instance.</para>
424 /// <para>Since EFL 1.23.</para>
320 /// </summary> 425 /// </summary>
321 protected struct ConstructingHandle 426 protected struct ConstructingHandle : IEquatable<ConstructingHandle>
322 { 427 {
323 /// <summary>Constructor for wrapping the native handle.</summary> 428 /// <summary>Constructor for wrapping the native handle.
429 /// <para>Since EFL 1.23.</para>
430 /// </summary>
324 public ConstructingHandle(IntPtr h) 431 public ConstructingHandle(IntPtr h)
325 { 432 {
326 NativeHandle = h; 433 NativeHandle = h;
327 } 434 }
328 435
329 /// <summary>Pointer to the native instance.</summary> 436 /// <summary>Pointer to the native instance.
437 /// <para>Since EFL 1.23.</para>
438 /// </summary>
330 public IntPtr NativeHandle { get; private set; } 439 public IntPtr NativeHandle { get; private set; }
440
441 /// <summary>
442 /// Gets a hash for <see cref="ConstructingHandle" />.
443 /// <para>Since EFL 1.24.</para>
444 /// </summary>
445 /// <returns>A hash code.</returns>
446 public override int GetHashCode() => NativeHandle.GetHashCode();
447
448 /// <summary>Returns whether this <see cref="ConstructingHandle" />
449 /// is equal to the given <see cref="object" />.
450 /// <para>Since EFL 1.24.</para>
451 /// </summary>
452 /// <param name="other">The <see cref="object" /> to be compared to.</param>
453 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
454 public override bool Equals(object other)
455 => (!(other is ConstructingHandle))
456 ? false : Equals((ConstructingHandle)other);
457
458 /// <summary>Returns whether this <see cref="ConstructingHandle" /> is equal
459 /// to the given <see cref="ConstructingHandle" />.
460 /// <para>Since EFL 1.24.</para>
461 /// </summary>
462 /// <param name="other">The <see cref="ConstructingHandle" /> to be compared to.</param>
463 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
464 public bool Equals(ConstructingHandle other)
465 => NativeHandle == other.NativeHandle;
466
467 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
468 /// <para>Since EFL 1.24.</para>
469 /// </summary>
470 /// <param name="lhs">The left hand side of the operator.</param>
471 /// <param name="rhs">The right hand side of the operator.</param>
472 /// <returns><c>true</c> if <c>lhs</c> is equal
473 /// to <c>rhs</c>.</returns>
474 public static bool operator==(ConstructingHandle lhs, ConstructingHandle rhs)
475 => lhs.Equals(rhs);
476
477 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
478 /// <para>Since EFL 1.24.</para>
479 /// </summary>
480 /// <param name="lhs">The left hand side of the operator.</param>
481 /// <param name="rhs">The right hand side of the operator.</param>
482 /// <returns><c>true</c> if <c>lhs</c> is not equal
483 /// to <c>rhs</c>.</returns>
484 public static bool operator!=(ConstructingHandle lhs, ConstructingHandle rhs)
485 => !(lhs == rhs);
331 } 486 }
332 487
333 /// <summary> 488 /// <summary>
334 /// Set a value object associated with a key object. 489 /// Set a value object associated with a key object.
490 /// <para>Since EFL 1.23.</para>
335 /// </summary> 491 /// </summary>
336 public void SetKeyValue(object key, object val) 492 public void SetKeyValue(object key, object val)
337 { 493 {
@@ -343,6 +499,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
343 499
344 /// <summary> 500 /// <summary>
345 /// Get a value object associated with a key object. 501 /// Get a value object associated with a key object.
502 /// <para>Since EFL 1.23.</para>
346 /// </summary> 503 /// </summary>
347 public object GetKeyValue(object key) 504 public object GetKeyValue(object key)
348 { 505 {
@@ -353,17 +510,21 @@ public abstract class EoWrapper : IWrapper, IDisposable
353 } 510 }
354 511
355 /// <summary>Wrapper for native methods and virtual method delegates. 512 /// <summary>Wrapper for native methods and virtual method delegates.
356 /// For internal use by generated code only.</summary> 513 /// <para>For internal use by generated code only.</para>
357 public abstract class NativeMethods : Efl.Eo.NativeClass 514 /// <para>Since EFL 1.23.</para>
515 /// </summary>
516 internal abstract class NativeMethods : Efl.Eo.NativeClass
358 { 517 {
359 private static EflConstructorDelegate csharpEflConstructorStaticDelegate = new EflConstructorDelegate(Constructor); 518 private static EflConstructorDelegate csharpEflConstructorStaticDelegate = new EflConstructorDelegate(Constructor);
360 private static Efl.Eo.NativeModule EoModule = new Efl.Eo.NativeModule("eo"); 519 private static Efl.Eo.NativeModule EoModule = new Efl.Eo.NativeModule("eo");
361 520
362 private delegate IntPtr EflConstructorDelegate(IntPtr obj, IntPtr pd); 521 private delegate IntPtr EflConstructorDelegate(IntPtr obj, IntPtr pd);
363 522
364 /// <summary>Gets the list of Eo operations to override.</summary> 523 /// <summary>Gets the list of Eo operations to override.
524 /// <para>Since EFL 1.23.</para>
525 /// </summary>
365 /// <returns>The list of Eo operations to be overload.</returns> 526 /// <returns>The list of Eo operations to be overload.</returns>
366 public override System.Collections.Generic.List<EflOpDescription> GetEoOps(Type type, bool includeInherited) 527 internal override System.Collections.Generic.List<EflOpDescription> GetEoOps(Type type, bool includeInherited)
367 { 528 {
368 var descs = new System.Collections.Generic.List<EflOpDescription>(); 529 var descs = new System.Collections.Generic.List<EflOpDescription>();
369 530
@@ -425,9 +586,10 @@ public abstract class EoWrapper : IWrapper, IDisposable
425/// allow minimal interaction with them through <see cref="Efl.Object" />. 586/// allow minimal interaction with them through <see cref="Efl.Object" />.
426/// 587///
427/// But as <see cref="Efl.Object" /> is abstract, whis realized class will allow us to create C# instances of it.</summary> 588/// But as <see cref="Efl.Object" /> is abstract, whis realized class will allow us to create C# instances of it.</summary>
589[Efl.Object.NativeMethods]
428internal class ObjectRealized : Efl.Object 590internal class ObjectRealized : Efl.Object
429{ 591{
430 protected ObjectRealized(Efl.Eo.Globals.WrappingHandle ch) : base(ch) { } 592 internal ObjectRealized(Efl.Eo.WrappingHandle ch) : base(ch) { }
431} 593}
432 594
433} // namespace Efl 595} // namespace Efl
diff --git a/src/bindings/mono/eo_mono/FunctionWrapper.cs b/src/bindings/mono/eo_mono/FunctionWrapper.cs
index 1ea2097..d37fba9 100644
--- a/src/bindings/mono/eo_mono/FunctionWrapper.cs
+++ b/src/bindings/mono/eo_mono/FunctionWrapper.cs
@@ -1,24 +1,40 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using System.Runtime.InteropServices; 17using System.Runtime.InteropServices;
3 18
4namespace Efl 19namespace Efl.Eo
5{ 20{
6 21
7namespace Eo 22/// <summary>Class to load functions pointers from a native module.
8{
9
10///<summary>Class to load functions pointers from a native module.
11/// 23///
12///This class has a platform-dependent implementation on whether it 24/// <para>This class has a platform-dependent implementation on whether it
13///is compiled for Windows (using LoadLibrary/GetProcAddress) or Unix 25/// is compiled for Windows (using LoadLibrary/GetProcAddress) or Unix
14///(dlopen/dlsym).</summary> 26/// (dlopen/dlsym).</para>
15public static partial class FunctionInterop 27/// <para>Since EFL 1.23.</para>
28/// </summary>
29internal static partial class FunctionInterop
16{ 30{
17 ///<summary>Loads a function pointer from the given module.</summary> 31 /// <summary>Loads a function pointer from the given module.
18 ///<param name="moduleName">The name of the module containing the function.</param> 32 /// <para>Since EFL 1.23.</para>
19 ///<param name="functionName">The name of the function to search for.</param> 33 /// </summary>
20 ///<returns>A function pointer that can be used with delegates.</returns> 34 /// <param name="moduleName">The name of the module containing the function.</param>
21 public static IntPtr LoadFunctionPointer(string moduleName, string functionName) 35 /// <param name="functionName">The name of the function to search for.</param>
36 /// <returns>A function pointer that can be used with delegates.</returns>
37 internal static IntPtr LoadFunctionPointer(string moduleName, string functionName)
22 { 38 {
23 IntPtr module = NativeModule.LoadLibrary(moduleName); 39 IntPtr module = NativeModule.LoadLibrary(moduleName);
24 Eina.Log.Debug($"searching {module} for {functionName}"); 40 Eina.Log.Debug($"searching {module} for {functionName}");
@@ -27,10 +43,12 @@ public static partial class FunctionInterop
27 return s; 43 return s;
28 } 44 }
29 45
30 ///<summary>Loads a function pointer from the default module.</summary> 46 /// <summary>Loads a function pointer from the default module.
31 ///<param name="functionName">The name of the function to search for.</param> 47 /// <para>Since EFL 1.23.</para>
32 ///<returns>A function pointer that can be used with delegates.</returns> 48 /// </summary>
33 public static IntPtr LoadFunctionPointer(string functionName) 49 /// <param name="functionName">The name of the function to search for.</param>
50 /// <returns>A function pointer that can be used with delegates.</returns>
51 internal static IntPtr LoadFunctionPointer(string functionName)
34 { 52 {
35 Eina.Log.Debug($"searching {null} for {functionName}"); 53 Eina.Log.Debug($"searching {null} for {functionName}");
36 var s = FunctionInterop.dlsym(IntPtr.Zero, functionName); 54 var s = FunctionInterop.dlsym(IntPtr.Zero, functionName);
@@ -39,13 +57,13 @@ public static partial class FunctionInterop
39 } 57 }
40} 58}
41 59
42///<summary>Wraps a native function in a portable manner. 60/// <summary>Wraps a native function in a portable manner.
43///
44///This is intended as a workaround DllImport limitations when switching between mono and dotnet.
45/// 61///
46///The parameter T must be a delegate. 62/// <para>This is intended as a workaround DllImport limitations when switching between mono and dotnet.</para>
47///</summary> 63/// <para>The parameter T must be a delegate.</para>
48public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate? 64/// <para>Since EFL 1.23.</para>
65/// </summary>
66class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate?
49{ 67{
50 private Lazy<FunctionLoadResult<T>> loadResult; 68 private Lazy<FunctionLoadResult<T>> loadResult;
51#pragma warning disable 0414 69#pragma warning disable 0414
@@ -72,18 +90,22 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T
72 } 90 }
73 } 91 }
74 92
75 ///<summary>Creates a wrapper for the given function of the given module.</summary> 93 /// <summary>Creates a wrapper for the given function of the given module.
76 ///<param name="moduleName">The name of the module containing the function.</param> 94 /// <para>Since EFL 1.23.</para>
77 ///<param name="functionName">The name of the function to search for.</param> 95 /// </summary>
78 public FunctionWrapper(string moduleName, string functionName) 96 /// <param name="moduleName">The name of the module containing the function.</param>
97 /// <param name="functionName">The name of the function to search for.</param>
98 internal FunctionWrapper(string moduleName, string functionName)
79 : this(new NativeModule(moduleName), functionName) 99 : this(new NativeModule(moduleName), functionName)
80 { 100 {
81 } 101 }
82 102
83 ///<summary>Creates a wrapper for the given function of the given module.</summary> 103 /// <summary>Creates a wrapper for the given function of the given module.
84 ///<param name="module">The module wrapper containing the function.</param> 104 /// <para>Since EFL 1.23.</para>
85 ///<param name="functionName">The name of the function to search for.</param> 105 /// </summary>
86 public FunctionWrapper(NativeModule module, string functionName) 106 /// <param name="module">The module wrapper containing the function.</param>
107 /// <param name="functionName">The name of the function to search for.</param>
108 internal FunctionWrapper(NativeModule module, string functionName)
87 { 109 {
88 this.module = module; 110 this.module = module;
89 loadResult = new Lazy<FunctionLoadResult<T>> 111 loadResult = new Lazy<FunctionLoadResult<T>>
@@ -93,9 +115,11 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T
93 }); 115 });
94 } 116 }
95 117
96 ///<summary>Retrieves the result of function load.</summary> 118 /// <summary>Retrieves the result of function load.
97 ///<returns>The load result.</returns> 119 /// <para>Since EFL 1.23.</para>
98 public FunctionLoadResult<T> Value 120 /// </summary>
121 /// <returns>The load result.</returns>
122 internal FunctionLoadResult<T> Value
99 { 123 {
100 get 124 get
101 { 125 {
@@ -104,8 +128,10 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T
104 } 128 }
105} 129}
106 130
107///<summary>The outcome of the function load process.</summary> 131/// <summary>The outcome of the function load process.
108public enum FunctionLoadResultKind 132/// <para>Since EFL 1.23.</para>
133/// </summary>
134enum FunctionLoadResultKind
109{ 135{
110 ///<summary>Function was loaded successfully.</summary> 136 ///<summary>Function was loaded successfully.</summary>
111 Success, 137 Success,
@@ -115,17 +141,24 @@ public enum FunctionLoadResultKind
115 FunctionNotFound 141 FunctionNotFound
116} 142}
117 143
118///<summary>Represents the result of loading a function pointer.</summary> 144/// <summary>Represents the result of loading a function pointer.
119public class FunctionLoadResult<T> 145/// <para>Since EFL 1.23.</para>
146/// </summary>
147class FunctionLoadResult<T>
120{ 148{
121 ///<summary>The status of the load.</summary> 149 /// <summary>The status of the load.
122 public FunctionLoadResultKind Kind; 150 /// <para>Since EFL 1.23.</para>
151 /// </summary>
152 FunctionLoadResultKind Kind;
123 private T _Delegate; 153 private T _Delegate;
124 154
125 ///<summary>The delegate wrapping the loaded function pointer. 155 /// <summary>The delegate wrapping the loaded function pointer.
126 /// 156 ///
127 ///Throws InvalidOperationException if trying to access while not loaded.</summary> 157 /// <para>Throws InvalidOperationException if trying to access while not loaded.</para>
128 public T Delegate 158 /// <para>Since EFL 1.23.</para>
159 /// </summary>
160 /// <value>The <c>delegate</c> wrapping the native function.</value>
161 internal T Delegate
129 { 162 {
130 get 163 get
131 { 164 {
@@ -138,16 +171,20 @@ public class FunctionLoadResult<T>
138 } 171 }
139 } 172 }
140 173
141 ///<summary>Creates a new load result of the given kind.</summary> 174 /// <summary>Creates a new load result of the given kind.
142 ///<param name="kind">The outcome of the load process.</param> 175 /// <para>Since EFL 1.23.</para>
143 public FunctionLoadResult(FunctionLoadResultKind kind) 176 /// </summary>
177 /// <param name="kind">The outcome of the load process.</param>
178 internal FunctionLoadResult(FunctionLoadResultKind kind)
144 { 179 {
145 this.Kind = kind; 180 this.Kind = kind;
146 } 181 }
147 182
148 ///<summary>Creates a new load result with the given delegate.</summary> 183 /// <summary>Creates a new load result with the given delegate.
149 ///<param name="Delegate">The delegate wrapping the native function.</param> 184 /// <para>Since EFL 1.23.</para>
150 public FunctionLoadResult(T Delegate) 185 /// </summary>
186 /// <param name="Delegate">The delegate wrapping the native function.</param>
187 internal FunctionLoadResult(T Delegate)
151 { 188 {
152 this._Delegate = Delegate; 189 this._Delegate = Delegate;
153 this.Kind = FunctionLoadResultKind.Success; 190 this.Kind = FunctionLoadResultKind.Success;
@@ -155,5 +192,3 @@ public class FunctionLoadResult<T>
155} 192}
156 193
157} 194}
158
159}
diff --git a/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs b/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs
index 0069fc6..636f83e 100644
--- a/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs
+++ b/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs
@@ -1,22 +1,36 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using System.Runtime.InteropServices; 17using System.Runtime.InteropServices;
3 18
4namespace Efl 19namespace Efl.Eo
5{ 20{
6 21
7namespace Eo 22internal static partial class FunctionInterop
8{
9
10public static partial class FunctionInterop
11{ 23{
12 [DllImport(efl.Libs.Libdl)] 24 [DllImport(efl.Libs.Libdl)]
13 private static extern IntPtr dlsym(IntPtr handle, string symbol); 25 private static extern IntPtr dlsym(IntPtr handle, string symbol);
14 26
15 ///<summary>Loads a function pointer from the given module.</summary> 27 /// <summary>Loads a function pointer from the given module.
16 ///<param name="nativeLibraryHandle">The module containing the function.</param> 28 /// <para>Since EFL 1.23.</para>
17 ///<param name="functionName">The name of the function to search for.</param> 29 /// </summary>
18 ///<returns>A function pointer that can be used with delegates.</returns> 30 /// <param name="nativeLibraryHandle">The module containing the function.</param>
19 public static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) 31 /// <param name="functionName">The name of the function to search for.</param>
32 /// <returns>A function pointer that can be used with delegates.</returns>
33 internal static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName)
20 { 34 {
21 Eina.Log.Debug($"searching {nativeLibraryHandle} for {functionName}"); 35 Eina.Log.Debug($"searching {nativeLibraryHandle} for {functionName}");
22 var s = FunctionInterop.dlsym(nativeLibraryHandle, functionName); 36 var s = FunctionInterop.dlsym(nativeLibraryHandle, functionName);
@@ -26,5 +40,3 @@ public static partial class FunctionInterop
26} 40}
27 41
28} 42}
29
30}
diff --git a/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs b/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs
index 7eda66a..1ff7627 100644
--- a/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs
+++ b/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs
@@ -1,21 +1,31 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using System.Runtime.InteropServices; 17using System.Runtime.InteropServices;
3 18
4namespace Efl 19namespace Efl.Eo
5{ 20{
6 21
7namespace Eo 22static partial class FunctionInterop
8{
9
10public static partial class FunctionInterop
11{ 23{
12 [DllImport(efl.Libs.Libdl)] 24 [DllImport(efl.Libs.Libdl)]
13 public static extern IntPtr GetProcAddress(IntPtr handle, string symbol); 25 internal static extern IntPtr GetProcAddress(IntPtr handle, string symbol);
14 26
15 private static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) 27 private static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName)
16 => FunctionInterop.GetProcAddress(nativeLibraryHandle, functionName); 28 => FunctionInterop.GetProcAddress(nativeLibraryHandle, functionName);
17} 29}
18 30
19} 31}
20
21}
diff --git a/src/bindings/mono/eo_mono/NativeModule.cs b/src/bindings/mono/eo_mono/NativeModule.cs
index 41f663e..932b453 100644
--- a/src/bindings/mono/eo_mono/NativeModule.cs
+++ b/src/bindings/mono/eo_mono/NativeModule.cs
@@ -1,19 +1,32 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2 17
3namespace Efl 18namespace Efl.Eo
4{
5
6namespace Eo
7{ 19{
8 20
9///<summary>Wraps a native module that was opened with dlopen/LoadLibrary.</summary> 21///<summary>Wraps a native module that was opened with dlopen/LoadLibrary.</summary>
10public partial class NativeModule : IDisposable 22internal partial class NativeModule : IDisposable
11{ 23{
12 private Lazy<IntPtr> module; 24 private Lazy<IntPtr> module;
25 private bool disposed = false;
13 26
14 ///<summary>Lazily tries to load the module with the given name.</summary> 27 ///<summary>Lazily tries to load the module with the given name.</summary>
15 ///<param name="libName">The name of the module to load.</param> 28 ///<param name="libName">The name of the module to load.</param>
16 public NativeModule(string libName) 29 internal NativeModule(string libName)
17 { 30 {
18 module = new Lazy<IntPtr> 31 module = new Lazy<IntPtr>
19 (() => 32 (() =>
@@ -23,7 +36,7 @@ public partial class NativeModule : IDisposable
23 } 36 }
24 37
25 ///<summary>The module that was loaded.</summary> 38 ///<summary>The module that was loaded.</summary>
26 public IntPtr Module 39 internal IntPtr Module
27 { 40 {
28 get 41 get
29 { 42 {
@@ -31,14 +44,39 @@ public partial class NativeModule : IDisposable
31 } 44 }
32 } 45 }
33 46
34 ///<summary>Unload and released the handle to the wrapped module.</summary> 47 /// <summary>Finalizer to be called from the Garbage Collector.</summary>
48 ~NativeModule()
49 {
50 Dispose(false);
51 }
52
53 /// <summary>Unload and released the handle to the wrapped module.</summary>
35 public void Dispose() 54 public void Dispose()
36 { 55 {
37 UnloadLibrary(module.Value); 56 Dispose(true);
38 module = null; 57 GC.SuppressFinalize(this);
39 } 58 }
40}
41 59
60 /// <summary>Unload and released the handle to the wrapped module.</summary>
61 protected virtual void Dispose(bool disposing)
62 {
63 if (disposed)
64 {
65 return;
66 }
67
68 if (disposing)
69 {
70 module = null;
71 }
72
73 if (module.IsValueCreated)
74 {
75 UnloadLibrary(module.Value);
76 }
77
78 disposed = true;
79 }
42} 80}
43 81
44} 82}
diff --git a/src/bindings/mono/eo_mono/NativeModule_Unix.cs b/src/bindings/mono/eo_mono/NativeModule_Unix.cs
index e63b9ba..67409e0 100644
--- a/src/bindings/mono/eo_mono/NativeModule_Unix.cs
+++ b/src/bindings/mono/eo_mono/NativeModule_Unix.cs
@@ -1,13 +1,25 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using System.Runtime.InteropServices; 17using System.Runtime.InteropServices;
3 18
4namespace Efl 19namespace Efl.Eo
5{ 20{
6 21
7namespace Eo 22internal partial class NativeModule
8{
9
10public partial class NativeModule
11{ 23{
12 private const int RTLD_NOW = 0x002; 24 private const int RTLD_NOW = 0x002;
13 // Currently we are using GLOBAL due to issues 25 // Currently we are using GLOBAL due to issues
@@ -21,7 +33,7 @@ public partial class NativeModule
21 33
22 ///<summary>Closes the library handle.</summary> 34 ///<summary>Closes the library handle.</summary>
23 ///<param name="handle">The handle to the library.</param> 35 ///<param name="handle">The handle to the library.</param>
24 public static void UnloadLibrary(IntPtr handle) 36 internal static void UnloadLibrary(IntPtr handle)
25 { 37 {
26 dlclose(handle); 38 dlclose(handle);
27 } 39 }
@@ -48,7 +60,7 @@ public partial class NativeModule
48 ///</summary> 60 ///</summary>
49 ///<param name="filename">The name to search for.</param> 61 ///<param name="filename">The name to search for.</param>
50 ///<returns>The loaded library handle or <see cref="System.IntPtr.Zero"/> on failure.</returns> 62 ///<returns>The loaded library handle or <see cref="System.IntPtr.Zero"/> on failure.</returns>
51 public static IntPtr LoadLibrary(string filename) 63 internal static IntPtr LoadLibrary(string filename)
52 { 64 {
53 Eina.Log.Debug($"Loading library {filename}"); 65 Eina.Log.Debug($"Loading library {filename}");
54 var r = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); 66 var r = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
@@ -70,5 +82,3 @@ public partial class NativeModule
70} 82}
71 83
72} 84}
73
74}
diff --git a/src/bindings/mono/eo_mono/NativeModule_Windows.cs b/src/bindings/mono/eo_mono/NativeModule_Windows.cs
index 1db8340..513eb72 100644
--- a/src/bindings/mono/eo_mono/NativeModule_Windows.cs
+++ b/src/bindings/mono/eo_mono/NativeModule_Windows.cs
@@ -1,18 +1,28 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using System.Runtime.InteropServices; 17using System.Runtime.InteropServices;
3 18
4namespace Efl 19namespace Efl.Eo
5{ 20{
6 21
7namespace Eo 22internal class partial NativeModule
8{
9
10public class partial NativeModule
11{ 23{
12 [DllImport(efl.Libs.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] 24 [DllImport(efl.Libs.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
13 public static extern IntPtr LoadLibrary(string libFilename); 25 internal static extern IntPtr LoadLibrary(string libFilename);
14}
15
16} 26}
17 27
18} 28}
diff --git a/src/bindings/mono/eo_mono/WrapperSupervisor.cs b/src/bindings/mono/eo_mono/WrapperSupervisor.cs
index 21ef052..31cdaa9 100644
--- a/src/bindings/mono/eo_mono/WrapperSupervisor.cs
+++ b/src/bindings/mono/eo_mono/WrapperSupervisor.cs
@@ -1,14 +1,26 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1using System; 16using System;
2using EventDictionary = System.Collections.Generic.Dictionary<(System.IntPtr desc, object evtDelegate), (System.IntPtr evtCallerPtr, Efl.EventCb evtCaller)>; 17using EventDictionary = System.Collections.Generic.Dictionary<(System.IntPtr desc, object evtDelegate), (System.IntPtr evtCallerPtr, Efl.EventCb evtCaller)>;
3 18
4namespace Efl 19namespace Efl.Eo
5{
6
7namespace Eo
8{ 20{
9 21
10/// <summary>Observe the ownership state of an Eo wrapper and control its life-cycle.</summary> 22/// <summary>Observe the ownership state of an Eo wrapper and control its life-cycle.</summary>
11public class WrapperSupervisor 23internal class WrapperSupervisor
12{ 24{
13 private System.WeakReference weakRef; 25 private System.WeakReference weakRef;
14#pragma warning disable CS0414 26#pragma warning disable CS0414
@@ -18,7 +30,7 @@ public class WrapperSupervisor
18 30
19 /// <summary>Create a new supervisor for the given.</summary> 31 /// <summary>Create a new supervisor for the given.</summary>
20 /// <param name="obj">Efl object to be supervised.</param> 32 /// <param name="obj">Efl object to be supervised.</param>
21 public WrapperSupervisor(Efl.Eo.IWrapper obj) 33 internal WrapperSupervisor(Efl.Eo.IWrapper obj)
22 { 34 {
23 weakRef = new WeakReference(obj); 35 weakRef = new WeakReference(obj);
24 sharedRef = null; 36 sharedRef = null;
@@ -26,7 +38,7 @@ public class WrapperSupervisor
26 } 38 }
27 39
28 /// <summary>Efl object being supervised.</summary> 40 /// <summary>Efl object being supervised.</summary>
29 public Efl.Eo.IWrapper Target 41 internal Efl.Eo.IWrapper Target
30 { 42 {
31 get 43 get
32 { 44 {
@@ -35,7 +47,7 @@ public class WrapperSupervisor
35 } 47 }
36 48
37 /// <summary>Dictionary that holds the events related with the supervised object.</summary> 49 /// <summary>Dictionary that holds the events related with the supervised object.</summary>
38 public EventDictionary EoEvents 50 internal EventDictionary EoEvents
39 { 51 {
40 get 52 get
41 { 53 {
@@ -44,13 +56,13 @@ public class WrapperSupervisor
44 } 56 }
45 57
46 /// <summary>To be called when the object is uniquely owned by C#, removing its strong reference and making it available to garbage collection.</summary> 58 /// <summary>To be called when the object is uniquely owned by C#, removing its strong reference and making it available to garbage collection.</summary>
47 public void MakeUnique() 59 internal void MakeUnique()
48 { 60 {
49 sharedRef = null; 61 sharedRef = null;
50 } 62 }
51 63
52 /// <summary>To be called when the object is owned in the native library too, adding a strong reference to it and making it unavailable for garbage collection.</summary> 64 /// <summary>To be called when the object is owned in the native library too, adding a strong reference to it and making it unavailable for garbage collection.</summary>
53 public void MakeShared() 65 internal void MakeShared()
54 { 66 {
55 if (this.Target == null) 67 if (this.Target == null)
56 throw new InvalidOperationException("Tried to make a null reference shared."); 68 throw new InvalidOperationException("Tried to make a null reference shared.");
@@ -60,5 +72,3 @@ public class WrapperSupervisor
60 72
61} 73}
62 74
63}
64
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index fcbd311..780735f 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -1,3 +1,18 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1#pragma warning disable 1591 16#pragma warning disable 1591
2 17
3using System; 18using System;
@@ -5,8 +20,10 @@ using System.Runtime.InteropServices;
5using System.Runtime.CompilerServices; 20using System.Runtime.CompilerServices;
6using System.Collections.Generic; 21using System.Collections.Generic;
7using System.Diagnostics; 22using System.Diagnostics;
23using System.Diagnostics.CodeAnalysis;
8using System.Reflection; 24using System.Reflection;
9using System.Threading; 25using System.Threading;
26using System.Linq;
10 27
11using static Eina.NativeCustomExportFunctions; 28using static Eina.NativeCustomExportFunctions;
12using EoG = Efl.Eo.Globals; 29using EoG = Efl.Eo.Globals;
@@ -17,10 +34,10 @@ namespace Efl
17namespace Eo 34namespace Eo
18{ 35{
19 36
20public static class Globals 37internal static class Globals
21{ 38{
22 /// <summary>Represents the type of the native Efl_Class.</summary> 39 /// <summary>Represents the type of the native Efl_Class.</summary>
23 public enum EflClassType 40 internal enum EflClassType
24 { 41 {
25 /// <summary>Regular EFL classes.</summary> 42 /// <summary>Regular EFL classes.</summary>
26 Regular = 0, 43 Regular = 0,
@@ -35,14 +52,14 @@ public static class Globals
35 } 52 }
36 53
37 [return: MarshalAs(UnmanagedType.U1)] 54 [return: MarshalAs(UnmanagedType.U1)]
38 public delegate bool efl_object_init_delegate(); 55 internal delegate bool efl_object_init_delegate();
39 public static readonly FunctionWrapper<efl_object_init_delegate> efl_object_init_ptr = 56 static readonly FunctionWrapper<efl_object_init_delegate> efl_object_init_ptr =
40 new FunctionWrapper<efl_object_init_delegate>(efl.Libs.EoModule, "efl_object_init"); 57 new FunctionWrapper<efl_object_init_delegate>(efl.Libs.EoModule, "efl_object_init");
41 public static bool efl_object_init() => efl_object_init_ptr.Value.Delegate(); 58 internal static bool efl_object_init() => efl_object_init_ptr.Value.Delegate();
42 59
43 public delegate void efl_object_shutdown_delegate(); 60 internal delegate void efl_object_shutdown_delegate();
44 public static readonly FunctionWrapper<efl_object_shutdown_delegate> efl_object_shutdown_ptr = new FunctionWrapper<efl_object_shutdown_delegate>(efl.Libs.EoModule, "efl_object_shutdown"); 61 static readonly FunctionWrapper<efl_object_shutdown_delegate> efl_object_shutdown_ptr = new FunctionWrapper<efl_object_shutdown_delegate>(efl.Libs.EoModule, "efl_object_shutdown");
45 public static void efl_object_shutdown() => efl_object_shutdown_ptr.Value.Delegate(); 62 internal static void efl_object_shutdown() => efl_object_shutdown_ptr.Value.Delegate();
46 // [DllImport(efl.Libs.Eo)] internal static extern void efl_object_shutdown(); 63 // [DllImport(efl.Libs.Eo)] internal static extern void efl_object_shutdown();
47 64
48 [DllImport(efl.Libs.CustomExports)] internal static extern IntPtr efl_mono_wrapper_supervisor_get(IntPtr eo); 65 [DllImport(efl.Libs.CustomExports)] internal static extern IntPtr efl_mono_wrapper_supervisor_get(IntPtr eo);
@@ -54,19 +71,19 @@ public static class Globals
54 [DllImport(efl.Libs.Eo)] internal static extern IntPtr 71 [DllImport(efl.Libs.Eo)] internal static extern IntPtr
55 _efl_add_internal_start_bindings([MarshalAs(UnmanagedType.LPStr)] String file, int line, IntPtr klass, IntPtr parent, 72 _efl_add_internal_start_bindings([MarshalAs(UnmanagedType.LPStr)] String file, int line, IntPtr klass, IntPtr parent,
56 byte is_ref, byte is_fallback, IntPtr substitute_ctor, IntPtr data); 73 byte is_ref, byte is_fallback, IntPtr substitute_ctor, IntPtr data);
57 public delegate IntPtr 74 internal delegate IntPtr
58 _efl_add_end_delegate(IntPtr eo, byte is_ref, byte is_fallback); 75 _efl_add_end_delegate(IntPtr eo, byte is_ref, byte is_fallback);
59 [DllImport(efl.Libs.Eo)] internal static extern IntPtr 76 [DllImport(efl.Libs.Eo)] internal static extern IntPtr
60 _efl_add_end(IntPtr eo, byte is_ref, byte is_fallback); 77 _efl_add_end(IntPtr eo, byte is_ref, byte is_fallback);
61 public delegate IntPtr 78 internal delegate IntPtr
62 efl_ref_delegate(IntPtr eo); 79 efl_ref_delegate(IntPtr eo);
63 [DllImport(efl.Libs.Eo)] internal static extern IntPtr 80 [DllImport(efl.Libs.Eo)] internal static extern IntPtr
64 efl_ref(IntPtr eo); 81 efl_ref(IntPtr eo);
65 public delegate void 82 internal delegate void
66 efl_unref_delegate(IntPtr eo); 83 efl_unref_delegate(IntPtr eo);
67 [DllImport(efl.Libs.CustomExports)] internal static extern void 84 [DllImport(efl.Libs.CustomExports)] internal static extern void
68 efl_unref(IntPtr eo); 85 efl_unref(IntPtr eo);
69 public delegate int 86 internal delegate int
70 efl_ref_count_delegate(IntPtr eo); 87 efl_ref_count_delegate(IntPtr eo);
71 [DllImport(efl.Libs.Eo)] internal static extern int 88 [DllImport(efl.Libs.Eo)] internal static extern int
72 efl_ref_count(IntPtr eo); 89 efl_ref_count(IntPtr eo);
@@ -183,11 +200,11 @@ public static class Globals
183 [DllImport(efl.Libs.Eo)] internal static extern IntPtr 200 [DllImport(efl.Libs.Eo)] internal static extern IntPtr
184 efl_class_new(IntPtr class_description, IntPtr parent, IntPtr extn1, IntPtr extn2, IntPtr extn3, IntPtr extn4, IntPtr extn5, IntPtr extn6, IntPtr extn7, IntPtr extn8, IntPtr extn9, IntPtr extn10, IntPtr extn11, IntPtr extn12, IntPtr extn13, IntPtr extn14, IntPtr extn15, IntPtr extn16, IntPtr extn17, IntPtr extn18, IntPtr extn19, IntPtr extn20, IntPtr extn21, IntPtr extn22, IntPtr extn23, IntPtr extn24, IntPtr extn25, IntPtr extn26, IntPtr extn27, IntPtr extn28, IntPtr extn29, IntPtr extn30, IntPtr extn31, IntPtr extn32, IntPtr extn33, IntPtr extn34, IntPtr extn35, IntPtr extn36, IntPtr extn37, IntPtr extn38, IntPtr extn39, IntPtr extn40, IntPtr extn41, IntPtr extn42, IntPtr extn43, IntPtr extn44, IntPtr extn45, IntPtr extn46, IntPtr extn47, IntPtr extn48, IntPtr term); 201 efl_class_new(IntPtr class_description, IntPtr parent, IntPtr extn1, IntPtr extn2, IntPtr extn3, IntPtr extn4, IntPtr extn5, IntPtr extn6, IntPtr extn7, IntPtr extn8, IntPtr extn9, IntPtr extn10, IntPtr extn11, IntPtr extn12, IntPtr extn13, IntPtr extn14, IntPtr extn15, IntPtr extn16, IntPtr extn17, IntPtr extn18, IntPtr extn19, IntPtr extn20, IntPtr extn21, IntPtr extn22, IntPtr extn23, IntPtr extn24, IntPtr extn25, IntPtr extn26, IntPtr extn27, IntPtr extn28, IntPtr extn29, IntPtr extn30, IntPtr extn31, IntPtr extn32, IntPtr extn33, IntPtr extn34, IntPtr extn35, IntPtr extn36, IntPtr extn37, IntPtr extn38, IntPtr extn39, IntPtr extn40, IntPtr extn41, IntPtr extn42, IntPtr extn43, IntPtr extn44, IntPtr extn45, IntPtr extn46, IntPtr extn47, IntPtr extn48, IntPtr term);
185 202
186 public delegate byte efl_class_functions_set_delegate(IntPtr klass_id, IntPtr object_ops, IntPtr class_ops); 203 internal delegate byte efl_class_functions_set_delegate(IntPtr klass_id, IntPtr object_ops, IntPtr class_ops);
187 [DllImport(efl.Libs.Eo)] internal static extern byte efl_class_functions_set(IntPtr klass_id, IntPtr object_ops, IntPtr class_ops); 204 [DllImport(efl.Libs.Eo)] internal static extern byte efl_class_functions_set(IntPtr klass_id, IntPtr object_ops, IntPtr class_ops);
188 public delegate IntPtr efl_data_scope_get_delegate(IntPtr obj, IntPtr klass); 205 internal delegate IntPtr efl_data_scope_get_delegate(IntPtr obj, IntPtr klass);
189 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_data_scope_get(IntPtr obj, IntPtr klass); 206 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_data_scope_get(IntPtr obj, IntPtr klass);
190 public delegate IntPtr efl_super_delegate(IntPtr obj, IntPtr klass); 207 internal delegate IntPtr efl_super_delegate(IntPtr obj, IntPtr klass);
191 208
192 /// <summary>Gets a native pointer to <c>obj</c> that forwards the method call to its parent 209 /// <summary>Gets a native pointer to <c>obj</c> that forwards the method call to its parent
193 /// implementation. 210 /// implementation.
@@ -198,13 +215,13 @@ public static class Globals
198 /// <param name="obj">The native pointer to be prepared.</param> 215 /// <param name="obj">The native pointer to be prepared.</param>
199 /// <param name="klass">The current class.</param> 216 /// <param name="klass">The current class.</param>
200 /// <returns>The native pointer to <c>obj</c> prepared to call the parent implementation of <c>klass</c>.</returns> 217 /// <returns>The native pointer to <c>obj</c> prepared to call the parent implementation of <c>klass</c>.</returns>
201 public static IntPtr Super(IntPtr obj, IntPtr klass) 218 internal static IntPtr Super(IntPtr obj, IntPtr klass)
202 { 219 {
203 return efl_super(obj, klass); 220 return efl_super(obj, klass);
204 } 221 }
205 222
206 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_super(IntPtr obj, IntPtr klass); 223 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_super(IntPtr obj, IntPtr klass);
207 public delegate IntPtr efl_class_get_delegate(IntPtr obj); 224 internal delegate IntPtr efl_class_get_delegate(IntPtr obj);
208 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_class_get(IntPtr obj); 225 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_class_get(IntPtr obj);
209 226
210 /// <summary>Gets the native EO class pointer for the given object. 227 /// <summary>Gets the native EO class pointer for the given object.
@@ -214,13 +231,13 @@ public static class Globals
214 /// <param name="obj">The native pointer to the <see cref="Efl.Object" /> instance to get the native class 231 /// <param name="obj">The native pointer to the <see cref="Efl.Object" /> instance to get the native class
215 /// from.</param> 232 /// from.</param>
216 /// <returns>The native class pointer or <see cref="IntPtr.Zero" /> if no such class existis.</returns> 233 /// <returns>The native class pointer or <see cref="IntPtr.Zero" /> if no such class existis.</returns>
217 public static IntPtr GetClass(IntPtr obj) 234 internal static IntPtr GetClass(IntPtr obj)
218 { 235 {
219 return efl_class_get(obj); 236 return efl_class_get(obj);
220 } 237 }
221 238
222 [DllImport(efl.Libs.Eo)] internal static extern EflClassType efl_class_type_get(IntPtr klass); 239 [DllImport(efl.Libs.Eo)] internal static extern EflClassType efl_class_type_get(IntPtr klass);
223 public delegate IntPtr dlerror_delegate(); 240 internal delegate IntPtr dlerror_delegate();
224 [DllImport(efl.Libs.Evil)] internal static extern IntPtr dlerror(); 241 [DllImport(efl.Libs.Evil)] internal static extern IntPtr dlerror();
225 242
226 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_constructor(IntPtr obj); 243 [DllImport(efl.Libs.Eo)] internal static extern IntPtr efl_constructor(IntPtr obj);
@@ -245,36 +262,36 @@ public static class Globals
245 /// <param name="desc">The native event description.</param> 262 /// <param name="desc">The native event description.</param>
246 /// <param name="event_info">The native payload of the event.</param> 263 /// <param name="event_info">The native payload of the event.</param>
247 /// <returns><c>false</c> if one of the callbacks aborted the call. <c>true</c> otherwise.</returns> 264 /// <returns><c>false</c> if one of the callbacks aborted the call. <c>true</c> otherwise.</returns>
248 public static bool CallEventCallback(IntPtr obj, IntPtr desc, IntPtr event_info) 265 internal static bool CallEventCallback(IntPtr obj, IntPtr desc, IntPtr event_info)
249 { 266 {
250 return efl_event_callback_call(obj, desc, event_info); 267 return efl_event_callback_call(obj, desc, event_info);
251 } 268 }
252 269
253 public const int RTLD_NOW = 2; 270 internal const int RTLD_NOW = 2;
254 271
255 public delegate byte class_initializer(IntPtr klass); 272 internal delegate byte class_initializer(IntPtr klass);
256 273
257 public static T GetParamHelper<T>(Nullable<T> v) where T : struct 274 internal static T GetParamHelper<T>(Nullable<T> v) where T : struct
258 { 275 {
259 return v.Value; 276 return v.Value;
260 } 277 }
261 278
262 public static U GetParamHelper<U>(U v) 279 internal static U GetParamHelper<U>(U v)
263 { 280 {
264 return v; 281 return v;
265 } 282 }
266 283
267 public static bool ParamHelperCheck<T>(Nullable<T> v) where T : struct 284 internal static bool ParamHelperCheck<T>(Nullable<T> v) where T : struct
268 { 285 {
269 return v.HasValue; 286 return v.HasValue;
270 } 287 }
271 288
272 public static bool ParamHelperCheck<U>(U v) 289 internal static bool ParamHelperCheck<U>(U v)
273 { 290 {
274 return v != null; 291 return v != null;
275 } 292 }
276 293
277 public static IntPtr register_class(String class_name, IntPtr base_klass, System.Type type) 294 internal static IntPtr register_class(String class_name, IntPtr base_klass, System.Type type)
278 { 295 {
279 ClassDescription description; 296 ClassDescription description;
280 description.version = 2; // EO_VERSION 297 description.version = 2; // EO_VERSION
@@ -313,7 +330,7 @@ public static class Globals
313 return klass; 330 return klass;
314 } 331 }
315 332
316 public static List<IntPtr> get_efl_interfaces(System.Type type) 333 internal static List<IntPtr> get_efl_interfaces(System.Type type)
317 { 334 {
318 System.Type base_type = type.BaseType; 335 System.Type base_type = type.BaseType;
319 336
@@ -353,30 +370,35 @@ public static class Globals
353 return null; 370 return null;
354 } 371 }
355 372
356 public static System.Collections.Generic.List<System.Reflection.MethodInfo> 373 internal static System.Collections.Generic.List<string>
357 GetUserMethods(System.Type type) 374 GetUserMethods(System.Type type)
358 { 375 {
359 var r = new System.Collections.Generic.List<System.Reflection.MethodInfo>(); 376 var r = new System.Collections.Generic.List<string>();
360 var flags = System.Reflection.BindingFlags.Instance 377 var flags =
361 | System.Reflection.BindingFlags.DeclaredOnly 378 System.Reflection.BindingFlags.Instance
362 | System.Reflection.BindingFlags.Public 379 | System.Reflection.BindingFlags.DeclaredOnly
363 | System.Reflection.BindingFlags.NonPublic; 380 | System.Reflection.BindingFlags.Public
364 r.AddRange(type.GetMethods(flags)); 381 | System.Reflection.BindingFlags.NonPublic;
365 var base_type = type.BaseType;
366 382
367 for (;base_type != null; base_type = base_type.BaseType) 383 for (var base_type = type;;base_type = base_type.BaseType)
368 { 384 {
369 if (IsGeneratedClass(base_type)) 385 r.AddRange(base_type.GetMethods(flags)
386 .AsParallel().Select(info=>info.Name).ToList());
387 if (IsGeneratedClass(base_type.BaseType))
370 { 388 {
371 return r; 389 break;
372 } 390 }
373 391
374 r.AddRange(base_type.GetMethods(flags)); 392 if (base_type.BaseType == null)
393 {
394 break;
395 }
375 } 396 }
397
376 return r; 398 return r;
377 } 399 }
378 400
379 public static byte class_initializer_call(IntPtr klass, System.Type type) 401 internal static byte class_initializer_call(IntPtr klass, System.Type type)
380 { 402 {
381 Eina.Log.Debug($"called with 0x{klass.ToInt64():x} {type}"); 403 Eina.Log.Debug($"called with 0x{klass.ToInt64():x} {type}");
382 var derived = type.BaseType; 404 var derived = type.BaseType;
@@ -425,7 +447,7 @@ public static class Globals
425 return 1; 447 return 1;
426 } 448 }
427 449
428 public static IntPtr call_efl_class_new(IntPtr desc, IntPtr bk, List<IntPtr> il = null) 450 internal static IntPtr call_efl_class_new(IntPtr desc, IntPtr bk, List<IntPtr> il = null)
429 { 451 {
430 IntPtr nul = IntPtr.Zero; 452 IntPtr nul = IntPtr.Zero;
431 int iface_list_count = (il == null ? 0 : il.Count); 453 int iface_list_count = (il == null ? 0 : il.Count);
@@ -484,12 +506,12 @@ public static class Globals
484 } 506 }
485 } 507 }
486 508
487 public static Efl.Eo.WrapperSupervisor WrapperSupervisorPtrToManaged(IntPtr wsPtr) 509 internal static Efl.Eo.WrapperSupervisor WrapperSupervisorPtrToManaged(IntPtr wsPtr)
488 { 510 {
489 return (Efl.Eo.WrapperSupervisor) GCHandle.FromIntPtr(wsPtr).Target; 511 return (Efl.Eo.WrapperSupervisor) GCHandle.FromIntPtr(wsPtr).Target;
490 } 512 }
491 513
492 public static Efl.Eo.WrapperSupervisor GetWrapperSupervisor(IntPtr eo) 514 internal static Efl.Eo.WrapperSupervisor GetWrapperSupervisor(IntPtr eo)
493 { 515 {
494 var wsPtr = Efl.Eo.Globals.efl_mono_wrapper_supervisor_get(eo); 516 var wsPtr = Efl.Eo.Globals.efl_mono_wrapper_supervisor_get(eo);
495 if (wsPtr == IntPtr.Zero) 517 if (wsPtr == IntPtr.Zero)
@@ -500,13 +522,13 @@ public static class Globals
500 return WrapperSupervisorPtrToManaged(wsPtr); 522 return WrapperSupervisorPtrToManaged(wsPtr);
501 } 523 }
502 524
503 public static void SetWrapperSupervisor(IntPtr eo, Efl.Eo.WrapperSupervisor ws) 525 internal static void SetWrapperSupervisor(IntPtr eo, Efl.Eo.WrapperSupervisor ws)
504 { 526 {
505 GCHandle gch = GCHandle.Alloc(ws); 527 GCHandle gch = GCHandle.Alloc(ws);
506 Efl.Eo.Globals.efl_mono_wrapper_supervisor_set(eo, GCHandle.ToIntPtr(gch)); 528 Efl.Eo.Globals.efl_mono_wrapper_supervisor_set(eo, GCHandle.ToIntPtr(gch));
507 } 529 }
508 530
509 public static void free_dict_values(Dictionary<String, IntPtr> dict) 531 internal static void free_dict_values(Dictionary<String, IntPtr> dict)
510 { 532 {
511 foreach (IntPtr ptr in dict.Values) 533 foreach (IntPtr ptr in dict.Values)
512 { 534 {
@@ -514,7 +536,7 @@ public static class Globals
514 } 536 }
515 } 537 }
516 538
517 public static void free_stringshare_values(Dictionary<String, IntPtr> dict) 539 internal static void free_stringshare_values(Dictionary<String, IntPtr> dict)
518 { 540 {
519 foreach (IntPtr ptr in dict.Values) 541 foreach (IntPtr ptr in dict.Values)
520 { 542 {
@@ -522,13 +544,13 @@ public static class Globals
522 } 544 }
523 } 545 }
524 546
525 public static void free_gchandle(IntPtr ptr) 547 internal static void free_gchandle(IntPtr ptr)
526 { 548 {
527 GCHandle handle = GCHandle.FromIntPtr(ptr); 549 GCHandle handle = GCHandle.FromIntPtr(ptr);
528 handle.Free(); 550 handle.Free();
529 } 551 }
530 552
531 public static System.Threading.Tasks.Task<Eina.Value> WrapAsync(Eina.Future future, CancellationToken token) 553 internal static System.Threading.Tasks.Task<Eina.Value> WrapAsync(Eina.Future future, CancellationToken token)
532 { 554 {
533 // Creates a task that will wait for SetResult for completion. 555 // Creates a task that will wait for SetResult for completion.
534 // TaskCompletionSource is used to create tasks for 'external' Task sources. 556 // TaskCompletionSource is used to create tasks for 'external' Task sources.
@@ -552,7 +574,7 @@ public static class Globals
552 } 574 }
553 else 575 else
554 { 576 {
555 tcs.TrySetException(new Efl.FutureException(received)); 577 tcs.TrySetException(new Efl.FutureException(err));
556 } 578 }
557 } 579 }
558 else 580 else
@@ -600,7 +622,7 @@ public static class Globals
600 /// <param name="handle">The Eo id to be wrapped.</param> 622 /// <param name="handle">The Eo id to be wrapped.</param>
601 /// <param name="shouldIncRef">Whether we should increase the refcount of the Eo instance.</param> 623 /// <param name="shouldIncRef">Whether we should increase the refcount of the Eo instance.</param>
602 /// <returns>The C# wrapper for this instance.</returns> 624 /// <returns>The C# wrapper for this instance.</returns>
603 public static Efl.Eo.IWrapper CreateWrapperFor(System.IntPtr handle, bool shouldIncRef=true) 625 internal static Efl.Eo.IWrapper CreateWrapperFor(System.IntPtr handle, bool shouldIncRef=true)
604 { 626 {
605 627
606 if (handle == IntPtr.Zero) 628 if (handle == IntPtr.Zero)
@@ -674,7 +696,7 @@ public static class Globals
674 } 696 }
675 697
676 private static Efl.FreeWrapperSupervisorCb FreeWrapperSupervisorCallbackDelegate = new Efl.FreeWrapperSupervisorCb(FreeWrapperSupervisorCallback); 698 private static Efl.FreeWrapperSupervisorCb FreeWrapperSupervisorCallbackDelegate = new Efl.FreeWrapperSupervisorCb(FreeWrapperSupervisorCallback);
677 public static void FreeWrapperSupervisorCallback(IntPtr eo) 699 internal static void FreeWrapperSupervisorCallback(IntPtr eo)
678 { 700 {
679 try 701 try
680 { 702 {
@@ -712,14 +734,14 @@ public static class Globals
712 } 734 }
713 } 735 }
714 736
715 public static void SetNativeDisposeCallbacks() 737 internal static void SetNativeDisposeCallbacks()
716 { 738 {
717 efl_mono_wrapper_supervisor_callbacks_set(FreeWrapperSupervisorCallbackDelegate); 739 efl_mono_wrapper_supervisor_callbacks_set(FreeWrapperSupervisorCallbackDelegate);
718 } 740 }
719 741
720 public static void ThreadSafeFreeCbExec(EinaFreeCb cbFreeCb, IntPtr cbData) 742 internal static void ThreadSafeFreeCbExec(Eina.Callbacks.EinaFreeCb cbFreeCb, IntPtr cbData)
721 { 743 {
722 EinaFreeCb cb = (IntPtr gcHandlePtr) => { 744 Eina.Callbacks.EinaFreeCb cb = (IntPtr gcHandlePtr) => {
723 cbFreeCb(cbData); 745 cbFreeCb(cbData);
724 GCHandle gcHandle = GCHandle.FromIntPtr(gcHandlePtr); 746 GCHandle gcHandle = GCHandle.FromIntPtr(gcHandlePtr);
725 gcHandle.Free(); 747 gcHandle.Free();
@@ -737,32 +759,261 @@ public static class Globals
737 Monitor.Exit(Efl.All.InitLock); 759 Monitor.Exit(Efl.All.InitLock);
738 } 760 }
739 761
740 /// <summary> 762 internal static IEnumerable<T> AccessorToIEnumerable<T>(IntPtr accessor)
741 /// Internal struct used by the binding to pass the native handle pointer 763 {
742 /// to the managed object wrapping constructor. 764 if (accessor == IntPtr.Zero)
743 /// Internal usage only: do not use this class in inherited classes. 765 throw new ArgumentException("accessor is null", nameof(accessor));
744 /// </summary> 766
745 public struct WrappingHandle 767 IntPtr data = IntPtr.Zero;
768 uint position = 0;
769
770 while (Eina.AccessorNativeFunctions.eina_accessor_data_get(accessor, position, out data))
771 {
772 yield return Eina.TraitFunctions.NativeToManaged<T>(data);
773 position += 1;
774 }
775 }
776
777 internal static IntPtr IEnumerableToAccessor<T>(IEnumerable<T> enumerable, bool isMoved)
778 {
779 if (enumerable == null)
780 {
781 throw new ArgumentException("enumerable is null", nameof(enumerable));
782 }
783
784 // If we are a wrapper around an existing Eina.Accessor, we can just forward
785 // it and avoid unnecessary copying in non-owning transfers.
786 var wrappedAccessor = enumerable as Eina.Accessor<T>;
787
788 if (wrappedAccessor != null && !isMoved)
789 {
790 return wrappedAccessor.Handle;
791 }
792
793 // TODO: Check if we're either an Eina.List or Eina.Collection?
794 // We could just rewrap their native accessors
795 IntPtr[] intPtrs = new IntPtr[enumerable.Count()];
796
797 int i = 0;
798 foreach (T data in enumerable)
799 {
800 intPtrs[i] = Eina.TraitFunctions.ManagedToNativeAlloc<T>(data);
801 i++;
802 }
803
804 GCHandle pinnedArray = GCHandle.Alloc(intPtrs, GCHandleType.Pinned);
805 IntPtr nativeAccessor = IntPtr.Zero;
806
807 if (isMoved)
808 {
809 // We need a custom accessor that would unpin the data when freed.
810 nativeAccessor = Eina.AccessorNativeFunctions.eina_mono_owned_carray_length_accessor_new(pinnedArray.AddrOfPinnedObject(),
811 (uint)IntPtr.Size,
812 (uint)intPtrs.Length,
813 free_gchandle,
814 GCHandle.ToIntPtr(pinnedArray));
815 }
816 else
817 {
818 // FIXME: Leaking....
819 nativeAccessor = Eina.AccessorNativeFunctions.eina_carray_length_accessor_new(pinnedArray.AddrOfPinnedObject(),
820 (uint)(IntPtr.Size),
821 (uint)intPtrs.Length);
822 }
823
824 if (nativeAccessor == IntPtr.Zero)
825 {
826 pinnedArray.Free();
827 throw new InvalidOperationException("Failed to get native accessor for the given container");
828 }
829
830 return nativeAccessor;
831 }
832
833 internal static IEnumerable<T> IteratorToIEnumerable<T>(IntPtr iterator)
834 {
835 if (iterator == IntPtr.Zero)
836 throw new ArgumentException("iterator is null", nameof(iterator));
837
838 while (Eina.IteratorNativeFunctions.eina_iterator_next(iterator, out IntPtr data))
839 {
840 yield return Eina.TraitFunctions.NativeToManaged<T>(data);
841 }
842 }
843
844 internal static IntPtr IEnumerableToIterator<T>(IEnumerable<T> enumerable, bool isMoved)
845 {
846 if (enumerable == null)
847 {
848 throw new ArgumentException("enumerable is null", nameof(enumerable));
849 }
850
851 // If we are a wrapper around an existing Eina.Iterator, we can just forward
852 // it and avoid unnecessary copying in non-owning transfers.
853 var wrappedIterator = enumerable as Eina.Iterator<T>;
854
855 if (wrappedIterator != null && !isMoved)
856 {
857 return wrappedIterator.Handle;
858 }
859
860 var list = new List<IntPtr>();
861 foreach (T data in enumerable)
862 {
863 list.Add(Eina.TraitFunctions.ManagedToNativeAlloc<T>(data));
864 }
865
866 IntPtr[] dataArray = list.ToArray();
867 GCHandle pinnedArray = GCHandle.Alloc(dataArray, GCHandleType.Pinned);
868 IntPtr ret = Eina.IteratorNativeFunctions.eina_carray_length_iterator_new(pinnedArray.AddrOfPinnedObject(), (uint)(IntPtr.Size), (uint)dataArray.Length);
869
870 if (!isMoved)
871 {
872 // FIXME Need to free ret and unpin pinnedArray in the future.
873 }
874
875 return ret;
876 }
877
878 internal static IList<T> NativeListToIList<T>(IntPtr nativeList)
746 { 879 {
747 public WrappingHandle(IntPtr h) 880 if (nativeList == IntPtr.Zero)
881 throw new ArgumentException("nativeList is null", nameof(nativeList));
882
883 IntPtr l;
884 List<T> list = new List<T>();
885 for (l = nativeList; l != IntPtr.Zero; l = Eina.ListNativeFunctions.eina_list_next_custom_export_mono(l))
748 { 886 {
749 NativeHandle = h; 887 list.Add(Eina.TraitFunctions.NativeToManaged<T>(Eina.ListNativeFunctions.eina_list_data_get_custom_export_mono(l)));
750 } 888 }
889 return list;
890 }
751 891
752 public IntPtr NativeHandle { get; private set; } 892 internal static IntPtr IListToNativeList<T>(IList<T> list, bool isMoved)
893 {
894 if (list == null)
895 throw new ArgumentException("list is null", nameof(list));
896
897 // If we are a wrapper around an existing Eina.List, we can just forward
898 // it and avoid unnecessary copying in non-owning transfers.
899 var wrappedList = list as Eina.List<T>;
900
901 if (wrappedList != null && !isMoved)
902 {
903 return wrappedList.Handle;
904 }
905
906 IntPtr nativeList = IntPtr.Zero;
907 foreach (T data in list)
908 {
909 nativeList = Eina.ListNativeFunctions.eina_list_append(nativeList, Eina.TraitFunctions.ManagedToNativeAlloc(data)); //FIXME: need to free
910 }
911
912 if (!isMoved)
913 {
914 // FIXME Need to free ret and unpin pinnedArray in the future.
915 }
916
917 return nativeList;
918 }
919
920 internal static IList<T> NativeArrayToIList<T>(IntPtr nativeArray)
921 {
922 if (nativeArray == IntPtr.Zero)
923 throw new ArgumentException("nativeArray is null", nameof(nativeArray));
924
925 List<T> list = new List<T>();
926 UpdateListFromNativeArray(list, nativeArray);
927
928 // FIXME need to free `list` if the returned list is not @moved
929 return list;
930 }
931
932 internal static IntPtr IListToNativeArray<T>(IList<T> list, bool isMoved)
933 {
934 if (list == null)
935 throw new ArgumentException("list is null", nameof(list));
936
937 // If we are a wrapper around an existing Eina.Array, we can just forward
938 // it and avoid unnecessary copying in non-owning transfers.
939 var wrappedArray = list as Eina.Array<T>;
940
941 if (wrappedArray != null && !isMoved)
942 {
943 return wrappedArray.Handle;
944 }
945
946 IntPtr nativeArray = Eina.ArrayNativeFunctions.eina_array_new(4);
947 foreach (T data in list)
948 {
949 Eina.ArrayNativeFunctions.eina_array_push_custom_export_mono(nativeArray, Eina.TraitFunctions.ManagedToNativeAlloc(data)); //FIXME: need to free
950 }
951
952 if (!isMoved)
953 {
954 // FIXME Need to free ret and unpin pinnedArray in the future.
955 }
956
957 return nativeArray;
958 }
959
960 internal static void UpdateListFromNativeArray<T>(IList<T> list, IntPtr nativeArray)
961 {
962 // Do not update if list Handle is same to nativeArray. They already updated in native code.
963 var wrappedArray = list as Eina.Array<T>;
964 if (wrappedArray != null && wrappedArray.Handle == nativeArray)
965 return;
966
967 list.Clear();
968 if (nativeArray == IntPtr.Zero)
969 {
970 return;
971 }
972
973 uint count = Eina.ArrayNativeFunctions.eina_array_count_custom_export_mono(nativeArray);
974 for (uint i = 0; i < count; i++)
975 {
976 list.Add(Eina.TraitFunctions.NativeToManaged<T>(Eina.ArrayNativeFunctions.eina_array_data_get_custom_export_mono(nativeArray, i)));
977 }
753 } 978 }
754 979
755} // Globals 980} // Globals
756 981
757public static class Config 982/// <summary>
983/// Internal struct used by the binding to pass the native handle pointer
984/// to the managed object wrapping constructor.
985/// Internal usage only: do not use this class in inherited classes.
986/// </summary>
987internal struct WrappingHandle
758{ 988{
989 public WrappingHandle(IntPtr h)
990 {
991 NativeHandle = h;
992 }
759 993
994 public IntPtr NativeHandle { get; private set; }
995}
996
997/// <summary>
998/// Manage the initialization and cleanup for the Efl object subsystem.
999/// <para>Since EFL 1.24.</para>
1000/// </summary>
1001public static class Config
1002{
1003 /// <summary>
1004 /// Initialize the EFL object subsystem.
1005 /// <para>Since EFL 1.24.</para>
1006 /// </summary>
760 public static void Init() 1007 public static void Init()
761 { 1008 {
762 Globals.efl_object_init(); 1009 Globals.efl_object_init();
763 Globals.SetNativeDisposeCallbacks(); 1010 Globals.SetNativeDisposeCallbacks();
764 } 1011 }
765 1012
1013 /// <summary>
1014 /// Shutdown the EFL object subsystem.
1015 /// <para>Since EFL 1.24.</para>
1016 /// </summary>
766 public static void Shutdown() 1017 public static void Shutdown()
767 { 1018 {
768 Globals.efl_object_shutdown(); 1019 Globals.efl_object_shutdown();
@@ -774,23 +1025,23 @@ public static class Config
774 AllowMultiple = false, 1025 AllowMultiple = false,
775 Inherited = false) 1026 Inherited = false)
776] 1027]
777public abstract class NativeClass : System.Attribute 1028abstract class NativeClass : System.Attribute
778{ 1029{
779 public abstract IntPtr GetEflClass(); 1030 internal abstract IntPtr GetEflClass();
780 public abstract System.Collections.Generic.List<EflOpDescription> GetEoOps(System.Type type, bool includeInherited); 1031 internal abstract System.Collections.Generic.List<EflOpDescription> GetEoOps(System.Type type, bool includeInherited);
781} 1032}
782 1033
783/// <summary>Attribute for private native classes. 1034/// <summary>Attribute for private native classes.
784/// 1035///
785/// <para>For internal usage by generated code only.</para></summary> 1036/// <para>For internal usage by generated code only.</para></summary>
786public class PrivateNativeClass : NativeClass 1037class PrivateNativeClass : NativeClass
787{ 1038{
788 public override IntPtr GetEflClass() 1039 internal override IntPtr GetEflClass()
789 { 1040 {
790 return IntPtr.Zero; 1041 return IntPtr.Zero;
791 } 1042 }
792 1043
793 public override System.Collections.Generic.List<EflOpDescription> GetEoOps(System.Type type, bool includeInherited) 1044 internal override System.Collections.Generic.List<EflOpDescription> GetEoOps(System.Type type, bool includeInherited)
794 { 1045 {
795 return null; 1046 return null;
796 } 1047 }
@@ -804,11 +1055,11 @@ public class PrivateNativeClass : NativeClass
804 AllowMultiple = false, 1055 AllowMultiple = false,
805 Inherited = false) 1056 Inherited = false)
806] 1057]
807public class BindingEntity: System.Attribute 1058internal class BindingEntityAttribute: System.Attribute
808{ 1059{
809 public static bool IsBindingEntity(System.Type t) 1060 public static bool IsBindingEntity(System.Type t)
810 { 1061 {
811 return Attribute.GetCustomAttribute(t, typeof(BindingEntity), false) != null; 1062 return Attribute.GetCustomAttribute(t, typeof(BindingEntityAttribute), false) != null;
812 } 1063 }
813} 1064}
814 1065
@@ -827,9 +1078,9 @@ public interface IWrapper
827 } 1078 }
828} 1079}
829 1080
830public static class ClassRegister 1081internal static class ClassRegister
831{ 1082{
832 public static System.Type GetManagedType(IntPtr klass) 1083 internal static System.Type GetManagedType(IntPtr klass)
833 { 1084 {
834 System.Type t; 1085 System.Type t;
835 if (Efl.Eo.ClassRegister.typeFromKlass.TryGetValue(klass, out t)) 1086 if (Efl.Eo.ClassRegister.typeFromKlass.TryGetValue(klass, out t))
@@ -843,16 +1094,17 @@ public static class ClassRegister
843 { 1094 {
844 throw new System.InvalidOperationException($"Could not get Native class name. Handle: {klass}"); 1095 throw new System.InvalidOperationException($"Could not get Native class name. Handle: {klass}");
845 } 1096 }
846 1097#pragma warning disable CA1307
847 string name = Eina.StringConversion.NativeUtf8ToManagedString(namePtr) 1098 string name = Eina.StringConversion.NativeUtf8ToManagedString(namePtr)
848 .Replace("_", ""); // Convert Efl C name to C# name 1099 .Replace("_", ""); // Convert Efl C name to C# name
1100#pragma warning restore CA1307
849 1101
850 // Check if this is an internal implementation of an abstract class 1102 // Check if this is an internal implementation of an abstract class
851 var abstract_impl_suffix = "Realized"; 1103 var abstract_impl_suffix = "Realized";
852 if (name.EndsWith(abstract_impl_suffix)) 1104 if (name.EndsWith(abstract_impl_suffix, StringComparison.Ordinal))
853 { 1105 {
854 name = name.Substring(0, name.Length - abstract_impl_suffix.Length); 1106 name = name.Substring(0, name.Length - abstract_impl_suffix.Length);
855 var lastDot = name.LastIndexOf("."); 1107 var lastDot = name.LastIndexOf(".", StringComparison.Ordinal);
856 var klassName = name.Substring(lastDot + 1); 1108 var klassName = name.Substring(lastDot + 1);
857 name += "+" + klassName + abstract_impl_suffix; // '+' is the separator for nested classes 1109 name += "+" + klassName + abstract_impl_suffix; // '+' is the separator for nested classes
858 } 1110 }
@@ -861,7 +1113,7 @@ public static class ClassRegister
861 var klass_type = Efl.Eo.Globals.efl_class_type_get(klass); 1113 var klass_type = Efl.Eo.Globals.efl_class_type_get(klass);
862 if (klass_type == Efl.Eo.Globals.EflClassType.Interface || klass_type == Efl.Eo.Globals.EflClassType.Mixin) 1114 if (klass_type == Efl.Eo.Globals.EflClassType.Interface || klass_type == Efl.Eo.Globals.EflClassType.Mixin)
863 { 1115 {
864 var pos = name.LastIndexOf("."); 1116 var pos = name.LastIndexOf(".", StringComparison.Ordinal);
865 name = name.Insert(pos + 1, "I"); // -1 if not found, inserts at 0 normally 1117 name = name.Insert(pos + 1, "I"); // -1 if not found, inserts at 0 normally
866 } 1118 }
867 1119
@@ -893,7 +1145,7 @@ public static class ClassRegister
893 return t; 1145 return t;
894 } 1146 }
895 1147
896 public static IntPtr GetKlass(System.Type objectType) 1148 internal static IntPtr GetKlass(System.Type objectType)
897 { 1149 {
898 IntPtr klass; 1150 IntPtr klass;
899 if (klassFromType.TryGetValue(objectType, out klass)) 1151 if (klassFromType.TryGetValue(objectType, out klass))
@@ -920,7 +1172,7 @@ public static class ClassRegister
920 return RegisterKlass(baseKlass, objectType); 1172 return RegisterKlass(baseKlass, objectType);
921 } 1173 }
922 1174
923 public static IntPtr GetInheritKlassOrRegister(IntPtr baseKlass, System.Type objectType) 1175 internal static IntPtr GetInheritKlassOrRegister(IntPtr baseKlass, System.Type objectType)
924 { 1176 {
925 IntPtr klass; 1177 IntPtr klass;
926 if (klassFromType.TryGetValue(objectType, out klass)) 1178 if (klassFromType.TryGetValue(objectType, out klass))
@@ -990,89 +1242,190 @@ public static class ClassRegister
990 return (IntPtr)(method.Invoke(null, null)); 1242 return (IntPtr)(method.Invoke(null, null));
991 } 1243 }
992 1244
993 public static void AddToKlassTypeBiDictionary(IntPtr klassPtr, System.Type objectType) 1245 internal static void AddToKlassTypeBiDictionary(IntPtr klassPtr, System.Type objectType)
994 { 1246 {
995 klassFromType[objectType] = klassPtr; 1247 klassFromType[objectType] = klassPtr;
996 typeFromKlass[klassPtr] = objectType; 1248 typeFromKlass[klassPtr] = objectType;
997 } 1249 }
998 1250
999 public static readonly System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.IntPtr> klassFromType 1251 internal static readonly System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.IntPtr> klassFromType
1000 = new System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.IntPtr>(); 1252 = new System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.IntPtr>();
1001 1253
1002 public static readonly System.Collections.Concurrent.ConcurrentDictionary<System.IntPtr, System.Type> typeFromKlass 1254 internal static readonly System.Collections.Concurrent.ConcurrentDictionary<System.IntPtr, System.Type> typeFromKlass
1003 = new System.Collections.Concurrent.ConcurrentDictionary<System.IntPtr, System.Type>(); 1255 = new System.Collections.Concurrent.ConcurrentDictionary<System.IntPtr, System.Type>();
1004 1256
1005 private static readonly object klassAllocLock = new object(); 1257 private static readonly object klassAllocLock = new object();
1006} 1258}
1007 1259
1008public interface IOwnershipTag 1260/// <summary>Custom marshaler for Eo objects that do not move ownership between native and managed code.
1261///
1262/// <para>For internal usage by generated code.</para>
1263///
1264/// <para>Since EFL 1.24.</para>
1265/// </summary>
1266class MarshalEoNoMove : ICustomMarshaler
1009{ 1267{
1010} 1268 private static ICustomMarshaler instance = new MarshalEoNoMove();
1011 1269
1012public class OwnTag : IOwnershipTag 1270 /// <summary>
1013{ 1271 /// Gets an instance of this marshaler.
1014} 1272 /// <para>Since EFL 1.24.</para>
1273 /// </summary>
1274 /// <param name="cookie">Cookie to identify the marshaler. Unused.</param>
1275 /// <returns>The marshaler instance.</returns>
1276 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "The same marshaler is used for all cases.")]
1277 public static ICustomMarshaler GetInstance(string cookie) => instance;
1015 1278
1016public class NonOwnTag : IOwnershipTag 1279 /// <summary>
1017{ 1280 /// Clean ups the managed data.
1018} 1281 /// <para>Since EFL 1.24.</para>
1282 /// </summary>
1283 /// <param name="ManagedObj">The object to be cleaned.</param>
1284 public void CleanUpManagedData(object ManagedObj)
1285 {
1286 }
1019 1287
1020public class MarshalEo<U> : ICustomMarshaler 1288 /// <summary>
1021 where U : IOwnershipTag 1289 /// Clean ups the native data if it was created.
1022{ 1290 /// <para>Since EFL 1.24.</para>
1023 public static ICustomMarshaler GetInstance(string cookie) 1291 /// </summary>
1292 /// <param name="pNativeData">The native data to be cleaned.</param>
1293 public void CleanUpNativeData(IntPtr pNativeData)
1024 { 1294 {
1025 Eina.Log.Debug("MarshalEo.GetInstace cookie " + cookie);
1026 return new MarshalEo<U>();
1027 } 1295 }
1028 1296
1029 public void CleanUpManagedData(object ManagedObj) 1297 /// <summary>
1298 /// Gets the native data size.
1299 /// <para>Since EFL 1.24.</para>
1300 /// </summary>
1301 /// <returns>The data size in bytes.</returns>
1302 public int GetNativeDataSize() => -1;
1303
1304 /// <summary>
1305 /// Marshals the given managed object to its native handle.
1306 /// <para>As this marshaler does not move the reference, the managed code
1307 /// can keep its reference and does not need to incref.</para>
1308 /// <para>Since EFL 1.24.</para>
1309 /// </summary>
1310 /// <param name="ManagedObj">The object to be marshalled.</param>
1311 /// <returns>The marshalled native data.</returns>
1312 public IntPtr MarshalManagedToNative(object ManagedObj)
1030 { 1313 {
1031 //Eina.Log.Warning("MarshalEo.CleanUpManagedData not implemented"); 1314 if (ManagedObj == null)
1032 //throw new NotImplementedException(); 1315 {
1316 return IntPtr.Zero;
1317 }
1318
1319 IWrapper wrapper = ManagedObj as IWrapper;
1320
1321 if (wrapper == null)
1322 {
1323 throw new ArgumentException("Managed object to be marshalled must be an IWrapper.");
1324 }
1325
1326 return wrapper.NativeHandle;
1033 } 1327 }
1034 1328
1035 public void CleanUpNativeData(IntPtr pNativeData) 1329 /// <summary>
1330 /// Marshals the given native pointer into a managed object.
1331 /// <para>The given native object has its reference count incremented in order to make
1332 /// the C# wrapper capable of accessing it while the wrapper is alive.</para>
1333 /// <para>Since EFL 1.24.</para>
1334 /// </summary>
1335 /// <param name="pNativeData">The native pointer to the EO object.</param>
1336 /// <returns>The managed wrapper for the given native object.</returns>
1337 public object MarshalNativeToManaged(IntPtr pNativeData)
1036 { 1338 {
1037 //Eina.Log.Warning("MarshalEo.CleanUpNativeData not implemented"); 1339 return Efl.Eo.Globals.CreateWrapperFor(pNativeData, shouldIncRef : true);
1038 //throw new NotImplementedException();
1039 } 1340 }
1341}
1040 1342
1041 public int GetNativeDataSize() 1343/// <summary>Custom marshaler for Eo objects that move ownership between native and managed code.
1344///
1345/// <para>For internal usage by generated code.</para>
1346///
1347/// <para>Since EFL 1.24.</para>
1348/// </summary>
1349class MarshalEoMove : ICustomMarshaler
1350{
1351 private static ICustomMarshaler instance = new MarshalEoMove();
1352
1353 /// <summary>
1354 /// Gets an instance of this marshaler.
1355 /// <para>Since EFL 1.24.</para>
1356 /// </summary>
1357 /// <param name="cookie">Cookie to identify the marshaler. Unused.</param>
1358 /// <returns>The marshaler instance.</returns>
1359 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification = "The same marshaler is used for all cases.")]
1360 public static ICustomMarshaler GetInstance(string cookie) => instance;
1361
1362 /// <summary>
1363 /// Clean ups the managed data.
1364 /// <para>Since EFL 1.24.</para>
1365 /// </summary>
1366 /// <param name="ManagedObj">The object to be cleaned.</param>
1367 public void CleanUpManagedData(object ManagedObj)
1042 { 1368 {
1043 Eina.Log.Debug("MarshalEo.GetNativeDataSize");
1044 return 0;
1045 //return 8;
1046 } 1369 }
1047 1370
1048 public IntPtr MarshalManagedToNative(object ManagedObj) 1371 /// <summary>
1372 /// Clean ups the native data if it was created.
1373 /// <para>Since EFL 1.24.</para>
1374 /// </summary>
1375 /// <param name="pNativeData">The native data to be cleaned.</param>
1376 public void CleanUpNativeData(IntPtr pNativeData)
1049 { 1377 {
1050 Eina.Log.Debug("MarshalEo.MarshallManagedToNative"); 1378 }
1379
1380 /// <summary>
1381 /// Gets the native data size.
1382 /// <para>Since EFL 1.24.</para>
1383 /// </summary>
1384 /// <returns>The data size in bytes.</returns>
1385 public int GetNativeDataSize() => -1;
1051 1386
1387 /// <summary>
1388 /// Marshals the given managed object to its native handle.
1389 /// <para>The wrapper given as parameter needs to keep a reference to the native
1390 /// object, so the EO has its refcount incremented.</para>
1391 /// <para>Since EFL 1.24.</para>
1392 /// </summary>
1393 /// <param name="ManagedObj">The object to be marshalled.</param>
1394 /// <returns>The marshalled native data.</returns>
1395 public IntPtr MarshalManagedToNative(object ManagedObj)
1396 {
1052 if (ManagedObj == null) 1397 if (ManagedObj == null)
1053 { 1398 {
1054 return IntPtr.Zero; 1399 return IntPtr.Zero;
1055 } 1400 }
1056 1401
1057 var r = ((IWrapper)ManagedObj).NativeHandle; 1402 IWrapper wrapper = ManagedObj as IWrapper;
1058 if (typeof(U) == typeof(OwnTag)) 1403
1404 if (wrapper == null)
1059 { 1405 {
1060 Efl.Eo.Globals.efl_ref(r); 1406 throw new ArgumentException("Managed object to be marshalled must be an IWrapper.");
1061 } 1407 }
1062 1408
1063 return r; 1409 return Efl.Eo.Globals.efl_ref(wrapper.NativeHandle);
1064 } 1410 }
1065 1411
1412 /// <summary>
1413 /// Marshals the given native pointer into a managed object.
1414 /// <para>The returned wrapper "steals" the reference to keep it alive.</para>
1415 /// <para>Since EFL 1.24.</para>
1416 /// </summary>
1417 /// <param name="pNativeData">The native pointer to the EO object.</param>
1418 /// <returns>The managed wrapper for the given native object.</returns>
1066 public object MarshalNativeToManaged(IntPtr pNativeData) 1419 public object MarshalNativeToManaged(IntPtr pNativeData)
1067 { 1420 {
1068 return Efl.Eo.Globals.CreateWrapperFor(pNativeData, shouldIncRef : typeof(U) != typeof(OwnTag)); 1421 return Efl.Eo.Globals.CreateWrapperFor(pNativeData, shouldIncRef : false);
1069 } 1422 }
1070} 1423}
1071 1424
1072///<summary>Marshals between System.Type instances and Eo classes (IntPtrs).</summary> 1425///<summary>Marshals between System.Type instances and Eo classes (IntPtrs).</summary>
1073public class MarshalEflClass : ICustomMarshaler 1426class MarshalEflClass : ICustomMarshaler
1074{ 1427{
1075 public static ICustomMarshaler GetInstance(string cookie) 1428 internal static ICustomMarshaler GetInstance(string cookie)
1076 { 1429 {
1077 Eina.Log.Debug("MarshalEflClass.GetInstance cookie " + cookie); 1430 Eina.Log.Debug("MarshalEflClass.GetInstance cookie " + cookie);
1078 return new MarshalEflClass(); 1431 return new MarshalEflClass();
@@ -1116,7 +1469,7 @@ public class MarshalEflClass : ICustomMarshaler
1116 } 1469 }
1117} 1470}
1118 1471
1119public class StringPassOwnershipMarshaler : ICustomMarshaler 1472class StringPassOwnershipMarshaler : ICustomMarshaler
1120{ 1473{
1121 public object MarshalNativeToManaged(IntPtr pNativeData) 1474 public object MarshalNativeToManaged(IntPtr pNativeData)
1122 { 1475 {
@@ -1144,7 +1497,7 @@ public class StringPassOwnershipMarshaler : ICustomMarshaler
1144 return -1; 1497 return -1;
1145 } 1498 }
1146 1499
1147 public static ICustomMarshaler GetInstance(string cookie) 1500 internal static ICustomMarshaler GetInstance(string cookie)
1148 { 1501 {
1149 if (marshaler == null) 1502 if (marshaler == null)
1150 { 1503 {
@@ -1157,7 +1510,7 @@ public class StringPassOwnershipMarshaler : ICustomMarshaler
1157 static private StringPassOwnershipMarshaler marshaler; 1510 static private StringPassOwnershipMarshaler marshaler;
1158} 1511}
1159 1512
1160public class StringKeepOwnershipMarshaler: ICustomMarshaler 1513class StringKeepOwnershipMarshaler: ICustomMarshaler
1161{ 1514{
1162 public object MarshalNativeToManaged(IntPtr pNativeData) 1515 public object MarshalNativeToManaged(IntPtr pNativeData)
1163 { 1516 {
@@ -1183,7 +1536,7 @@ public class StringKeepOwnershipMarshaler: ICustomMarshaler
1183 return -1; 1536 return -1;
1184 } 1537 }
1185 1538
1186 public static ICustomMarshaler GetInstance(string cookie) 1539 internal static ICustomMarshaler GetInstance(string cookie)
1187 { 1540 {
1188 if (marshaler == null) 1541 if (marshaler == null)
1189 { 1542 {
@@ -1196,7 +1549,7 @@ public class StringKeepOwnershipMarshaler: ICustomMarshaler
1196 static private StringKeepOwnershipMarshaler marshaler; 1549 static private StringKeepOwnershipMarshaler marshaler;
1197} 1550}
1198 1551
1199public class StringsharePassOwnershipMarshaler : ICustomMarshaler 1552class StringsharePassOwnershipMarshaler : ICustomMarshaler
1200{ 1553{
1201 public object MarshalNativeToManaged(IntPtr pNativeData) 1554 public object MarshalNativeToManaged(IntPtr pNativeData)
1202 { 1555 {
@@ -1224,7 +1577,7 @@ public class StringsharePassOwnershipMarshaler : ICustomMarshaler
1224 return -1; 1577 return -1;
1225 } 1578 }
1226 1579
1227 public static ICustomMarshaler GetInstance(string cookie) 1580 internal static ICustomMarshaler GetInstance(string cookie)
1228 { 1581 {
1229 if (marshaler == null) 1582 if (marshaler == null)
1230 { 1583 {
@@ -1237,7 +1590,7 @@ public class StringsharePassOwnershipMarshaler : ICustomMarshaler
1237 static private StringsharePassOwnershipMarshaler marshaler; 1590 static private StringsharePassOwnershipMarshaler marshaler;
1238} 1591}
1239 1592
1240public class StringshareKeepOwnershipMarshaler : ICustomMarshaler 1593class StringshareKeepOwnershipMarshaler : ICustomMarshaler
1241{ 1594{
1242 public object MarshalNativeToManaged(IntPtr pNativeData) 1595 public object MarshalNativeToManaged(IntPtr pNativeData)
1243 { 1596 {
@@ -1263,7 +1616,7 @@ public class StringshareKeepOwnershipMarshaler : ICustomMarshaler
1263 return -1; 1616 return -1;
1264 } 1617 }
1265 1618
1266 public static ICustomMarshaler GetInstance(string cookie) 1619 internal static ICustomMarshaler GetInstance(string cookie)
1267 { 1620 {
1268 if (marshaler == null) 1621 if (marshaler == null)
1269 { 1622 {
@@ -1276,7 +1629,7 @@ public class StringshareKeepOwnershipMarshaler : ICustomMarshaler
1276 static private StringshareKeepOwnershipMarshaler marshaler; 1629 static private StringshareKeepOwnershipMarshaler marshaler;
1277} 1630}
1278 1631
1279public class StrbufPassOwnershipMarshaler : ICustomMarshaler 1632class StrbufPassOwnershipMarshaler : ICustomMarshaler
1280{ 1633{
1281 public object MarshalNativeToManaged(IntPtr pNativeData) 1634 public object MarshalNativeToManaged(IntPtr pNativeData)
1282 { 1635 {
@@ -1304,7 +1657,7 @@ public class StrbufPassOwnershipMarshaler : ICustomMarshaler
1304 return -1; 1657 return -1;
1305 } 1658 }
1306 1659
1307 public static ICustomMarshaler GetInstance(string cookie) 1660 internal static ICustomMarshaler GetInstance(string cookie)
1308 { 1661 {
1309 if (marshaler == null) 1662 if (marshaler == null)
1310 { 1663 {
@@ -1317,7 +1670,7 @@ public class StrbufPassOwnershipMarshaler : ICustomMarshaler
1317 static private StrbufPassOwnershipMarshaler marshaler; 1670 static private StrbufPassOwnershipMarshaler marshaler;
1318} 1671}
1319 1672
1320public class StrbufKeepOwnershipMarshaler: ICustomMarshaler 1673class StrbufKeepOwnershipMarshaler: ICustomMarshaler
1321{ 1674{
1322 public object MarshalNativeToManaged(IntPtr pNativeData) 1675 public object MarshalNativeToManaged(IntPtr pNativeData)
1323 { 1676 {
@@ -1344,7 +1697,7 @@ public class StrbufKeepOwnershipMarshaler: ICustomMarshaler
1344 return -1; 1697 return -1;
1345 } 1698 }
1346 1699
1347 public static ICustomMarshaler GetInstance(string cookie) 1700 internal static ICustomMarshaler GetInstance(string cookie)
1348 { 1701 {
1349 if (marshaler == null) 1702 if (marshaler == null)
1350 { 1703 {
@@ -1362,10 +1715,29 @@ public class StrbufKeepOwnershipMarshaler: ICustomMarshaler
1362/// <summary>General exception for errors inside the binding.</summary> 1715/// <summary>General exception for errors inside the binding.</summary>
1363public class EflException : Exception 1716public class EflException : Exception
1364{ 1717{
1718 /// <summary>
1719 /// Default Constructor.
1720 /// <para>Since EFL 1.23.</para>
1721 /// </summary>
1722 public EflException()
1723 {
1724 }
1725
1365 /// <summary>Create a new EflException with the given message.</summary> 1726 /// <summary>Create a new EflException with the given message.</summary>
1366 public EflException(string message) : base(message) 1727 public EflException(string message) : base(message)
1367 { 1728 {
1368 } 1729 }
1730
1731 /// <summary>
1732 /// Create a new EflException with the given message and inner exception.
1733 /// <para>Since EFL 1.23.</para>
1734 /// </summary>
1735 /// <param name="message">The message of the exception.</param>
1736 /// <param name="innerException">The inner exception.</param>
1737 public EflException(string message, Exception innerException)
1738 : base(message, innerException)
1739 {
1740 }
1369} 1741}
1370 1742
1371/// <summary>Exception to be raised when a Task fails due to a failed Eina.Future.</summary> 1743/// <summary>Exception to be raised when a Task fails due to a failed Eina.Future.</summary>
@@ -1374,18 +1746,70 @@ public class FutureException : EflException
1374 /// <summary>The error code returned by the failed Eina.Future.</summary> 1746 /// <summary>The error code returned by the failed Eina.Future.</summary>
1375 public Eina.Error Error { get; private set; } 1747 public Eina.Error Error { get; private set; }
1376 1748
1377 /// <summary>Construct a new exception from the Eina.Error stored in the given Eina.Value.</summary> 1749 /// <summary>
1378 public FutureException(Eina.Value value) : base("Future failed.") 1750 /// Default constructor.
1751 /// <para>Since EFL 1.23.</para>
1752 /// </summary>
1753 public FutureException() : this(Eina.Error.UNHANDLED_EXCEPTION)
1379 { 1754 {
1380 if (value.GetValueType() != Eina.ValueType.Error) 1755 }
1381 {
1382 throw new ArgumentException("FutureException must receive an Eina.Value with Eina.Error.");
1383 }
1384 1756
1385 Eina.Error err; 1757 /// <summary>
1386 value.Get(out err); 1758 /// Construct a new exception from the <see cref="Eina.Error" />
1387 Error = err; 1759 /// with a given message
1760 /// <para>Since EFL 1.23.</para>
1761 /// </summary>
1762 /// <param name="message">The message of the exception.</param>
1763 public FutureException(string message)
1764 : this(Eina.Error.UNHANDLED_EXCEPTION, message)
1765 {
1766 }
1767
1768 /// <summary>
1769 /// Construct a new exception from the <see cref="Eina.Error" />
1770 /// with a given message and inner exception.
1771 /// <para>Since EFL 1.23.</para>
1772 /// </summary>
1773 /// <param name="message">The message of the exception.</param>
1774 /// <param name="innerException">The inner exception.</param>
1775 public FutureException(string message, Exception innerException)
1776 : this(Eina.Error.UNHANDLED_EXCEPTION, message, innerException)
1777 {
1778 }
1779
1780 /// <summary>
1781 /// Construct a new exception from the <see cref="Eina.Error" />
1782 /// with a given error.
1783 /// <para>Since EFL 1.23.</para>
1784 /// </summary>
1785 /// <param name="error">The error of the exception..</param>
1786 public FutureException(Eina.Error error)
1787 : this(error, "Future failed.")
1788 {
1789 }
1790
1791 /// <summary>
1792 /// Construct a new exception from the <see cref="Eina.Error" />
1793 /// with a given error and message.
1794 /// <para>Since EFL 1.23.</para>
1795 /// </summary>
1796 /// <param name="error">The error of the exception..</param>
1797 /// <param name="message">The message of the exception.</param>
1798 public FutureException(Eina.Error error, string message)
1799 : this(error, message, null)
1800 {
1388 } 1801 }
1389}
1390 1802
1803 /// <summary>
1804 /// Construct a new exception from the <see cref="Eina.Error" />
1805 /// with a given error, message and innerException.
1806 /// <para>Since EFL 1.23.</para>
1807 /// </summary>
1808 /// <param name="error">The error of the exception..</param>
1809 /// <param name="message">The message of the exception.</param>
1810 /// <param name="innerException">The inner exception.</param>
1811 public FutureException(Eina.Error error, string message,
1812 Exception innerException)
1813 : base(message, innerException) => Error = error;
1814}
1391} // namespace efl 1815} // namespace efl
diff --git a/src/bindings/mono/eo_mono/workaround.cs b/src/bindings/mono/eo_mono/workaround.cs
index 30759d1..0afe958 100644
--- a/src/bindings/mono/eo_mono/workaround.cs
+++ b/src/bindings/mono/eo_mono/workaround.cs
@@ -1,3 +1,18 @@
1/*
2 * Copyright 2019 by its authors. See AUTHORS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
1#pragma warning disable 1591 16#pragma warning disable 1591
2 17
3using System; 18using System;
@@ -6,50 +21,102 @@ using System.Collections.Generic;
6 21
7///<summary>Eo class description, passed to efl_class_new.</summary> 22///<summary>Eo class description, passed to efl_class_new.</summary>
8[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] 23[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
9public struct ClassDescription 24internal struct ClassDescription : IEquatable<ClassDescription>
10{ 25{
11 ///<summary>Current Eo version.</summary> 26 ///<summary>Current Eo version.</summary>
12 public uint version; 27 internal uint version;
13 ///<summary>Name of the class.</summary> 28 ///<summary>Name of the class.</summary>
14 [MarshalAs(UnmanagedType.LPStr)] public String name; 29 [MarshalAs(UnmanagedType.LPStr)] internal String name;
15 ///<summary>Class type.</summary> 30 ///<summary>Class type.</summary>
16 public int class_type; 31 internal int class_type;
17 ///<summary>Size of data (private + protected + public) per instance.</summary> 32 ///<summary>Size of data (private + protected + public) per instance.</summary>
18 public UIntPtr data_size; 33 internal UIntPtr data_size;
19 ///<summary>Initializer for the class.</summary> 34 ///<summary>Initializer for the class.</summary>
20 public IntPtr class_initializer; 35 internal IntPtr class_initializer;
21 ///<summary>Constructor of the class.</summary> 36 ///<summary>Constructor of the class.</summary>
22 public IntPtr class_constructor; 37 internal IntPtr class_constructor;
23 ///<summary>Destructor of the class.</summary> 38 ///<summary>Destructor of the class.</summary>
24 public IntPtr class_destructor; 39 internal IntPtr class_destructor;
40
41 /// <summary>
42 /// Gets a hash for <see cref="ClassDescription" />.
43 /// <para>Since EFL 1.24.</para>
44 /// </summary>
45 /// <returns>A hash code.</returns>
46 public override int GetHashCode()
47 => version.GetHashCode() ^ name.GetHashCode(StringComparison.Ordinal)
48 ^ class_type ^ data_size.GetHashCode();
49
50 /// <summary>Returns whether this <see cref="ClassDescription" />
51 /// is equal to the given <see cref="object" />.
52 /// <para>Since EFL 1.24.</para>
53 /// </summary>
54 /// <param name="other">The <see cref="object" /> to be compared to.</param>
55 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
56 public override bool Equals(object other)
57 => (!(other is ClassDescription)) ? false
58 : Equals((ClassDescription)other);
59
60
61 /// <summary>Returns whether this <see cref="ClassDescription" /> is equal
62 /// to the given <see cref="ClassDescription" />.
63 /// <para>Since EFL 1.24.</para>
64 /// </summary>
65 /// <param name="other">The <see cref="ClassDescription" /> to be compared to.</param>
66 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
67 public bool Equals(ClassDescription other)
68 => (name == other.name) && (class_type == other.class_type);
69
70 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
71 /// <para>Since EFL 1.24.</para>
72 /// </summary>
73 /// <param name="lhs">The left hand side of the operator.</param>
74 /// <param name="rhs">The right hand side of the operator.</param>
75 /// <returns><c>true</c> if <c>lhs</c> is equal
76 /// to <c>rhs</c>.</returns>
77 public static bool operator==(ClassDescription lhs, ClassDescription rhs)
78 => lhs.Equals(rhs);
79
80 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
81 /// <para>Since EFL 1.24.</para>
82 /// </summary>
83 /// <param name="lhs">The left hand side of the operator.</param>
84 /// <param name="rhs">The right hand side of the operator.</param>
85 /// <returns><c>true</c> if <c>lhs</c> is not equal
86 /// to <c>rhs</c>.</returns>
87 public static bool operator!=(ClassDescription lhs, ClassDescription rhs)
88 => !(lhs == rhs);
25} 89}
26 90
27///<summary>Description of an Eo API operation.</summary> 91///<summary>Description of an Eo API operation.</summary>
28[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] 92[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
29public struct EflOpDescription 93internal struct EflOpDescription
30{ 94{
31 ///<summary>The EAPI function offering this op. (String with the name of the function on Windows)</summary> 95 ///<summary>The EAPI function offering this op. (String with the name of the function on Windows)</summary>
32 public IntPtr api_func; 96 internal IntPtr api_func;
33 ///<summary>The static function to be called for this op</summary> 97 ///<summary>The static function to be called for this op</summary>
34 public IntPtr func; 98 internal IntPtr func;
35} 99}
36 100
37///<summary>List of operations on a given Object.</summary> 101///<summary>List of operations on a given Object.</summary>
38[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)] 102[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
39public struct EflObjectOps 103internal struct EflObjectOps
40{ 104{
41 ///<summary>The op descriptions array of size count.</summary> 105 ///<summary>The op descriptions array of size count.</summary>
42 public IntPtr descs; 106 internal IntPtr descs;
43 ///<summary>Number of op descriptions.</summary> 107 ///<summary>Number of op descriptions.</summary>
44 public UIntPtr count; 108 internal UIntPtr count;
45}; 109};
46 110
47namespace Efl 111namespace Efl
48{ 112{
49 113
50///<summary>This struct holds the description of a specific event (Since EFL 1.22).</summary> 114/// <summary>
115/// This struct holds the description of a specific event.
116/// <para>Since EFL 1.22.</para>
117/// </summary>
51[StructLayout(LayoutKind.Sequential)] 118[StructLayout(LayoutKind.Sequential)]
52public struct EventDescription 119internal struct EventDescription
53{ 120{
54 ///<summary>Name of the event.</summary> 121 ///<summary>Name of the event.</summary>
55 public IntPtr Name; 122 public IntPtr Name;
@@ -100,25 +167,31 @@ public struct EventDescription
100/// <summary> 167/// <summary>
101/// A parameter passed in event callbacks holding extra event parameters. 168/// A parameter passed in event callbacks holding extra event parameters.
102/// This is the full event information passed to callbacks in C. 169/// This is the full event information passed to callbacks in C.
103/// (Since EFL 1.22) 170/// <para>Since EFL 1.22.</para>
104/// </summary> 171/// </summary>
105[StructLayout(LayoutKind.Sequential)] 172[StructLayout(LayoutKind.Sequential)]
106[Efl.Eo.BindingEntity] 173[Efl.Eo.BindingEntity]
107public struct Event 174internal struct Event
108{ 175{
109 /// <summary>The object the callback was called on. 176 /// <summary>
110 /// (Since EFL 1.22)</summary> 177 /// The object the callback was called on.
178 /// <para>Since EFL 1.22.</para>
179 /// </summary>
111 public Efl.Object Object; 180 public Efl.Object Object;
112 181
113 /// <summary>The event description. 182 /// <summary>
114 /// (Since EFL 1.22)</summary> 183 /// The event description.
184 /// <para>Since EFL 1.22.</para>
185 /// </summary>
115 public Efl.EventDescription Desc; 186 public Efl.EventDescription Desc;
116 187
117 /// <summary>Extra event information passed by the event caller. 188 /// <summary>
189 /// Extra event information passed by the event caller.
118 /// Must be cast to the event type declared in the EO file. Keep in mind that: 190 /// Must be cast to the event type declared in the EO file. Keep in mind that:
119 /// 1) Objects are passed as a normal Eo*. Event subscribers can call functions on these objects. 191 /// 1) Objects are passed as a normal Eo*. Event subscribers can call functions on these objects.
120 /// 2) Structs, built-in types and containers are passed as const pointers, with one level of indirection. 192 /// 2) Structs, built-in types and containers are passed as const pointers, with one level of indirection.
121 /// (Since EFL 1.22)</summary> 193 /// <para>Since EFL 1.22.</para>
194 /// </summary>
122 public System.IntPtr Info; 195 public System.IntPtr Info;
123 196
124 /// <summary>Constructor for Event.</summary> 197 /// <summary>Constructor for Event.</summary>
@@ -179,43 +252,71 @@ public struct Event
179 } 252 }
180} 253}
181 254
182public delegate void EventCb(System.IntPtr data, ref Event.NativeStruct evt); 255internal delegate void EventCb(System.IntPtr data, ref Event.NativeStruct evt);
183public delegate void FreeWrapperSupervisorCb(System.IntPtr obj); 256internal delegate void FreeWrapperSupervisorCb(System.IntPtr obj);
184
185[StructLayout(LayoutKind.Sequential)]
186public struct TextCursorCursor
187{
188 IntPtr obj;
189 UIntPtr pos; // UIntPtr to automatically change size_t between 32/64
190 IntPtr node;
191 [MarshalAsAttribute(UnmanagedType.U1)]bool changed;
192}
193
194[StructLayout(LayoutKind.Sequential)]
195public struct TextAnnotateAnnotation
196{
197 IntPtr list;
198 IntPtr obj;
199 IntPtr start_node;
200 IntPtr end_node;
201 [MarshalAsAttribute(UnmanagedType.U1)]bool is_item;
202}
203 257
204namespace Access 258namespace Access
205{ 259{
206 260
207public struct ActionData 261public struct ActionData : IEquatable<ActionData>
208{ 262{
209 public IntPtr name; 263 public IntPtr name;
210 public IntPtr action; 264 public IntPtr action;
211 public IntPtr param; 265 public IntPtr param;
212 public IntPtr func; 266 public IntPtr func;
267
268
269 /// <summary>
270 /// Gets a hash for <see cref="ActionData" />.
271 /// <para>Since EFL 1.24.</para>
272 /// </summary>
273 /// <returns>A hash code.</returns>
274 public override int GetHashCode()
275 => name.GetHashCode() ^ action.GetHashCode()
276 ^ param.GetHashCode() ^ func.GetHashCode();
277
278 /// <summary>Returns whether this <see cref="ActionData" />
279 /// is equal to the given <see cref="object" />.
280 /// <para>Since EFL 1.24.</para>
281 /// </summary>
282 /// <param name="other">The <see cref="object" /> to be compared to.</param>
283 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
284 public override bool Equals(object other)
285 => (!(other is ActionData)) ? false
286 : Equals((ActionData)other);
287
288
289 /// <summary>Returns whether this <see cref="ActionData" /> is equal
290 /// to the given <see cref="ActionData" />.
291 /// <para>Since EFL 1.24.</para>
292 /// </summary>
293 /// <param name="other">The <see cref="ActionData" /> to be compared to.</param>
294 /// <returns><c>true</c> if is equal to <c>other</c>.</returns>
295 public bool Equals(ActionData other)
296 => (name == other.name) && (action == other.action)
297 && (param == other.param) && (func == other.func);
298
299 /// <summary>Returns whether <c>lhs</c> is equal to <c>rhs</c>.
300 /// <para>Since EFL 1.24.</para>
301 /// </summary>
302 /// <param name="lhs">The left hand side of the operator.</param>
303 /// <param name="rhs">The right hand side of the operator.</param>
304 /// <returns><c>true</c> if <c>lhs</c> is equal
305 /// to <c>rhs</c>.</returns>
306 public static bool operator==(ActionData lhs, ActionData rhs)
307 => lhs.Equals(rhs);
308
309 /// <summary>Returns whether <c>lhs</c> is not equal to <c>rhs</c>.
310 /// <para>Since EFL 1.24.</para>
311 /// </summary>
312 /// <param name="lhs">The left hand side of the operator.</param>
313 /// <param name="rhs">The right hand side of the operator.</param>
314 /// <returns><c>true</c> if <c>lhs</c> is not equal
315 /// to <c>rhs</c>.</returns>
316 public static bool operator!=(ActionData lhs, ActionData rhs)
317 => !(lhs == rhs);
213} 318}
214 319
215} // namespace Access 320} // namespace Access
216 321
217} // namespace Efl 322} // namespace Efl
218
219// Global delegates
220public delegate void EinaFreeCb(IntPtr data);
221public delegate void EvasSmartCb(IntPtr data, IntPtr obj, IntPtr event_info);