@@ -54,7 +54,7 @@ internal void AddMethod(MethodBase m)
54
54
/// Given a sequence of MethodInfo and a sequence of types, return the
55
55
/// MethodInfo that matches the signature represented by those types.
56
56
/// </summary>
57
- internal static MethodInfo MatchSignature ( MethodInfo [ ] mi , Type [ ] tp )
57
+ internal static MethodInfo ? MatchSignature ( MethodInfo [ ] mi , Type [ ] tp )
58
58
{
59
59
if ( tp == null )
60
60
{
@@ -88,7 +88,7 @@ internal static MethodInfo MatchSignature(MethodInfo[] mi, Type[] tp)
88
88
/// return the MethodInfo that represents the matching closed generic.
89
89
/// If unsuccessful, returns null and may set a Python error.
90
90
/// </summary>
91
- internal static MethodInfo MatchParameters ( MethodInfo [ ] mi , Type [ ] tp )
91
+ internal static MethodInfo ? MatchParameters ( MethodInfo [ ] mi , Type [ ] ? tp )
92
92
{
93
93
if ( tp == null )
94
94
{
@@ -127,7 +127,7 @@ internal static MethodInfo MatchParameters(MethodInfo[] mi, Type[] tp)
127
127
/// Given a sequence of MethodInfo and two sequences of type parameters,
128
128
/// return the MethodInfo that matches the signature and the closed generic.
129
129
/// </summary>
130
- internal static MethodInfo MatchSignatureAndParameters ( MethodInfo [ ] mi , Type [ ] genericTp , Type [ ] sigTp )
130
+ internal static MethodInfo ? MatchSignatureAndParameters ( MethodInfo [ ] mi , Type [ ] genericTp , Type [ ] sigTp )
131
131
{
132
132
if ( genericTp == null || sigTp == null )
133
133
{
@@ -300,7 +300,7 @@ internal static int ArgPrecedence(Type t)
300
300
/// <param name="args">The Python arguments.</param>
301
301
/// <param name="kw">The Python keyword arguments.</param>
302
302
/// <returns>A Binding if successful. Otherwise null.</returns>
303
- internal Binding Bind ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw )
303
+ internal Binding ? Bind ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw )
304
304
{
305
305
return Bind ( inst , args , kw , null , null ) ;
306
306
}
@@ -316,14 +316,14 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
316
316
/// <param name="kw">The Python keyword arguments.</param>
317
317
/// <param name="info">If not null, only bind to that method.</param>
318
318
/// <returns>A Binding if successful. Otherwise null.</returns>
319
- internal Binding Bind ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase info )
319
+ internal Binding ? Bind ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase ? info )
320
320
{
321
321
return Bind ( inst , args , kw , info , null ) ;
322
322
}
323
323
324
324
private readonly struct MatchedMethod
325
325
{
326
- public MatchedMethod ( int kwargsMatched , int defaultsNeeded , object [ ] margs , int outs , MethodBase mb )
326
+ public MatchedMethod ( int kwargsMatched , int defaultsNeeded , object ? [ ] margs , int outs , MethodBase mb )
327
327
{
328
328
KwargsMatched = kwargsMatched ;
329
329
DefaultsNeeded = defaultsNeeded ;
@@ -334,7 +334,7 @@ public MatchedMethod(int kwargsMatched, int defaultsNeeded, object[] margs, int
334
334
335
335
public int KwargsMatched { get ; }
336
336
public int DefaultsNeeded { get ; }
337
- public object [ ] ManagedArgs { get ; }
337
+ public object ? [ ] ManagedArgs { get ; }
338
338
public int Outs { get ; }
339
339
public MethodBase Method { get ; }
340
340
}
@@ -363,11 +363,9 @@ public MismatchedMethod(Exception exception, MethodBase mb)
363
363
/// <param name="info">If not null, only bind to that method.</param>
364
364
/// <param name="methodinfo">If not null, additionally attempt to bind to the generic methods in this array by inferring generic type parameters.</param>
365
365
/// <returns>A Binding if successful. Otherwise null.</returns>
366
- internal Binding Bind ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase info , MethodInfo [ ] methodinfo )
366
+ internal Binding ? Bind ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase ? info , MethodInfo [ ] ? methodinfo )
367
367
{
368
368
// loop to find match, return invoker w/ or w/o error
369
- MethodBase [ ] _methods = null ;
370
-
371
369
var kwargDict = new Dictionary < string , PyObject > ( ) ;
372
370
if ( kw != null )
373
371
{
@@ -384,6 +382,8 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
384
382
385
383
var pynargs = ( int ) Runtime . PyTuple_Size ( args ) ;
386
384
var isGeneric = false ;
385
+
386
+ MethodBase [ ] _methods ;
387
387
if ( info != null )
388
388
{
389
389
_methods = new MethodBase [ 1 ] ;
@@ -405,7 +405,7 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
405
405
isGeneric = true ;
406
406
}
407
407
ParameterInfo [ ] pi = mi . GetParameters ( ) ;
408
- ArrayList defaultArgList ;
408
+ ArrayList ? defaultArgList ;
409
409
bool paramsArray ;
410
410
int kwargsMatched ;
411
411
int defaultsNeeded ;
@@ -447,7 +447,7 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
447
447
{
448
448
bool isUnary = pynargs == 0 ;
449
449
// Postprocessing to extend margs.
450
- var margsTemp = isUnary ? new object [ 1 ] : new object [ 2 ] ;
450
+ var margsTemp = isUnary ? new object ? [ 1 ] : new object ? [ 2 ] ;
451
451
// If reverse, the bound instance is the right operand.
452
452
int boundOperandIndex = isReverse ? 1 : 0 ;
453
453
// If reverse, the passed instance is the left operand.
@@ -512,7 +512,7 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
512
512
var outs = bestMatch . Outs ;
513
513
var mi = bestMatch . Method ;
514
514
515
- object target = null ;
515
+ object ? target = null ;
516
516
if ( ! mi . IsStatic && inst != null )
517
517
{
518
518
//CLRObject co = (CLRObject)ManagedType.GetManagedObject(inst);
@@ -540,8 +540,8 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
540
540
// is a generic method and info is null. That happens when a generic
541
541
// method was not called using the [] syntax. Let's introspect the
542
542
// type of the arguments and use it to construct the correct method.
543
- Type [ ] types = Runtime . PythonArgsToTypeArray ( args , true ) ;
544
- MethodInfo mi = MatchParameters ( methodinfo , types ) ;
543
+ Type [ ] ? types = Runtime . PythonArgsToTypeArray ( args , true ) ;
544
+ MethodInfo ? mi = MatchParameters ( methodinfo , types ) ;
545
545
if ( mi != null )
546
546
{
547
547
return Bind ( inst , args , kw , mi , null ) ;
@@ -605,14 +605,14 @@ static BorrowedReference HandleParamsArray(BorrowedReference args, int arrayStar
605
605
/// <param name="needsResolution"><c>true</c>, if overloading resolution is required</param>
606
606
/// <param name="outs">Returns number of output parameters</param>
607
607
/// <returns>If successful, an array of .NET arguments that can be passed to the method. Otherwise null.</returns>
608
- static object [ ] TryConvertArguments ( ParameterInfo [ ] pi , bool paramsArray ,
608
+ static object ? [ ] ? TryConvertArguments ( ParameterInfo [ ] pi , bool paramsArray ,
609
609
BorrowedReference args , int pyArgCount ,
610
610
Dictionary < string , PyObject > kwargDict ,
611
- ArrayList defaultArgList ,
611
+ ArrayList ? defaultArgList ,
612
612
out int outs )
613
613
{
614
614
outs = 0 ;
615
- var margs = new object [ pi . Length ] ;
615
+ var margs = new object ? [ pi . Length ] ;
616
616
int arrayStart = paramsArray ? pi . Length - 1 : - 1 ;
617
617
618
618
for ( int paramIndex = 0 ; paramIndex < pi . Length ; paramIndex ++ )
@@ -634,7 +634,7 @@ static object[] TryConvertArguments(ParameterInfo[] pi, bool paramsArray,
634
634
NewReference tempObject = default ;
635
635
if ( hasNamedParam )
636
636
{
637
- op = kwargDict [ parameter . Name ] ;
637
+ op = kwargDict [ parameter . Name ! ] ;
638
638
}
639
639
else
640
640
{
@@ -676,7 +676,7 @@ static object[] TryConvertArguments(ParameterInfo[] pi, bool paramsArray,
676
676
/// <param name="isOut">Whether the CLR type is passed by reference.</param>
677
677
/// <returns>true on success</returns>
678
678
static bool TryConvertArgument ( BorrowedReference op , Type parameterType ,
679
- out object arg , out bool isOut )
679
+ out object ? arg , out bool isOut )
680
680
{
681
681
arg = null ;
682
682
isOut = false ;
@@ -701,12 +701,12 @@ static bool TryConvertArgument(BorrowedReference op, Type parameterType,
701
701
/// <param name="parameterType">The parameter's managed type.</param>
702
702
/// <param name="argument">Pointer to the Python argument object.</param>
703
703
/// <returns>null if conversion is not possible</returns>
704
- static Type TryComputeClrArgumentType ( Type parameterType , BorrowedReference argument )
704
+ static Type ? TryComputeClrArgumentType ( Type parameterType , BorrowedReference argument )
705
705
{
706
706
// this logic below handles cases when multiple overloading methods
707
707
// are ambiguous, hence comparison between Python and CLR types
708
708
// is necessary
709
- Type clrtype = null ;
709
+ Type ? clrtype = null ;
710
710
711
711
if ( clrtype != null )
712
712
{
@@ -773,7 +773,7 @@ static Type TryComputeClrArgumentType(Type parameterType, BorrowedReference argu
773
773
static bool MatchesArgumentCount ( int positionalArgumentCount , ParameterInfo [ ] parameters ,
774
774
Dictionary < string , PyObject > kwargDict ,
775
775
out bool paramsArray ,
776
- out ArrayList defaultArgList ,
776
+ out ArrayList ? defaultArgList ,
777
777
out int kwargsMatched ,
778
778
out int defaultsNeeded )
779
779
{
@@ -834,7 +834,7 @@ internal virtual NewReference Invoke(BorrowedReference inst, BorrowedReference a
834
834
return Invoke ( inst , args , kw , null , null ) ;
835
835
}
836
836
837
- internal virtual NewReference Invoke ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase info )
837
+ internal virtual NewReference Invoke ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase ? info )
838
838
{
839
839
return Invoke ( inst , args , kw , info , null ) ;
840
840
}
@@ -872,7 +872,7 @@ protected static void AppendArgumentTypes(StringBuilder to, BorrowedReference ar
872
872
to . Append ( ')' ) ;
873
873
}
874
874
875
- internal virtual NewReference Invoke ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase info , MethodInfo [ ] methodinfo )
875
+ internal virtual NewReference Invoke ( BorrowedReference inst , BorrowedReference args , BorrowedReference kw , MethodBase ? info , MethodInfo [ ] ? methodinfo )
876
876
{
877
877
// No valid methods, nothing to bind.
878
878
if ( GetMethods ( ) . Length == 0 )
@@ -885,7 +885,7 @@ internal virtual NewReference Invoke(BorrowedReference inst, BorrowedReference a
885
885
return Exceptions . RaiseTypeError ( msg . ToString ( ) ) ;
886
886
}
887
887
888
- Binding binding = Bind ( inst , args , kw , info , methodinfo ) ;
888
+ Binding ? binding = Bind ( inst , args , kw , info , methodinfo ) ;
889
889
object result ;
890
890
IntPtr ts = IntPtr . Zero ;
891
891
@@ -1041,11 +1041,11 @@ int IComparer<MaybeMethodBase>.Compare(MaybeMethodBase m1, MaybeMethodBase m2)
1041
1041
internal class Binding
1042
1042
{
1043
1043
public MethodBase info ;
1044
- public object [ ] args ;
1045
- public object inst ;
1044
+ public object ? [ ] args ;
1045
+ public object ? inst ;
1046
1046
public int outs ;
1047
1047
1048
- internal Binding ( MethodBase info , object inst , object [ ] args , int outs )
1048
+ internal Binding ( MethodBase info , object ? inst , object ? [ ] args , int outs )
1049
1049
{
1050
1050
this . info = info ;
1051
1051
this . inst = inst ;
@@ -1057,7 +1057,7 @@ internal Binding(MethodBase info, object inst, object[] args, int outs)
1057
1057
1058
1058
static internal class ParameterInfoExtensions
1059
1059
{
1060
- public static object GetDefaultValue ( this ParameterInfo parameterInfo )
1060
+ public static object ? GetDefaultValue ( this ParameterInfo parameterInfo )
1061
1061
{
1062
1062
// parameterInfo.HasDefaultValue is preferable but doesn't exist in .NET 4.0
1063
1063
bool hasDefaultValue = ( parameterInfo . Attributes & ParameterAttributes . HasDefault ) ==
0 commit comments