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
dbd85bf2
Commit
dbd85bf2
authored
Jan 15, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpp template tests
parent
58955c26
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
1 deletion
+133
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+0
-1
tests/bugs.txt
tests/bugs.txt
+1
-0
tests/run/cpp_nested_templates.pyx
tests/run/cpp_nested_templates.pyx
+31
-0
tests/run/cpp_templates.pyx
tests/run/cpp_templates.pyx
+80
-0
tests/run/cpp_templates_helper.h
tests/run/cpp_templates_helper.h
+21
-0
No files found.
Cython/Compiler/Parsing.py
View file @
dbd85bf2
...
@@ -1900,7 +1900,6 @@ def p_buffer_or_template(s, base_type_node):
...
@@ -1900,7 +1900,6 @@ def p_buffer_or_template(s, base_type_node):
ExprNodes
.
DictItemNode
(
pos
=
key
.
pos
,
key
=
key
,
value
=
value
)
ExprNodes
.
DictItemNode
(
pos
=
key
.
pos
,
key
=
key
,
value
=
value
)
for
key
,
value
in
keyword_args
for
key
,
value
in
keyword_args
])
])
result
=
Nodes
.
TemplatedTypeNode
(
pos
,
result
=
Nodes
.
TemplatedTypeNode
(
pos
,
positional_args
=
positional_args
,
positional_args
=
positional_args
,
keyword_args
=
keyword_dict
,
keyword_args
=
keyword_dict
,
...
...
tests/bugs.txt
View file @
dbd85bf2
...
@@ -9,3 +9,4 @@ missing_baseclass_in_predecl_T262
...
@@ -9,3 +9,4 @@ missing_baseclass_in_predecl_T262
cfunc_call_tuple_args_T408
cfunc_call_tuple_args_T408
ifelseexpr_T267
ifelseexpr_T267
compile.cpp_operators
compile.cpp_operators
cpp_nested_templates
\ No newline at end of file
tests/run/cpp_nested_templates.pyx
0 → 100644
View file @
dbd85bf2
from
cython
import
dereference
as
deref
cdef
extern
from
"cpp_templates_helper.h"
:
cdef
cppclass
Wrap
[
T
]:
Wrap
(
T
)
void
set
(
T
)
T
get
()
bint
operator
==
(
Wrap
[
T
])
cdef
cppclass
Pair
[
T1
,
T2
]:
Pair
(
T1
,
T2
)
T1
first
()
T2
second
()
bint
operator
==
(
Pair
[
T1
,
T2
])
bint
operator
!=
(
Pair
[
T1
,
T2
])
def
test_wrap_pair
(
int
i
,
double
x
):
"""
>>> test_wrap_pair(1, 1.5)
(1, 1.5, True, False)
>>> test_wrap_pair(2, 2.25)
(2, 2.25, True, False)
"""
cdef
Pair
[
int
,
double
]
*
pair
cdef
Wrap
[
Pair
[
int
,
double
]]
*
wrap
try
:
pair
=
new
Pair
[
int
,
double
](
i
,
x
)
warp
=
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.pyx
0 → 100644
View file @
dbd85bf2
from
cython
import
dereference
as
deref
cdef
extern
from
"cpp_templates_helper.h"
:
cdef
cppclass
Wrap
[
T
]:
Wrap
(
T
)
void
set
(
T
)
T
get
()
bint
operator
==
(
Wrap
[
T
])
cdef
cppclass
Pair
[
T1
,
T2
]:
Pair
(
T1
,
T2
)
T1
first
()
T2
second
()
bint
operator
==
(
Pair
[
T1
,
T2
])
bint
operator
!=
(
Pair
[
T1
,
T2
])
def
test_int
(
int
x
,
int
y
):
"""
>>> test_int(3, 4)
(3, 4, False)
>>> test_int(100, 100)
(100, 100, True)
"""
cdef
Wrap
[
int
]
*
a
,
*
b
try
:
a
=
new
Wrap
[
int
](
x
)
b
=
new
Wrap
[
int
](
0
)
b
.
set
(
y
)
return
a
.
get
(),
b
.
get
(),
a
[
0
]
==
b
[
0
]
finally
:
del
a
,
b
def
test_double
(
double
x
,
double
y
):
"""
>>> test_double(3, 3.5)
(3.0, 3.5, False)
>>> test_double(100, 100)
(100.0, 100.0, True)
"""
cdef
Wrap
[
double
]
*
a
,
*
b
try
:
a
=
new
Wrap
[
double
](
x
)
b
=
new
Wrap
[
double
](
-
1
)
b
.
set
(
y
)
return
a
.
get
(),
b
.
get
(),
deref
(
a
)
==
deref
(
b
)
finally
:
del
a
,
b
def
test_pair
(
int
i
,
double
x
):
"""
>>> test_pair(1, 1.5)
(1, 1.5, True, False)
>>> test_pair(2, 2.25)
(2, 2.25, True, False)
"""
cdef
Pair
[
int
,
double
]
*
pair
try
:
pair
=
new
Pair
[
int
,
double
](
i
,
x
)
return
pair
.
first
(),
pair
.
second
(),
deref
(
pair
)
==
deref
(
pair
),
deref
(
pair
)
!=
deref
(
pair
)
finally
:
del
pair
def
test_wrap_pair
(
int
i
,
double
x
):
"""
>>> test_wrap_pair(1, 1.5)
(1, 1.5, True, False)
>>> test_wrap_pair(2, 2.25)
(2, 2.25, True, False)
"""
cdef
Pair
[
int
,
double
]
*
pair
cdef
Wrap
[
Pair
[
int
,
double
]]
*
wrap
try
:
pair
=
new
Pair
[
int
,
double
](
i
,
x
)
warp
=
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
0 → 100644
View file @
dbd85bf2
template
<
class
T
>
class
Wrap
{
T
value
;
public:
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
;
}
};
template
<
class
T1
,
class
T2
>
class
Pair
{
T1
_first
;
T2
_second
;
public:
Pair
(
T1
u
,
T2
v
)
{
_first
=
u
;
_second
=
v
;
}
T1
first
(
void
)
{
return
_first
;
}
T2
second
(
void
)
{
return
_second
;
}
bool
operator
==
(
Pair
<
T1
,
T2
>
other
)
{
return
_first
==
other
.
_first
&&
_second
==
other
.
_second
;
}
bool
operator
!=
(
Pair
<
T1
,
T2
>
other
)
{
return
_first
!=
other
.
_first
||
_second
!=
other
.
_second
;
}
};
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