| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 69cd539 commit 5d90263
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,13 +33,27 @@ internal ConstructorBinder () : base() {} | |||
| 33 | 33 | // Python type to use when wrapping the result (may be a subclass). | |
| 34 | 34 | //==================================================================== | |
| 35 | 35 | ||
| 36 | - internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw) { | ||
| 36 | + internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw) { | ||
| 37 | 37 | return this.InvokeRaw(inst, args, kw, null); | |
| 38 | 38 | } | |
| 39 | - | ||
| 39 | + /// <summary> | ||
| 40 | + /// Allows ctor selection to be limited to a single attempt at a | ||
| 41 | + /// match by providing the MethodBase to use instead of searching | ||
| 42 | + /// the entire MethodBinder.list (generic ArrayList) | ||
| 43 | + /// </summary> | ||
| 44 | + /// <param name="inst"> (possibly null) instance </param> | ||
| 45 | + /// <param name="args"> PyObject* to the arg tuple </param> | ||
| 46 | + /// <param name="kw"> PyObject* to the keyword args dict </param> | ||
| 47 | + /// <param name="info"> The sole ContructorInfo to use or null </param> | ||
| 48 | + /// <returns> The result of the constructor call with converted params </returns> | ||
| 49 | + /// <remarks> | ||
| 50 | + /// 2010-07-24 BC: I added the info parameter to the call to Bind() | ||
| 51 | + /// Binding binding = this.Bind(inst, args, kw, info); | ||
| 52 | + /// to take advantage of Bind()'s ability to use a single MethodBase (CI or MI). | ||
| 53 | + /// </remarks> | ||
| 40 | 54 | internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, | |
| 41 | 55 | MethodBase info) { | |
| 42 | - Binding binding = this.Bind(inst, args, kw); | ||
| 56 | + Binding binding = this.Bind(inst, args, kw, info); | ||
| 43 | 57 | Object result; | |
| 44 | 58 | ||
| 45 | 59 | if (binding == null) { | |
@@ -55,17 +69,17 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, | |||
| 55 | 69 | Runtime.Decref(eargs); | |
| 56 | 70 | ||
| 57 | 71 | if (binding == null) { | |
| 58 | - Exceptions.SetError(Exceptions.TypeError, | ||
| 72 | + Exceptions.SetError(Exceptions.TypeError, | ||
| 59 | 73 | "no constructor matches given arguments" | |
| 60 | 74 | ); | |
| 61 | 75 | return null; | |
| 62 | 76 | } | |
| 63 | 77 | } | |
| 64 | 78 | ||
| 79 | + // Fire the selected ctor and catch errors... | ||
| 80 | + ConstructorInfo ci = (ConstructorInfo)binding.info; | ||
| 65 | 81 | // Object construction is presumed to be non-blocking and fast | |
| 66 | 82 | // enough that we shouldn't really need to release the GIL. | |
| 67 | - | ||
| 68 | - ConstructorInfo ci = (ConstructorInfo)binding.info; | ||
| 69 | 83 | try { | |
| 70 | 84 | result = ci.Invoke(binding.args); | |
| 71 | 85 | } | |
@@ -76,12 +90,7 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, | |||
| 76 | 90 | Exceptions.SetError(e); | |
| 77 | 91 | return null; | |
| 78 | 92 | } | |
| 79 | - | ||
| 80 | 93 | return result; | |
| 81 | 94 | } | |
| 82 | - | ||
| 83 | - | ||
| 84 | 95 | } | |
| 85 | - | ||
| 86 | - | ||
| 87 | 96 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments