| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -309,26 +309,38 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, | |||
| 309 | 309 | ||
| 310 | 310 | ||
| 311 | 311 | if (clrtype != null) { | |
| 312 | + bool typematch = false; | ||
| 312 | 313 | if (pi[n].ParameterType != clrtype) { | |
| 313 | 314 | IntPtr pytype = Converter.GetPythonTypeByAlias(pi[n].ParameterType); | |
| 314 | 315 | pyoptype = Runtime.PyObject_Type(op); | |
| 315 | 316 | Exceptions.Clear(); | |
| 316 | 317 | if (pyoptype != IntPtr.Zero) { | |
| 317 | 318 | if (pytype != pyoptype) { | |
| 318 | - Runtime.Decref(pyoptype); | ||
| 319 | - margs = null; | ||
| 320 | - break; | ||
| 319 | + typematch = false; | ||
| 321 | 320 | } | |
| 322 | 321 | else { | |
| 322 | + typematch = true; | ||
| 323 | 323 | clrtype = pi[n].ParameterType; | |
| 324 | 324 | } | |
| 325 | 325 | } | |
| 326 | - else { | ||
| 327 | - Runtime.Decref(pyoptype); | ||
| 326 | + if (!typematch) { | ||
| 327 | + // this takes care of enum values | ||
| 328 | + TypeCode argtypecode = Type.GetTypeCode(pi[n].ParameterType); | ||
| 329 | + TypeCode paramtypecode = Type.GetTypeCode(clrtype); | ||
| 330 | + if (argtypecode == paramtypecode) { | ||
| 331 | + typematch = true; | ||
| 332 | + clrtype = pi[n].ParameterType; | ||
| 333 | + } | ||
| 334 | + } | ||
| 335 | + Runtime.Decref(pyoptype); | ||
| 336 | + if (!typematch) { | ||
| 328 | 337 | margs = null; | |
| 329 | 338 | break; | |
| 330 | 339 | } | |
| 331 | - Runtime.Decref(pyoptype); | ||
| 340 | + } | ||
| 341 | + else { | ||
| 342 | + typematch = true; | ||
| 343 | + clrtype = pi[n].ParameterType; | ||
| 332 | 344 | } | |
| 333 | 345 | } | |
| 334 | 346 | else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -375,6 +375,12 @@ def testCorrectOverloadSelection(self): | |||
| 375 | 375 | atype(value1), | |
| 376 | 376 | atype(value2))) | |
| 377 | 377 | ||
| 378 | + clr.AddReference("System.Runtime.InteropServices") | ||
| 379 | + from System.Runtime.InteropServices import GCHandle, GCHandleType | ||
| 380 | + from System import Array, Byte | ||
| 381 | + CSArray = Array.CreateInstance(Byte, 1000) | ||
| 382 | + handler = GCHandle.Alloc(CSArray, GCHandleType.Pinned) | ||
| 383 | + | ||
| 378 | 384 | def testGenericMethodOverloadSelection(self): | |
| 379 | 385 | """ | |
| 380 | 386 | Test explicit overload selection with generic methods. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments