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
d6d38a4d
Commit
d6d38a4d
authored
Apr 15, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attrwrapper.pop
parent
050fe962
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
src/runtime/types.cpp
src/runtime/types.cpp
+22
-3
No files found.
src/runtime/types.cpp
View file @
d6d38a4d
...
...
@@ -1153,9 +1153,7 @@ public:
DEFAULT_CLASS
(
attrwrapper_cls
);
Box
*
getUnderlying
()
{
return
b
;
}
Box
*
getUnderlying
()
{
return
b
;
}
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
b
)
{
boxGCHandler
(
v
,
b
);
...
...
@@ -1219,6 +1217,25 @@ public:
return
r
;
}
static
Box
*
pop
(
Box
*
_self
,
Box
*
_key
,
Box
*
default_
)
{
RELEASE_ASSERT
(
_self
->
cls
==
attrwrapper_cls
,
""
);
AttrWrapper
*
self
=
static_cast
<
AttrWrapper
*>
(
_self
);
_key
=
coerceUnicodeToStr
(
_key
);
RELEASE_ASSERT
(
_key
->
cls
==
str_cls
,
""
);
BoxedString
*
key
=
static_cast
<
BoxedString
*>
(
_key
);
Box
*
r
=
self
->
b
->
getattr
(
key
->
s
);
if
(
r
)
{
self
->
b
->
delattr
(
key
->
s
,
NULL
);
return
r
;
}
else
{
if
(
default_
)
return
default_
;
raiseExcHelper
(
KeyError
,
"'%s'"
,
key
->
data
());
}
}
static
Box
*
delitem
(
Box
*
_self
,
Box
*
_key
)
{
RELEASE_ASSERT
(
_self
->
cls
==
attrwrapper_cls
,
""
);
AttrWrapper
*
self
=
static_cast
<
AttrWrapper
*>
(
_self
);
...
...
@@ -2210,6 +2227,8 @@ void setupRuntime() {
slice_cls
->
freeze
();
attrwrapper_cls
->
giveAttr
(
"__setitem__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
setitem
,
UNKNOWN
,
3
)));
attrwrapper_cls
->
giveAttr
(
"pop"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
pop
,
UNKNOWN
,
3
,
1
,
false
,
false
),
{
NULL
}));
attrwrapper_cls
->
giveAttr
(
"__getitem__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
getitem
,
UNKNOWN
,
2
)));
attrwrapper_cls
->
giveAttr
(
"__delitem__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
AttrWrapper
::
delitem
,
UNKNOWN
,
2
)));
attrwrapper_cls
->
giveAttr
(
"setdefault"
,
...
...
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