lauromoura pushed a commit to branch master.

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

commit f4d9188ca75b1961d1936abf47fb2685c35d5ee2
Author: Yeongjong Lee <[email protected]>
Date:   Sun Sep 8 22:13:40 2019 -0300

    eolian_mono: remove redundant code in NativeMethods
    
    Summary:
    Duplicated interface's NativeMethods code will be removed. they are called 
in
    `GetInterfaces`.
    
    Size of efl_mono.dll
    6,587,392 bytes(6.6MB) -> 4,112,384 bytes (4.1MB)
    
    Test Plan: ninja test
    
    Reviewers: felipealmeida, lauromoura, vitor.sousa
    
    Reviewed By: lauromoura
    
    Subscribers: cedric, #reviewers, woohyun, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D9752
---
 src/bin/eolian_mono/eolian/mono/klass.hh | 20 +++++++++++++++++---
 src/bindings/mono/eo_mono/EoWrapper.cs   |  2 +-
 src/bindings/mono/eo_mono/iwrapper.cs    | 24 +++---------------------
 3 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/src/bin/eolian_mono/eolian/mono/klass.hh 
b/src/bin/eolian_mono/eolian/mono/klass.hh
index f1b89abc71..c10bfb3fda 100644
--- a/src/bin/eolian_mono/eolian/mono/klass.hh
+++ b/src/bin/eolian_mono/eolian/mono/klass.hh
@@ -398,7 +398,7 @@ struct klass
                                             context);
          auto native_inherit_name = 
name_helpers::klass_native_inherit_name(cls);
          auto inherit_name = name_helpers::klass_inherit_name(cls);
-         auto implementable_methods = 
helpers::get_all_implementable_methods(cls, context);
+         auto implementable_methods = cls.functions;
          bool root = !helpers::has_regular_ancestor(cls);
          auto const& indent = current_indentation(inative_cxt);
 
@@ -430,7 +430,7 @@ struct klass
          if(!as_generator(
              indent << scope_tab << "/// <summary>Gets the list of Eo 
operations to override.</summary>\n"
              << indent << scope_tab << "/// <returns>The list of Eo operations 
to be overload.</returns>\n"
-             << indent << scope_tab << "public override 
System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type 
type)\n"
+             << indent << scope_tab << "public override 
System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type, 
bool includeInherited)\n"
              << indent << scope_tab << "{\n"
              << indent << scope_tab << scope_tab << "var descs = new 
System.Collections.Generic.List<Efl_Op_Description>();\n"
             )
@@ -452,8 +452,22 @@ struct klass
                 ).generate(sink,  attributes::unused, inative_cxt))
              return false;
 
+         if(!as_generator(
+             indent << scope_tab << scope_tab << "if (includeInherited)\n"
+             << indent << scope_tab(2) << "{\n"
+             << indent << scope_tab(3) << "var all_interfaces = 
type.GetInterfaces();\n"
+             << indent << scope_tab(3) << "foreach (var iface in 
all_interfaces)\n"
+             << indent << scope_tab(3) << "{\n"
+             << indent << scope_tab(4) <<  "var moredescs = 
((Efl.Eo.NativeClass)iface.GetCustomAttributes(false)?.FirstOrDefault(attr => 
attr is Efl.Eo.NativeClass))?.GetEoOps(type, false);\n"
+             << indent << scope_tab(4) <<  "if (moredescs != null)\n"
+             << indent << scope_tab(5) <<  "descs.AddRange(moredescs);\n"
+             << indent << scope_tab(3) << "}\n"
+             << indent << scope_tab(2) << "}\n"
+           ).generate(sink, attributes::unused, inative_cxt))
+             return false;
+
          if (!root || 
context_find_tag<class_context>(context).current_wrapper_kind != 
class_context::concrete)
-           if(!as_generator(indent << scope_tab << scope_tab << 
"descs.AddRange(base.GetEoOps(type));\n").generate(sink, attributes::unused, 
inative_cxt))
+           if(!as_generator(indent << scope_tab << scope_tab << 
"descs.AddRange(base.GetEoOps(type, false));\n").generate(sink, 
attributes::unused, inative_cxt))
              return false;
 
          if(!as_generator(
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs 
b/src/bindings/mono/eo_mono/EoWrapper.cs
index 688de85cae..1805071175 100644
--- a/src/bindings/mono/eo_mono/EoWrapper.cs
+++ b/src/bindings/mono/eo_mono/EoWrapper.cs
@@ -357,7 +357,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
 
         /// <summary>Gets the list of Eo operations to override.</summary>
         /// <returns>The list of Eo operations to be overload.</returns>
-        public override System.Collections.Generic.List<Efl_Op_Description> 
GetEoOps(Type type)
+        public override System.Collections.Generic.List<Efl_Op_Description> 
GetEoOps(Type type, bool includeInherited)
         {
             var descs = new 
System.Collections.Generic.List<Efl_Op_Description>();
 
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs 
b/src/bindings/mono/eo_mono/iwrapper.cs
index 6b7719e61f..a03e48a326 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -351,26 +351,8 @@ public class Globals
         if (nativeClass != null)
         {
             Eina.Log.Debug("nativeClass != null");
-            var descs = nativeClass.GetEoOps(type);
+            var descs = nativeClass.GetEoOps(type, true);
             var count = descs.Count;
-
-            var all_interfaces = type.GetInterfaces();
-            var base_interfaces = type.BaseType.GetInterfaces();
-            foreach (var iface in all_interfaces)
-            {
-                if (!System.Array.Exists(base_interfaces, element => element 
== iface))
-                {
-                    var nc = GetNativeClass(iface);
-                    if (nc != null)
-                    {
-                        var moredescs = nc.GetEoOps(type);
-                        Eina.Log.Debug($"adding {moredescs.Count} more descs 
to registration");
-                        descs.AddRange(moredescs);
-                        count = descs.Count;
-                    }
-                }
-            }
-
             IntPtr descs_ptr = IntPtr.Zero;
 
             if (count > 0)
@@ -753,7 +735,7 @@ public static class Config
 public abstract class NativeClass : System.Attribute
 {
     public abstract IntPtr GetEflClass();
-    public abstract System.Collections.Generic.List<Efl_Op_Description> 
GetEoOps(System.Type type);
+    public abstract System.Collections.Generic.List<Efl_Op_Description> 
GetEoOps(System.Type type, bool includeInherited);
 }
 
 /// <summary>Attribute for private native classes.
@@ -766,7 +748,7 @@ public class PrivateNativeClass : NativeClass
         return IntPtr.Zero;
     }
 
-    public override System.Collections.Generic.List<Efl_Op_Description> 
GetEoOps(System.Type type)
+    public override System.Collections.Generic.List<Efl_Op_Description> 
GetEoOps(System.Type type, bool includeInherited)
     {
         return null;
     }

-- 


Reply via email to