diff --git a/src/bin/eolian_mono/eolian/mono/events.hh b/src/bin/eolian_mono/eolian/mono/events.hh
index 9b4b8c362f..c1a45033f9 100644
--- a/src/bin/eolian_mono/eolian/mono/events.hh
+++ b/src/bin/eolian_mono/eolian/mono/events.hh
@@ -435,7 +435,7 @@ struct event_definition_generator
scope_tab << "{\n"
<< scope_tab << scope_tab << "add\n"
<< scope_tab << scope_tab << "{\n"
- << scope_tab << scope_tab << scope_tab << "lock (eventLock)\n"
+ << scope_tab << scope_tab << scope_tab << "lock (eflBindingEventLock)\n"
<< scope_tab << scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "{\n"
@@ -460,7 +460,7 @@ struct event_definition_generator
<< scope_tab << scope_tab << "}\n\n"
<< scope_tab << scope_tab << "remove\n"
<< scope_tab << scope_tab << "{\n"
- << scope_tab << scope_tab << scope_tab << "lock (eventLock)\n"
+ << scope_tab << scope_tab << scope_tab << "lock (eflBindingEventLock)\n"
<< scope_tab << scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "string key = \"_" << upper_c_name << "\";\n"
<< scope_tab << scope_tab << scope_tab << scope_tab << "RemoveNativeEventHandler(" << library_name << ", key, value);\n"
diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh
index f2dda1e7ca..8c43008c53 100644
--- a/src/bin/eolian_mono/eolian/mono/function_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh
@@ -178,9 +178,10 @@ struct function_definition_generator
std::string self = "this.NativeHandle";
- // inherited is set in the constructor, true if this instance is from a pure C# class (not generated).
+ // IsGeneratedBindingClass is set in the constructor, true if this
+ // instance is from a pure C# class (not generated).
if (do_super && !f.is_static)
- self = "(inherited ? Efl.Eo.Globals.efl_super(" + self + ", this.NativeClass) : " + self + ")";
+ self = "(IsGeneratedBindingClass ? " + self + " : Efl.Eo.Globals.efl_super(" + self + ", this.NativeClass))";
else if (f.is_static)
self = "";
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh b/src/bin/eolian_mono/eolian/mono/klass.hh
index 8b018f6413..8f9932664b 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -214,7 +214,7 @@ struct klass
<< scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
<< scope_tab << "/// Initializes a new instance of the class.\n"
<< scope_tab << "/// Internal usage: This is used when interacting with C code and should not be used directly.\n"
- << scope_tab << "private " << concrete_name << "(System.IntPtr raw) : base(raw)\n"
+ << scope_tab << "private " << concrete_name << "(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
<< scope_tab << "{\n"
<< scope_tab << "}\n\n"
)
@@ -511,7 +511,7 @@ struct klass
<< scope_tab << "/// Initializes a new instance of the class.\n"
<< scope_tab << "/// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.\n"
<< scope_tab << "/// The native pointer to be wrapped.\n"
- << scope_tab << "protected " << inherit_name << "(System.IntPtr raw) : base(raw)\n"
+ << scope_tab << "protected " << inherit_name << "(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
<< scope_tab << "{\n"
<< scope_tab << "}\n\n"
).generate(sink, std::make_tuple(constructors, constructors, constructors), context))
@@ -526,7 +526,7 @@ struct klass
scope_tab << "[Efl.Eo.PrivateNativeClass]\n"
<< scope_tab << "private class " << inherit_name << "Realized : " << inherit_name << "\n"
<< scope_tab << "{\n"
- << scope_tab << scope_tab << "private " << inherit_name << "Realized(IntPtr ptr) : base(ptr)\n"
+ << scope_tab << scope_tab << "private " << inherit_name << "Realized(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
<< scope_tab << scope_tab << "{\n"
<< scope_tab << scope_tab << "}\n"
<< scope_tab << "}\n"
diff --git a/src/bindings/mono/eina_mono/eina_promises.cs b/src/bindings/mono/eina_mono/eina_promises.cs
index 34561a5b08..dc8642aeaa 100644
--- a/src/bindings/mono/eina_mono/eina_promises.cs
+++ b/src/bindings/mono/eina_mono/eina_promises.cs
@@ -295,12 +295,14 @@ public Future Then(ResolvedCb cb)
private static IntPtr ThenRaw(IntPtr previous, ResolvedCb cb)
{
FutureDesc desc = new FutureDesc();
- desc.cb = NativeResolvedCb;
+ desc.cb = NativeResolvedCbDelegate;
GCHandle handle = GCHandle.Alloc(cb);
desc.data = GCHandle.ToIntPtr(handle);
return eina_future_then_from_desc(previous, desc);
}
+ private static FutureCb NativeResolvedCbDelegate = new FutureCb(NativeResolvedCb);
+
private static Eina.ValueNative NativeResolvedCb(IntPtr data, Eina.ValueNative value, IntPtr dead_future)
{
GCHandle handle = GCHandle.FromIntPtr(data);
@@ -340,7 +342,7 @@ public Future Chain(IEnumerable cbs)
for (; i < cbsList.Count(); i++)
{
ResolvedCb cb = cbsList[i];
- descs[i].cb = NativeResolvedCb;
+ descs[i].cb = NativeResolvedCbDelegate;
GCHandle handle = GCHandle.Alloc(cb);
descs[i].data = GCHandle.ToIntPtr(handle);
}
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs
index 7e512acf56..5b14b48695 100644
--- a/src/bindings/mono/eo_mono/EoWrapper.cs
+++ b/src/bindings/mono/eo_mono/EoWrapper.cs
@@ -12,9 +12,9 @@ namespace Eo
public abstract class EoWrapper : IWrapper, IDisposable
{
- protected readonly object eventLock = new object();
- protected bool inherited = false;
- protected System.IntPtr handle = IntPtr.Zero;
+ protected readonly object eflBindingEventLock = new object();
+ private bool generated = true;
+ private System.IntPtr handle = IntPtr.Zero;
private static Efl.EventCb ownershipUniqueDelegate = new Efl.EventCb(OwnershipUniqueCallback);
private static Efl.EventCb ownershipSharedDelegate = new Efl.EventCb(OwnershipSharedCallback);
@@ -32,7 +32,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
/// Tag struct storing the native handle of the object being constructed.
protected EoWrapper(ConstructingHandle ch)
{
- inherited = true;
+ generated = false;
handle = Efl.Eo.Globals.efl_constructor(Efl.Eo.Globals.efl_super(ch.NativeHandle, Efl.Eo.Globals.efl_class_get(ch.NativeHandle)));
if (handle == IntPtr.Zero)
{
@@ -47,11 +47,12 @@ protected EoWrapper(ConstructingHandle ch)
}
/// Initializes a new instance of the class.
- /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.
+ /// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.
+ /// Do not implement this constructor.
/// The native pointer to be wrapped.
- protected EoWrapper(System.IntPtr raw)
+ protected EoWrapper(Efl.Eo.Globals.WrappingHandle wh)
{
- handle = raw;
+ handle = wh.NativeHandle;
AddWrapperSupervisor();
}
@@ -67,9 +68,9 @@ protected EoWrapper(IntPtr baseKlass, System.Type managedType, Efl.Object parent
[CallerFilePath] string file = null,
[CallerLineNumber] int line = 0)
{
- inherited = ((object)this).GetType() != managedType;
+ generated = ((object)this).GetType() == managedType;
IntPtr actual_klass = baseKlass;
- if (inherited)
+ if (!generated)
{
actual_klass = Efl.Eo.ClassRegister.GetInheritKlassOrRegister(baseKlass, ((object)this).GetType());
}
@@ -82,7 +83,7 @@ protected EoWrapper(IntPtr baseKlass, System.Type managedType, Efl.Object parent
parent_ptr = parent.NativeHandle;
}
- if (!inherited)
+ if (generated)
{
handle = Efl.Eo.Globals._efl_add_internal_start(file, line, actual_klass, parent_ptr, 1, 0);
}
@@ -123,6 +124,11 @@ public abstract System.IntPtr NativeClass
get;
}
+ protected bool IsGeneratedBindingClass
+ {
+ get { return generated; }
+ }
+
/// Releases the underlying native instance.
protected virtual void Dispose(bool disposing)
{
@@ -292,7 +298,7 @@ public ConstructingHandle(IntPtr h)
NativeHandle = h;
}
- public IntPtr NativeHandle { get; set; }
+ public IntPtr NativeHandle { get; private set; }
}
public abstract class NativeMethods : Efl.Eo.NativeClass
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index caf28a700f..7c2eeb452b 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -624,14 +624,15 @@ public static Efl.Eo.IWrapper CreateWrapperFor(System.IntPtr handle, bool should
try
{
var flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
- constructor = managedType.GetConstructor(flags, null, new Type[1] { typeof(System.IntPtr) }, null);
+ constructor = managedType.GetConstructor(flags, null, new Type[1] { typeof(WrappingHandle) }, null);
}
catch (InvalidOperationException)
{
throw new InvalidOperationException($"Can't get constructor for type {managedType}");
}
- var ret = (Efl.Eo.IWrapper) constructor.Invoke(new object[1] { handle });
+ WrappingHandle wh = new WrappingHandle(handle);
+ var ret = (Efl.Eo.IWrapper) constructor.Invoke(new object[1] { wh });
if (ret == null)
{
@@ -715,6 +716,21 @@ public static void ThreadSafeFreeCbExec(EinaFreeCb cbFreeCb, IntPtr cbData)
Monitor.Exit(Efl.All.InitLock);
}
+ ///
+ /// Internal struct used by the binding to pass the native handle pointer
+ /// to the managed object wrapping constructor.
+ /// Internal usage only: do not use this class in inherited classes.
+ ///
+ public struct WrappingHandle
+ {
+ public WrappingHandle(IntPtr h)
+ {
+ NativeHandle = h;
+ }
+
+ public IntPtr NativeHandle { get; private set; }
+ }
+
} // Globals
public static class Config
diff --git a/src/tests/efl_mono/EoConstruction.cs b/src/tests/efl_mono/EoConstruction.cs
index 4708befc5b..bfcf40b0f1 100644
--- a/src/tests/efl_mono/EoConstruction.cs
+++ b/src/tests/efl_mono/EoConstruction.cs
@@ -27,9 +27,10 @@ private InheritedConstructibleObject(ConstructingHandle ch) : base(ch)
public int DefaultConstrutorCallCount { get; set; } = 0;
public int SpecialConstrutorCallCount { get; set; } = 0;
- public bool InheritedFlag
+ /// Pointer to the native class description.
+ public bool IsInheritedClass
{
- get { return inherited; }
+ get { return !this.IsGeneratedBindingClass; }
}
public override int MultiplyIntegerValue(int v)
@@ -56,7 +57,7 @@ public static void TestGeneratedEoDirectConstruction()
public static void TestInheritedEoDirectConstruction()
{
var obj = new InheritedConstructibleObject();
- Test.AssertEquals(obj.InheritedFlag, true);
+ Test.AssertEquals(obj.IsInheritedClass, true);
Test.AssertEquals(obj.NativeConstructionCount, 1);
Test.AssertEquals(obj.DefaultConstructionCount, 1);
Test.AssertEquals(obj.SpecialConstructionCount, 0);
@@ -75,7 +76,7 @@ public static void TestInheritedEoIndirectConstruction()
Test.AssertEquals(obj.MultiplyIntegerValue(21), 42);
var obj2 = (InheritedConstructibleObject) obj.ConstructTypeAndStore(typeof(InheritedConstructibleObject));
- Test.AssertEquals(obj2.InheritedFlag, true);
+ Test.AssertEquals(obj2.IsInheritedClass, true);
Test.AssertEquals(obj2.NativeConstructionCount, 1);
Test.AssertEquals(obj2.DefaultConstructionCount, 0);
Test.AssertEquals(obj2.SpecialConstructionCount, 1);