Skip to content
Closed
Changes from 1 commit
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
Next Next commit
Update methodbinder.cs
  • Loading branch information
denfromufa committed Feb 8, 2016
commit e4b10281cdbbf2c3eff3d3a5ee35e2ad98235130
28 changes: 24 additions & 4 deletions src/runtime/methodbinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ internal void AddMethod(MethodBase m) {
//====================================================================

internal static MethodInfo MatchSignature(MethodInfo[] mi, Type[] tp) {
int count = tp.Length;
if (tp == null) {
return null;
}
int count = tp.Length;
for (int i = 0; i < mi.Length; i++) {
ParameterInfo[] pi = mi[i].GetParameters();
if (pi.Length != count) {
Expand Down Expand Up @@ -99,7 +102,10 @@ internal static MethodInfo MatchParameters(MethodInfo[] mi, Type[] tp) {

internal static MethodInfo MatchSignatureAndParameters(MethodInfo[] mi, Type[] genericTp, Type[] sigTp)
{
int genericCount = genericTp.Length;
if ((genericTp == null) || (sigTp == null)) {
return null;
}
int genericCount = genericTp.Length;
int signatureCount = sigTp.Length;
for (int i = 0; i < mi.Length; i++)
{
Expand Down Expand Up @@ -239,9 +245,10 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw,
else {
_methods = GetMethods();
}

Type type;
for (int i = 0; i < _methods.Length; i++) {
MethodBase mi = _methods[i];

if (mi.IsGenericMethod) { isGeneric = true; }
ParameterInfo[] pi = mi.GetParameters();
int clrnargs = pi.Length;
Expand Down Expand Up @@ -287,7 +294,20 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw,
{
op = Runtime.PyTuple_GetItem(args, n);
}
Type type = pi[n].ParameterType;

type = Converter.GetTypeByAlias(Runtime.PyObject_Type(op));

if (type != null) {
if (pi[n].ParameterType != type) {
Exceptions.Clear();
margs = null;
break;
}
}
else {
type = pi[n].ParameterType;
}

if (pi[n].IsOut || type.IsByRef)
{
outs++;
Expand Down