| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1a2499b commit 86937bb
36 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,7 +57,7 @@ public virtual IntPtr type_subscript(IntPtr idx) | |||
| 57 | 57 | { | |
| 58 | 58 | Type t = target.MakeGenericType(types); | |
| 59 | 59 | ManagedType c = (ManagedType)ClassManager.GetClass(t); | |
| 60 | - Runtime.Incref(c.pyHandle); | ||
| 60 | + Runtime.XIncref(c.pyHandle); | ||
| 61 | 61 | return c.pyHandle; | |
| 62 | 62 | } | |
| 63 | 63 | ||
@@ -71,7 +71,7 @@ public virtual IntPtr type_subscript(IntPtr idx) | |||
| 71 | 71 | public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) { | |
| 72 | 72 | if (op != Runtime.Py_EQ && op != Runtime.Py_NE) | |
| 73 | 73 | { | |
| 74 | - Runtime.Incref(Runtime.PyNotImplemented); | ||
| 74 | + Runtime.XIncref(Runtime.PyNotImplemented); | ||
| 75 | 75 | return Runtime.PyNotImplemented; | |
| 76 | 76 | } | |
| 77 | 77 | ||
@@ -86,26 +86,26 @@ public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) { | |||
| 86 | 86 | } | |
| 87 | 87 | ||
| 88 | 88 | if (ob == other) { | |
| 89 | - Runtime.Incref(pytrue); | ||
| 89 | + Runtime.XIncref(pytrue); | ||
| 90 | 90 | return pytrue; | |
| 91 | 91 | } | |
| 92 | 92 | ||
| 93 | 93 | CLRObject co1 = GetManagedObject(ob) as CLRObject; | |
| 94 | 94 | CLRObject co2 = GetManagedObject(other) as CLRObject; | |
| 95 | 95 | if (null == co2) { | |
| 96 | - Runtime.Incref(pyfalse); | ||
| 96 | + Runtime.XIncref(pyfalse); | ||
| 97 | 97 | return pyfalse; | |
| 98 | 98 | } | |
| 99 | 99 | ||
| 100 | 100 | Object o1 = co1.inst; | |
| 101 | 101 | Object o2 = co2.inst; | |
| 102 | 102 | ||
| 103 | 103 | if (Object.Equals(o1, o2)) { | |
| 104 | - Runtime.Incref(pytrue); | ||
| 104 | + Runtime.XIncref(pytrue); | ||
| 105 | 105 | return pytrue; | |
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | - Runtime.Incref(pyfalse); | ||
| 108 | + Runtime.XIncref(pyfalse); | ||
| 109 | 109 | return pyfalse; | |
| 110 | 110 | } | |
| 111 | 111 | #else | |
@@ -237,11 +237,11 @@ public static void tp_dealloc(IntPtr ob) | |||
| 237 | 237 | IntPtr dict = Marshal.ReadIntPtr(ob, ObjectOffset.DictOffset(ob)); | |
| 238 | 238 | if (dict != IntPtr.Zero) | |
| 239 | 239 | { | |
| 240 | - Runtime.Decref(dict); | ||
| 240 | + Runtime.XDecref(dict); | ||
| 241 | 241 | } | |
| 242 | 242 | Runtime.PyObject_GC_UnTrack(self.pyHandle); | |
| 243 | 243 | Runtime.PyObject_GC_Del(self.pyHandle); | |
| 244 | - Runtime.Decref(self.tpHandle); | ||
| 244 | + Runtime.XDecref(self.tpHandle); | ||
| 245 | 245 | self.gcHandle.Free(); | |
| 246 | 246 | } | |
| 247 | 247 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,7 +81,7 @@ internal static IntPtr ToPython(IPythonDerivedType obj) | |||
| 81 | 81 | FieldInfo fi = obj.GetType().GetField("__pyobj__"); | |
| 82 | 82 | CLRObject self = (CLRObject)fi.GetValue(obj); | |
| 83 | 83 | ||
| 84 | - Runtime.Incref(self.pyHandle); | ||
| 84 | + Runtime.XIncref(self.pyHandle); | ||
| 85 | 85 | ||
| 86 | 86 | // when the C# constructor creates the python object it starts as a weak | |
| 87 | 87 | // reference with a reference count of 0. Now we're passing this object | |
@@ -153,7 +153,7 @@ internal static Type CreateDerivedType(string name, | |||
| 153 | 153 | HashSet<string> pyProperties = new HashSet<string>(); | |
| 154 | 154 | if (py_dict != IntPtr.Zero && Runtime.PyDict_Check(py_dict)) | |
| 155 | 155 | { | |
| 156 | - Runtime.Incref(py_dict); | ||
| 156 | + Runtime.XIncref(py_dict); | ||
| 157 | 157 | using (PyDict dict = new PyDict(py_dict)) | |
| 158 | 158 | using (PyObject keys = dict.Keys()) | |
| 159 | 159 | { | |
@@ -196,7 +196,7 @@ internal static Type CreateDerivedType(string name, | |||
| 196 | 196 | // Add any additional methods and properties explicitly exposed from Python. | |
| 197 | 197 | if (py_dict != IntPtr.Zero && Runtime.PyDict_Check(py_dict)) | |
| 198 | 198 | { | |
| 199 | - Runtime.Incref(py_dict); | ||
| 199 | + Runtime.XIncref(py_dict); | ||
| 200 | 200 | using (PyDict dict = new PyDict(py_dict)) | |
| 201 | 201 | using (PyObject keys = dict.Keys()) | |
| 202 | 202 | { | |
@@ -588,11 +588,11 @@ public static T InvokeMethod<T>(IPythonDerivedType obj, string methodName, strin | |||
| 588 | 588 | IntPtr gs = Runtime.PyGILState_Ensure(); | |
| 589 | 589 | try | |
| 590 | 590 | { | |
| 591 | - Runtime.Incref(self.pyHandle); | ||
| 591 | + Runtime.XIncref(self.pyHandle); | ||
| 592 | 592 | PyObject pyself = new PyObject(self.pyHandle); | |
| 593 | 593 | disposeList.Add(pyself); | |
| 594 | 594 | ||
| 595 | - Runtime.Incref(Runtime.PyNone); | ||
| 595 | + Runtime.XIncref(Runtime.PyNone); | ||
| 596 | 596 | PyObject pynone = new PyObject(Runtime.PyNone); | |
| 597 | 597 | disposeList.Add(pynone); | |
| 598 | 598 | ||
@@ -649,11 +649,11 @@ public static void InvokeMethodVoid(IPythonDerivedType obj, string methodName, s | |||
| 649 | 649 | IntPtr gs = Runtime.PyGILState_Ensure(); | |
| 650 | 650 | try | |
| 651 | 651 | { | |
| 652 | - Runtime.Incref(self.pyHandle); | ||
| 652 | + Runtime.XIncref(self.pyHandle); | ||
| 653 | 653 | PyObject pyself = new PyObject(self.pyHandle); | |
| 654 | 654 | disposeList.Add(pyself); | |
| 655 | 655 | ||
| 656 | - Runtime.Incref(Runtime.PyNone); | ||
| 656 | + Runtime.XIncref(Runtime.PyNone); | ||
| 657 | 657 | PyObject pynone = new PyObject(Runtime.PyNone); | |
| 658 | 658 | disposeList.Add(pynone); | |
| 659 | 659 | ||
@@ -710,7 +710,7 @@ public static T InvokeGetProperty<T>(IPythonDerivedType obj, string propertyName | |||
| 710 | 710 | IntPtr gs = Runtime.PyGILState_Ensure(); | |
| 711 | 711 | try | |
| 712 | 712 | { | |
| 713 | - Runtime.Incref(self.pyHandle); | ||
| 713 | + Runtime.XIncref(self.pyHandle); | ||
| 714 | 714 | using (PyObject pyself = new PyObject(self.pyHandle)) | |
| 715 | 715 | using (PyObject pyvalue = pyself.GetAttr(propertyName)) | |
| 716 | 716 | return (T)pyvalue.AsManagedObject(typeof(T)); | |
@@ -732,7 +732,7 @@ public static void InvokeSetProperty<T>(IPythonDerivedType obj, string propertyN | |||
| 732 | 732 | IntPtr gs = Runtime.PyGILState_Ensure(); | |
| 733 | 733 | try | |
| 734 | 734 | { | |
| 735 | - Runtime.Incref(self.pyHandle); | ||
| 735 | + Runtime.XIncref(self.pyHandle); | ||
| 736 | 736 | using (PyObject pyself = new PyObject(self.pyHandle)) | |
| 737 | 737 | using (PyObject pyvalue = new PyObject(Converter.ToPythonImplicit(value))) | |
| 738 | 738 | pyself.SetAttr(propertyName, pyvalue); | |
@@ -766,11 +766,11 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, Objec | |||
| 766 | 766 | FieldInfo fi = obj.GetType().GetField("__pyobj__"); | |
| 767 | 767 | fi.SetValue(obj, self); | |
| 768 | 768 | ||
| 769 | - Runtime.Incref(self.pyHandle); | ||
| 769 | + Runtime.XIncref(self.pyHandle); | ||
| 770 | 770 | PyObject pyself = new PyObject(self.pyHandle); | |
| 771 | 771 | disposeList.Add(pyself); | |
| 772 | 772 | ||
| 773 | - Runtime.Incref(Runtime.PyNone); | ||
| 773 | + Runtime.XIncref(Runtime.PyNone); | ||
| 774 | 774 | PyObject pynone = new PyObject(Runtime.PyNone); | |
| 775 | 775 | disposeList.Add(pynone); | |
| 776 | 776 | ||
@@ -806,7 +806,7 @@ public static void InvokeCtor(IPythonDerivedType obj, string origCtorName, Objec | |||
| 806 | 806 | // This doesn't actually destroy the object, it just sets the reference to this object | |
| 807 | 807 | // to be a weak reference and it will be destroyed when the C# object is destroyed. | |
| 808 | 808 | if (null != self) | |
| 809 | - Runtime.Decref(self.pyHandle); | ||
| 809 | + Runtime.XDecref(self.pyHandle); | ||
| 810 | 810 | ||
| 811 | 811 | Runtime.PyGILState_Release(gs); | |
| 812 | 812 | } | |
@@ -848,7 +848,7 @@ public static void Finalize(IPythonDerivedType obj) | |||
| 848 | 848 | // python object. | |
| 849 | 849 | IntPtr dict = Marshal.ReadIntPtr(self.pyHandle, ObjectOffset.DictOffset(self.pyHandle)); | |
| 850 | 850 | if (dict != IntPtr.Zero) | |
| 851 | - Runtime.Decref(dict); | ||
| 851 | + Runtime.XDecref(dict); | ||
| 852 | 852 | Runtime.PyObject_GC_Del(self.pyHandle); | |
| 853 | 853 | self.gcHandle.Free(); | |
| 854 | 854 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,7 +160,7 @@ private static void InitClassBase(Type type, ClassBase impl) | |||
| 160 | 160 | string docStr = attr.DocString; | |
| 161 | 161 | doc = Runtime.PyString_FromString(docStr); | |
| 162 | 162 | Runtime.PyDict_SetItemString(dict, "__doc__", doc); | |
| 163 | - Runtime.Decref(doc); | ||
| 163 | + Runtime.XDecref(doc); | ||
| 164 | 164 | } | |
| 165 | 165 | ||
| 166 | 166 | ClassObject co = impl as ClassObject; | |
@@ -185,7 +185,7 @@ private static void InitClassBase(Type type, ClassBase impl) | |||
| 185 | 185 | { | |
| 186 | 186 | doc = co.GetDocString(); | |
| 187 | 187 | Runtime.PyDict_SetItemString(dict, "__doc__", doc); | |
| 188 | - Runtime.Decref(doc); | ||
| 188 | + Runtime.XDecref(doc); | ||
| 189 | 189 | } | |
| 190 | 190 | } | |
| 191 | 191 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -139,7 +139,7 @@ public override IntPtr type_subscript(IntPtr idx) | |||
| 139 | 139 | } | |
| 140 | 140 | Type a = t.MakeArrayType(); | |
| 141 | 141 | ClassBase o = ClassManager.GetClass(a); | |
| 142 | - Runtime.Incref(o.pyHandle); | ||
| 142 | + Runtime.XIncref(o.pyHandle); | ||
| 143 | 143 | return o.pyHandle; | |
| 144 | 144 | } | |
| 145 | 145 | ||
@@ -159,7 +159,7 @@ public override IntPtr type_subscript(IntPtr idx) | |||
| 159 | 159 | { | |
| 160 | 160 | GenericType g = ClassManager.GetClass(gtype) as GenericType; | |
| 161 | 161 | return g.type_subscript(idx); | |
| 162 | - /*Runtime.Incref(g.pyHandle); | ||
| 162 | + /*Runtime.XIncref(g.pyHandle); | ||
| 163 | 163 | return g.pyHandle;*/ | |
| 164 | 164 | } | |
| 165 | 165 | return Exceptions.RaiseTypeError("unsubscriptable object"); | |
@@ -194,7 +194,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) | |||
| 194 | 194 | if (!Runtime.PyTuple_Check(idx)) | |
| 195 | 195 | { | |
| 196 | 196 | args = Runtime.PyTuple_New(1); | |
| 197 | - Runtime.Incref(idx); | ||
| 197 | + Runtime.XIncref(idx); | ||
| 198 | 198 | Runtime.PyTuple_SetItem(args, 0, idx); | |
| 199 | 199 | free = true; | |
| 200 | 200 | } | |
@@ -209,7 +209,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) | |||
| 209 | 209 | { | |
| 210 | 210 | if (free) | |
| 211 | 211 | { | |
| 212 | - Runtime.Decref(args); | ||
| 212 | + Runtime.XDecref(args); | ||
| 213 | 213 | } | |
| 214 | 214 | } | |
| 215 | 215 | return value; | |
@@ -243,7 +243,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) | |||
| 243 | 243 | if (!Runtime.PyTuple_Check(idx)) | |
| 244 | 244 | { | |
| 245 | 245 | args = Runtime.PyTuple_New(1); | |
| 246 | - Runtime.Incref(idx); | ||
| 246 | + Runtime.XIncref(idx); | ||
| 247 | 247 | Runtime.PyTuple_SetItem(args, 0, idx); | |
| 248 | 248 | free = true; | |
| 249 | 249 | } | |
@@ -257,23 +257,23 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) | |||
| 257 | 257 | for (int n = 0; n < i; n++) | |
| 258 | 258 | { | |
| 259 | 259 | IntPtr item = Runtime.PyTuple_GetItem(args, n); | |
| 260 | - Runtime.Incref(item); | ||
| 260 | + Runtime.XIncref(item); | ||
| 261 | 261 | Runtime.PyTuple_SetItem(real, n, item); | |
| 262 | 262 | } | |
| 263 | 263 | ||
| 264 | 264 | // Add Default Args if needed | |
| 265 | 265 | for (int n = 0; n < numOfDefaultArgs; n++) | |
| 266 | 266 | { | |
| 267 | 267 | IntPtr item = Runtime.PyTuple_GetItem(defaultArgs, n); | |
| 268 | - Runtime.Incref(item); | ||
| 268 | + Runtime.XIncref(item); | ||
| 269 | 269 | Runtime.PyTuple_SetItem(real, n + i, item); | |
| 270 | 270 | } | |
| 271 | 271 | // no longer need defaultArgs | |
| 272 | - Runtime.Decref(defaultArgs); | ||
| 272 | + Runtime.XDecref(defaultArgs); | ||
| 273 | 273 | i = temp; | |
| 274 | 274 | ||
| 275 | 275 | // Add value to argument list | |
| 276 | - Runtime.Incref(v); | ||
| 276 | + Runtime.XIncref(v); | ||
| 277 | 277 | Runtime.PyTuple_SetItem(real, i, v); | |
| 278 | 278 | ||
| 279 | 279 | try | |
@@ -282,11 +282,11 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) | |||
| 282 | 282 | } | |
| 283 | 283 | finally | |
| 284 | 284 | { | |
| 285 | - Runtime.Decref(real); | ||
| 285 | + Runtime.XDecref(real); | ||
| 286 | 286 | ||
| 287 | 287 | if (free) | |
| 288 | 288 | { | |
| 289 | - Runtime.Decref(args); | ||
| 289 | + Runtime.XDecref(args); | ||
| 290 | 290 | } | |
| 291 | 291 | } | |
| 292 | 292 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,7 +92,7 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, | |||
| 92 | 92 | ||
| 93 | 93 | IntPtr eargs = Runtime.PyTuple_New(0); | |
| 94 | 94 | binding = this.Bind(inst, eargs, kw); | |
| 95 | - Runtime.Decref(eargs); | ||
| 95 | + Runtime.XDecref(eargs); | ||
| 96 | 96 | ||
| 97 | 97 | if (binding == null) | |
| 98 | 98 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,7 +30,7 @@ internal class ConstructorBinding : ExtensionType | |||
| 30 | 30 | public ConstructorBinding(Type type, IntPtr pyTypeHndl, ConstructorBinder ctorBinder) : base() | |
| 31 | 31 | { | |
| 32 | 32 | this.type = type; | |
| 33 | - Runtime.Incref(pyTypeHndl); | ||
| 33 | + Runtime.XIncref(pyTypeHndl); | ||
| 34 | 34 | this.pyTypeHndl = pyTypeHndl; | |
| 35 | 35 | this.ctorBinder = ctorBinder; | |
| 36 | 36 | repr = IntPtr.Zero; | |
@@ -73,7 +73,7 @@ public static IntPtr tp_descr_get(IntPtr op, IntPtr instance, IntPtr owner) | |||
| 73 | 73 | return Exceptions.RaiseTypeError("How in the world could that happen!"); | |
| 74 | 74 | } | |
| 75 | 75 | }*/ | |
| 76 | - Runtime.Incref(self.pyHandle); // Decref'd by the interpreter. | ||
| 76 | + Runtime.XIncref(self.pyHandle); // Decref'd by the interpreter. | ||
| 77 | 77 | return self.pyHandle; | |
| 78 | 78 | } | |
| 79 | 79 | ||
@@ -108,7 +108,7 @@ public static IntPtr mp_subscript(IntPtr op, IntPtr key) | |||
| 108 | 108 | BoundContructor boundCtor = new BoundContructor(self.type, self.pyTypeHndl, self.ctorBinder, ci); | |
| 109 | 109 | ||
| 110 | 110 | /* Since nothing's chached, do we need the increment??? | |
| 111 | - Runtime.Incref(boundCtor.pyHandle); // Decref'd by the interpreter??? */ | ||
| 111 | + Runtime.XIncref(boundCtor.pyHandle); // Decref'd by the interpreter??? */ | ||
| 112 | 112 | return boundCtor.pyHandle; | |
| 113 | 113 | } | |
| 114 | 114 | ||
@@ -121,7 +121,7 @@ public static IntPtr tp_repr(IntPtr ob) | |||
| 121 | 121 | ConstructorBinding self = (ConstructorBinding)GetManagedObject(ob); | |
| 122 | 122 | if (self.repr != IntPtr.Zero) | |
| 123 | 123 | { | |
| 124 | - Runtime.Incref(self.repr); | ||
| 124 | + Runtime.XIncref(self.repr); | ||
| 125 | 125 | return self.repr; | |
| 126 | 126 | } | |
| 127 | 127 | MethodBase[] methods = self.ctorBinder.GetMethods(); | |
@@ -136,7 +136,7 @@ public static IntPtr tp_repr(IntPtr ob) | |||
| 136 | 136 | doc += String.Format("{0}{1}", name, str.Substring(idx)); | |
| 137 | 137 | } | |
| 138 | 138 | self.repr = Runtime.PyString_FromString(doc); | |
| 139 | - Runtime.Incref(self.repr); | ||
| 139 | + Runtime.XIncref(self.repr); | ||
| 140 | 140 | return self.repr; | |
| 141 | 141 | } | |
| 142 | 142 | ||
@@ -147,8 +147,8 @@ public static IntPtr tp_repr(IntPtr ob) | |||
| 147 | 147 | public static new void tp_dealloc(IntPtr ob) | |
| 148 | 148 | { | |
| 149 | 149 | ConstructorBinding self = (ConstructorBinding)GetManagedObject(ob); | |
| 150 | - Runtime.Decref(self.repr); | ||
| 151 | - Runtime.Decref(self.pyTypeHndl); | ||
| 150 | + Runtime.XDecref(self.repr); | ||
| 151 | + Runtime.XDecref(self.pyTypeHndl); | ||
| 152 | 152 | ExtensionType.FinalizeObject(self); | |
| 153 | 153 | } | |
| 154 | 154 | } | |
@@ -173,7 +173,7 @@ public BoundContructor(Type type, IntPtr pyTypeHndl, ConstructorBinder ctorBinde | |||
| 173 | 173 | : base() | |
| 174 | 174 | { | |
| 175 | 175 | this.type = type; | |
| 176 | - Runtime.Incref(pyTypeHndl); | ||
| 176 | + Runtime.XIncref(pyTypeHndl); | ||
| 177 | 177 | this.pyTypeHndl = pyTypeHndl; | |
| 178 | 178 | this.ctorBinder = ctorBinder; | |
| 179 | 179 | ctorInfo = ci; | |
@@ -217,15 +217,15 @@ public static IntPtr tp_repr(IntPtr ob) | |||
| 217 | 217 | BoundContructor self = (BoundContructor)GetManagedObject(ob); | |
| 218 | 218 | if (self.repr != IntPtr.Zero) | |
| 219 | 219 | { | |
| 220 | - Runtime.Incref(self.repr); | ||
| 220 | + Runtime.XIncref(self.repr); | ||
| 221 | 221 | return self.repr; | |
| 222 | 222 | } | |
| 223 | 223 | string name = self.type.FullName; | |
| 224 | 224 | string str = self.ctorInfo.ToString(); | |
| 225 | 225 | int idx = str.IndexOf("("); | |
| 226 | 226 | str = String.Format("returns a new {0}{1}", name, str.Substring(idx)); | |
| 227 | 227 | self.repr = Runtime.PyString_FromString(str); | |
| 228 | - Runtime.Incref(self.repr); | ||
| 228 | + Runtime.XIncref(self.repr); | ||
| 229 | 229 | return self.repr; | |
| 230 | 230 | } | |
| 231 | 231 | ||
@@ -236,8 +236,8 @@ public static IntPtr tp_repr(IntPtr ob) | |||
| 236 | 236 | public static new void tp_dealloc(IntPtr ob) | |
| 237 | 237 | { | |
| 238 | 238 | BoundContructor self = (BoundContructor)GetManagedObject(ob); | |
| 239 | - Runtime.Decref(self.repr); | ||
| 240 | - Runtime.Decref(self.pyTypeHndl); | ||
| 239 | + Runtime.XDecref(self.repr); | ||
| 240 | + Runtime.XDecref(self.pyTypeHndl); | ||
| 241 | 241 | ExtensionType.FinalizeObject(self); | |
| 242 | 242 | } | |
| 243 | 243 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments