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
Show 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 @@
...
@@ -27,6 +27,11 @@
namespace
pyston
{
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
)
{
Box
*
dictRepr
(
BoxedDict
*
self
)
{
std
::
vector
<
char
>
chars
;
std
::
vector
<
char
>
chars
;
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
int
status
=
Py_ReprEnter
((
PyObject
*
)
self
);
...
@@ -677,18 +682,16 @@ extern "C" Box* dictInit(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) {
...
@@ -677,18 +682,16 @@ extern "C" Box* dictInit(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) {
return
None
;
return
None
;
}
}
BoxedClass
*
dict_iterator_cls
=
NULL
;
static
void
BoxedDictIterator
:::
gcHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
extern
"C"
void
dictIteratorGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
assert
(
b
->
cls
==
dict_iterator_cls
);
boxGCHandler
(
v
,
b
);
boxGCHandler
(
v
,
b
);
BoxedDictIterator
*
it
=
static_cast
<
BoxedDictIterator
*>
(
b
);
BoxedDictIterator
*
it
=
static_cast
<
BoxedDictIterator
*>
(
b
);
v
->
visit
(
it
->
d
);
v
->
visit
(
it
->
d
);
}
}
BoxedClass
*
dict_keys_cls
=
NULL
;
static
void
BoxedDictView
::
gcHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
BoxedClass
*
dict_values_cls
=
NULL
;
assert
(
b
->
cls
==
dict_items_cls
);
BoxedClass
*
dict_items_cls
=
NULL
;
extern
"C"
void
dictViewGCHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
boxGCHandler
(
v
,
b
);
BoxedDictView
*
view
=
static_cast
<
BoxedDictView
*>
(
b
);
BoxedDictView
*
view
=
static_cast
<
BoxedDictView
*>
(
b
);
...
@@ -717,14 +720,14 @@ static Box* dict_repr(PyObject* self) noexcept {
...
@@ -717,14 +720,14 @@ static Box* dict_repr(PyObject* self) noexcept {
}
}
void
setupDict
()
{
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"
);
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_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"
);
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"
);
false
,
"dict_items"
);
dict_cls
->
giveAttr
(
"__len__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
dictLen
,
BOXED_INT
,
1
)));
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;
...
@@ -24,6 +24,7 @@ extern BoxedClass* dict_iterator_cls;
extern
BoxedClass
*
dict_keys_cls
;
extern
BoxedClass
*
dict_keys_cls
;
extern
BoxedClass
*
dict_values_cls
;
extern
BoxedClass
*
dict_values_cls
;
extern
BoxedClass
*
dict_items_cls
;
extern
BoxedClass
*
dict_items_cls
;
class
BoxedDictIterator
:
public
Box
{
class
BoxedDictIterator
:
public
Box
{
public:
public:
enum
IteratorType
{
KeyIterator
,
ValueIterator
,
ItemIterator
};
enum
IteratorType
{
KeyIterator
,
ValueIterator
,
ItemIterator
};
...
@@ -36,6 +37,8 @@ public:
...
@@ -36,6 +37,8 @@ public:
BoxedDictIterator
(
BoxedDict
*
d
,
IteratorType
type
);
BoxedDictIterator
(
BoxedDict
*
d
,
IteratorType
type
);
DEFAULT_CLASS
(
dict_iterator_cls
);
DEFAULT_CLASS
(
dict_iterator_cls
);
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
self
);
};
};
Box
*
dictGetitem
(
BoxedDict
*
self
,
Box
*
k
);
Box
*
dictGetitem
(
BoxedDict
*
self
,
Box
*
k
);
...
@@ -52,6 +55,8 @@ class BoxedDictView : public Box {
...
@@ -52,6 +55,8 @@ class BoxedDictView : public Box {
public:
public:
BoxedDict
*
d
;
BoxedDict
*
d
;
BoxedDictView
(
BoxedDict
*
d
);
BoxedDictView
(
BoxedDict
*
d
);
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
self
);
};
};
Box
*
dictViewKeysIter
(
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