Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
6a00f8c1
Commit
6a00f8c1
authored
Nov 08, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
e527ed66
0efdb76f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
21 deletions
+39
-21
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+13
-8
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+8
-8
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-4
tests/run/switch.pyx
tests/run/switch.pyx
+12
-0
No files found.
Cython/Compiler/Code.py
View file @
6a00f8c1
...
@@ -293,7 +293,7 @@ class GlobalState(object):
...
@@ -293,7 +293,7 @@ class GlobalState(object):
def
add_interned_num_decl
(
self
,
entry
):
def
add_interned_num_decl
(
self
,
entry
):
if
self
.
should_declare
(
entry
.
cname
,
entry
):
if
self
.
should_declare
(
entry
.
cname
,
entry
):
if
entry
.
init
[
-
1
]
==
"L"
:
if
entry
.
init
[
-
1
]
==
"L"
:
self
.
initwriter
.
putln
(
'%s = PyLong_FromString("%s", 0, 0); %s;'
%
(
self
.
initwriter
.
putln
(
'%s = PyLong_FromString(
(char *)
"%s", 0, 0); %s;'
%
(
entry
.
cname
,
entry
.
cname
,
entry
.
init
,
entry
.
init
,
self
.
initwriter
.
error_goto_if_null
(
entry
.
cname
,
self
.
module_pos
)))
self
.
initwriter
.
error_goto_if_null
(
entry
.
cname
,
self
.
module_pos
)))
...
...
Cython/Compiler/ExprNodes.py
View file @
6a00f8c1
...
@@ -899,7 +899,7 @@ class LongNode(AtomicExprNode):
...
@@ -899,7 +899,7 @@ class LongNode(AtomicExprNode):
def
generate_evaluation_code
(
self
,
code
):
def
generate_evaluation_code
(
self
,
code
):
code
.
putln
(
code
.
putln
(
'%s = PyLong_FromString("%s", 0, 0); %s'
%
(
'%s = PyLong_FromString(
(char *)
"%s", 0, 0); %s'
%
(
self
.
result
(),
self
.
result
(),
self
.
value
,
self
.
value
,
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
...
@@ -4692,8 +4692,8 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
...
@@ -4692,8 +4692,8 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
empty_dict = PyDict_New();
empty_dict = PyDict_New();
if (!empty_dict)
if (!empty_dict)
goto bad;
goto bad;
module = PyObject_CallFunction
(__import__, "OOOO"
,
module = PyObject_CallFunction
ObjArgs(__import__
,
name, global_dict, empty_dict, list);
name, global_dict, empty_dict, list
, NULL
);
bad:
bad:
Py_XDECREF(empty_list);
Py_XDECREF(empty_list);
Py_XDECREF(__import__);
Py_XDECREF(__import__);
...
@@ -4810,11 +4810,11 @@ static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
...
@@ -4810,11 +4810,11 @@ static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
create_class_utility_code
=
UtilityCode
(
create_class_utility_code
=
UtilityCode
(
proto
=
"""
proto
=
"""
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/
static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, c
onst c
har *modname); /*proto*/
"""
,
"""
,
impl
=
"""
impl
=
"""
static PyObject *__Pyx_CreateClass(
static PyObject *__Pyx_CreateClass(
PyObject *bases, PyObject *dict, PyObject *name, char *modname)
PyObject *bases, PyObject *dict, PyObject *name, c
onst c
har *modname)
{
{
PyObject *py_modname;
PyObject *py_modname;
PyObject *result = 0;
PyObject *result = 0;
...
@@ -4877,7 +4877,12 @@ static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
...
@@ -4877,7 +4877,12 @@ static INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
return Py_None; // this is just to have an accurate signature
return Py_None; // this is just to have an accurate signature
}
}
else {
else {
return PyObject_CallMethod(L, "append", "(O)", x);
PyObject *r, *m;
m = PyObject_GetAttrString(L, "append");
if (!m) return NULL;
r = PyObject_CallFunctionObjArgs(m, x, NULL);
Py_DECREF(m);
return r;
}
}
}
}
"""
,
"""
,
...
@@ -4968,10 +4973,10 @@ impl = """
...
@@ -4968,10 +4973,10 @@ impl = """
raise_noneattr_error_utility_code
=
UtilityCode
(
raise_noneattr_error_utility_code
=
UtilityCode
(
proto
=
"""
proto
=
"""
static INLINE void __Pyx_RaiseNoneAttributeError(char* attrname);
static INLINE void __Pyx_RaiseNoneAttributeError(c
onst c
har* attrname);
"""
,
"""
,
impl
=
"""
impl
=
"""
static INLINE void __Pyx_RaiseNoneAttributeError(char* attrname) {
static INLINE void __Pyx_RaiseNoneAttributeError(c
onst c
har* attrname) {
PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", attrname);
PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", attrname);
}
}
"""
)
"""
)
...
...
Cython/Compiler/ModuleNode.py
View file @
6a00f8c1
...
@@ -1448,7 +1448,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1448,7 +1448,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
flags
=
"READONLY"
flags
=
"READONLY"
else
:
else
:
flags
=
"0"
flags
=
"0"
code
.
putln
(
'{"%s", %s, %s, %s, 0},'
%
(
code
.
putln
(
'{
(char *)
"%s", %s, %s, %s, 0},'
%
(
entry
.
name
,
entry
.
name
,
type_code
,
type_code
,
"offsetof(%s, %s)"
%
(
objstruct
,
entry
.
cname
),
"offsetof(%s, %s)"
%
(
objstruct
,
entry
.
cname
),
...
@@ -1466,7 +1466,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1466,7 +1466,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env
.
getset_table_cname
)
env
.
getset_table_cname
)
for
entry
in
env
.
property_entries
:
for
entry
in
env
.
property_entries
:
code
.
putln
(
code
.
putln
(
'{"%s", %s, %s, %s, 0},'
%
(
'{
(char *)
"%s", %s, %s, %s, 0},'
%
(
entry
.
name
,
entry
.
name
,
entry
.
getter_cname
or
"0"
,
entry
.
getter_cname
or
"0"
,
entry
.
setter_cname
or
"0"
,
entry
.
setter_cname
or
"0"
,
...
@@ -2050,10 +2050,10 @@ bad:
...
@@ -2050,10 +2050,10 @@ bad:
function_export_utility_code
=
UtilityCode
(
function_export_utility_code
=
UtilityCode
(
proto
=
"""
proto
=
"""
static int __Pyx_ExportFunction(c
har *name, void *f,
char *sig); /*proto*/
static int __Pyx_ExportFunction(c
onst char *name, void *f, const
char *sig); /*proto*/
"""
,
"""
,
impl
=
r"""
impl
=
r"""
static int __Pyx_ExportFunction(c
har *name, void *f,
char *sig) {
static int __Pyx_ExportFunction(c
onst char *name, void *f, const
char *sig) {
PyObject *d = 0;
PyObject *d = 0;
PyObject *p = 0;
PyObject *p = 0;
d = PyObject_GetAttrString(%(MODULE)s, "%(API)s");
d = PyObject_GetAttrString(%(MODULE)s, "%(API)s");
...
@@ -2066,7 +2066,7 @@ static int __Pyx_ExportFunction(char *name, void *f, char *sig) {
...
@@ -2066,7 +2066,7 @@ static int __Pyx_ExportFunction(char *name, void *f, char *sig) {
if (PyModule_AddObject(%(MODULE)s, "%(API)s", d) < 0)
if (PyModule_AddObject(%(MODULE)s, "%(API)s", d) < 0)
goto bad;
goto bad;
}
}
p = PyCObject_FromVoidPtrAndDesc(f, sig, 0);
p = PyCObject_FromVoidPtrAndDesc(f,
(void *)
sig, 0);
if (!p)
if (!p)
goto bad;
goto bad;
if (PyDict_SetItemString(d, name, p) < 0)
if (PyDict_SetItemString(d, name, p) < 0)
...
@@ -2085,16 +2085,16 @@ bad:
...
@@ -2085,16 +2085,16 @@ bad:
function_import_utility_code
=
UtilityCode
(
function_import_utility_code
=
UtilityCode
(
proto
=
"""
proto
=
"""
static int __Pyx_ImportFunction(PyObject *module, c
har *funcname, void **f,
char *sig); /*proto*/
static int __Pyx_ImportFunction(PyObject *module, c
onst char *funcname, void **f, const
char *sig); /*proto*/
"""
,
"""
,
impl
=
"""
impl
=
"""
#ifndef __PYX_HAVE_RT_ImportFunction
#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, c
har *funcname, void **f,
char *sig) {
static int __Pyx_ImportFunction(PyObject *module, c
onst char *funcname, void **f, const
char *sig) {
PyObject *d = 0;
PyObject *d = 0;
PyObject *cobj = 0;
PyObject *cobj = 0;
char *desc;
char *desc;
d = PyObject_GetAttrString(module, "%(API)s");
d = PyObject_GetAttrString(module, "%(API)s");
if (!d)
if (!d)
goto bad;
goto bad;
...
...
Cython/Compiler/Nodes.py
View file @
6a00f8c1
...
@@ -3469,6 +3469,7 @@ class SwitchStatNode(StatNode):
...
@@ -3469,6 +3469,7 @@ class SwitchStatNode(StatNode):
if
self
.
else_clause
is
not
None
:
if
self
.
else_clause
is
not
None
:
code
.
putln
(
"default:"
)
code
.
putln
(
"default:"
)
self
.
else_clause
.
generate_execution_code
(
code
)
self
.
else_clause
.
generate_execution_code
(
code
)
code
.
putln
(
"break;"
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
...
@@ -4493,7 +4494,7 @@ static PyObject* %s = 0;
...
@@ -4493,7 +4494,7 @@ static PyObject* %s = 0;
impl
=
r"""
impl
=
r"""
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
static PyObject *__Pyx_GetStdout(void) {
PyObject *f = PySys_GetObject("stdout");
PyObject *f = PySys_GetObject(
(char *)
"stdout");
if (!f) {
if (!f) {
PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
}
}
...
@@ -4504,7 +4505,7 @@ static int __Pyx_Print(PyObject *arg_tuple, int newline) {
...
@@ -4504,7 +4505,7 @@ static int __Pyx_Print(PyObject *arg_tuple, int newline) {
PyObject *f;
PyObject *f;
PyObject* v;
PyObject* v;
int i;
int i;
if (!(f = __Pyx_GetStdout()))
if (!(f = __Pyx_GetStdout()))
return -1;
return -1;
for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
...
@@ -5117,8 +5118,8 @@ impl = r"""
...
@@ -5117,8 +5118,8 @@ impl = r"""
static int __Pyx_GetVtable(PyObject *dict, void *vtabptr) {
static int __Pyx_GetVtable(PyObject *dict, void *vtabptr) {
int result;
int result;
PyObject *pycobj;
PyObject *pycobj;
pycobj = PyMapping_GetItemString(dict, "__pyx_vtable__");
pycobj = PyMapping_GetItemString(dict,
(char *)
"__pyx_vtable__");
if (!pycobj)
if (!pycobj)
goto bad;
goto bad;
*(void **)vtabptr = PyCObject_AsVoidPtr(pycobj);
*(void **)vtabptr = PyCObject_AsVoidPtr(pycobj);
...
...
tests/run/switch.pyx
View file @
6a00f8c1
...
@@ -89,6 +89,9 @@ __doc__ = u"""
...
@@ -89,6 +89,9 @@ __doc__ = u"""
1
1
>>> switch_off(2)
>>> switch_off(2)
0
0
>>> switch_pass(1)
1
"""
"""
def
switch_simple_py
(
x
):
def
switch_simple_py
(
x
):
...
@@ -173,3 +176,12 @@ def switch_off(int x):
...
@@ -173,3 +176,12 @@ def switch_off(int x):
else
:
else
:
return
0
return
0
return
-
1
return
-
1
def
switch_pass
(
int
x
):
if
x
==
1
:
pass
elif
x
==
2
:
pass
else
:
pass
return
x
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