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
1ebb95b4
Commit
1ebb95b4
authored
Jan 08, 2016
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing attributes to complex and adjust some API
parent
2526c94e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
331 additions
and
673 deletions
+331
-673
from_cpython/Include/complexobject.h
from_cpython/Include/complexobject.h
+0
-4
from_cpython/Objects/complexobject.c
from_cpython/Objects/complexobject.c
+32
-16
src/runtime/complex.cpp
src/runtime/complex.cpp
+295
-653
src/runtime/types.h
src/runtime/types.h
+4
-0
No files found.
from_cpython/Include/complexobject.h
View file @
1ebb95b4
...
...
@@ -39,14 +39,10 @@ PyComplexObject represents a complex number with double-precision
real and imaginary parts.
*/
// Pyston change: this is not our object format
#if 0
typedef
struct
{
PyObject_HEAD
Py_complex
cval
;
}
PyComplexObject
;
#endif
typedef
struct
_PyComplexObject
PyComplexObject
;
// Pyston change: this is not a static object any more
// PyAPI_DATA(PyTypeObject) PyComplex_Type;
...
...
from_cpython/Objects/complexobject.c
View file @
1ebb95b4
...
...
@@ -215,8 +215,6 @@ c_abs(Py_complex z)
return
result
;
}
// Pyston changes: comment this out
#if 0
static
PyObject
*
complex_subtype_from_c_complex
(
PyTypeObject
*
type
,
Py_complex
cval
)
{
...
...
@@ -356,14 +354,18 @@ PyComplex_AsCComplex(PyObject *op)
}
}
// Pyston changes: comment this out
#if 0
static void
complex_dealloc(PyObject *op)
{
op->ob_type->tp_free(op);
}
#endif
static PyObject *
// Pyston change: make no static
PyObject
*
complex_format
(
PyComplexObject
*
v
,
int
precision
,
char
format_code
)
{
PyObject
*
result
=
NULL
;
...
...
@@ -426,6 +428,8 @@ complex_format(PyComplexObject *v, int precision, char format_code)
return
result
;
}
// Pyston changes: comment this out
#if 0
static int
complex_print(PyComplexObject *v, FILE *fp, int flags)
{
...
...
@@ -788,8 +792,10 @@ complex_coerce(PyObject **pv, PyObject **pw)
}
return 1; /* Can't do it */
}
#endif
static PyObject *
// Pyston change: make no static
PyObject
*
complex_richcompare
(
PyObject
*
v
,
PyObject
*
w
,
int
op
)
{
PyObject
*
res
;
...
...
@@ -858,6 +864,8 @@ complex_richcompare(PyObject *v, PyObject *w, int op)
return
Py_NotImplemented
;
}
// Pyston change: comment this out
#if 0
static PyObject *
complex_int(PyObject *v)
{
...
...
@@ -907,8 +915,10 @@ PyDoc_STRVAR(complex__format__doc,
"complex.__format__() -> str\n"
"\n"
"Convert to a string according to format_spec.");
#endif
static PyObject *
// Pyston changes: make no static
PyObject
*
complex__format__
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
format_spec
;
...
...
@@ -952,7 +962,6 @@ PyDoc_STRVAR(complex_is_finite_doc,
"complex.is_finite() -> bool\n"
"\n"
"Returns True if the real and the imaginary part is finite.");
#endif
static PyMethodDef complex_methods[] = {
{"conjugate", (PyCFunction)complex_conjugate, METH_NOARGS,
...
...
@@ -974,6 +983,7 @@ static PyMemberDef complex_members[] = {
"the imaginary part of a complex number"},
{0},
};
#endif
static
PyObject
*
complex_subtype_from_string
(
PyTypeObject
*
type
,
PyObject
*
v
)
...
...
@@ -1136,22 +1146,26 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
return
NULL
;
}
static PyObject *
complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *r, *i, *tmp;
// Pyston changes: change the API, make it no static
// and let complex_new accept unpacked arguments
PyObject
*
complex_new
(
PyTypeObject
*
type
,
PyObject
*
r
,
PyObject
*
i
)
{
PyObject
*
tmp
;
PyNumberMethods
*
nbr
,
*
nbi
=
NULL
;
Py_complex
cr
,
ci
;
int
own_r
=
0
;
int
cr_is_complex
=
0
;
int
ci_is_complex
=
0
;
static char *kwlist[] = {"real", "imag", 0};
r = Py_False;
i = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:complex", kwlist,
&r, &i))
return NULL;
/* Pyston changes: comment this out, pyston don't use tuple arg.
static char *kwlist[] = {"real", "imag", 0};
r = Py_False;
i = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO:complex", kwlist,
&r, &i))
return NULL;
*/
/* Special-case for a single argument when type(arg) is complex. */
if
(
PyComplex_CheckExact
(
r
)
&&
i
==
NULL
&&
...
...
@@ -1269,6 +1283,8 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return
complex_subtype_from_doubles
(
type
,
cr
.
real
,
ci
.
real
);
}
// Pyston changes: comment this out
#if 0
PyDoc_STRVAR(complex_doc,
"complex(real[, imag]) -> complex number\n"
"\n"
...
...
src/runtime/complex.cpp
View file @
1ebb95b4
This diff is collapsed.
Click to expand it.
src/runtime/types.h
View file @
1ebb95b4
...
...
@@ -390,6 +390,10 @@ public:
DEFAULT_CLASS_SIMPLE
(
complex_cls
);
};
static_assert
(
sizeof
(
BoxedComplex
)
==
sizeof
(
PyComplexObject
),
""
);
static_assert
(
offsetof
(
BoxedComplex
,
real
)
==
offsetof
(
PyComplexObject
,
cval
.
real
),
""
);
static_assert
(
offsetof
(
BoxedComplex
,
imag
)
==
offsetof
(
PyComplexObject
,
cval
.
imag
),
""
);
class
BoxedBool
:
public
BoxedInt
{
public:
BoxedBool
(
bool
b
)
__attribute__
((
visibility
(
"default"
)))
:
BoxedInt
(
b
?
1
:
0
)
{}
...
...
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