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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
6fc9c910
Commit
6fc9c910
authored
Oct 01, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #384
parent
d36f3b8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
7 deletions
+32
-7
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+9
-4
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-2
tests/run/division_T384.pyx
tests/run/division_T384.pyx
+20
-0
No files found.
Cython/Compiler/Code.py
View file @
6fc9c910
...
@@ -24,7 +24,9 @@ class UtilityCode(object):
...
@@ -24,7 +24,9 @@ class UtilityCode(object):
#
#
# hashes/equals by instance
# hashes/equals by instance
def
__init__
(
self
,
proto
=
None
,
impl
=
None
,
init
=
None
,
cleanup
=
None
,
requires
=
None
):
def
__init__
(
self
,
proto
=
None
,
impl
=
None
,
init
=
None
,
cleanup
=
None
,
requires
=
None
,
proto_block
=
'utility_code_proto'
):
# proto_block: Which code block to dump prototype in. See GlobalState.
self
.
proto
=
proto
self
.
proto
=
proto
self
.
impl
=
impl
self
.
impl
=
impl
self
.
init
=
init
self
.
init
=
init
...
@@ -32,6 +34,7 @@ class UtilityCode(object):
...
@@ -32,6 +34,7 @@ class UtilityCode(object):
self
.
requires
=
requires
self
.
requires
=
requires
self
.
_cache
=
{}
self
.
_cache
=
{}
self
.
specialize_list
=
[]
self
.
specialize_list
=
[]
self
.
proto_block
=
proto_block
def
specialize
(
self
,
pyrex_type
=
None
,
**
data
):
def
specialize
(
self
,
pyrex_type
=
None
,
**
data
):
# Dicts aren't hashable...
# Dicts aren't hashable...
...
@@ -51,7 +54,7 @@ class UtilityCode(object):
...
@@ -51,7 +54,7 @@ class UtilityCode(object):
none_or_sub
(
self
.
impl
,
data
),
none_or_sub
(
self
.
impl
,
data
),
none_or_sub
(
self
.
init
,
data
),
none_or_sub
(
self
.
init
,
data
),
none_or_sub
(
self
.
cleanup
,
data
),
none_or_sub
(
self
.
cleanup
,
data
),
requires
)
requires
,
self
.
proto_block
)
self
.
specialize_list
.
append
(
s
)
self
.
specialize_list
.
append
(
s
)
return
s
return
s
...
@@ -60,7 +63,7 @@ class UtilityCode(object):
...
@@ -60,7 +63,7 @@ class UtilityCode(object):
for
dependency
in
self
.
requires
:
for
dependency
in
self
.
requires
:
output
.
use_utility_code
(
dependency
)
output
.
use_utility_code
(
dependency
)
if
self
.
proto
:
if
self
.
proto
:
output
[
'utility_code_proto'
].
put
(
self
.
proto
)
output
[
self
.
proto_block
].
put
(
self
.
proto
)
if
self
.
impl
:
if
self
.
impl
:
output
[
'utility_code_def'
].
put
(
self
.
impl
)
output
[
'utility_code_def'
].
put
(
self
.
impl
)
if
self
.
init
:
if
self
.
init
:
...
@@ -390,8 +393,10 @@ class GlobalState(object):
...
@@ -390,8 +393,10 @@ class GlobalState(object):
code_layout = [
code_layout = [
'h_code',
'h_code',
'utility_code_proto',
'complex_numbers_utility_code',
'utility_code_proto_before_types',
'type_declarations',
'type_declarations',
'utility_code_proto',
'module_declarations',
'module_declarations',
'typeinfo',
'typeinfo',
'before_global_var',
'before_global_var',
...
...
Cython/Compiler/ModuleNode.py
View file @
6fc9c910
...
@@ -2515,4 +2515,4 @@ packed_struct_utility_code = UtilityCode(proto="""
...
@@ -2515,4 +2515,4 @@ packed_struct_utility_code = UtilityCode(proto="""
#else
#else
#define __Pyx_PACKED
#define __Pyx_PACKED
#endif
#endif
"""
,
impl
=
""
)
"""
,
impl
=
""
,
proto_block
=
'utility_code_proto_before_types'
)
Cython/Compiler/PyrexTypes.py
View file @
6fc9c910
...
@@ -612,7 +612,7 @@ static INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x) {
...
@@ -612,7 +612,7 @@ static INLINE %(type)s __Pyx_PyInt_As%(SignWord)s%(TypeName)s(PyObject* x) {
}
}
return (%(type)s)__Pyx_PyInt_As%(SignWord)sLong(x);
return (%(type)s)__Pyx_PyInt_As%(SignWord)sLong(x);
}
}
"""
)
"""
)
#fool emacs: '
c_long_from_py_function
=
UtilityCode
(
c_long_from_py_function
=
UtilityCode
(
proto
=
"""
proto
=
"""
...
@@ -1013,7 +1013,7 @@ proto="""
...
@@ -1013,7 +1013,7 @@ proto="""
}
}
#endif
#endif
"""
)
"""
,
proto_block
=
'complex_numbers_utility_code'
)
class
CArrayType
(
CType
):
class
CArrayType
(
CType
):
...
...
tests/run/division_T384.pyx
0 → 100644
View file @
6fc9c910
"""
>>> test(3)
(3+1j)
"""
cimport
cython
ctypedef
Py_ssize_t
index_t
ctypedef
double
complex
mycomplex
ctypedef
struct
MyStruct
:
mycomplex
a
,
b
@
cython
.
cdivision
(
False
)
def
test
(
index_t
x
):
cdef
index_t
y
=
x
//
2
cdef
MyStruct
s
s
.
a
=
x
+
y
*
1j
return
s
.
a
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