File tree 3 files changed +2
-23
lines changed
3 files changed +2
-23
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ readonly ref struct BorrowedReference
10
10
readonly IntPtr pointer ;
11
11
public bool IsNull => this . pointer == IntPtr . Zero ;
12
12
13
- public static implicit operator IntPtr ( in BorrowedReference self ) => self . DangerousGetAddress ( ) ;
14
13
15
14
/// <summary>Gets a raw pointer to the Python object</summary>
16
15
public IntPtr DangerousGetAddress ( )
Original file line number Diff line number Diff line change @@ -15,10 +15,6 @@ ref struct NewReference
15
15
public static implicit operator BorrowedReference ( in NewReference reference )
16
16
=> new BorrowedReference ( reference . pointer ) ;
17
17
18
- [ Pure ]
19
- public static implicit operator IntPtr ( in NewReference reference )
20
- => DangerousGetAddress ( reference ) ;
21
-
22
18
/// <summary>
23
19
/// Returns <see cref="PyObject"/> wrapper around this reference, which now owns
24
20
/// the pointer. Sets the original reference to <c>null</c>, as it no longer owns it.
Original file line number Diff line number Diff line change @@ -748,22 +748,6 @@ internal static IntPtr SelfIncRef(IntPtr op)
748
748
return op ;
749
749
}
750
750
751
- /// <remark>
752
- /// We need this method because BorrowedReference can be implicitly casted to IntPtr.
753
- /// </remark>
754
- internal static void XDecref ( BorrowedReference op )
755
- {
756
- throw new InvalidOperationException ( "Cannot DecRef a borrowed reference." ) ;
757
- }
758
-
759
- /// <remark>
760
- /// We need this method because NewReference can be implicitly casted to IntPtr.
761
- /// </remark>
762
- internal static void XDecref ( NewReference op )
763
- {
764
- op . Dispose ( ) ;
765
- }
766
-
767
751
internal static unsafe void XDecref ( IntPtr op )
768
752
{
769
753
#if PYTHON_WITH_PYDEBUG || NETSTANDARD
@@ -2148,10 +2132,10 @@ internal static void Py_CLEAR(ref IntPtr ob)
2148
2132
internal static extern NewReference PyCapsule_New( IntPtr pointer, string name, IntPtr destructor) ;
2149
2133
2150
2134
[ DllImport( _PythonDll, CallingConvention = CallingConvention. Cdecl) ]
2151
- internal static extern IntPtr PyCapsule_GetPointer( IntPtr capsule, string name) ;
2135
+ internal static extern IntPtr PyCapsule_GetPointer( BorrowedReference capsule, string name) ;
2152
2136
2153
2137
[ DllImport( _PythonDll, CallingConvention = CallingConvention. Cdecl) ]
2154
- internal static extern int PyCapsule_SetPointer( IntPtr capsule, IntPtr pointer) ;
2138
+ internal static extern int PyCapsule_SetPointer( BorrowedReference capsule, IntPtr pointer) ;
2155
2139
2156
2140
//====================================================================
2157
2141
// Miscellaneous
You can’t perform that action at this time.
0 commit comments