zmike pushed a commit to branch efl-1.22.

http://git.enlightenment.org/core/efl.git/commit/?id=06991872dd7fe19bf935f038ca6a1cb5f5c240c4

commit 06991872dd7fe19bf935f038ca6a1cb5f5c240c4
Author: Felipe Magno de Almeida <fel...@expertisesolutions.com.br>
Date:   Tue Apr 9 11:16:17 2019 -0300

    efl-mono: Make override of methods only for methods that are defined by the 
user
    
    Summary:
    Instead of overriding every method and making the callback to C, we
    just override the methods that are found by reflection on the type.
    
    Reviewers: bu5hm4n, vitor.sousa, segfaultxavi, woohyun, Jaehyun_Cho, 
YOhoho, lauromoura
    
    Reviewed By: lauromoura
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D8579
---
 .../eolian/mono/function_registration.hh           |  7 +++++--
 src/bin/eolian_mono/eolian/mono/klass.hh           |  1 +
 src/bindings/mono/eo_mono/iwrapper.cs              | 23 ++++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/bin/eolian_mono/eolian/mono/function_registration.hh 
b/src/bin/eolian_mono/eolian/mono/function_registration.hh
index 5898af9c27..fc044e6b72 100644
--- a/src/bin/eolian_mono/eolian/mono/function_registration.hh
+++ b/src/bin/eolian_mono/eolian/mono/function_registration.hh
@@ -44,7 +44,10 @@ struct function_registration_generator
       return false;
 
     if(!as_generator
-       (scope_tab << scope_tab << "descs.Add(new Efl_Op_Description() {"
+       (scope_tab << scope_tab
+        << "if (methods.FirstOrDefault(m => m.Name == \"" << string << "\") != 
null)\n"
+        << scope_tab << scope_tab << scope_tab
+        << "descs.Add(new Efl_Op_Description() {"
 #ifdef _WIN32
         << "api_func = Marshal.StringToHGlobalAnsi(\"" << string << "\")"
 #else
@@ -52,7 +55,7 @@ struct function_registration_generator
 #endif
         << ", func = Marshal.GetFunctionPointerForDelegate(" << string << 
"_static_delegate)});\n"
        )
-       .generate(sink, std::make_tuple(f.c_name, f.c_name), context))
+       .generate(sink, std::make_tuple(name_helpers::managed_method_name(f), 
f.c_name, f.c_name), context))
       return false;
     return true;
       }
diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh 
b/src/bin/eolian_mono/eolian/mono/klass.hh
index e34a126321..87ad1bd5a7 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -369,6 +369,7 @@ struct klass
              << scope_tab << "public override 
System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type 
type)\n"
              << scope_tab << "{\n"
              << scope_tab << scope_tab << "var descs = new 
System.Collections.Generic.List<Efl_Op_Description>();\n"
+             << scope_tab << scope_tab << "var methods = 
Efl.Eo.Globals.GetUserMethods(type);\n"
             )
             .generate(sink, attributes::unused, inative_cxt))
            return false;
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs 
b/src/bindings/mono/eo_mono/iwrapper.cs
index 1aab776f26..f3696606d2 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -302,6 +302,29 @@ public class Globals
         return null;
     }
 
+    public static System.Collections.Generic.List<System.Reflection.MethodInfo>
+        GetUserMethods(System.Type type)
+    {
+        var r = new 
System.Collections.Generic.List<System.Reflection.MethodInfo>();
+        r.AddRange(type.GetMethods());
+        var base_type = type.BaseType;
+
+        for (;base_type != null; base_type = base_type.BaseType)
+        {
+            var attrs = System.Attribute.GetCustomAttributes(type);
+            foreach (var attr in attrs)
+            {
+                if (attr is Efl.Eo.NativeClass)
+                {
+                    return r;
+                }
+            }
+
+            r.AddRange(base_type.GetMethods());
+        }
+        return r;
+    }
+
     public static byte class_initializer_call(IntPtr klass, System.Type type)
     {
         Eina.Log.Debug($"called with 0x{klass.ToInt64():x} {type}");

-- 


Reply via email to