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
c492bab6
Commit
c492bab6
authored
8 years ago
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect function template parameters through pointers and references.
Fixes #1541
parent
ba006541
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+6
-0
tests/run/cpp_template_functions.pyx
tests/run/cpp_template_functions.pyx
+8
-0
tests/run/cpp_template_functions_helper.h
tests/run/cpp_template_functions_helper.h
+5
-0
No files found.
Cython/Compiler/Nodes.py
View file @
c492bab6
...
@@ -545,6 +545,9 @@ class CPtrDeclaratorNode(CDeclaratorNode):
...
@@ -545,6 +545,9 @@ class CPtrDeclaratorNode(CDeclaratorNode):
child_attrs
=
[
"base"
]
child_attrs
=
[
"base"
]
def
analyse_templates
(
self
):
return
self
.
base
.
analyse_templates
()
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
if
base_type
.
is_pyobject
:
if
base_type
.
is_pyobject
:
error
(
self
.
pos
,
"Pointer base type cannot be a Python object"
)
error
(
self
.
pos
,
"Pointer base type cannot be a Python object"
)
...
@@ -557,6 +560,9 @@ class CReferenceDeclaratorNode(CDeclaratorNode):
...
@@ -557,6 +560,9 @@ class CReferenceDeclaratorNode(CDeclaratorNode):
child_attrs
=
[
"base"
]
child_attrs
=
[
"base"
]
def
analyse_templates
(
self
):
return
self
.
base
.
analyse_templates
()
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
if
base_type
.
is_pyobject
:
if
base_type
.
is_pyobject
:
error
(
self
.
pos
,
"Reference base type cannot be a Python object"
)
error
(
self
.
pos
,
"Reference base type cannot be a Python object"
)
...
...
This diff is collapsed.
Click to expand it.
tests/run/cpp_template_functions.pyx
View file @
c492bab6
...
@@ -10,6 +10,7 @@ cdef extern from "cpp_template_functions_helper.h":
...
@@ -10,6 +10,7 @@ cdef extern from "cpp_template_functions_helper.h":
pair
[
T
,
U
]
method
[
U
](
T
,
U
)
pair
[
T
,
U
]
method
[
U
](
T
,
U
)
cdef
T
nested_deduction
[
T
](
const
T
*
)
cdef
T
nested_deduction
[
T
](
const
T
*
)
pair
[
T
,
U
]
pair_arg
[
T
,
U
](
pair
[
T
,
U
]
a
)
pair
[
T
,
U
]
pair_arg
[
T
,
U
](
pair
[
T
,
U
]
a
)
cdef
T
*
pointer_param
[
T
](
T
*
)
def
test_no_arg
():
def
test_no_arg
():
"""
"""
...
@@ -63,3 +64,10 @@ def test_class_deductions(pair[long, double] x):
...
@@ -63,3 +64,10 @@ def test_class_deductions(pair[long, double] x):
"""
"""
return
pair_arg
(
x
)
return
pair_arg
(
x
)
def
test_deduce_through_pointers
(
int
k
):
"""
>>> test_deduce_through_pointers(5)
(5, 5.0)
"""
cdef
double
x
=
k
return
pointer_param
(
&
k
)[
0
],
pointer_param
(
&
x
)[
0
]
This diff is collapsed.
Click to expand it.
tests/run/cpp_template_functions_helper.h
View file @
c492bab6
...
@@ -31,3 +31,8 @@ template <typename T, typename U>
...
@@ -31,3 +31,8 @@ template <typename T, typename U>
std
::
pair
<
T
,
U
>
pair_arg
(
std
::
pair
<
T
,
U
>
a
)
{
std
::
pair
<
T
,
U
>
pair_arg
(
std
::
pair
<
T
,
U
>
a
)
{
return
a
;
return
a
;
}
}
template
<
typename
T
>
T
*
pointer_param
(
T
*
param
)
{
return
param
;
}
This diff is collapsed.
Click to expand it.
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