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
6501e274
Commit
6501e274
authored
Oct 14, 2017
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow pure python annotations in type declarations.
Related to #1838.
parent
131f7fd0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+7
-2
tests/run/cpp_templates.pyx
tests/run/cpp_templates.pyx
+14
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
6501e274
...
...
@@ -632,7 +632,7 @@ class TrackNumpyAttributes(VisitorTransform, SkipDeclarations):
visit_Node
=
VisitorTransform
.
recurse_to_children
class
InterpretCompilerDirectives
(
CythonTransform
,
SkipDeclarations
):
class
InterpretCompilerDirectives
(
CythonTransform
):
"""
After parsing, directives can be stored in a number of places:
- #cython-comments at the top of the file (stored in ModuleNode)
...
...
@@ -857,6 +857,11 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
node
.
cython_attribute
=
directive
return
node
def
visit_NewExprNode
(
self
,
node
):
self
.
visit
(
node
.
cppclass
)
self
.
visitchildren
(
node
)
return
node
def
try_to_parse_directives
(
self
,
node
):
# If node is the contents of an directive (in a with statement or
# decorator), returns a list of (directivename, value) pairs.
...
...
@@ -987,7 +992,7 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
def
visit_CVarDefNode
(
self
,
node
):
directives
=
self
.
_extract_directives
(
node
,
'function'
)
if
not
directives
:
return
node
return
self
.
visit_Node
(
node
)
for
name
,
value
in
directives
.
items
():
if
name
==
'locals'
:
node
.
directive_locals
=
value
...
...
tests/run/cpp_templates.pyx
View file @
6501e274
# tag: cpp
cimport
cython
from
cython.operator
import
dereference
as
deref
cdef
extern
from
"cpp_templates_helper.h"
:
...
...
@@ -148,3 +149,16 @@ def test_static(x):
(1, 1.5)
"""
return
Div
[
int
].
half
(
x
),
Div
[
double
].
half
(
x
)
def
test_pure_syntax
(
int
i
):
"""
>>> test_ptr(3)
3
>>> test_ptr(5)
5
"""
try
:
w
=
new
Wrap
[
cython
.
pointer
(
int
)](
&
i
)
return
deref
(
w
.
get
())
finally
:
del
w
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