Skip to content

Commit

Permalink
Merge pull request #150 from dwango/fix_UNITY_5_symbol
Browse files Browse the repository at this point in the history
Fix unity 5 symbol
  • Loading branch information
yutopp authored Jan 28, 2019
2 parents c05f3cd + 1b213c8 commit 43af638
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 404 deletions.
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

0 comments on commit 43af638

Please sign in to comment.