FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/Native/BorrowedReference.cs at v3.2.0 · pythonnet/pythonnet · GitHub
pythonnet
pythonnet
Repository navigation
Code
Issues
147
(147)
Pull requests
11
(11)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
runtime
/
Native
/
BorrowedReference.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (48 loc) · 2.15 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
Native
/
BorrowedReference.cs
Copy path
File metadata and controls
57 lines (48 loc) · 2.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
namespace
Python
.
Runtime
{
using
System
;
using
System
.
Diagnostics
;
/// <summary>
/// Represents a reference to a Python object, that is being lent, and
/// can only be safely used until execution returns to the caller.
/// </summary>
readonly
ref
struct
BorrowedReference
{
readonly
IntPtr
pointer
;
public
bool
IsNull
=>
this
.
pointer
==
IntPtr
.
Zero
;
/// <summary>Gets a raw pointer to the Python object</summary>
[
DebuggerHidden
]
public
IntPtr
DangerousGetAddress
(
)
=>
this
.
IsNull
?
throw
new
NullReferenceException
(
)
:
this
.
pointer
;
/// <summary>Gets a raw pointer to the Python object</summary>
public
IntPtr
DangerousGetAddressOrNull
(
)
=>
this
.
pointer
;
public
static
BorrowedReference
Null
=>
new
(
)
;
/// <summary>
/// Creates new instance of <see cref="BorrowedReference"/> from raw pointer. Unsafe.
/// </summary>
public
BorrowedReference
(
IntPtr
pointer
)
{
this
.
pointer
=
pointer
;
}
public
static
bool
operator
==
(
BorrowedReference
a
,
BorrowedReference
b
)
=>
a
.
pointer
==
b
.
pointer
;
public
static
bool
operator
!=
(
BorrowedReference
a
,
BorrowedReference
b
)
=>
a
.
pointer
!=
b
.
pointer
;
public
static
bool
operator
==
(
BorrowedReference
reference
,
NullOnly
?
@null
)
=>
reference
.
IsNull
;
public
static
bool
operator
!=
(
BorrowedReference
reference
,
NullOnly
?
@null
)
=>
!
reference
.
IsNull
;
public
static
bool
operator
==
(
NullOnly
?
@null
,
BorrowedReference
reference
)
=>
reference
.
IsNull
;
public
static
bool
operator
!=
(
NullOnly
?
@null
,
BorrowedReference
reference
)
=>
!
reference
.
IsNull
;
public
override
bool
Equals
(
object
obj
)
{
if
(
obj
is
IntPtr
ptr
)
return
ptr
==
pointer
;
return
false
;
}
public
static
implicit
operator
BorrowedReference
(
PyObject
pyObject
)
=>
pyObject
.
Reference
;
public
static
implicit
operator
BorrowedReference
(
NullOnly
?
@null
)
=>
Null
;
public
override
int
GetHashCode
(
)
=>
pointer
.
GetHashCode
(
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL