csharp: Fix GetUserMethods and NativeClass

Summary:
- Should only search for methods locally.
- dotnet requires passing false to GetAttributes
- Also added a check when the class overrides no Eo ops.

Reviewers: felipealmeida, vitor.sousa, woohyun

Reviewed By: felipealmeida, vitor.sousa

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8588
This commit is contained in:
Lauro Moura 2019-04-10 15:04:22 -03:00 committed by Vitor Sousa
parent e2b56fe71d
commit feaf0e9299
1 changed files with 16 additions and 10 deletions

View File

@ -290,7 +290,7 @@ public class Globals
private static Efl.Eo.NativeClass GetNativeClass(System.Type type) private static Efl.Eo.NativeClass GetNativeClass(System.Type type)
{ {
var attrs = System.Attribute.GetCustomAttributes(type); var attrs = System.Attribute.GetCustomAttributes(type, false);
foreach (var attr in attrs) foreach (var attr in attrs)
{ {
if (attr is Efl.Eo.NativeClass) if (attr is Efl.Eo.NativeClass)
@ -306,21 +306,21 @@ public class Globals
GetUserMethods(System.Type type) GetUserMethods(System.Type type)
{ {
var r = new System.Collections.Generic.List<System.Reflection.MethodInfo>(); var r = new System.Collections.Generic.List<System.Reflection.MethodInfo>();
r.AddRange(type.GetMethods()); var flags = System.Reflection.BindingFlags.Instance
| System.Reflection.BindingFlags.DeclaredOnly
| System.Reflection.BindingFlags.Public
| System.Reflection.BindingFlags.NonPublic;
r.AddRange(type.GetMethods(flags));
var base_type = type.BaseType; var base_type = type.BaseType;
for (;base_type != null; base_type = base_type.BaseType) for (;base_type != null; base_type = base_type.BaseType)
{ {
var attrs = System.Attribute.GetCustomAttributes(type); if (IsGeneratedClass(base_type))
foreach (var attr in attrs)
{ {
if (attr is Efl.Eo.NativeClass) return r;
{
return r;
}
} }
r.AddRange(base_type.GetMethods()); r.AddRange(base_type.GetMethods(flags));
} }
return r; return r;
} }
@ -353,7 +353,13 @@ public class Globals
} }
} }
IntPtr descs_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(descs[0]) * count); IntPtr descs_ptr = IntPtr.Zero;
if (count > 0)
{
descs_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(descs[0]) * count);
}
IntPtr ptr = descs_ptr; IntPtr ptr = descs_ptr;
for (int i = 0; i != count; ++i) for (int i = 0; i != count; ++i)
{ {