FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/clrobject.cs at drop-python2 · filmor/pythonnet · GitHub
filmor
/
pythonnet
Public
forked from
pythonnet/pythonnet
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
runtime
/
clrobject.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
72 lines (57 loc) · 1.97 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
clrobject.cs
Copy path
File metadata and controls
72 lines (57 loc) · 1.97 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using
System
;
using
System
.
Runtime
.
InteropServices
;
namespace
Python
.
Runtime
{
internal
class
CLRObject
:
ManagedType
{
internal
object
inst
;
internal
CLRObject
(
object
ob
,
IntPtr
tp
)
{
IntPtr
py
=
Runtime
.
PyType_GenericAlloc
(
tp
,
0
)
;
long
flags
=
Util
.
ReadCLong
(
tp
,
TypeOffset
.
tp_flags
)
;
if
(
(
flags
&
TypeFlags
.
Subclass
)
!=
0
)
{
IntPtr
dict
=
Marshal
.
ReadIntPtr
(
py
,
ObjectOffset
.
TypeDictOffset
(
tp
)
)
;
if
(
dict
==
IntPtr
.
Zero
)
{
dict
=
Runtime
.
PyDict_New
(
)
;
Marshal
.
WriteIntPtr
(
py
,
ObjectOffset
.
TypeDictOffset
(
tp
)
,
dict
)
;
}
}
GCHandle
gc
=
GCHandle
.
Alloc
(
this
)
;
Marshal
.
WriteIntPtr
(
py
,
ObjectOffset
.
magic
(
tp
)
,
(
IntPtr
)
gc
)
;
tpHandle
=
tp
;
pyHandle
=
py
;
gcHandle
=
gc
;
inst
=
ob
;
// Fix the BaseException args (and __cause__ in case of Python 3)
// slot if wrapping a CLR exception
Exceptions
.
SetArgsAndCause
(
py
)
;
}
static
CLRObject
GetInstance
(
object
ob
,
IntPtr
pyType
)
{
return
new
CLRObject
(
ob
,
pyType
)
;
}
static
CLRObject
GetInstance
(
object
ob
)
{
ClassBase
cc
=
ClassManager
.
GetClass
(
ob
.
GetType
(
)
)
;
return
GetInstance
(
ob
,
cc
.
tpHandle
)
;
}
internal
static
IntPtr
GetInstHandle
(
object
ob
,
IntPtr
pyType
)
{
CLRObject
co
=
GetInstance
(
ob
,
pyType
)
;
return
co
.
pyHandle
;
}
internal
static
IntPtr
GetInstHandle
(
object
ob
,
Type
type
)
{
ClassBase
cc
=
ClassManager
.
GetClass
(
type
)
;
CLRObject
co
=
GetInstance
(
ob
,
cc
.
tpHandle
)
;
return
co
.
pyHandle
;
}
internal
static
IntPtr
GetInstHandle
(
object
ob
)
{
CLRObject
co
=
GetInstance
(
ob
)
;
return
co
.
pyHandle
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL