Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unity 5 symbol #150

Merged
merged 1 commit into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -42,26 +43,18 @@ public static partial class GenericExpressionCallFactory
{
");
// 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);
Expand All @@ -70,16 +63,12 @@ public static partial class GenericExpressionCallFactory
}

// 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)
{
Expand Down Expand Up @@ -108,10 +97,6 @@ public static partial class GenericExpressionCallFactory
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<$0>)
#endif
Expression.Lambda(call, args).Compile();
}
".Replace("$0", g);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,119 +11,37 @@ public static partial class GenericExpressionCallFactory
{


#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)
{
Expand Down Expand Up @@ -152,19 +70,11 @@ public static Action<A0> CreateWithThis<S, A0>(MethodInfo m, S instance)
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)
{
Expand Down Expand Up @@ -193,19 +103,11 @@ public static Action<A0, A1> CreateWithThis<S, A0, A1>(MethodInfo m, S instance)
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)
{
Expand Down Expand Up @@ -234,101 +136,11 @@ public static Action<A0, A1, A2> CreateWithThis<S, A0, A1, A2>(MethodInfo m, S i
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)
{
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>)
#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)
{
Expand Down Expand Up @@ -357,10 +169,6 @@ public static Action<A0, A1, A2, A3, A4, A5> CreateWithThis<S, A0, A1, A2, A3, A
call = Expression.Call(self, m, args);
}
return
#if UNITY_5
#else
(Action<A0, A1, A2, A3, A4, A5>)
#endif
Expression.Lambda(call, args).Compile();
}

Expand Down
Loading