Skip to content

Commit

Permalink
fix some errors for UWP project (Tencent#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosddp authored and chexiongsheng committed Oct 16, 2017
1 parent 9f8023e commit 4f63d2a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Assets/XLua/Src/ObjectTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,19 @@ Delegate getDelegate(DelegateBridgeBase bridge, Type delegateType)
{
return null;
}

// get by parameters
MethodInfo delegateMethod = delegateType.GetMethod("Invoke");
var methods = bridge.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
for(int i = 0; i < methods.Length; i++)
for (int i = 0; i < methods.Length; i++)
{
if (!methods[i].IsConstructor && Utils.IsParamsMatch(delegateMethod, methods[i]))
{
#if UNITY_EDITOR || XLUA_GENERAL
return Delegate.CreateDelegate(delegateType, bridge, methods[i]);
#else
return methods[i].CreateDelegate(delegateType, bridge);
#endif
}
}

Expand Down
17 changes: 17 additions & 0 deletions Assets/XLua/Src/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,22 @@ public static Type[] GetGenericParameterConstraints(this Type type)
}
#endif

public static bool IsNestedPublic(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsNestedPublic;
#else
return type.GetTypeInfo().IsNestedPublic;
#endif
}

public static bool IsPublic(this Type type)
{
#if !UNITY_WSA || UNITY_EDITOR
return type.IsPublic;
#else
return type.GetTypeInfo().IsPublic;
#endif
}
}
}
4 changes: 2 additions & 2 deletions Assets/XLua/Src/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,10 +1584,10 @@ public static bool IsPublic(Type type)
{
if (type.IsNested)
{
if (!type.IsNestedPublic) return false;
if (!type.IsNestedPublic()) return false;
return IsPublic(type.DeclaringType);
}
return type.IsPublic;
return type.IsPublic();
}
}
}

0 comments on commit 4f63d2a

Please sign in to comment.