Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77e9bcb

Browse files
committed
MethodBinderEvents.CoerceBind
1 parenta21c797 commit77e9bcb

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

‎src/runtime/MethodBinder.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
namespacePython.Runtime
1010
{
1111
usingMaybeMethodBase=MaybeMethodBase<MethodBase>;
12+
13+
publicdelegatevoidMethodBinderCoerceBindDelegate(
14+
Dictionary<string,PyObject>arguments,
15+
MethodBase[]methods,
16+
refMethodBase?foundBinding);
17+
1218
/// <summary>
1319
/// A MethodBinder encapsulates information about a (possibly overloaded)
1420
/// managed method, and is responsible for selecting the right method given
@@ -516,7 +522,7 @@ public MismatchedMethod(Exception exception, MethodBase mb)
516522
}
517523
}
518524

519-
returnnewBinding(mi,target,margs,outs);
525+
returnCoerceResult(newBinding(mi,target,margs,outs));
520526
}
521527
elseif(matchGenerics&&isGeneric)
522528
{
@@ -528,7 +534,7 @@ public MismatchedMethod(Exception exception, MethodBase mb)
528534
MethodInfo[]overloads=MatchParameters(methods,types);
529535
if(overloads.Length!=0)
530536
{
531-
returnBind(inst,args,kwargDict,overloads,matchGenerics:false);
537+
returnCoerceResult(Bind(inst,args,kwargDict,overloads,matchGenerics:false));
532538
}
533539
}
534540
if(mismatchedMethods.Count>0)
@@ -537,6 +543,19 @@ public MismatchedMethod(Exception exception, MethodBase mb)
537543
Exceptions.SetError(aggregateException);
538544
}
539545
returnnull;
546+
547+
Binding?CoerceResult(Binding?binding)
548+
{
549+
if(bindingis notnull)
550+
{
551+
varfoundMethod=binding.info;
552+
MethodBinderEvents.CoerceBind?.Invoke(kwargDict,methods,reffoundMethod);
553+
if(foundMethodisnull)
554+
returnnull;
555+
}
556+
557+
returnbinding;
558+
}
540559
}
541560

542561
staticAggregateExceptionGetAggregateException(IEnumerable<MismatchedMethod>mismatchedMethods)
@@ -1068,4 +1087,9 @@ static internal class ParameterInfoExtensions
10681087
}
10691088
}
10701089
}
1090+
1091+
publicstaticclassMethodBinderEvents
1092+
{
1093+
publicstaticMethodBinderCoerceBindDelegate?CoerceBind;
1094+
}
10711095
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp