Skip to content

Commit

Permalink
[unity]格式化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Dec 4, 2024
1 parent bcfabbd commit 2bd39b7
Showing 1 changed file with 61 additions and 61 deletions.
122 changes: 61 additions & 61 deletions unity/Assets/core/upm/Runtime/Src/IL2Cpp/TypeRegister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,76 +208,76 @@ private static void Register(Type type, MethodBase[] ctors = null, MethodBase[]
}
}

Action<string, MethodInfo, bool, bool, bool> AddMethodToType = (string name, MethodInfo method, bool isGetter, bool isSetter, bool isExtensionMethod) =>
{
method = TypeUtils.HandleMaybeGenericMethod(method);
if (method == null) return;
List<Type> usedTypes = TypeUtils.GetUsedTypes(method, isExtensionMethod);
var signature = TypeUtils.GetMethodSignature(method, false, isExtensionMethod);
// UnityEngine.Debug.Log(string.Format("add method {0}, usedTypes count: {1}", method, usedTypes.Count));
Action<string, MethodInfo, bool, bool, bool> AddMethodToType = (string name, MethodInfo method, bool isGetter, bool isSetter, bool isExtensionMethod) =>
{
method = TypeUtils.HandleMaybeGenericMethod(method);
if (method == null) return;
List<Type> usedTypes = TypeUtils.GetUsedTypes(method, isExtensionMethod);
var signature = TypeUtils.GetMethodSignature(method, false, isExtensionMethod);
// UnityEngine.Debug.Log(string.Format("add method {0}, usedTypes count: {1}", method, usedTypes.Count));

var wrapper = GetWrapperFunc(registerInfo, method, signature);
if (wrapper == IntPtr.Zero)
{
UnityEngine.Debug.LogWarning(string.Format("wrapper is null for {0}:{1}, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
return;
}

var methodInfoPointer = NativeAPI.GetMethodInfoPointer(method);
var methodPointer = NativeAPI.GetMethodPointer(method);
if (methodInfoPointer == IntPtr.Zero)
var wrapper = GetWrapperFunc(registerInfo, method, signature);
if (wrapper == IntPtr.Zero)
{
UnityEngine.Debug.LogWarning(string.Format("wrapper is null for {0}:{1}, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
return;
}

var methodInfoPointer = NativeAPI.GetMethodInfoPointer(method);
var methodPointer = NativeAPI.GetMethodPointer(method);
if (methodInfoPointer == IntPtr.Zero)
{
UnityEngine.Debug.LogWarning(string.Format("cannot get method info for {0}:{1}, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
return;
}
if (methodPointer == IntPtr.Zero)
{
UnityEngine.Debug.LogWarning(string.Format("cannot get method pointer for {0}:{1}, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
return;
}
var wrapData = NativeAPI.AddMethod(
typeInfo,
signature,
wrapper,
name,
!isExtensionMethod && method.IsStatic,
isExtensionMethod,
isGetter,
isSetter,
methodInfoPointer,
methodPointer,
usedTypes.Count
);
if (wrapData == IntPtr.Zero)
{
if (throwIfMemberFail)
{
UnityEngine.Debug.LogWarning(string.Format("cannot get method info for {0}:{1}, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
return;
throw new Exception(string.Format("add method for {0}:{1} fail, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
}
if (methodPointer == IntPtr.Zero)
else
{
UnityEngine.Debug.LogWarning(string.Format("cannot get method pointer for {0}:{1}, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
#if WARNING_IF_MEMBERFAIL
UnityEngine.Debug.LogWarning(string.Format("add method for {0}:{1} fail, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
#endif
return;
}
var wrapData = NativeAPI.AddMethod(
typeInfo,
signature,
wrapper,
name,
!isExtensionMethod && method.IsStatic,
isExtensionMethod,
isGetter,
isSetter,
methodInfoPointer,
methodPointer,
usedTypes.Count
);
if (wrapData == IntPtr.Zero)
{
if (throwIfMemberFail)
{
throw new Exception(string.Format("add method for {0}:{1} fail, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
}
else
{
#if WARNING_IF_MEMBERFAIL
UnityEngine.Debug.LogWarning(string.Format("add method for {0}:{1} fail, signature:{2}", type, method, TypeUtils.GetMethodSignature(method, false, isExtensionMethod)));
#endif
return;
}
}
for (int i = 0; i < usedTypes.Count; ++i)
{
var usedTypeId = NativeAPI.GetTypeId(usedTypes[i]);
//UnityEngine.Debug.Log(string.Format("set used type for method {0}: {1}={2}, typeId:{3}", method, i, usedTypes[i], usedTypeId));
NativeAPI.SetTypeInfo(wrapData, i, usedTypeId);
}
};
}
for (int i = 0; i < usedTypes.Count; ++i)
{
var usedTypeId = NativeAPI.GetTypeId(usedTypes[i]);
//UnityEngine.Debug.Log(string.Format("set used type for method {0}: {1}={2}, typeId:{3}", method, i, usedTypes[i], usedTypeId));
NativeAPI.SetTypeInfo(wrapData, i, usedTypeId);
}
};

if (methods != null && (!type.IsArray || type == typeof(System.Array)))
if (methods != null && (!type.IsArray || type == typeof(System.Array)))
{
foreach (var method in methods)
{
foreach (var method in methods)
{
if (method.IsAbstract) continue;
AddMethodToType(method.Name, method as MethodInfo, false, false, false);
}
if (method.IsAbstract) continue;
AddMethodToType(method.Name, method as MethodInfo, false, false, false);
}
}

if (!isDelegate)
{
Expand Down

0 comments on commit 2bd39b7

Please sign in to comment.