Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
b4914956
Commit
b4914956
authored
Sep 10, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix const-correctness of cypclass builtin dict and list
parent
f6afb399
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
23 deletions
+26
-23
Cython/Includes/libcythonplus/dict.pxd
Cython/Includes/libcythonplus/dict.pxd
+21
-18
Cython/Includes/libcythonplus/list.pxd
Cython/Includes/libcythonplus/list.pxd
+5
-5
No files found.
Cython/Includes/libcythonplus/dict.pxd
View file @
b4914956
...
...
@@ -77,7 +77,7 @@ cdef extern from * nogil:
cdef
cppclass
dict_key_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]:
dict_key_iterator_t
()
dict_key_iterator_t
(
base_iterator_t
)
dict_key_iterator_t
(
base_iterator_t
,
const
dict_t
)
dict_key_iterator_t
(
base_iterator_t
,
dict_t
)
reference_t
operator
*
()
dict_key_iterator_t
operator
++
()
bint
operator
!=
(
base_iterator_t
)
...
...
@@ -85,7 +85,7 @@ cdef extern from * nogil:
cdef
cppclass
dict_value_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]:
dict_value_iterator_t
()
dict_value_iterator_t
(
base_iterator_t
)
dict_value_iterator_t
(
base_iterator_t
,
const
dict_t
)
dict_value_iterator_t
(
base_iterator_t
,
dict_t
)
reference_t
operator
*
()
dict_value_iterator_t
operator
++
()
bint
operator
!=
(
base_iterator_t
)
...
...
@@ -93,7 +93,7 @@ cdef extern from * nogil:
cdef
cppclass
dict_item_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]:
dict_item_iterator_t
()
dict_item_iterator_t
(
base_iterator_t
)
dict_item_iterator_t
(
base_iterator_t
,
const
dict_t
)
dict_item_iterator_t
(
base_iterator_t
,
dict_t
)
reference_t
operator
*
()
dict_item_iterator_t
operator
++
()
bint
operator
!=
(
base_iterator_t
)
...
...
@@ -101,21 +101,21 @@ cdef extern from * nogil:
cdef
cppclass
dict_keys_view_t
[
dict_t
,
base_iterator_t
,
reference_t
]:
ctypedef
dict_key_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]
iterator
dict_keys_view_t
()
dict_keys_view_t
(
const
dict_t
)
dict_keys_view_t
(
dict_t
)
dict_key_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]
begin
()
base_iterator_t
end
()
cdef
cppclass
dict_values_view_t
[
dict_t
,
base_iterator_t
,
reference_t
]:
ctypedef
dict_value_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]
iterator
dict_values_view_t
()
dict_values_view_t
(
const
dict_t
)
dict_values_view_t
(
dict_t
)
dict_value_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]
begin
()
base_iterator_t
end
()
cdef
cppclass
dict_items_view_t
[
dict_t
,
base_iterator_t
,
reference_t
]:
ctypedef
dict_item_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]
iterator
dict_items_view_t
()
dict_items_view_t
(
const
dict_t
)
dict_items_view_t
(
dict_t
)
dict_item_iterator_t
[
dict_t
,
base_iterator_t
,
reference_t
]
begin
()
base_iterator_t
end
()
...
...
@@ -125,11 +125,14 @@ cdef cypclass cypdict[K, V]:
ctypedef
V
value_type
ctypedef
pair
[
key_type
,
value_type
]
item_type
ctypedef
vector
[
item_type
].
size_type
size_type
ctypedef
dict_key_iterator_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
key_type
]
iterator
ctypedef
dict_key_iterator_t
[
const
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
key_type
]
iterator
ctypedef
dict_keys_view_t
[
const
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
key_type
]
keys_view
ctypedef
dict_values_view_t
[
const
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
value_type
]
values_view
ctypedef
dict_items_view_t
[
const
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
item_type
]
items_view
vector
[
item_type
]
_items
unordered_map
[
key_type
,
size_type
]
_indices
atomic
[
int
]
_active_iterators
mutable
vector
[
item_type
]
_items
mutable
unordered_map
[
key_type
,
size_type
]
_indices
mutable
atomic
[
int
]
_active_iterators
__init__
(
self
):
self
.
_active_iterators
.
store
(
0
)
...
...
@@ -179,8 +182,8 @@ cdef cypclass cypdict[K, V]:
with
gil
:
raise
RuntimeError
(
"Modifying a dictionary with active iterators"
)
dict_key_iterator_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
key_type
]
begin
(
self
)
const
:
return
dict_key_iterator_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
key_type
]
(
self
.
_items
.
begin
(),
self
)
iterator
begin
(
self
)
const
:
return
iterator
(
self
.
_items
.
begin
(),
self
)
vector
[
item_type
].
iterator
end
(
self
)
const
:
return
self
.
_items
.
end
()
...
...
@@ -191,11 +194,11 @@ cdef cypclass cypdict[K, V]:
bint
__contains__
(
self
,
const
key_type
key
)
const
:
return
self
.
_indices
.
count
(
key
)
dict_keys_view_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
key_type
]
keys
(
self
)
const
:
return
dict_keys_view_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
key_type
]
(
self
)
keys_view
keys
(
self
)
const
:
return
keys_view
(
self
)
dict_values_view_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
value_type
]
values
(
self
)
const
:
return
dict_values_view_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
value_type
]
(
self
)
values_view
values
(
self
)
const
:
return
values_view
(
self
)
dict_items_view_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
item_type
]
items
(
self
)
const
:
return
dict_items_view_t
[
cypdict
[
K
,
V
],
vector
[
item_type
].
iterator
,
item_type
]
(
self
)
items_view
items
(
self
)
const
:
return
items_view
(
self
)
Cython/Includes/libcythonplus/list.pxd
View file @
b4914956
...
...
@@ -26,10 +26,10 @@ cdef extern from * nogil:
cdef
cypclass
cyplist
[
V
]:
ctypedef
V
value_type
ctypedef
vector
[
value_type
].
size_type
size_type
ctypedef
list_iterator_t
[
cyplist
[
V
],
vector
[
value_type
].
iterator
,
value_type
]
iterator
ctypedef
list_iterator_t
[
c
onst
c
yplist
[
V
],
vector
[
value_type
].
iterator
,
value_type
]
iterator
vector
[
value_type
]
_elements
atomic
[
int
]
_active_iterators
mutable
vector
[
value_type
]
_elements
mutable
atomic
[
int
]
_active_iterators
__init__
(
self
):
self
.
_active_iterators
.
store
(
0
)
...
...
@@ -125,8 +125,8 @@ cdef cypclass cyplist[V]:
with
gil
:
raise
RuntimeError
(
"Modifying a list with active iterators"
)
list_iterator_t
[
cyplist
[
V
],
vector
[
value_type
].
iterator
,
value_type
]
begin
(
self
)
const
:
return
list_iterator_t
[
cyplist
[
V
],
vector
[
value_type
].
iterator
,
value_type
]
(
self
.
_elements
.
begin
(),
self
)
iterator
begin
(
self
)
const
:
return
iterator
(
self
.
_elements
.
begin
(),
self
)
vector
[
value_type
].
iterator
end
(
self
)
const
:
return
self
.
_elements
.
end
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment