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
Kirill Smelkov
cython
Commits
40f879db
Commit
40f879db
authored
Nov 18, 2014
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added reference tracking to template arguments. Not fully tested, complete solution to ticket #838.
parent
5284bb23
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
12 deletions
+17
-12
Cython/Compiler/DebugFlags.py
Cython/Compiler/DebugFlags.py
+1
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-2
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+12
-7
No files found.
Cython/Compiler/DebugFlags.py
View file @
40f879db
# Can be enabled at the command line with --debug-xxx.
debug_disposal_code
=
0
debug_temp_alloc
=
0
debug_temp_alloc
=
1
debug_coercion
=
0
# Write comments into the C code that show where temporary variables
...
...
Cython/Compiler/Nodes.py
View file @
40f879db
...
...
@@ -1110,7 +1110,7 @@ class TemplatedTypeNode(CBaseTypeNode):
error
(
template_node
.
pos
,
"unknown type in template argument"
)
return
error_type
template_types
.
append
(
type
)
self
.
type
=
base_type
.
specialize_here
(
self
.
pos
,
template_types
)
self
.
type
=
base_type
.
specialize_here
(
self
.
pos
,
template_types
,
is_reference
=
self
.
is_reference
)
elif
base_type
.
is_pyobject
:
# Buffer
...
...
@@ -2821,7 +2821,6 @@ class DefNode(FuncDefNode):
error
(
arg
.
pos
,
"Only Python type arguments can have 'not None'"
)
if
arg
.
or_none
:
error
(
arg
.
pos
,
"Only Python type arguments can have 'or None'"
)
env
.
fused_to_specific
=
f2s
def
analyse_signature
(
self
,
env
):
...
...
Cython/Compiler/Parsing.py
View file @
40f879db
...
...
@@ -2168,7 +2168,8 @@ def p_buffer_or_template(s, base_type_node, templates):
result
=
Nodes
.
TemplatedTypeNode
(
pos
,
positional_args
=
positional_args
,
keyword_args
=
keyword_dict
,
base_type_node
=
base_type_node
)
base_type_node
=
base_type_node
,
is_reference
=
(
s
.
sy
==
'&'
))
return
result
def
p_bracketed_base_type
(
s
,
base_type_node
,
nonempty
,
empty
):
...
...
Cython/Compiler/PyrexTypes.py
View file @
40f879db
...
...
@@ -12,7 +12,7 @@ from .Code import UtilityCode, LazyUtilityCode, TempitaUtilityCode
from
.
import
StringEncoding
from
.
import
Naming
from
.Errors
import
error
from
.Errors
import
error
,
warning
class
BaseType
(
object
):
...
...
@@ -3217,7 +3217,7 @@ class CppClassType(CType):
subtypes
=
[
'templates'
]
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
):
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
,
is_reference
=
False
):
self
.
name
=
name
self
.
cname
=
cname
self
.
scope
=
scope
...
...
@@ -3227,6 +3227,7 @@ class CppClassType(CType):
self
.
template_type
=
template_type
self
.
specializations
=
{}
self
.
is_cpp_string
=
cname
in
cpp_string_conversions
self
.
is_reference
=
is_reference
def
use_conversion_utility
(
self
,
from_or_to
):
pass
...
...
@@ -3286,6 +3287,10 @@ class CppClassType(CType):
tags
=
type_identifier
(
self
),
else
:
cls
=
self
.
cname
[
5
:]
if
self
.
is_reference
:
warning
(
"dwqkokw"
,
-
1
)
print
"warned"
cname
=
'__pyx_convert_%s_from_py_%s'
%
(
cls
,
'__and_'
.
join
(
tags
))
context
=
{
'template_type_declarations'
:
'
\
n
'
.
join
(
declarations
),
...
...
@@ -3350,7 +3355,7 @@ class CppClassType(CType):
T
.
get_fused_types
(
result
,
seen
)
return
result
def
specialize_here
(
self
,
pos
,
template_values
=
None
):
def
specialize_here
(
self
,
pos
,
template_values
=
None
,
is_reference
=
False
):
if
not
self
.
is_template_type
():
error
(
pos
,
"'%s' type is not a template"
%
self
)
return
error_type
...
...
@@ -3366,19 +3371,19 @@ class CppClassType(CType):
"Python object type '%s' cannot be used as a template argument"
%
value
)
if
has_object_template_param
:
return
error_type
return
self
.
specialize
(
dict
(
zip
(
self
.
templates
,
template_values
)))
return
self
.
specialize
(
dict
(
zip
(
self
.
templates
,
template_values
))
,
is_reference
)
def
specialize
(
self
,
values
):
def
specialize
(
self
,
values
,
is_reference
=
False
):
if
not
self
.
templates
and
not
self
.
namespace
:
return
self
if
self
.
templates
is
None
:
self
.
templates
=
[]
key
=
tuple
(
values
.
items
()
)
key
=
tuple
(
values
.
items
()
+
[
is_reference
])
# Python 3?
if
key
in
self
.
specializations
:
return
self
.
specializations
[
key
]
template_values
=
[
t
.
specialize
(
values
)
for
t
in
self
.
templates
]
specialized
=
self
.
specializations
[
key
]
=
\
CppClassType
(
self
.
name
,
None
,
self
.
cname
,
[],
template_values
,
template_type
=
self
)
CppClassType
(
self
.
name
,
None
,
self
.
cname
,
[],
template_values
,
template_type
=
self
,
is_reference
=
is_reference
)
# Need to do these *after* self.specializations[key] is set
# to avoid infinite recursion on circular references.
specialized
.
base_classes
=
[
b
.
specialize
(
values
)
for
b
in
self
.
base_classes
]
...
...
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