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
bcc15b5d
Commit
bcc15b5d
authored
Oct 16, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add empty declaration code method.
parent
3cd6c6ac
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
69 additions
and
63 deletions
+69
-63
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+4
-4
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-10
Cython/Compiler/FusedNode.py
Cython/Compiler/FusedNode.py
+1
-1
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+6
-6
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+8
-8
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-5
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+32
-26
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+1
-1
No files found.
Cython/Compiler/Buffer.py
View file @
bcc15b5d
...
@@ -256,7 +256,7 @@ class BufferEntry(object):
...
@@ -256,7 +256,7 @@ class BufferEntry(object):
defcode
=
code
.
globalstate
[
'utility_code_def'
]
defcode
=
code
.
globalstate
[
'utility_code_def'
]
funcgen
(
protocode
,
defcode
,
name
=
funcname
,
nd
=
nd
)
funcgen
(
protocode
,
defcode
,
name
=
funcname
,
nd
=
nd
)
buf_ptr_type_code
=
self
.
buf_ptr_type
.
declaration_code
(
""
)
buf_ptr_type_code
=
self
.
buf_ptr_type
.
empty_declaration_code
(
)
ptrcode
=
"%s(%s, %s, %s)"
%
(
funcname
,
buf_ptr_type_code
,
self
.
buf_ptr
,
ptrcode
=
"%s(%s, %s, %s)"
%
(
funcname
,
buf_ptr_type_code
,
self
.
buf_ptr
,
", "
.
join
(
params
))
", "
.
join
(
params
))
return
ptrcode
return
ptrcode
...
@@ -627,7 +627,7 @@ def mangle_dtype_name(dtype):
...
@@ -627,7 +627,7 @@ def mangle_dtype_name(dtype):
prefix
=
"nn_"
prefix
=
"nn_"
else
:
else
:
prefix
=
""
prefix
=
""
type_decl
=
dtype
.
declaration_code
(
""
)
type_decl
=
dtype
.
empty_declaration_code
(
)
type_decl
=
type_decl
.
replace
(
" "
,
"_"
)
type_decl
=
type_decl
.
replace
(
" "
,
"_"
)
return
prefix
+
type_decl
.
replace
(
"["
,
"_"
).
replace
(
"]"
,
"_"
)
return
prefix
+
type_decl
.
replace
(
"["
,
"_"
).
replace
(
"]"
,
"_"
)
...
@@ -665,7 +665,7 @@ def get_type_information_cname(code, dtype, maxdepth=None):
...
@@ -665,7 +665,7 @@ def get_type_information_cname(code, dtype, maxdepth=None):
complex_possible
=
dtype
.
is_struct_or_union
and
dtype
.
can_be_complex
()
complex_possible
=
dtype
.
is_struct_or_union
and
dtype
.
can_be_complex
()
declcode
=
dtype
.
declaration_code
(
""
)
declcode
=
dtype
.
empty_declaration_code
(
)
if
dtype
.
is_simple_buffer_dtype
():
if
dtype
.
is_simple_buffer_dtype
():
structinfo_name
=
"NULL"
structinfo_name
=
"NULL"
elif
dtype
.
is_struct
:
elif
dtype
.
is_struct
:
...
@@ -678,7 +678,7 @@ def get_type_information_cname(code, dtype, maxdepth=None):
...
@@ -678,7 +678,7 @@ def get_type_information_cname(code, dtype, maxdepth=None):
typecode
.
putln
(
"static __Pyx_StructField %s[] = {"
%
structinfo_name
,
safe
=
True
)
typecode
.
putln
(
"static __Pyx_StructField %s[] = {"
%
structinfo_name
,
safe
=
True
)
for
f
,
typeinfo
in
zip
(
fields
,
types
):
for
f
,
typeinfo
in
zip
(
fields
,
types
):
typecode
.
putln
(
' {&%s, "%s", offsetof(%s, %s)},'
%
typecode
.
putln
(
' {&%s, "%s", offsetof(%s, %s)},'
%
(
typeinfo
,
f
.
name
,
dtype
.
declaration_code
(
""
),
f
.
cname
),
safe
=
True
)
(
typeinfo
,
f
.
name
,
dtype
.
empty_declaration_code
(
),
f
.
cname
),
safe
=
True
)
typecode
.
putln
(
' {NULL, NULL, 0}'
,
safe
=
True
)
typecode
.
putln
(
' {NULL, NULL, 0}'
,
safe
=
True
)
typecode
.
putln
(
"};"
,
safe
=
True
)
typecode
.
putln
(
"};"
,
safe
=
True
)
else
:
else
:
...
...
Cython/Compiler/Code.py
View file @
bcc15b5d
...
@@ -369,7 +369,7 @@ class UtilityCode(UtilityCodeBase):
...
@@ -369,7 +369,7 @@ class UtilityCode(UtilityCodeBase):
def specialize(self, pyrex_type=None, **data):
def specialize(self, pyrex_type=None, **data):
# Dicts aren't hashable...
# Dicts aren't hashable...
if pyrex_type is not None:
if pyrex_type is not None:
data['type'] = pyrex_type.
declaration_code(''
)
data['type'] = pyrex_type.
empty_declaration_code(
)
data['type_name'] = pyrex_type.specialization_name()
data['type_name'] = pyrex_type.specialization_name()
key = tuple(sorted(data.items()))
key = tuple(sorted(data.items()))
try:
try:
...
...
Cython/Compiler/ExprNodes.py
View file @
bcc15b5d
...
@@ -1560,7 +1560,7 @@ class NewExprNode(AtomicExprNode):
...
@@ -1560,7 +1560,7 @@ class NewExprNode(AtomicExprNode):
pass
pass
def
calculate_result_code
(
self
):
def
calculate_result_code
(
self
):
return
"new "
+
self
.
class_type
.
declaration_code
(
""
)
return
"new "
+
self
.
class_type
.
empty_declaration_code
(
)
class
NameNode
(
AtomicExprNode
):
class
NameNode
(
AtomicExprNode
):
...
@@ -3460,7 +3460,7 @@ class IndexNode(ExprNode):
...
@@ -3460,7 +3460,7 @@ class IndexNode(ExprNode):
elif
self
.
base
.
type
.
is_cfunction
:
elif
self
.
base
.
type
.
is_cfunction
:
return
"%s<%s>"
%
(
return
"%s<%s>"
%
(
self
.
base
.
result
(),
self
.
base
.
result
(),
","
.
join
([
param
.
declaration_code
(
""
)
for
param
in
self
.
type_indices
]))
","
.
join
([
param
.
empty_declaration_code
(
)
for
param
in
self
.
type_indices
]))
elif
self
.
base
.
type
.
is_ctuple
:
elif
self
.
base
.
type
.
is_ctuple
:
index
=
self
.
index
.
constant_result
index
=
self
.
index
.
constant_result
if
index
<
0
:
if
index
<
0
:
...
@@ -3483,7 +3483,7 @@ class IndexNode(ExprNode):
...
@@ -3483,7 +3483,7 @@ class IndexNode(ExprNode):
and
self
.
index
.
constant_result
>=
0
))
and
self
.
index
.
constant_result
>=
0
))
boundscheck
=
bool
(
code
.
globalstate
.
directives
[
'boundscheck'
])
boundscheck
=
bool
(
code
.
globalstate
.
directives
[
'boundscheck'
])
return
", %s, %d, %s, %d, %d, %d"
%
(
return
", %s, %d, %s, %d, %d, %d"
%
(
self
.
original_index_type
.
declaration_code
(
""
),
self
.
original_index_type
.
empty_declaration_code
(
),
self
.
original_index_type
.
signed
and
1
or
0
,
self
.
original_index_type
.
signed
and
1
or
0
,
self
.
original_index_type
.
to_py_function
,
self
.
original_index_type
.
to_py_function
,
is_list
,
wraparound
,
boundscheck
)
is_list
,
wraparound
,
boundscheck
)
...
@@ -4372,7 +4372,7 @@ class CallNode(ExprNode):
...
@@ -4372,7 +4372,7 @@ class CallNode(ExprNode):
constructor
=
type
.
scope
.
lookup
(
"<init>"
)
constructor
=
type
.
scope
.
lookup
(
"<init>"
)
self
.
function
=
RawCNameExprNode
(
self
.
function
.
pos
,
constructor
.
type
)
self
.
function
=
RawCNameExprNode
(
self
.
function
.
pos
,
constructor
.
type
)
self
.
function
.
entry
=
constructor
self
.
function
.
entry
=
constructor
self
.
function
.
set_cname
(
type
.
declaration_code
(
""
))
self
.
function
.
set_cname
(
type
.
empty_declaration_code
(
))
self
.
analyse_c_function_call
(
env
)
self
.
analyse_c_function_call
(
env
)
self
.
type
=
type
self
.
type
=
type
return
True
return
True
...
@@ -8971,7 +8971,7 @@ class CythonArrayNode(ExprNode):
...
@@ -8971,7 +8971,7 @@ class CythonArrayNode(ExprNode):
shapes_temp
=
code
.
funcstate
.
allocate_temp
(
py_object_type
,
True
)
shapes_temp
=
code
.
funcstate
.
allocate_temp
(
py_object_type
,
True
)
format_temp
=
code
.
funcstate
.
allocate_temp
(
py_object_type
,
True
)
format_temp
=
code
.
funcstate
.
allocate_temp
(
py_object_type
,
True
)
itemsize
=
"sizeof(%s)"
%
dtype
.
declaration_code
(
""
)
itemsize
=
"sizeof(%s)"
%
dtype
.
empty_declaration_code
(
)
type_info
=
Buffer
.
get_type_information_cname
(
code
,
dtype
)
type_info
=
Buffer
.
get_type_information_cname
(
code
,
dtype
)
if
self
.
operand
.
type
.
is_ptr
:
if
self
.
operand
.
type
.
is_ptr
:
...
@@ -9091,7 +9091,7 @@ class SizeofTypeNode(SizeofNode):
...
@@ -9091,7 +9091,7 @@ class SizeofTypeNode(SizeofNode):
# we want the size of the actual struct
# we want the size of the actual struct
arg_code
=
self
.
arg_type
.
declaration_code
(
""
,
deref
=
1
)
arg_code
=
self
.
arg_type
.
declaration_code
(
""
,
deref
=
1
)
else
:
else
:
arg_code
=
self
.
arg_type
.
declaration_code
(
""
)
arg_code
=
self
.
arg_type
.
empty_declaration_code
(
)
return
"(sizeof(%s))"
%
arg_code
return
"(sizeof(%s))"
%
arg_code
...
@@ -9719,12 +9719,12 @@ class DivNode(NumBinopNode):
...
@@ -9719,12 +9719,12 @@ class DivNode(NumBinopNode):
# explicitly signed, no runtime check needed
# explicitly signed, no runtime check needed
minus1_check
=
'unlikely(%s == -1)'
%
self
.
operand2
.
result
()
minus1_check
=
'unlikely(%s == -1)'
%
self
.
operand2
.
result
()
else
:
else
:
type_of_op2
=
self
.
operand2
.
type
.
declaration_code
(
''
)
type_of_op2
=
self
.
operand2
.
type
.
empty_declaration_code
(
)
minus1_check
=
'(!(((%s)-1) > 0)) && unlikely(%s == (%s)-1)'
%
(
minus1_check
=
'(!(((%s)-1) > 0)) && unlikely(%s == (%s)-1)'
%
(
type_of_op2
,
self
.
operand2
.
result
(),
type_of_op2
)
type_of_op2
,
self
.
operand2
.
result
(),
type_of_op2
)
code
.
putln
(
"else if (sizeof(%s) == sizeof(long) && %s "
code
.
putln
(
"else if (sizeof(%s) == sizeof(long) && %s "
" && unlikely(UNARY_NEG_WOULD_OVERFLOW(%s))) {"
%
(
" && unlikely(UNARY_NEG_WOULD_OVERFLOW(%s))) {"
%
(
self
.
type
.
declaration_code
(
''
),
self
.
type
.
empty_declaration_code
(
),
minus1_check
,
minus1_check
,
self
.
operand1
.
result
()))
self
.
operand1
.
result
()))
code
.
put_ensure_gil
()
code
.
put_ensure_gil
()
...
@@ -9872,11 +9872,11 @@ class PowNode(NumBinopNode):
...
@@ -9872,11 +9872,11 @@ class PowNode(NumBinopNode):
elif
self
.
type
.
is_float
:
elif
self
.
type
.
is_float
:
self
.
pow_func
=
"pow"
+
self
.
type
.
math_h_modifier
self
.
pow_func
=
"pow"
+
self
.
type
.
math_h_modifier
elif
self
.
type
.
is_int
:
elif
self
.
type
.
is_int
:
self
.
pow_func
=
"__Pyx_pow_%s"
%
self
.
type
.
declaration_code
(
''
).
replace
(
' '
,
'_'
)
self
.
pow_func
=
"__Pyx_pow_%s"
%
self
.
type
.
empty_declaration_code
(
).
replace
(
' '
,
'_'
)
env
.
use_utility_code
(
env
.
use_utility_code
(
int_pow_utility_code
.
specialize
(
int_pow_utility_code
.
specialize
(
func_name
=
self
.
pow_func
,
func_name
=
self
.
pow_func
,
type
=
self
.
type
.
declaration_code
(
''
),
type
=
self
.
type
.
empty_declaration_code
(
),
signed
=
self
.
type
.
signed
and
1
or
0
))
signed
=
self
.
type
.
signed
and
1
or
0
))
elif
not
self
.
type
.
is_error
:
elif
not
self
.
type
.
is_error
:
error
(
self
.
pos
,
"got unexpected types for C power operator: %s, %s"
%
error
(
self
.
pos
,
"got unexpected types for C power operator: %s, %s"
%
...
...
Cython/Compiler/FusedNode.py
View file @
bcc15b5d
...
@@ -481,7 +481,7 @@ class FusedCFuncDefNode(StatListNode):
...
@@ -481,7 +481,7 @@ class FusedCFuncDefNode(StatListNode):
# self._dtype_name(dtype)))
# self._dtype_name(dtype)))
decl_code
.
putln
(
'ctypedef %s %s "%s"'
%
(
dtype
.
resolve
(),
decl_code
.
putln
(
'ctypedef %s %s "%s"'
%
(
dtype
.
resolve
(),
self
.
_dtype_name
(
dtype
),
self
.
_dtype_name
(
dtype
),
dtype
.
declaration_code
(
""
)))
dtype
.
empty_declaration_code
(
)))
if
buffer_type
.
dtype
.
is_int
:
if
buffer_type
.
dtype
.
is_int
:
if
str
(
dtype
)
not
in
seen_int_dtypes
:
if
str
(
dtype
)
not
in
seen_int_dtypes
:
...
...
Cython/Compiler/MemoryView.py
View file @
bcc15b5d
...
@@ -237,7 +237,7 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
...
@@ -237,7 +237,7 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
def
_generate_buffer_lookup_code
(
self
,
code
,
axes
,
cast_result
=
True
):
def
_generate_buffer_lookup_code
(
self
,
code
,
axes
,
cast_result
=
True
):
bufp
=
self
.
buf_ptr
bufp
=
self
.
buf_ptr
type_decl
=
self
.
type
.
dtype
.
declaration_code
(
""
)
type_decl
=
self
.
type
.
dtype
.
empty_declaration_code
(
)
for
dim
,
index
,
access
,
packing
in
axes
:
for
dim
,
index
,
access
,
packing
in
axes
:
shape
=
"%s.shape[%d]"
%
(
self
.
cname
,
dim
)
shape
=
"%s.shape[%d]"
%
(
self
.
cname
,
dim
)
...
@@ -464,7 +464,7 @@ def copy_broadcast_memview_src_to_dst(src, dst, code):
...
@@ -464,7 +464,7 @@ def copy_broadcast_memview_src_to_dst(src, dst, code):
def
get_1d_fill_scalar_func
(
type
,
code
):
def
get_1d_fill_scalar_func
(
type
,
code
):
dtype
=
type
.
dtype
dtype
=
type
.
dtype
type_decl
=
dtype
.
declaration_code
(
""
)
type_decl
=
dtype
.
empty_declaration_code
(
)
dtype_name
=
mangle_dtype_name
(
dtype
)
dtype_name
=
mangle_dtype_name
(
dtype
)
context
=
dict
(
dtype_name
=
dtype_name
,
type_decl
=
type_decl
)
context
=
dict
(
dtype_name
=
dtype_name
,
type_decl
=
type_decl
)
...
@@ -479,8 +479,8 @@ def assign_scalar(dst, scalar, code):
...
@@ -479,8 +479,8 @@ def assign_scalar(dst, scalar, code):
"""
"""
verify_direct_dimensions
(
dst
)
verify_direct_dimensions
(
dst
)
dtype
=
dst
.
type
.
dtype
dtype
=
dst
.
type
.
dtype
type_decl
=
dtype
.
declaration_code
(
""
)
type_decl
=
dtype
.
empty_declaration_code
(
)
slice_decl
=
dst
.
type
.
declaration_code
(
""
)
slice_decl
=
dst
.
type
.
empty_declaration_code
(
)
code
.
begin_block
()
code
.
begin_block
()
code
.
putln
(
"%s __pyx_temp_scalar = %s;"
%
(
type_decl
,
scalar
.
result
()))
code
.
putln
(
"%s __pyx_temp_scalar = %s;"
%
(
type_decl
,
scalar
.
result
()))
...
@@ -524,7 +524,7 @@ class ContigSliceIter(SliceIter):
...
@@ -524,7 +524,7 @@ class ContigSliceIter(SliceIter):
code
=
self
.
code
code
=
self
.
code
code
.
begin_block
()
code
.
begin_block
()
type_decl
=
self
.
slice_type
.
dtype
.
declaration_code
(
""
)
type_decl
=
self
.
slice_type
.
dtype
.
empty_declaration_code
(
)
total_size
=
' * '
.
join
(
"%s.shape[%d]"
%
(
self
.
slice_temp
,
i
)
total_size
=
' * '
.
join
(
"%s.shape[%d]"
%
(
self
.
slice_temp
,
i
)
for
i
in
range
(
self
.
ndim
))
for
i
in
range
(
self
.
ndim
))
...
@@ -610,7 +610,7 @@ def get_copy_new_utility(pos, from_memview, to_memview):
...
@@ -610,7 +610,7 @@ def get_copy_new_utility(pos, from_memview, to_memview):
context
=
dict
(
context
=
dict
(
context
,
context
,
mode
=
mode
,
mode
=
mode
,
dtype_decl
=
to_memview
.
dtype
.
declaration_code
(
''
),
dtype_decl
=
to_memview
.
dtype
.
empty_declaration_code
(
),
contig_flag
=
contig_flag
,
contig_flag
=
contig_flag
,
ndim
=
to_memview
.
ndim
,
ndim
=
to_memview
.
ndim
,
func_cname
=
copy_c_or_fortran_cname
(
to_memview
),
func_cname
=
copy_c_or_fortran_cname
(
to_memview
),
...
...
Cython/Compiler/ModuleNode.py
View file @
bcc15b5d
...
@@ -251,7 +251,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -251,7 +251,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
%
(
entry
.
name
,
cname
,
sig
))
%
(
entry
.
name
,
cname
,
sig
))
for
entry
in
api_vars
:
for
entry
in
api_vars
:
cname
=
env
.
mangle
(
Naming
.
varptr_prefix
,
entry
.
name
)
cname
=
env
.
mangle
(
Naming
.
varptr_prefix
,
entry
.
name
)
sig
=
entry
.
type
.
declaration_code
(
""
)
sig
=
entry
.
type
.
empty_declaration_code
(
)
h_code
.
putln
(
h_code
.
putln
(
'if (__Pyx_ImportVoidPtr(module, "%s", (void **)&%s, "%s") < 0) goto bad;'
'if (__Pyx_ImportVoidPtr(module, "%s", (void **)&%s, "%s") < 0) goto bad;'
%
(
entry
.
name
,
cname
,
sig
))
%
(
entry
.
name
,
cname
,
sig
))
...
@@ -776,7 +776,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -776,7 +776,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
generate_struct_union_predeclaration
(
self
,
entry
,
code
):
def
generate_struct_union_predeclaration
(
self
,
entry
,
code
):
type
=
entry
.
type
type
=
entry
.
type
if
type
.
is_cpp_class
and
type
.
templates
:
if
type
.
is_cpp_class
and
type
.
templates
:
code
.
putln
(
"template <typename %s>"
%
", typename "
.
join
([
T
.
declaration_code
(
""
)
for
T
in
type
.
templates
]))
code
.
putln
(
"template <typename %s>"
%
", typename "
.
join
([
T
.
empty_declaration_code
(
)
for
T
in
type
.
templates
]))
code
.
putln
(
self
.
sue_predeclaration
(
type
,
type
.
kind
,
type
.
cname
))
code
.
putln
(
self
.
sue_predeclaration
(
type
,
type
.
kind
,
type
.
cname
))
def
sue_header_footer
(
self
,
type
,
kind
,
name
):
def
sue_header_footer
(
self
,
type
,
kind
,
name
):
...
@@ -826,12 +826,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -826,12 +826,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
scope
=
type
.
scope
scope
=
type
.
scope
if
scope
:
if
scope
:
if
type
.
templates
:
if
type
.
templates
:
code
.
putln
(
"template <class %s>"
%
", class "
.
join
([
T
.
declaration_code
(
""
)
for
T
in
type
.
templates
]))
code
.
putln
(
"template <class %s>"
%
", class "
.
join
([
T
.
empty_declaration_code
(
)
for
T
in
type
.
templates
]))
# Just let everything be public.
# Just let everything be public.
code
.
put
(
"struct %s"
%
type
.
cname
)
code
.
put
(
"struct %s"
%
type
.
cname
)
if
type
.
base_classes
:
if
type
.
base_classes
:
base_class_decl
=
", public "
.
join
(
base_class_decl
=
", public "
.
join
(
[
base_class
.
declaration_code
(
""
)
for
base_class
in
type
.
base_classes
])
[
base_class
.
empty_declaration_code
(
)
for
base_class
in
type
.
base_classes
])
code
.
put
(
" : public %s"
%
base_class_decl
)
code
.
put
(
" : public %s"
%
base_class_decl
)
code
.
putln
(
" {"
)
code
.
putln
(
" {"
)
has_virtual_methods
=
False
has_virtual_methods
=
False
...
@@ -1124,7 +1124,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1124,7 +1124,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
code
.
putln
(
"%s = (%s)o;"
%
(
"%s = (%s)o;"
%
(
type
.
declaration_code
(
"p"
),
type
.
declaration_code
(
"p"
),
type
.
declaration_code
(
""
)))
type
.
empty_declaration_code
(
)))
def
generate_new_function
(
self
,
scope
,
code
,
cclass_entry
):
def
generate_new_function
(
self
,
scope
,
code
,
cclass_entry
):
tp_slot
=
TypeSlots
.
ConstructorSlot
(
"tp_new"
,
'__new__'
)
tp_slot
=
TypeSlots
.
ConstructorSlot
(
"tp_new"
,
'__new__'
)
...
@@ -1226,7 +1226,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1226,7 +1226,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
for
entry
in
cpp_class_attrs
:
for
entry
in
cpp_class_attrs
:
code
.
putln
(
"new((void*)&(p->%s)) %s();"
%
code
.
putln
(
"new((void*)&(p->%s)) %s();"
%
(
entry
.
cname
,
entry
.
type
.
declaration_code
(
""
)))
(
entry
.
cname
,
entry
.
type
.
empty_declaration_code
(
)))
for
entry
in
py_attrs
:
for
entry
in
py_attrs
:
code
.
put_init_var_to_py_none
(
entry
,
"p->%s"
,
nanny
=
False
)
code
.
put_init_var_to_py_none
(
entry
,
"p->%s"
,
nanny
=
False
)
...
@@ -2427,7 +2427,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -2427,7 +2427,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
entries
:
if
entries
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"VoidPtrExport"
,
"ImportExport.c"
))
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"VoidPtrExport"
,
"ImportExport.c"
))
for
entry
in
entries
:
for
entry
in
entries
:
signature
=
entry
.
type
.
declaration_code
(
""
)
signature
=
entry
.
type
.
empty_declaration_code
(
)
name
=
code
.
intern_identifier
(
entry
.
name
)
name
=
code
.
intern_identifier
(
entry
.
name
)
code
.
putln
(
'if (__Pyx_ExportVoidPtr(%s, (void *)&%s, "%s") < 0) %s'
%
(
code
.
putln
(
'if (__Pyx_ExportVoidPtr(%s, (void *)&%s, "%s") < 0) %s'
%
(
name
,
entry
.
cname
,
signature
,
name
,
entry
.
cname
,
signature
,
...
@@ -2495,7 +2495,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -2495,7 +2495,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
cname
=
entry
.
cname
cname
=
entry
.
cname
else
:
else
:
cname
=
module
.
mangle
(
Naming
.
varptr_prefix
,
entry
.
name
)
cname
=
module
.
mangle
(
Naming
.
varptr_prefix
,
entry
.
name
)
signature
=
entry
.
type
.
declaration_code
(
""
)
signature
=
entry
.
type
.
empty_declaration_code
(
)
code
.
putln
(
code
.
putln
(
'if (__Pyx_ImportVoidPtr(%s, "%s", (void **)&%s, "%s") < 0) %s'
%
(
'if (__Pyx_ImportVoidPtr(%s, "%s", (void **)&%s, "%s") < 0) %s'
%
(
temp
,
entry
.
name
,
cname
,
signature
,
temp
,
entry
.
name
,
cname
,
signature
,
...
...
Cython/Compiler/Nodes.py
View file @
bcc15b5d
...
@@ -805,7 +805,7 @@ class CArgDeclNode(Node):
...
@@ -805,7 +805,7 @@ class CArgDeclNode(Node):
if
self
.
base_type
.
is_basic_c_type
:
if
self
.
base_type
.
is_basic_c_type
:
# char, short, long called "int"
# char, short, long called "int"
type
=
self
.
base_type
.
analyse
(
env
,
could_be_name
=
True
)
type
=
self
.
base_type
.
analyse
(
env
,
could_be_name
=
True
)
arg_name
=
type
.
declaration_code
(
""
)
arg_name
=
type
.
empty_declaration_code
(
)
else
:
else
:
arg_name
=
self
.
base_type
.
name
arg_name
=
self
.
base_type
.
name
self
.
declarator
.
name
=
EncodedString
(
arg_name
)
self
.
declarator
.
name
=
EncodedString
(
arg_name
)
...
@@ -1792,7 +1792,7 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1792,7 +1792,7 @@ class FuncDefNode(StatNode, BlockNode):
slot_func_cname
=
'%s->tp_new'
%
lenv
.
scope_class
.
type
.
typeptr_cname
slot_func_cname
=
'%s->tp_new'
%
lenv
.
scope_class
.
type
.
typeptr_cname
code
.
putln
(
"%s = (%s)%s(%s, %s, NULL);"
%
(
code
.
putln
(
"%s = (%s)%s(%s, %s, NULL);"
%
(
Naming
.
cur_scope_cname
,
Naming
.
cur_scope_cname
,
lenv
.
scope_class
.
type
.
declaration_code
(
''
),
lenv
.
scope_class
.
type
.
empty_declaration_code
(
),
slot_func_cname
,
slot_func_cname
,
lenv
.
scope_class
.
type
.
typeptr_cname
,
lenv
.
scope_class
.
type
.
typeptr_cname
,
Naming
.
empty_tuple
))
Naming
.
empty_tuple
))
...
@@ -1814,12 +1814,12 @@ class FuncDefNode(StatNode, BlockNode):
...
@@ -1814,12 +1814,12 @@ class FuncDefNode(StatNode, BlockNode):
if
self
.
is_cyfunction
:
if
self
.
is_cyfunction
:
code
.
putln
(
"%s = (%s) __Pyx_CyFunction_GetClosure(%s);"
%
(
code
.
putln
(
"%s = (%s) __Pyx_CyFunction_GetClosure(%s);"
%
(
outer_scope_cname
,
outer_scope_cname
,
cenv
.
scope_class
.
type
.
declaration_code
(
''
),
cenv
.
scope_class
.
type
.
empty_declaration_code
(
),
Naming
.
self_cname
))
Naming
.
self_cname
))
else
:
else
:
code
.
putln
(
"%s = (%s) %s;"
%
(
code
.
putln
(
"%s = (%s) %s;"
%
(
outer_scope_cname
,
outer_scope_cname
,
cenv
.
scope_class
.
type
.
declaration_code
(
''
),
cenv
.
scope_class
.
type
.
empty_declaration_code
(
),
Naming
.
self_cname
))
Naming
.
self_cname
))
if
lenv
.
is_passthrough
:
if
lenv
.
is_passthrough
:
code
.
putln
(
"%s = %s;"
%
(
Naming
.
cur_scope_cname
,
outer_scope_cname
))
code
.
putln
(
"%s = %s;"
%
(
Naming
.
cur_scope_cname
,
outer_scope_cname
))
...
@@ -7804,7 +7804,7 @@ class ParallelStatNode(StatNode, ParallelNode):
...
@@ -7804,7 +7804,7 @@ class ParallelStatNode(StatNode, ParallelNode):
if
not
lastprivate
or
entry
.
type
.
is_pyobject
:
if
not
lastprivate
or
entry
.
type
.
is_pyobject
:
continue
continue
type_decl
=
entry
.
type
.
declaration_code
(
""
)
type_decl
=
entry
.
type
.
empty_declaration_code
(
)
temp_cname
=
"__pyx_parallel_temp%d"
%
temp_count
temp_cname
=
"__pyx_parallel_temp%d"
%
temp_count
private_cname
=
entry
.
cname
private_cname
=
entry
.
cname
...
...
Cython/Compiler/Optimize.py
View file @
bcc15b5d
...
@@ -2593,7 +2593,7 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
...
@@ -2593,7 +2593,7 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
constant_result
=
orig_index_type
.
signed
and
1
or
0
,
constant_result
=
orig_index_type
.
signed
and
1
or
0
,
type
=
PyrexTypes
.
c_int_type
),
type
=
PyrexTypes
.
c_int_type
),
ExprNodes
.
RawCNameExprNode
(
index
.
pos
,
PyrexTypes
.
c_void_type
,
ExprNodes
.
RawCNameExprNode
(
index
.
pos
,
PyrexTypes
.
c_void_type
,
orig_index_type
.
declaration_code
(
""
)),
orig_index_type
.
empty_declaration_code
(
)),
ExprNodes
.
RawCNameExprNode
(
index
.
pos
,
conversion_type
,
convert_func
)],
ExprNodes
.
RawCNameExprNode
(
index
.
pos
,
conversion_type
,
convert_func
)],
may_return_none
=
True
,
may_return_none
=
True
,
is_temp
=
node
.
is_temp
,
is_temp
=
node
.
is_temp
,
...
...
Cython/Compiler/PyrexTypes.py
View file @
bcc15b5d
...
@@ -20,18 +20,24 @@ class BaseType(object):
...
@@ -20,18 +20,24 @@ class BaseType(object):
# List of attribute names of any subtypes
# List of attribute names of any subtypes
subtypes
=
[]
subtypes
=
[]
_empty_declaration
=
None
def
can_coerce_to_pyobject
(
self
,
env
):
def
can_coerce_to_pyobject
(
self
,
env
):
return
False
return
False
def
cast_code
(
self
,
expr_code
):
def
cast_code
(
self
,
expr_code
):
return
"((%s)%s)"
%
(
self
.
declaration_code
(
""
),
expr_code
)
return
"((%s)%s)"
%
(
self
.
empty_declaration_code
(),
expr_code
)
def
empty_declaration_code
(
self
):
if
self
.
_empty_declaration
is
None
:
self
.
_empty_declaration
=
self
.
declaration_code
(
''
)
return
self
.
_empty_declaration
def
specialization_name
(
self
):
def
specialization_name
(
self
):
# This is not entirely robust.
# This is not entirely robust.
safe
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789'
safe
=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789'
all
=
[]
all
=
[]
for
c
in
self
.
declaration_code
(
""
).
replace
(
"unsigned "
,
"unsigned_"
).
replace
(
"long long"
,
"long_long"
).
replace
(
" "
,
"__"
):
for
c
in
self
.
empty_declaration_code
(
).
replace
(
"unsigned "
,
"unsigned_"
).
replace
(
"long long"
,
"long_long"
).
replace
(
" "
,
"__"
):
if
c
in
safe
:
if
c
in
safe
:
all
.
append
(
c
)
all
.
append
(
c
)
else
:
else
:
...
@@ -389,7 +395,7 @@ class CTypedefType(BaseType):
...
@@ -389,7 +395,7 @@ class CTypedefType(BaseType):
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"CIntToPy"
,
"TypeConversion.c"
,
"CIntToPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
declaration_code
(
''
),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(
),
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
return
True
return
True
elif
base_type
.
is_float
:
elif
base_type
.
is_float
:
...
@@ -411,7 +417,7 @@ class CTypedefType(BaseType):
...
@@ -411,7 +417,7 @@ class CTypedefType(BaseType):
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"CIntFromPy"
,
"TypeConversion.c"
,
"CIntFromPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
declaration_code
(
''
),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(
),
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
return
True
return
True
elif
base_type
.
is_float
:
elif
base_type
.
is_float
:
...
@@ -426,7 +432,7 @@ class CTypedefType(BaseType):
...
@@ -426,7 +432,7 @@ class CTypedefType(BaseType):
def
overflow_check_binop
(
self
,
binop
,
env
,
const_rhs
=
False
):
def
overflow_check_binop
(
self
,
binop
,
env
,
const_rhs
=
False
):
env
.
use_utility_code
(
UtilityCode
.
load
(
"Common"
,
"Overflow.c"
))
env
.
use_utility_code
(
UtilityCode
.
load
(
"Common"
,
"Overflow.c"
))
type
=
self
.
declaration_code
(
""
)
type
=
self
.
empty_declaration_code
(
)
name
=
self
.
specialization_name
()
name
=
self
.
specialization_name
()
if
binop
==
"lshift"
:
if
binop
==
"lshift"
:
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
...
@@ -687,7 +693,7 @@ class MemoryViewSliceType(PyrexType):
...
@@ -687,7 +693,7 @@ class MemoryViewSliceType(PyrexType):
buf_flag
=
self
.
flags
,
buf_flag
=
self
.
flags
,
ndim
=
self
.
ndim
,
ndim
=
self
.
ndim
,
axes_specs
=
', '
.
join
(
self
.
axes_to_code
()),
axes_specs
=
', '
.
join
(
self
.
axes_to_code
()),
dtype_typedecl
=
self
.
dtype
.
declaration_code
(
""
),
dtype_typedecl
=
self
.
dtype
.
empty_declaration_code
(
),
struct_nesting_depth
=
self
.
dtype
.
struct_nesting_depth
(),
struct_nesting_depth
=
self
.
dtype
.
struct_nesting_depth
(),
c_or_f_flag
=
c_or_f_flag
,
c_or_f_flag
=
c_or_f_flag
,
funcname
=
funcname
,
funcname
=
funcname
,
...
@@ -737,7 +743,7 @@ class MemoryViewSliceType(PyrexType):
...
@@ -737,7 +743,7 @@ class MemoryViewSliceType(PyrexType):
context
.
update
(
context
.
update
(
to_py_function
=
self
.
dtype
.
to_py_function
,
to_py_function
=
self
.
dtype
.
to_py_function
,
from_py_function
=
self
.
dtype
.
from_py_function
,
from_py_function
=
self
.
dtype
.
from_py_function
,
dtype
=
self
.
dtype
.
declaration_code
(
""
),
dtype
=
self
.
dtype
.
empty_declaration_code
(
),
error_condition
=
error_condition
,
error_condition
=
error_condition
,
)
)
...
@@ -1423,7 +1429,7 @@ class CIntType(CNumericType):
...
@@ -1423,7 +1429,7 @@ class CIntType(CNumericType):
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"CIntToPy"
,
"TypeConversion.c"
,
"CIntToPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
declaration_code
(
''
),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(
),
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
return
True
return
True
...
@@ -1432,7 +1438,7 @@ class CIntType(CNumericType):
...
@@ -1432,7 +1438,7 @@ class CIntType(CNumericType):
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"CIntFromPy"
,
"TypeConversion.c"
,
"CIntFromPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
declaration_code
(
''
),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(
),
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
return
True
return
True
...
@@ -1467,7 +1473,7 @@ class CIntType(CNumericType):
...
@@ -1467,7 +1473,7 @@ class CIntType(CNumericType):
def
overflow_check_binop
(
self
,
binop
,
env
,
const_rhs
=
False
):
def
overflow_check_binop
(
self
,
binop
,
env
,
const_rhs
=
False
):
env
.
use_utility_code
(
UtilityCode
.
load
(
"Common"
,
"Overflow.c"
))
env
.
use_utility_code
(
UtilityCode
.
load
(
"Common"
,
"Overflow.c"
))
type
=
self
.
declaration_code
(
""
)
type
=
self
.
empty_declaration_code
(
)
name
=
self
.
specialization_name
()
name
=
self
.
specialization_name
()
if
binop
==
"lshift"
:
if
binop
==
"lshift"
:
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
...
@@ -1756,7 +1762,7 @@ class CComplexType(CNumericType):
...
@@ -1756,7 +1762,7 @@ class CComplexType(CNumericType):
env
.
use_utility_code
(
env
.
use_utility_code
(
utility_code
.
specialize
(
utility_code
.
specialize
(
self
,
self
,
real_type
=
self
.
real_type
.
declaration_code
(
''
),
real_type
=
self
.
real_type
.
empty_declaration_code
(
),
m
=
self
.
funcsuffix
,
m
=
self
.
funcsuffix
,
is_float
=
self
.
real_type
.
is_float
))
is_float
=
self
.
real_type
.
is_float
))
return
True
return
True
...
@@ -1774,7 +1780,7 @@ class CComplexType(CNumericType):
...
@@ -1774,7 +1780,7 @@ class CComplexType(CNumericType):
env
.
use_utility_code
(
env
.
use_utility_code
(
utility_code
.
specialize
(
utility_code
.
specialize
(
self
,
self
,
real_type
=
self
.
real_type
.
declaration_code
(
''
),
real_type
=
self
.
real_type
.
empty_declaration_code
(
),
m
=
self
.
funcsuffix
,
m
=
self
.
funcsuffix
,
is_float
=
self
.
real_type
.
is_float
))
is_float
=
self
.
real_type
.
is_float
))
self
.
from_py_function
=
"__Pyx_PyComplex_As_"
+
self
.
specialization_name
()
self
.
from_py_function
=
"__Pyx_PyComplex_As_"
+
self
.
specialization_name
()
...
@@ -2549,7 +2555,7 @@ class CFuncType(CType):
...
@@ -2549,7 +2555,7 @@ class CFuncType(CType):
func_name
,
arg_code
,
trailer
)
func_name
,
arg_code
,
trailer
)
def
signature_string
(
self
):
def
signature_string
(
self
):
s
=
self
.
declaration_code
(
""
)
s
=
self
.
empty_declaration_code
(
)
return
s
return
s
def
signature_cast_string
(
self
):
def
signature_cast_string
(
self
):
...
@@ -2828,7 +2834,7 @@ class ToPyStructUtilityCode(object):
...
@@ -2828,7 +2834,7 @@ class ToPyStructUtilityCode(object):
# This is a bit of a hack, we need a forward declaration
# This is a bit of a hack, we need a forward declaration
# due to the way things are ordered in the module...
# due to the way things are ordered in the module...
if
self
.
forward_decl
:
if
self
.
forward_decl
:
proto
.
putln
(
self
.
type
.
declaration_code
(
''
)
+
';'
)
proto
.
putln
(
self
.
type
.
empty_declaration_code
(
)
+
';'
)
proto
.
putln
(
self
.
header
+
";"
)
proto
.
putln
(
self
.
header
+
";"
)
def
inject_tree_and_scope_into
(
self
,
module_node
):
def
inject_tree_and_scope_into
(
self
,
module_node
):
...
@@ -2898,7 +2904,7 @@ class CStructOrUnionType(CType):
...
@@ -2898,7 +2904,7 @@ class CStructOrUnionType(CType):
return
False
return
False
context
=
dict
(
context
=
dict
(
struct_type_decl
=
self
.
declaration_code
(
""
),
struct_type_decl
=
self
.
empty_declaration_code
(
),
var_entries
=
self
.
scope
.
var_entries
,
var_entries
=
self
.
scope
.
var_entries
,
funcname
=
self
.
from_py_function
,
funcname
=
self
.
from_py_function
,
)
)
...
@@ -2955,8 +2961,8 @@ class CStructOrUnionType(CType):
...
@@ -2955,8 +2961,8 @@ class CStructOrUnionType(CType):
if
len
(
fields
)
!=
2
:
return
False
if
len
(
fields
)
!=
2
:
return
False
a
,
b
=
fields
a
,
b
=
fields
return
(
a
.
type
.
is_float
and
b
.
type
.
is_float
and
return
(
a
.
type
.
is_float
and
b
.
type
.
is_float
and
a
.
type
.
declaration_code
(
""
)
==
a
.
type
.
empty_declaration_code
(
)
==
b
.
type
.
declaration_code
(
""
))
b
.
type
.
empty_declaration_code
(
))
def
struct_nesting_depth
(
self
):
def
struct_nesting_depth
(
self
):
child_depths
=
[
x
.
type
.
struct_nesting_depth
()
child_depths
=
[
x
.
type
.
struct_nesting_depth
()
...
@@ -3048,12 +3054,12 @@ class CppClassType(CType):
...
@@ -3048,12 +3054,12 @@ class CppClassType(CType):
except_clause
=
"? %s"
%
except_clause
except_clause
=
"? %s"
%
except_clause
declarations
.
append
(
declarations
.
append
(
" ctypedef %s %s '%s'"
%
(
" ctypedef %s %s '%s'"
%
(
except_type
.
declaration_code
(
""
,
for_display
=
True
),
X
[
ix
],
T
.
declaration_code
(
""
)))
except_type
.
declaration_code
(
""
,
for_display
=
True
),
X
[
ix
],
T
.
empty_declaration_code
(
)))
else
:
else
:
except_clause
=
"*"
except_clause
=
"*"
declarations
.
append
(
declarations
.
append
(
" ctypedef struct %s '%s':
\
n
pass"
%
(
" ctypedef struct %s '%s':
\
n
pass"
%
(
X
[
ix
],
T
.
declaration_code
(
""
)))
X
[
ix
],
T
.
empty_declaration_code
(
)))
declarations
.
append
(
declarations
.
append
(
" cdef %s %s_from_py '%s' (object) except %s"
%
(
" cdef %s %s_from_py '%s' (object) except %s"
%
(
X
[
ix
],
X
[
ix
],
T
.
from_py_function
,
except_clause
))
X
[
ix
],
X
[
ix
],
T
.
from_py_function
,
except_clause
))
...
@@ -3087,7 +3093,7 @@ class CppClassType(CType):
...
@@ -3087,7 +3093,7 @@ class CppClassType(CType):
tags
.
append
(
T
.
specialization_name
())
tags
.
append
(
T
.
specialization_name
())
declarations
.
append
(
declarations
.
append
(
" ctypedef struct %s '%s':
\
n
pass"
%
(
" ctypedef struct %s '%s':
\
n
pass"
%
(
X
[
ix
],
T
.
declaration_code
(
""
)))
X
[
ix
],
T
.
empty_declaration_code
(
)))
declarations
.
append
(
declarations
.
append
(
" cdef object %s_to_py '%s' (%s)"
%
(
" cdef object %s_to_py '%s' (%s)"
%
(
X
[
ix
],
T
.
to_py_function
,
X
[
ix
]))
X
[
ix
],
T
.
to_py_function
,
X
[
ix
]))
...
@@ -3155,7 +3161,7 @@ class CppClassType(CType):
...
@@ -3155,7 +3161,7 @@ class CppClassType(CType):
if
self
==
actual
:
if
self
==
actual
:
return
{}
return
{}
# TODO(robertwb): Actual type equality.
# TODO(robertwb): Actual type equality.
elif
self
.
declaration_code
(
""
)
==
actual
.
template_type
.
declaration_code
(
""
):
elif
self
.
empty_declaration_code
(
)
==
actual
.
template_type
.
declaration_code
(
""
):
return
reduce
(
return
reduce
(
merge_template_deductions
,
merge_template_deductions
,
[
formal_param
.
deduce_template_params
(
actual_param
)
for
(
formal_param
,
actual_param
)
in
zip
(
self
.
templates
,
actual
.
templates
)],
[
formal_param
.
deduce_template_params
(
actual_param
)
for
(
formal_param
,
actual_param
)
in
zip
(
self
.
templates
,
actual
.
templates
)],
...
@@ -3180,7 +3186,7 @@ class CppClassType(CType):
...
@@ -3180,7 +3186,7 @@ class CppClassType(CType):
else
:
else
:
base_code
=
"%s%s"
%
(
self
.
cname
,
templates
)
base_code
=
"%s%s"
%
(
self
.
cname
,
templates
)
if
self
.
namespace
is
not
None
:
if
self
.
namespace
is
not
None
:
base_code
=
"%s::%s"
%
(
self
.
namespace
.
declaration_code
(
''
),
base_code
)
base_code
=
"%s::%s"
%
(
self
.
namespace
.
empty_declaration_code
(
),
base_code
)
base_code
=
public_decl
(
base_code
,
dll_linkage
)
base_code
=
public_decl
(
base_code
,
dll_linkage
)
return
self
.
base_declaration_code
(
base_code
,
entity_code
)
return
self
.
base_declaration_code
(
base_code
,
entity_code
)
...
@@ -3349,7 +3355,7 @@ class CTupleType(CType):
...
@@ -3349,7 +3355,7 @@ class CTupleType(CType):
return
False
return
False
context
=
dict
(
context
=
dict
(
struct_type_decl
=
self
.
declaration_code
(
""
),
struct_type_decl
=
self
.
empty_declaration_code
(
),
components
=
self
.
components
,
components
=
self
.
components
,
funcname
=
self
.
to_py_function
,
funcname
=
self
.
to_py_function
,
size
=
len
(
self
.
components
)
size
=
len
(
self
.
components
)
...
@@ -3372,7 +3378,7 @@ class CTupleType(CType):
...
@@ -3372,7 +3378,7 @@ class CTupleType(CType):
return
False
return
False
context
=
dict
(
context
=
dict
(
struct_type_decl
=
self
.
declaration_code
(
""
),
struct_type_decl
=
self
.
empty_declaration_code
(
),
components
=
self
.
components
,
components
=
self
.
components
,
funcname
=
self
.
from_py_function
,
funcname
=
self
.
from_py_function
,
size
=
len
(
self
.
components
)
size
=
len
(
self
.
components
)
...
@@ -3671,7 +3677,7 @@ def best_match(args, functions, pos=None, env=None):
...
@@ -3671,7 +3677,7 @@ def best_match(args, functions, pos=None, env=None):
from
.Symtab
import
Entry
from
.Symtab
import
Entry
specialization
=
Entry
(
specialization
=
Entry
(
name
=
func
.
name
+
"[%s]"
%
","
.
join
([
str
(
t
)
for
t
in
type_list
]),
name
=
func
.
name
+
"[%s]"
%
","
.
join
([
str
(
t
)
for
t
in
type_list
]),
cname
=
func
.
cname
+
"<%s>"
%
","
.
join
([
t
.
declaration_code
(
""
)
for
t
in
type_list
]),
cname
=
func
.
cname
+
"<%s>"
%
","
.
join
([
t
.
empty_declaration_code
(
)
for
t
in
type_list
]),
type
=
func_type
.
specialize
(
deductions
),
type
=
func_type
.
specialize
(
deductions
),
pos
=
func
.
pos
)
pos
=
func
.
pos
)
candidates
.
append
((
specialization
,
specialization
.
type
))
candidates
.
append
((
specialization
,
specialization
.
type
))
...
@@ -3996,7 +4002,7 @@ def type_list_identifier(types):
...
@@ -3996,7 +4002,7 @@ def type_list_identifier(types):
_type_identifier_cache
=
{}
_type_identifier_cache
=
{}
def
type_identifier
(
type
):
def
type_identifier
(
type
):
decl
=
type
.
declaration_code
(
""
)
decl
=
type
.
empty_declaration_code
(
)
safe
=
_type_identifier_cache
.
get
(
decl
)
safe
=
_type_identifier_cache
.
get
(
decl
)
if
safe
is
None
:
if
safe
is
None
:
safe
=
decl
safe
=
decl
...
...
Cython/Compiler/Symtab.py
View file @
bcc15b5d
...
@@ -2121,7 +2121,7 @@ class CppClassScope(Scope):
...
@@ -2121,7 +2121,7 @@ class CppClassScope(Scope):
entry
.
is_variable
=
1
entry
.
is_variable
=
1
if
type
.
is_cfunction
and
self
.
type
:
if
type
.
is_cfunction
and
self
.
type
:
if
not
self
.
type
.
templates
or
not
any
(
T
.
is_fused
for
T
in
self
.
type
.
templates
):
if
not
self
.
type
.
templates
or
not
any
(
T
.
is_fused
for
T
in
self
.
type
.
templates
):
entry
.
func_cname
=
"%s::%s"
%
(
self
.
type
.
declaration_code
(
""
),
cname
)
entry
.
func_cname
=
"%s::%s"
%
(
self
.
type
.
empty_declaration_code
(
),
cname
)
if
name
!=
"this"
and
(
defining
or
name
!=
"<init>"
):
if
name
!=
"this"
and
(
defining
or
name
!=
"<init>"
):
self
.
var_entries
.
append
(
entry
)
self
.
var_entries
.
append
(
entry
)
if
type
.
is_pyobject
and
not
allow_pyobject
:
if
type
.
is_pyobject
and
not
allow_pyobject
:
...
...
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