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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
736b910d
Commit
736b910d
authored
Feb 10, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for nested templates.
parent
ca6c6743
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
9 deletions
+12
-9
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
tests/bugs.txt
tests/bugs.txt
+0
-1
tests/run/cpp_nested_templates.pyx
tests/run/cpp_nested_templates.pyx
+4
-4
tests/run/cpp_templates_helper.h
tests/run/cpp_templates_helper.h
+1
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
736b910d
...
...
@@ -1048,7 +1048,7 @@ class NewExprNode(AtomicExprNode):
# cppclass string c++ class to create
# template_parameters None or [ExprNode] temlate parameters, if any
def
analyse_types
(
self
,
env
):
def
infer_type
(
self
,
env
):
entry
=
env
.
lookup
(
self
.
cppclass
)
if
entry
is
None
or
not
entry
.
is_cpp_class
:
error
(
self
.
pos
,
"new operator can only be applied to a C++ class"
)
...
...
@@ -1068,6 +1068,10 @@ class NewExprNode(AtomicExprNode):
self
.
class_type
=
type
self
.
entry
=
constructor
self
.
type
=
constructor
.
type
return
self
.
type
def
analyse_types
(
self
,
env
):
self
.
infer_type
(
env
)
def
generate_result_code
(
self
,
code
):
pass
...
...
@@ -1803,7 +1807,7 @@ class IndexNode(ExprNode):
base_type
=
self
.
base
.
analyse_as_type
(
env
)
if
base_type
and
not
base_type
.
is_pyobject
:
if
base_type
.
is_cpp_class
:
if
isinstance
(
self
.
index
,
Tuple
Expr
Node
):
if
isinstance
(
self
.
index
,
TupleNode
):
template_values
=
self
.
index
.
args
else
:
template_values
=
[
self
.
index
]
...
...
Cython/Compiler/Nodes.py
View file @
736b910d
...
...
@@ -792,7 +792,7 @@ class TemplatedTypeNode(CBaseTypeNode):
if
base_type
.
is_cpp_class
:
# Templated class
if
len
(
self
.
keyword_args
.
key_value_pairs
)
!=
0
:
if
self
.
keyword_args
and
self
.
keyword_args
.
key_value_pairs
:
error
(
self
.
pos
,
"c++ templates cannot take keyword arguments"
);
self
.
type
=
PyrexTypes
.
error_type
else
:
...
...
tests/bugs.txt
View file @
736b910d
...
...
@@ -9,6 +9,5 @@ missing_baseclass_in_predecl_T262
cfunc_call_tuple_args_T408
cascaded_list_unpacking_T467
compile.cpp_operators
cpp_nested_templates
cppwrap
cpp_overload_wrapper
tests/run/cpp_nested_templates.pyx
View file @
736b910d
from
cython
import
dereference
as
deref
from
cython
.operator
c
import
dereference
as
deref
cdef
extern
from
"cpp_templates_helper.h"
:
cdef
cppclass
Wrap
[
T
]:
...
...
@@ -17,15 +17,15 @@ cdef extern from "cpp_templates_helper.h":
def
test_wrap_pair
(
int
i
,
double
x
):
"""
>>> test_wrap_pair(1, 1.5)
(1, 1.5, True
, False
)
(1, 1.5, True)
>>> test_wrap_pair(2, 2.25)
(2, 2.25, True
, False
)
(2, 2.25, True)
"""
cdef
Pair
[
int
,
double
]
*
pair
cdef
Wrap
[
Pair
[
int
,
double
]]
*
wrap
try
:
pair
=
new
Pair
[
int
,
double
](
i
,
x
)
w
ar
p
=
new
Wrap
[
Pair
[
int
,
double
]](
deref
(
pair
))
w
ra
p
=
new
Wrap
[
Pair
[
int
,
double
]](
deref
(
pair
))
return
wrap
.
get
().
first
(),
wrap
.
get
().
second
(),
deref
(
wrap
)
==
deref
(
wrap
)
finally
:
del
pair
,
wrap
tests/run/cpp_templates_helper.h
View file @
736b910d
...
...
@@ -2,7 +2,7 @@ template <class T>
class
Wrap
{
T
value
;
public:
Wrap
(
T
v
)
{
value
=
v
;
}
Wrap
(
T
v
)
:
value
(
v
)
{
}
void
set
(
T
v
)
{
value
=
v
;
}
T
get
(
void
)
{
return
value
;
}
bool
operator
==
(
Wrap
<
T
>
other
)
{
return
value
==
other
.
value
;
}
...
...
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