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
d14249f1
Commit
d14249f1
authored
Aug 29, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function.__call__
parent
9c86cf20
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
6 deletions
+28
-6
lib_python/2.7/os.py
lib_python/2.7/os.py
+0
-3
lib_python/2.7/re.py
lib_python/2.7/re.py
+0
-3
src/runtime/types.cpp
src/runtime/types.cpp
+15
-0
test/tests/functions.py
test/tests/functions.py
+13
-0
No files found.
lib_python/2.7/os.py
View file @
d14249f1
...
@@ -712,8 +712,6 @@ if _exists("fork"):
...
@@ -712,8 +712,6 @@ if _exists("fork"):
return
p
.
stdin
,
p
.
stdout
return
p
.
stdin
,
p
.
stdout
__all__
.
append
(
"popen4"
)
__all__
.
append
(
"popen4"
)
# Pyston change: disable custom pickle-registration for now
"""
import
copy_reg
as
_copy_reg
import
copy_reg
as
_copy_reg
def
_make_stat_result
(
tup
,
dict
):
def
_make_stat_result
(
tup
,
dict
):
...
@@ -740,4 +738,3 @@ try:
...
@@ -740,4 +738,3 @@ try:
_make_statvfs_result
)
_make_statvfs_result
)
except
NameError
:
# statvfs_result may not exist
except
NameError
:
# statvfs_result may not exist
pass
pass
"""
lib_python/2.7/re.py
View file @
d14249f1
...
@@ -280,15 +280,12 @@ def _subx(pattern, template):
...
@@ -280,15 +280,12 @@ def _subx(pattern, template):
# register myself for pickling
# register myself for pickling
# Pyston change: disable the pickle-registration for now
"""
import
copy_reg
import
copy_reg
def
_pickle
(
p
):
def
_pickle
(
p
):
return
_compile
,
(
p
.
pattern
,
p
.
flags
)
return
_compile
,
(
p
.
pattern
,
p
.
flags
)
copy_reg
.
pickle
(
_pattern_type
,
_pickle
,
_compile
)
copy_reg
.
pickle
(
_pattern_type
,
_pickle
,
_compile
)
"""
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# experimental stuff (see python-dev discussions for details)
# experimental stuff (see python-dev discussions for details)
...
...
src/runtime/types.cpp
View file @
d14249f1
...
@@ -386,6 +386,19 @@ static Box* functionGet(BoxedFunction* self, Box* inst, Box* owner) {
...
@@ -386,6 +386,19 @@ static Box* functionGet(BoxedFunction* self, Box* inst, Box* owner) {
return
boxInstanceMethod
(
inst
,
self
);
return
boxInstanceMethod
(
inst
,
self
);
}
}
static
Box
*
functionCall
(
BoxedFunction
*
self
,
Box
*
args
,
Box
*
kwargs
)
{
RELEASE_ASSERT
(
self
->
cls
==
function_cls
,
"%s"
,
getTypeName
(
self
)
->
c_str
());
// This won't work if you subclass from function_cls, since runtimeCall will
// just call back into this function.
// Fortunately, CPython disallows subclassing FunctionType; we don't currently
// disallow it but it's good to know.
assert
(
args
->
cls
==
tuple_cls
);
assert
(
kwargs
->
cls
==
dict_cls
);
return
runtimeCall
(
self
,
ArgPassSpec
(
0
,
0
,
true
,
true
),
args
,
kwargs
,
NULL
,
NULL
,
NULL
);
}
extern
"C"
{
extern
"C"
{
Box
*
None
=
NULL
;
Box
*
None
=
NULL
;
Box
*
NotImplemented
=
NULL
;
Box
*
NotImplemented
=
NULL
;
...
@@ -763,6 +776,8 @@ void setupRuntime() {
...
@@ -763,6 +776,8 @@ void setupRuntime() {
function_cls
->
giveAttr
(
"__module__"
,
function_cls
->
giveAttr
(
"__module__"
,
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFunction
,
modname
)));
new
BoxedMemberDescriptor
(
BoxedMemberDescriptor
::
OBJECT
,
offsetof
(
BoxedFunction
,
modname
)));
function_cls
->
giveAttr
(
"__get__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
functionGet
,
UNKNOWN
,
3
)));
function_cls
->
giveAttr
(
"__get__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
functionGet
,
UNKNOWN
,
3
)));
function_cls
->
giveAttr
(
"__call__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
functionCall
,
UNKNOWN
,
1
,
0
,
true
,
true
)));
function_cls
->
freeze
();
function_cls
->
freeze
();
instancemethod_cls
->
giveAttr
(
"__name__"
,
boxStrConstant
(
"instancemethod"
));
instancemethod_cls
->
giveAttr
(
"__name__"
,
boxStrConstant
(
"instancemethod"
));
...
...
test/tests/functions.py
0 → 100644
View file @
d14249f1
def
f
():
print
"f"
return
2
print
f
.
__call__
()
def
g
():
print
"g"
return
3
print
type
(
f
).
__call__
(
f
)
print
type
(
f
).
__call__
(
g
)
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