Merge pull request #150 from dwango/fix_UNITY_5_symbol

Fix unity 5 symbol
This commit is contained in:
yutopp
2019-01-28 21:24:04 +09:00
committed by GitHub
4 changed files with 6 additions and 404 deletions

View File

@@ -12,6 +12,7 @@ namespace UniJSON
public static partial class GenericExpressionCallFactory
{
#if UNITY_EDITOR && VRM_DEVELOP
const int NET35MAX = 4;
const int ARGS = 6;
const string GENERATE_PATH = "Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericExpressionCallFactory.g.cs";
@@ -42,26 +43,18 @@ namespace UniJSON
{
");
// Create
for (int i = 1; i <= ARGS; ++i)
for (int i = 1; i <= ARGS && i<NET35MAX; ++i)
{
var g = String.Join(", ", GetArgs("A", i).ToArray());
var a = String.Join(", ", GetArgs("a", i).ToArray());
var source = @"
#if UNITY_5
public static Delegate Create<S, $0>(MethodInfo m)
#else
public static Action<S, $0> Create<S, $0>(MethodInfo m)
#endif
{
var self = Expression.Parameter(m.DeclaringType, m.Name);
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
var call = Expression.Call(self, m, args);
return
#if UNITY_5
#else
(Action<S, $0>)
#endif
Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
}
".Replace("$0", g).Replace("$1", a);
@@ -70,16 +63,12 @@ namespace UniJSON
}
// CreateWithThis
for (int i = 1; i <= ARGS; ++i)
for (int i = 1; i <= ARGS && i<=NET35MAX; ++i)
{
var g = String.Join(", ", GetArgs("A", i).ToArray());
var source = @"
#if UNITY_5
public static Delegate CreateWithThis<S, $0>(MethodInfo m, S instance)
#else
public static Action<$0> CreateWithThis<S, $0>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -108,10 +97,6 @@ namespace UniJSON
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<$0>)
#endif
Expression.Lambda(call, args).Compile();
}
".Replace("$0", g);

View File

@@ -11,119 +11,37 @@ namespace UniJSON
{
#if UNITY_5
public static Delegate Create<S, A0>(MethodInfo m)
#else
public static Action<S, A0> Create<S, A0>(MethodInfo m)
#endif
{
var self = Expression.Parameter(m.DeclaringType, m.Name);
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
var call = Expression.Call(self, m, args);
return
#if UNITY_5
#else
(Action<S, A0>)
#endif
Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
}
#if UNITY_5
public static Delegate Create<S, A0, A1>(MethodInfo m)
#else
public static Action<S, A0, A1> Create<S, A0, A1>(MethodInfo m)
#endif
{
var self = Expression.Parameter(m.DeclaringType, m.Name);
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
var call = Expression.Call(self, m, args);
return
#if UNITY_5
#else
(Action<S, A0, A1>)
#endif
Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
}
#if UNITY_5
public static Delegate Create<S, A0, A1, A2>(MethodInfo m)
#else
public static Action<S, A0, A1, A2> Create<S, A0, A1, A2>(MethodInfo m)
#endif
{
var self = Expression.Parameter(m.DeclaringType, m.Name);
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
var call = Expression.Call(self, m, args);
return
#if UNITY_5
#else
(Action<S, A0, A1, A2>)
#endif
Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
}
#if UNITY_5
public static Delegate Create<S, A0, A1, A2, A3>(MethodInfo m)
#else
public static Action<S, A0, A1, A2, A3> Create<S, A0, A1, A2, A3>(MethodInfo m)
#endif
{
var self = Expression.Parameter(m.DeclaringType, m.Name);
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
var call = Expression.Call(self, m, args);
return
#if UNITY_5
#else
(Action<S, A0, A1, A2, A3>)
#endif
Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
}
#if UNITY_5
public static Delegate Create<S, A0, A1, A2, A3, A4>(MethodInfo m)
#else
public static Action<S, A0, A1, A2, A3, A4> Create<S, A0, A1, A2, A3, A4>(MethodInfo m)
#endif
{
var self = Expression.Parameter(m.DeclaringType, m.Name);
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
var call = Expression.Call(self, m, args);
return
#if UNITY_5
#else
(Action<S, A0, A1, A2, A3, A4>)
#endif
Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
}
#if UNITY_5
public static Delegate Create<S, A0, A1, A2, A3, A4, A5>(MethodInfo m)
#else
public static Action<S, A0, A1, A2, A3, A4, A5> Create<S, A0, A1, A2, A3, A4, A5>(MethodInfo m)
#endif
{
var self = Expression.Parameter(m.DeclaringType, m.Name);
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
var call = Expression.Call(self, m, args);
return
#if UNITY_5
#else
(Action<S, A0, A1, A2, A3, A4, A5>)
#endif
Expression.Lambda(call, new[] { self }.Concat(args).ToArray()).Compile();
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0>(MethodInfo m, S instance)
#else
public static Action<A0> CreateWithThis<S, A0>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -152,19 +70,11 @@ namespace UniJSON
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<A0>)
#endif
Expression.Lambda(call, args).Compile();
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1>(MethodInfo m, S instance)
#else
public static Action<A0, A1> CreateWithThis<S, A0, A1>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -193,19 +103,11 @@ namespace UniJSON
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<A0, A1>)
#endif
Expression.Lambda(call, args).Compile();
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2> CreateWithThis<S, A0, A1, A2>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -234,19 +136,11 @@ namespace UniJSON
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<A0, A1, A2>)
#endif
Expression.Lambda(call, args).Compile();
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2, A3>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2, A3> CreateWithThis<S, A0, A1, A2, A3>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -275,92 +169,6 @@ namespace UniJSON
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<A0, A1, A2, A3>)
#endif
Expression.Lambda(call, args).Compile();
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2, A3, A4>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2, A3, A4> CreateWithThis<S, A0, A1, A2, A3, A4>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
if (instance != null)
{
throw new ArgumentException();
}
}
else
{
if (instance == null)
{
throw new ArgumentNullException();
}
}
var self = Expression.Constant(instance, typeof(S)); // thisを定数化
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
MethodCallExpression call;
if (m.IsStatic)
{
call = Expression.Call(m, args);
}
else
{
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<A0, A1, A2, A3, A4>)
#endif
Expression.Lambda(call, args).Compile();
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2, A3, A4, A5>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2, A3, A4, A5> CreateWithThis<S, A0, A1, A2, A3, A4, A5>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
if (instance != null)
{
throw new ArgumentException();
}
}
else
{
if (instance == null)
{
throw new ArgumentNullException();
}
}
var self = Expression.Constant(instance, typeof(S)); // thisを定数化
var args = m.GetParameters().Select(x => Expression.Parameter(x.ParameterType, x.Name)).ToArray();
MethodCallExpression call;
if (m.IsStatic)
{
call = Expression.Call(m, args);
}
else
{
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<A0, A1, A2, A3, A4, A5>)
#endif
Expression.Lambda(call, args).Compile();
}

View File

@@ -13,6 +13,7 @@ namespace UniJSON
public static partial class GenericInvokeCallFactory
{
#if UNITY_EDITOR && VRM_DEVELOP
const int NET35MAX = 4;
const int ARGS = 6;
const string GENERATE_PATH = "Assets/VRM/UniJSON/Scripts/GenericCallUtility/GenericInvokeCallFactory.g.cs";
@@ -45,23 +46,15 @@ namespace UniJSON
w.WriteLine("//////////// Create");
// Create
for (int i = 1; i <= ARGS; ++i)
for (int i = 1; i <= ARGS && i< NET35MAX; ++i)
{
var g = String.Join(", ", GetArgs("A", i).ToArray());
var a = String.Join(", ", GetArgs("a", i).ToArray());
if (i >= 4) w.WriteLine(@"
#if UNITY_5
#else
");
var source = @"
#if UNITY_5
public static Delegate Create<S, $0>(MethodInfo m)
#else
public static Action<S, $0> Create<S, $0>(MethodInfo m)
#endif
{
Action<S, $0> callback=
(s, $1) =>
@@ -74,30 +67,18 @@ namespace UniJSON
w.WriteLine(source);
if (i >= 4) w.WriteLine(@"
#endif
");
}
// CreateWithThis
w.WriteLine("//////////// CreateWithThis");
for (int i = 1; i <= ARGS; ++i)
for (int i = 1; i <= ARGS && i<= NET35MAX; ++i)
{
var g = String.Join(", ", GetArgs("A", i).ToArray());
var a = String.Join(", ", GetArgs("a", i).ToArray());
if (i > 4) w.WriteLine(@"
#if UNITY_5
#else
");
var source = @"
#if UNITY_5
public static Delegate CreateWithThis<S, $0>(MethodInfo m, S instance)
#else
public static Action<$0> CreateWithThis<S, $0>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -124,10 +105,6 @@ namespace UniJSON
".Replace("$0", g).Replace("$1", a);
w.WriteLine(source);
if (i > 4) w.WriteLine(@"
#endif
");
}

View File

@@ -10,11 +10,7 @@ namespace UniJSON
//////////// Create
#if UNITY_5
public static Delegate Create<S, A0>(MethodInfo m)
#else
public static Action<S, A0> Create<S, A0>(MethodInfo m)
#endif
{
Action<S, A0> callback=
(s, a0) =>
@@ -25,11 +21,7 @@ namespace UniJSON
}
#if UNITY_5
public static Delegate Create<S, A0, A1>(MethodInfo m)
#else
public static Action<S, A0, A1> Create<S, A0, A1>(MethodInfo m)
#endif
{
Action<S, A0, A1> callback=
(s, a0, a1) =>
@@ -40,11 +32,7 @@ namespace UniJSON
}
#if UNITY_5
public static Delegate Create<S, A0, A1, A2>(MethodInfo m)
#else
public static Action<S, A0, A1, A2> Create<S, A0, A1, A2>(MethodInfo m)
#endif
{
Action<S, A0, A1, A2> callback=
(s, a0, a1, a2) =>
@@ -54,79 +42,9 @@ namespace UniJSON
return callback;
}
#if UNITY_5
#else
#if UNITY_5
public static Delegate Create<S, A0, A1, A2, A3>(MethodInfo m)
#else
public static Action<S, A0, A1, A2, A3> Create<S, A0, A1, A2, A3>(MethodInfo m)
#endif
{
Action<S, A0, A1, A2, A3> callback=
(s, a0, a1, a2, a3) =>
{
m.Invoke(s, new object[] { a0, a1, a2, a3 });
};
return callback;
}
#endif
#if UNITY_5
#else
#if UNITY_5
public static Delegate Create<S, A0, A1, A2, A3, A4>(MethodInfo m)
#else
public static Action<S, A0, A1, A2, A3, A4> Create<S, A0, A1, A2, A3, A4>(MethodInfo m)
#endif
{
Action<S, A0, A1, A2, A3, A4> callback=
(s, a0, a1, a2, a3, a4) =>
{
m.Invoke(s, new object[] { a0, a1, a2, a3, a4 });
};
return callback;
}
#endif
#if UNITY_5
#else
#if UNITY_5
public static Delegate Create<S, A0, A1, A2, A3, A4, A5>(MethodInfo m)
#else
public static Action<S, A0, A1, A2, A3, A4, A5> Create<S, A0, A1, A2, A3, A4, A5>(MethodInfo m)
#endif
{
Action<S, A0, A1, A2, A3, A4, A5> callback=
(s, a0, a1, a2, a3, a4, a5) =>
{
m.Invoke(s, new object[] { a0, a1, a2, a3, a4, a5 });
};
return callback;
}
#endif
//////////// CreateWithThis
#if UNITY_5
public static Delegate CreateWithThis<S, A0>(MethodInfo m, S instance)
#else
public static Action<A0> CreateWithThis<S, A0>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -152,11 +70,7 @@ namespace UniJSON
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1>(MethodInfo m, S instance)
#else
public static Action<A0, A1> CreateWithThis<S, A0, A1>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -182,11 +96,7 @@ namespace UniJSON
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2> CreateWithThis<S, A0, A1, A2>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -212,11 +122,7 @@ namespace UniJSON
}
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2, A3>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2, A3> CreateWithThis<S, A0, A1, A2, A3>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
@@ -242,80 +148,6 @@ namespace UniJSON
}
#if UNITY_5
#else
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2, A3, A4>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2, A3, A4> CreateWithThis<S, A0, A1, A2, A3, A4>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
if (instance != null)
{
throw new ArgumentException();
}
}
else
{
if (instance == null)
{
throw new ArgumentNullException();
}
}
// ToDo: CreateDelegate
Action<A0, A1, A2, A3, A4> callback=
(a0, a1, a2, a3, a4) => {
m.Invoke(instance, new object[]{ a0, a1, a2, a3, a4 });
};
return callback;
}
#endif
#if UNITY_5
#else
#if UNITY_5
public static Delegate CreateWithThis<S, A0, A1, A2, A3, A4, A5>(MethodInfo m, S instance)
#else
public static Action<A0, A1, A2, A3, A4, A5> CreateWithThis<S, A0, A1, A2, A3, A4, A5>(MethodInfo m, S instance)
#endif
{
if (m.IsStatic)
{
if (instance != null)
{
throw new ArgumentException();
}
}
else
{
if (instance == null)
{
throw new ArgumentNullException();
}
}
// ToDo: CreateDelegate
Action<A0, A1, A2, A3, A4, A5> callback=
(a0, a1, a2, a3, a4, a5) => {
m.Invoke(instance, new object[]{ a0, a1, a2, a3, a4, a5 });
};
return callback;
}
#endif
}
}