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
45e59971
Commit
45e59971
authored
Dec 12, 2010
by
Vitja Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote branch 'upstream/master'
parents
351d69aa
d93ea8d2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
5 deletions
+39
-5
Cython/Build/Inline.py
Cython/Build/Inline.py
+12
-2
Cython/Build/Tests/TestInline.py
Cython/Build/Tests/TestInline.py
+1
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+20
-1
tests/run/complex_numbers_T305.pyx
tests/run/complex_numbers_T305.pyx
+5
-0
No files found.
Cython/Build/Inline.py
View file @
45e59971
...
...
@@ -17,6 +17,16 @@ from Cython.Compiler.ParseTreeTransforms import CythonTransform, SkipDeclaration
from
Cython.Compiler.TreeFragment
import
parse_from_strings
from
Cython.Build.Dependencies
import
strip_string_literals
,
cythonize
# A utility function to convert user-supplied ASCII strings to unicode.
if
sys
.
version_info
[
0
]
<
3
:
def
to_unicode
(
s
):
if
not
isinstance
(
s
,
unicode
):
return
s
.
decode
(
'ascii'
)
else
:
return
s
else
:
to_unicode
=
lambda
x
:
x
_code_cache
=
{}
...
...
@@ -28,11 +38,10 @@ class AllSymbols(CythonTransform, SkipDeclarations):
self
.
names
.
add
(
node
.
name
)
def
unbound_symbols
(
code
,
context
=
None
):
code
=
to_unicode
(
code
)
if
context
is
None
:
context
=
Context
([],
default_options
)
from
Cython.Compiler.ParseTreeTransforms
import
AnalyseDeclarationsTransform
if
isinstance
(
code
,
str
):
code
=
code
.
decode
(
'ascii'
)
tree
=
parse_from_strings
(
'(tree fragment)'
,
code
)
for
phase
in
context
.
create_pipeline
(
pxd
=
False
):
if
phase
is
None
:
...
...
@@ -90,6 +99,7 @@ def cython_inline(code,
**
kwds
):
if
get_type
is
None
:
get_type
=
lambda
x
:
'object'
code
=
to_unicode
(
code
)
code
,
literals
=
strip_string_literals
(
code
)
code
=
strip_common_indent
(
code
)
ctx
=
Context
(
cython_include_dirs
,
default_options
)
...
...
Cython/Build/Tests/TestInline.py
View file @
45e59971
...
...
@@ -12,7 +12,7 @@ test_kwds = dict(force=True, quiet=True)
global_value
=
100
class
Test
StripLiterals
(
CythonTest
):
class
Test
Inline
(
CythonTest
):
def
test_simple
(
self
):
self
.
assertEquals
(
inline
(
"return 1+2"
,
**
test_kwds
),
3
)
...
...
Cython/Compiler/ExprNodes.py
View file @
45e59971
...
...
@@ -4051,7 +4051,7 @@ class ListNode(SequenceNode):
self
.
obj_conversion_errors
=
[]
if
not
self
.
type
.
subtype_of
(
dst_type
):
error
(
self
.
pos
,
"Cannot coerce list to type '%s'"
%
dst_type
)
elif
dst_type
.
is_ptr
:
elif
dst_type
.
is_ptr
and
dst_type
.
base_type
is
not
PyrexTypes
.
c_void_type
:
base_type
=
dst_type
.
base_type
self
.
type
=
PyrexTypes
.
CArrayType
(
base_type
,
len
(
self
.
args
))
for
i
in
range
(
len
(
self
.
original_args
)):
...
...
Cython/Compiler/PyrexTypes.py
View file @
45e59971
...
...
@@ -635,6 +635,8 @@ class CNumericType(CType):
is_numeric
=
1
default_value
=
"0"
has_attributes
=
True
scope
=
None
sign_words
=
(
"unsigned "
,
""
,
"signed "
)
...
...
@@ -658,6 +660,23 @@ class CNumericType(CType):
else
:
base_code
=
public_decl
(
type_name
,
dll_linkage
)
return
self
.
base_declaration_code
(
base_code
,
entity_code
)
def
attributes_known
(
self
):
if
self
.
scope
is
None
:
import
Symtab
self
.
scope
=
scope
=
Symtab
.
CClassScope
(
''
,
None
,
visibility
=
"extern"
)
scope
.
parent_type
=
self
scope
.
directives
=
{}
entry
=
scope
.
declare_cfunction
(
"conjugate"
,
CFuncType
(
self
,
[
CFuncTypeArg
(
"self"
,
self
,
None
)],
nogil
=
True
),
pos
=
None
,
defining
=
1
,
cname
=
" "
)
return
True
type_conversion_predeclarations
=
""
...
...
@@ -1080,7 +1099,7 @@ class CComplexType(CNumericType):
scope
.
declare_var
(
"imag"
,
self
.
real_type
,
None
,
"imag"
,
is_cdef
=
True
)
entry
=
scope
.
declare_cfunction
(
"conjugate"
,
CFuncType
(
self
,
[
CFuncTypeArg
(
"self"
,
self
,
None
)]),
CFuncType
(
self
,
[
CFuncTypeArg
(
"self"
,
self
,
None
)]
,
nogil
=
True
),
pos
=
None
,
defining
=
1
,
cname
=
"__Pyx_c_conj%s"
%
self
.
funcsuffix
)
...
...
tests/run/complex_numbers_T305.pyx
View file @
45e59971
...
...
@@ -162,6 +162,11 @@ def test_conjugate_typedef(cdouble z):
"""
return
z
.
conjugate
()
cdef
cdouble
test_conjugate_nogil
(
cdouble
z
)
nogil
:
# Really just a compile test.
return
z
.
conjugate
()
test_conjugate_nogil
(
0
)
# use it
## cdef extern from "complex_numbers_T305.h":
## ctypedef double double_really_float "myfloat"
## ctypedef float float_really_double "mydouble"
...
...
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