aboutsummaryrefslogtreecommitdiffstats
path: root/src/bindings
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-03-15 11:30:24 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-03-15 11:38:08 -0300
commit4acc7e066758eca4837df83ccf6262fb479cc4ff (patch)
tree95b0d5fcd4aa6363e8d9f8927cd3895cf46812e1 /src/bindings
parentefreet: Fix resource leak (diff)
downloadefl-4acc7e066758eca4837df83ccf6262fb479cc4ff.tar.gz
csharp: Support Efl.Class for interfaces
Summary: The `GetEflClassStatic` method for interface is in their Concrete sidekick. Previously, passing a valid Eo interface as a type caused the binding to complain that `Type is not an Efl.Object`. Test Plan: run test case Reviewers: vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8360
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 001c8f0cc7..13f82cf090 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -609,19 +609,34 @@ public static class ClassRegister
{
for (System.Type t = objectType.BaseType; t != null; t = t.BaseType)
{
- var method = t.GetMethod("GetEflClassStatic",
- System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
- if (method != null)
- return (IntPtr) method.Invoke(null, null);
+ var ptr = GetNativeKlassPtr(t);
+ if (ptr != IntPtr.Zero)
+ return ptr;
}
throw new System.InvalidOperationException($"Class '{objectType.FullName}' is not an Efl object");
}
private static IntPtr GetNativeKlassPtr(System.Type objectType)
{
+ if (objectType == null)
+ return IntPtr.Zero;
+
+ if (objectType.IsInterface)
+ {
+ // Try to get the *Concrete class
+ var assembly = objectType.Assembly;
+ objectType = assembly.GetType(objectType.FullName + "Concrete");
+
+ if (objectType == null)
+ return IntPtr.Zero;
+ }
+
var method = objectType.GetMethod("GetEflClassStatic",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
- return (IntPtr) method?.Invoke(null, null);
+
+ if (method == null)
+ return IntPtr.Zero;
+ return (IntPtr) (method.Invoke(null, null));
}
public static void AddToKlassTypeBiDictionary(IntPtr klassPtr, System.Type objectType)