FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnet/src/runtime/CollectionWrappers/ListWrapper.cs at python3.14 · devtrack/pythonnet · GitHub
devtrack
pythonnet
Repository navigation
Code
Pull requests
1
(1)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnet
/
src
/
runtime
/
CollectionWrappers
/
ListWrapper.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (51 loc) · 1.66 KB
Breadcrumbs
pythonnet
/
src
/
runtime
/
CollectionWrappers
/
ListWrapper.cs
Copy path
File metadata and controls
60 lines (51 loc) · 1.66 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
using
System
;
using
System
.
Collections
.
Generic
;
namespace
Python
.
Runtime
.
CollectionWrappers
{
internal
class
ListWrapper
<
T
>
:
SequenceWrapper
<
T
>
,
IList
<
T
>
{
public
ListWrapper
(
PyObject
pyObj
)
:
base
(
pyObj
)
{
}
public
T
this
[
int
index
]
{
get
{
using
var
_
=
Py
.
GIL
(
)
;
var
item
=
Runtime
.
PyList_GetItem
(
pyObject
,
index
)
;
var
pyItem
=
new
PyObject
(
item
)
;
return
pyItem
.
As
<
T
>
(
)
!
;
}
set
{
using
var
_
=
Py
.
GIL
(
)
;
var
pyItem
=
value
.
ToPython
(
)
;
var
result
=
Runtime
.
PyList_SetItem
(
pyObject
,
index
,
new
NewReference
(
pyItem
)
.
Steal
(
)
)
;
if
(
result
==
-
1
)
Runtime
.
CheckExceptionOccurred
(
)
;
}
}
public
int
IndexOf
(
T
item
)
{
return
indexOf
(
item
)
;
}
public
void
Insert
(
int
index
,
T
item
)
{
if
(
IsReadOnly
)
throw
new
InvalidOperationException
(
"Collection is read-only"
)
;
using
var
_
=
Py
.
GIL
(
)
;
var
pyItem
=
item
.
ToPython
(
)
;
int
result
=
Runtime
.
PyList_Insert
(
pyObject
,
index
,
pyItem
)
;
if
(
result
==
-
1
)
Runtime
.
CheckExceptionOccurred
(
)
;
}
public
void
RemoveAt
(
int
index
)
{
var
result
=
removeAt
(
index
)
;
//PySequence_DelItem will set an error if it fails. throw it here
//since RemoveAt does not have a bool return value.
if
(
result
==
false
)
Runtime
.
CheckExceptionOccurred
(
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL