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
Gwenaël Samain
cython
Commits
906bbedc
Commit
906bbedc
authored
Jul 23, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix modifiers of functions with overrides in external .pxd files
parent
ffe34c3a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
23 deletions
+45
-23
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+9
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+11
-18
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-5
tests/run/external_inline_declaration.srctree
tests/run/external_inline_declaration.srctree
+24
-0
No files found.
Cython/Compiler/Code.py
View file @
906bbedc
...
...
@@ -46,6 +46,10 @@ uncachable_builtins = [
'WindowsError'
,
]
modifier_output_mapper
=
{
'inline'
:
'CYTHON_INLINE'
}.
get
def
get_utility_dir
():
# make this a function and not global variables:
# http://trac.cython.org/cython_trac/ticket/475
...
...
@@ -1566,6 +1570,11 @@ class CCodeWriter(object):
else
:
return
cond
def
build_function_modifiers
(
self
,
modifiers
,
mapper
=
modifier_output_mapper
):
if
not
modifiers
:
return
''
return
'%s '
%
' '
.
join
([
mapper
(
m
,
m
)
for
m
in
modifiers
])
# Python objects and reference counting
def
entry_as_pyobject
(
self
,
entry
):
...
...
Cython/Compiler/ModuleNode.py
View file @
906bbedc
...
...
@@ -811,12 +811,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
not
method_entry
.
is_inherited
and
method_entry
.
final_func_cname
:
declaration
=
method_entry
.
type
.
declaration_code
(
method_entry
.
final_func_cname
)
if
method_entry
.
func_modifiers
:
modifiers
=
" %s "
%
' '
.
join
(
method_entry
.
func_modifiers
).
upper
()
modifiers
=
modifiers
.
replace
(
" INLINE "
,
" CYTHON_INLINE "
)
else
:
modifiers
=
" "
code
.
putln
(
"static%s%s;"
%
(
modifiers
,
declaration
))
modifiers
=
code
.
build_function_modifiers
(
method_entry
.
func_modifiers
)
code
.
putln
(
"static %s%s;"
%
(
modifiers
,
declaration
))
def
generate_objstruct_predeclaration
(
self
,
type
,
code
):
if
not
type
.
scope
:
...
...
@@ -2336,31 +2332,28 @@ def generate_cfunction_declaration(entry, env, code, definition):
if
entry
.
used
and
entry
.
inline_func_in_pxd
or
(
not
entry
.
in_cinclude
and
(
definition
or
entry
.
defined_in_pxd
or
entry
.
visibility
==
'extern'
or
from_cy_utility
)):
if
entry
.
visibility
==
'extern'
:
storage_class
=
"%s "
%
Naming
.
extern_c_macro
storage_class
=
Naming
.
extern_c_macro
dll_linkage
=
"DL_IMPORT"
elif
entry
.
visibility
==
'public'
:
storage_class
=
"%s "
%
Naming
.
extern_c_macro
storage_class
=
Naming
.
extern_c_macro
dll_linkage
=
"DL_EXPORT"
elif
entry
.
visibility
==
'private'
:
storage_class
=
"static
"
storage_class
=
"static"
dll_linkage
=
None
else
:
storage_class
=
"static
"
storage_class
=
"static"
dll_linkage
=
None
type
=
entry
.
type
if
entry
.
defined_in_pxd
and
not
definition
:
storage_class
=
"static
"
storage_class
=
"static"
dll_linkage
=
None
type
=
CPtrType
(
type
)
header
=
type
.
declaration_code
(
entry
.
cname
,
dll_linkage
=
dll_linkage
)
if
entry
.
func_modifiers
:
modifiers
=
"%s "
%
' '
.
join
(
entry
.
func_modifiers
).
upper
()
else
:
modifiers
=
''
code
.
putln
(
"%s%s%s; /*proto*/"
%
(
header
=
type
.
declaration_code
(
entry
.
cname
,
dll_linkage
=
dll_linkage
)
modifiers
=
code
.
build_function_modifiers
(
entry
.
func_modifiers
)
code
.
putln
(
"%s %s%s; /*proto*/"
%
(
storage_class
,
modifiers
,
header
))
...
...
Cython/Compiler/Nodes.py
View file @
906bbedc
...
...
@@ -2135,11 +2135,7 @@ class CFuncDefNode(FuncDefNode):
else
:
storage_class
=
""
dll_linkage
=
None
modifiers
=
""
if
'inline'
in
self
.
modifiers
:
self
.
modifiers
[
self
.
modifiers
.
index
(
'inline'
)]
=
'cython_inline'
if
self
.
modifiers
:
modifiers
=
"%s "
%
' '
.
join
(
self
.
modifiers
).
upper
()
modifiers
=
code
.
build_function_modifiers
(
self
.
entry
.
func_modifiers
)
header
=
self
.
return_type
.
declaration_code
(
entity
,
dll_linkage
=
dll_linkage
)
#print (storage_class, modifiers, header)
...
...
tests/run/external_inline_declaration.srctree
0 → 100644
View file @
906bbedc
PYTHON setup.py build_ext --inplace
PYTHON -c "import a; assert a.test() == 1"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize("a.py"),
)
######## a.py ########
def inlined_func(x):
return x
def test():
return inlined_func(1)
######## a.pxd ########
cdef inline int inlined_func(int 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