Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
7ca763c7
Commit
7ca763c7
authored
Aug 06, 2015
by
Rudi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move around some dict declarations.
parent
3d8398be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
src/runtime/dict.cpp
src/runtime/dict.cpp
+13
-10
src/runtime/dict.h
src/runtime/dict.h
+5
-0
No files found.
src/runtime/dict.cpp
View file @
7ca763c7
...
...
@@ -27,6 +27,11 @@
namespace
pyston
{
BoxedClass
*
dict_iterator_cls
=
NULL
;
BoxedClass
*
dict_keys_cls
=
NULL
;
BoxedClass
*
dict_values_cls
=
NULL
;
BoxedClass
*
dict_items_cls
=
NULL
;
Box
*
dictRepr
(
BoxedDict
*
self
)
{
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
...
...
@@ -677,18 +682,16 @@ extern "C" Box* dictInit(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) {
return
None
;
}
BoxedClass
*
dict_iterator_cls
=
NULL
;
extern
"C"
void
dictIteratorGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
static
void
BoxedDictIterator
:::
gcHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
assert
(
b
->
cls
==
dict_iterator_cls
);
boxGCHandler
(
v
,
b
);
BoxedDictIterator
*
it
=
static_cast
<
BoxedDictIterator
*>
(
b
);
v
->
visit
(
it
->
d
);
}
BoxedClass
*
dict_keys_cls
=
NULL
;
BoxedClass
*
dict_values_cls
=
NULL
;
BoxedClass
*
dict_items_cls
=
NULL
;
extern
"C"
void
dictViewGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
static
void
BoxedDictView
::
gcHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
assert
(
b
->
cls
==
dict_items_cls
);
boxGCHandler
(
v
,
b
);
BoxedDictView
*
view
=
static_cast
<
BoxedDictView
*>
(
b
);
...
...
@@ -717,14 +720,14 @@ static Box* dict_repr(PyObject* self) noexcept {
}
void
setupDict
()
{
dict_iterator_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
dictIteratorGC
Handler
,
0
,
0
,
dict_iterator_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
BoxedDictIterator
::
gc
Handler
,
0
,
0
,
sizeof
(
BoxedDictIterator
),
false
,
"dictionary-itemiterator"
);
dict_keys_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
dictViewGC
Handler
,
0
,
0
,
sizeof
(
BoxedDictView
),
false
,
dict_keys_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
BoxedDictView
::
gc
Handler
,
0
,
0
,
sizeof
(
BoxedDictView
),
false
,
"dict_keys"
);
dict_values_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
dictViewGC
Handler
,
0
,
0
,
sizeof
(
BoxedDictView
),
dict_values_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
BoxedDictView
::
gc
Handler
,
0
,
0
,
sizeof
(
BoxedDictView
),
false
,
"dict_values"
);
dict_items_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
dictViewGC
Handler
,
0
,
0
,
sizeof
(
BoxedDictView
),
dict_items_cls
=
BoxedHeapClass
::
create
(
type_cls
,
object_cls
,
&
BoxedDictView
::
gc
Handler
,
0
,
0
,
sizeof
(
BoxedDictView
),
false
,
"dict_items"
);
dict_cls
->
giveAttr
(
"__len__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
dictLen
,
BOXED_INT
,
1
)));
...
...
src/runtime/dict.h
View file @
7ca763c7
...
...
@@ -24,6 +24,7 @@ extern BoxedClass* dict_iterator_cls;
extern
BoxedClass
*
dict_keys_cls
;
extern
BoxedClass
*
dict_values_cls
;
extern
BoxedClass
*
dict_items_cls
;
class
BoxedDictIterator
:
public
Box
{
public:
enum
IteratorType
{
KeyIterator
,
ValueIterator
,
ItemIterator
};
...
...
@@ -36,6 +37,8 @@ public:
BoxedDictIterator
(
BoxedDict
*
d
,
IteratorType
type
);
DEFAULT_CLASS
(
dict_iterator_cls
);
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
self
);
};
Box
*
dictGetitem
(
BoxedDict
*
self
,
Box
*
k
);
...
...
@@ -52,6 +55,8 @@ class BoxedDictView : public Box {
public:
BoxedDict
*
d
;
BoxedDictView
(
BoxedDict
*
d
);
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
self
);
};
Box
*
dictViewKeysIter
(
Box
*
self
);
...
...
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