| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ public static void GetManagedStringTwice() | |||
| 27 | 27 | string s1 = Runtime.Runtime.GetManagedString(op.BorrowOrThrow()); | |
| 28 | 28 | string s2 = Runtime.Runtime.GetManagedString(op.Borrow()); | |
| 29 | 29 | ||
| 30 | - Assert.AreEqual(1, Runtime.Runtime.Refcount(op.Borrow())); | ||
| 30 | + Assert.AreEqual(1, Runtime.Runtime.Refcount32(op.Borrow())); | ||
| 31 | 31 | Assert.AreEqual(expected, s1); | |
| 32 | 32 | Assert.AreEqual(expected, s2); | |
| 33 | 33 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,7 +92,7 @@ public void GetAttrDefault_IgnoresAttributeErrorOnly() | |||
| 92 | 92 | var typeErrResult = Assert.Throws<PythonException>( | |
| 93 | 93 | () => ob.GetAttr(nameof(PyObjectTestMethods.RaisesTypeError), fallback) | |
| 94 | 94 | ); | |
| 95 | - Assert.AreEqual(Exceptions.TypeError, typeErrResult.Type.Handle); | ||
| 95 | + Assert.AreEqual(Exceptions.TypeError, typeErrResult.Type); | ||
| 96 | 96 | } | |
| 97 | 97 | } | |
| 98 | 98 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,9 +87,9 @@ public void TestIndex() | |||
| 87 | 87 | { | |
| 88 | 88 | var t1 = new PyString("FooBar"); | |
| 89 | 89 | ||
| 90 | - Assert.AreEqual(4, t1.Index(new PyString("a"))); | ||
| 91 | - Assert.AreEqual(5, t1.Index(new PyString("r"))); | ||
| 92 | - Assert.AreEqual(-1, t1.Index(new PyString("z"))); | ||
| 90 | + Assert.AreEqual(4, t1.Index32(new PyString("a"))); | ||
| 91 | + Assert.AreEqual(5L, t1.Index64(new PyString("r"))); | ||
| 92 | + Assert.AreEqual(-(nint)1, t1.Index(new PyString("z"))); | ||
| 93 | 93 | } | |
| 94 | 94 | } | |
| 95 | 95 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,26 +39,26 @@ public static void RefCountTest() | |||
| 39 | 39 | using var op = Runtime.Runtime.PyString_FromString("FooBar"); | |
| 40 | 40 | ||
| 41 | 41 | // New object RefCount should be one | |
| 42 | - Assert.AreEqual(1, Runtime.Runtime.Refcount(op.BorrowOrThrow())); | ||
| 42 | + Assert.AreEqual(1, Runtime.Runtime.Refcount32(op.BorrowOrThrow())); | ||
| 43 | 43 | ||
| 44 | 44 | // Checking refcount didn't change refcount | |
| 45 | - Assert.AreEqual(1, Runtime.Runtime.Refcount(op.Borrow())); | ||
| 45 | + Assert.AreEqual(1, Runtime.Runtime.Refcount32(op.Borrow())); | ||
| 46 | 46 | ||
| 47 | 47 | // Borrowing a reference doesn't increase refcount | |
| 48 | 48 | BorrowedReference p = op.Borrow(); | |
| 49 | - Assert.AreEqual(1, Runtime.Runtime.Refcount(p)); | ||
| 49 | + Assert.AreEqual(1, Runtime.Runtime.Refcount32(p)); | ||
| 50 | 50 | ||
| 51 | 51 | // Py_IncRef/Py_DecRef increase and decrease RefCount | |
| 52 | 52 | Runtime.Runtime.Py_IncRef(op.Borrow()); | |
| 53 | - Assert.AreEqual(2, Runtime.Runtime.Refcount(p)); | ||
| 53 | + Assert.AreEqual(2, Runtime.Runtime.Refcount32(p)); | ||
| 54 | 54 | Runtime.Runtime.Py_DecRef(StolenReference.DangerousFromPointer(op.DangerousGetAddress())); | |
| 55 | - Assert.AreEqual(1, Runtime.Runtime.Refcount(p)); | ||
| 55 | + Assert.AreEqual(1, Runtime.Runtime.Refcount32(p)); | ||
| 56 | 56 | ||
| 57 | 57 | // XIncref/XDecref increase and decrease RefCount | |
| 58 | 58 | Runtime.Runtime.XIncref(p); | |
| 59 | - Assert.AreEqual(2, Runtime.Runtime.Refcount(p)); | ||
| 59 | + Assert.AreEqual(2, Runtime.Runtime.Refcount32(p)); | ||
| 60 | 60 | Runtime.Runtime.XDecref(p); | |
| 61 | - Assert.AreEqual(1, Runtime.Runtime.Refcount(p)); | ||
| 61 | + Assert.AreEqual(1, Runtime.Runtime.Refcount32(p)); | ||
| 62 | 62 | ||
| 63 | 63 | op.Dispose(); | |
| 64 | 64 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,8 @@ public bool CanEncode(Type type) | |||
| 42 | 42 | } | |
| 43 | 43 | ||
| 44 | 44 | public bool CanDecode(PyType objectType, Type targetType) | |
| 45 | - => objectType == Runtime.PyTupleType && this.CanEncode(targetType); | ||
| 45 | + => PythonReferenceComparer.Instance.Equals(objectType, Runtime.PyTupleType) | ||
| 46 | + && this.CanEncode(targetType); | ||
| 46 | 47 | ||
| 47 | 48 | public bool TryDecode<T>(PyObject pyObj, out T? value) | |
| 48 | 49 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -732,6 +732,8 @@ internal static unsafe nint Refcount(BorrowedReference op) | |||
| 732 | 732 | var p = (nint*)(op.DangerousGetAddress() + ABI.RefCountOffset); | |
| 733 | 733 | return *p; | |
| 734 | 734 | } | |
| 735 | + [Pure] | ||
| 736 | + internal static int Refcount32(BorrowedReference op) => checked((int)Refcount(op)); | ||
| 735 | 737 | ||
| 736 | 738 | /// <summary> | |
| 737 | 739 | /// Call specified function, and handle PythonDLL-related failures. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments