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
Boxiang Sun
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
Expand all
Show 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
This diff is collapsed.
Click to expand it.
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