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
ca90416c
Commit
ca90416c
authored
9 years ago
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #550 from tjhance:builtin_format
Some minor merge conflicts due to duplication with #544.
parents
96c7b4f2
f49316ac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
from_cpython/Objects/floatobject.c
from_cpython/Objects/floatobject.c
+2
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+10
-0
src/runtime/float.cpp
src/runtime/float.cpp
+3
-1
test/tests/builtins.py
test/tests/builtins.py
+4
-0
No files found.
from_cpython/Objects/floatobject.c
View file @
ca90416c
...
...
@@ -1995,7 +1995,8 @@ float_getzero(PyObject *v, void *closure)
return
PyFloat_FromDouble
(
0
.
0
);
}
static
PyObject
*
// pyston change: make not static
PyObject
*
float__format__
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
format_spec
;
...
...
This diff is collapsed.
Click to expand it.
src/runtime/builtin_modules/builtins.cpp
View file @
ca90416c
...
...
@@ -1096,6 +1096,14 @@ Box* builtinApply(Box* func, Box* args, Box* keywords) {
return
runtimeCall
(
func
,
ArgPassSpec
(
0
,
0
,
true
,
keywords
!=
NULL
),
args
,
keywords
,
NULL
,
NULL
,
NULL
);
}
Box
*
builtinFormat
(
Box
*
value
,
Box
*
format_spec
)
{
Box
*
res
=
PyObject_Format
(
value
,
format_spec
);
if
(
!
res
)
{
throwCAPIException
();
}
return
res
;
}
void
setupBuiltins
()
{
builtins_module
=
createModule
(
"__builtin__"
,
NULL
,
"Built-in functions, exceptions, and other objects.
\n\n
Noteworthy: None is "
...
...
@@ -1331,5 +1339,7 @@ void setupBuiltins() {
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
input
,
UNKNOWN
,
1
,
1
,
false
,
false
),
"input"
,
{
NULL
}));
builtins_module
->
giveAttr
(
"cmp"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
builtinCmp
,
UNKNOWN
,
2
),
"cmp"
));
builtins_module
->
giveAttr
(
"format"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
builtinFormat
,
UNKNOWN
,
2
),
"format"
));
}
}
This diff is collapsed.
Click to expand it.
src/runtime/float.cpp
View file @
ca90416c
...
...
@@ -29,6 +29,7 @@ extern "C" PyObject* float_hex(PyObject* v) noexcept;
extern
"C"
PyObject
*
float_fromhex
(
PyObject
*
cls
,
PyObject
*
arg
)
noexcept
;
extern
"C"
PyObject
*
float_as_integer_ratio
(
PyObject
*
v
,
PyObject
*
unused
)
noexcept
;
extern
"C"
PyObject
*
float_is_integer
(
PyObject
*
v
)
noexcept
;
extern
"C"
PyObject
*
float__format__
(
PyObject
*
v
)
noexcept
;
namespace
pyston
{
...
...
@@ -1442,7 +1443,8 @@ static PyMethodDef float_methods[] = { { "hex", (PyCFunction)float_hex, METH_NOA
{
"fromhex"
,
(
PyCFunction
)
float_fromhex
,
METH_O
|
METH_CLASS
,
NULL
},
{
"as_integer_ratio"
,
(
PyCFunction
)
float_as_integer_ratio
,
METH_NOARGS
,
NULL
},
{
"is_integer"
,
(
PyCFunction
)
float_is_integer
,
METH_NOARGS
,
NULL
}
};
{
"is_integer"
,
(
PyCFunction
)
float_is_integer
,
METH_NOARGS
,
NULL
},
{
"__format__"
,
(
PyCFunction
)
float__format__
,
METH_VARARGS
,
NULL
}
};
void
setupFloat
()
{
_addFunc
(
"__add__"
,
BOXED_FLOAT
,
(
void
*
)
floatAddFloat
,
(
void
*
)
floatAddInt
,
(
void
*
)
floatAdd
);
...
...
This diff is collapsed.
Click to expand it.
test/tests/builtins.py
View file @
ca90416c
...
...
@@ -117,3 +117,7 @@ print bytearray(xrange(256))
l
=
[
2
,
1
,
3
]
print
apply
(
sorted
,
[
l
])
print
apply
(
sorted
,
[
l
],
{
"reverse"
:
True
})
print
format
(
5.0
,
'+'
)
print
format
(
5.011111111111
,
'+.6'
)
print
format
(
"abc"
,
''
)
This diff is collapsed.
Click to expand it.
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