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
468cc9c1
Commit
468cc9c1
authored
Oct 12, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wrapping of pointer types.
Of course it's "cdef char *foo()" not "cdef char* foo()"
parent
1cd370dc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
7 deletions
+22
-7
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-6
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+4
-1
tests/run/cpdef_extern_func.pxd
tests/run/cpdef_extern_func.pxd
+3
-0
tests/run/cpdef_extern_func.pyx
tests/run/cpdef_extern_func.pyx
+10
-0
No files found.
Cython/Compiler/Nodes.py
View file @
468cc9c1
...
@@ -1271,13 +1271,12 @@ class CVarDefNode(StatNode):
...
@@ -1271,13 +1271,12 @@ class CVarDefNode(StatNode):
"Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). "
+
"Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). "
+
"Each pointer declaration should be on its own line."
,
1
)
"Each pointer declaration should be on its own line."
,
1
)
create_extern_wrapper
=
False
create_extern_wrapper
=
(
self
.
overridable
and
self
.
visibility
==
'extern'
and
env
.
is_module_scope
)
if
create_extern_wrapper
:
declarator
.
overridable
=
False
if
isinstance
(
declarator
,
CFuncDeclaratorNode
):
if
isinstance
(
declarator
,
CFuncDeclaratorNode
):
create_extern_wrapper
=
(
self
.
overridable
and
self
.
visibility
==
'extern'
and
env
.
is_module_scope
)
if
create_extern_wrapper
:
declarator
.
overridable
=
False
name_declarator
,
type
=
declarator
.
analyse
(
base_type
,
env
,
directive_locals
=
self
.
directive_locals
)
name_declarator
,
type
=
declarator
.
analyse
(
base_type
,
env
,
directive_locals
=
self
.
directive_locals
)
else
:
else
:
name_declarator
,
type
=
declarator
.
analyse
(
base_type
,
env
)
name_declarator
,
type
=
declarator
.
analyse
(
base_type
,
env
)
...
...
Cython/Compiler/PyrexTypes.py
View file @
468cc9c1
...
@@ -1236,7 +1236,10 @@ class CConstType(BaseType):
...
@@ -1236,7 +1236,10 @@ class CConstType(BaseType):
def
declaration_code
(
self
,
entity_code
,
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
return
self
.
const_base_type
.
declaration_code
(
"const %s"
%
entity_code
,
for_display
,
dll_linkage
,
pyrex
)
if
for_display
or
pyrex
:
return
"const "
+
self
.
const_base_type
.
declaration_code
(
entity_code
,
for_display
,
dll_linkage
,
pyrex
)
else
:
return
self
.
const_base_type
.
declaration_code
(
"const %s"
%
entity_code
,
for_display
,
dll_linkage
,
pyrex
)
def
specialize
(
self
,
values
):
def
specialize
(
self
,
values
):
base_type
=
self
.
const_base_type
.
specialize
(
values
)
base_type
=
self
.
const_base_type
.
specialize
(
values
)
...
...
tests/run/cpdef_extern_func.pxd
View file @
468cc9c1
# cython: c_string_type=str
# cython: c_string_encoding=ascii
cdef
extern
from
"math.h"
:
cdef
extern
from
"math.h"
:
cpdef
double
pxd_sqrt
"sqrt"
(
double
)
cpdef
double
pxd_sqrt
"sqrt"
(
double
)
tests/run/cpdef_extern_func.pyx
View file @
468cc9c1
# cython: c_string_type=str
# cython: c_string_encoding=ascii
__doc__
=
"""
__doc__
=
"""
>>> sqrt(1)
>>> sqrt(1)
1.0
1.0
...
@@ -7,10 +10,17 @@ __doc__ = """
...
@@ -7,10 +10,17 @@ __doc__ = """
3.0
3.0
>>> log(10)
>>> log(10)
Traceback (most recent call last):
Traceback (most recent call last):
...
NameError: name 'log' is not defined
NameError: name 'log' is not defined
>>> strchr('abcabc', ord('c'))
'cabc'
"""
"""
cdef
extern
from
"math.h"
:
cdef
extern
from
"math.h"
:
cpdef
double
sqrt
(
double
)
cpdef
double
sqrt
(
double
)
cpdef
double
pyx_sqrt
"sqrt"
(
double
)
cpdef
double
pyx_sqrt
"sqrt"
(
double
)
cdef
double
log
(
double
)
# not wrapped
cdef
double
log
(
double
)
# not wrapped
cdef
extern
from
"string.h"
:
cpdef
char
*
strchr
(
const
char
*
haystack
,
int
needle
);
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