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
5b2f63ca
Commit
5b2f63ca
authored
Jan 14, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C++ templating fixes.
parent
bd9e529d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+13
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+8
-3
No files found.
Cython/Compiler/Nodes.py
View file @
5b2f63ca
...
...
@@ -477,6 +477,19 @@ class CArrayDeclaratorNode(CDeclaratorNode):
child_attrs
=
[
"base"
,
"dimension"
]
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
if
base_type
.
is_cpp_class
:
from
ExprNodes
import
TupleNode
if
isinstance
(
self
.
dimension
,
TupleNode
):
args
=
self
.
dimension
.
args
else
:
args
=
self
.
dimension
,
values
=
[
v
.
analyse_as_type
(
env
)
for
v
in
args
]
if
None
in
values
:
ix
=
values
.
index
(
None
)
error
(
args
[
ix
].
pos
,
"Template parameter not a type."
)
return
error_type
base_type
=
base_type
.
specialize_here
(
self
.
pos
,
values
)
return
self
.
base
.
analyse
(
base_type
,
env
,
nonempty
=
nonempty
)
if
self
.
dimension
:
self
.
dimension
.
analyse_const_expression
(
env
)
if
not
self
.
dimension
.
type
.
is_int
:
...
...
Cython/Compiler/PyrexTypes.py
View file @
5b2f63ca
...
...
@@ -1832,6 +1832,7 @@ class CppClassType(CType):
self
.
operators
=
[]
self
.
templates
=
templates
self
.
template_type
=
template_type
self
.
specializations
=
{}
def
specialize_here
(
self
,
pos
,
template_values
=
None
):
if
self
.
templates
is
None
:
...
...
@@ -1844,10 +1845,14 @@ class CppClassType(CType):
return
self
.
specialize
(
dict
(
zip
(
self
.
templates
,
template_values
)))
def
specialize
(
self
,
values
):
# TODO(danilo): Cache for efficiency.
key
=
tuple
(
values
.
items
())
if
key
in
self
.
specializations
:
return
self
.
specializations
[
key
]
template_values
=
[
t
.
specialize
(
values
)
for
t
in
self
.
templates
]
return
CppClassType
(
self
.
name
,
self
.
scope
.
specialize
(
values
),
self
.
cname
,
self
.
base_classes
,
template_values
,
template_type
=
self
)
specialized
=
self
.
specializations
[
key
]
=
\
CppClassType
(
self
.
name
,
None
,
self
.
cname
,
self
.
base_classes
,
template_values
,
template_type
=
self
)
specialized
.
scope
=
self
.
scope
.
specialize
(
values
)
return
specialized
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
if
self
.
templates
:
...
...
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