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
fee03687
Commit
fee03687
authored
Aug 15, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix templating, actually works
parent
c599ab4b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+15
-6
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+7
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+1
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+1
-0
Cython/Includes/python_ref.pxd
Cython/Includes/python_ref.pxd
+2
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
fee03687
...
...
@@ -1078,19 +1078,28 @@ class ImagNode(AtomicNewTempExprNode):
class
NewExprNode
(
AtomicExprNode
):
# C++ new statement
#
# cppclass string c++ class to create
# template_parameters None or [ExprNode] temlate parameters, if any
def
analyse_types
(
self
,
env
):
print
self
.
cppclass
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"
)
return
if
self
.
template_parameters
is
not
None
:
template_types
=
[
v
.
analyse_as_type
(
env
)
for
v
in
self
.
template_parameters
]
type
=
entry
.
type
.
specialize_here
(
self
.
pos
,
template_types
)
else
:
type
=
entry
.
type
constructor
=
entry
.
type
.
scope
.
lookup
(
u'__init__'
)
constructor
=
type
.
scope
.
lookup
(
u'__init__'
)
if
constructor
is
None
:
print
"no constructor declared"
# create one
self
.
class_
entry
=
entry
#
TODO(danilo):
create one
self
.
class_
type
=
type
self
.
entry
=
constructor
self
.
type
=
constructor
.
type
...
...
@@ -1098,7 +1107,7 @@ class NewExprNode(AtomicExprNode):
pass
def
calculate_result_code
(
self
):
return
"new "
+
self
.
class_
entry
.
cname
return
"new "
+
self
.
class_
type
.
declaration_code
(
""
)
class
NameNode
(
AtomicExprNode
):
...
...
@@ -2442,7 +2451,7 @@ class SimpleCallNode(CallNode):
"Python object cannot be passed as a varargs parameter"
)
# Calc result type and code fragment
if
isinstance
(
self
.
function
,
NewExprNode
):
self
.
type
=
PyrexTypes
.
CPtrType
(
self
.
function
.
class_
entry
.
type
)
self
.
type
=
PyrexTypes
.
CPtrType
(
self
.
function
.
class_type
)
else
:
self
.
type
=
func_type
.
return_type
if
self
.
type
.
is_pyobject
:
...
...
Cython/Compiler/Parsing.py
View file @
fee03687
...
...
@@ -297,7 +297,13 @@ def p_new_expr(s):
pos
=
s
.
position
()
s
.
next
()
name
=
p_ident
(
s
)
return
p_call
(
s
,
ExprNodes
.
NewExprNode
(
pos
,
cppclass
=
name
))
if
s
.
sy
==
'['
:
s
.
next
()
template_parameters
=
p_simple_expr_list
(
s
)
s
.
expect
(
']'
)
else
:
template_parameters
=
None
return
p_call
(
s
,
ExprNodes
.
NewExprNode
(
pos
,
cppclass
=
name
,
template_parameters
=
template_parameters
))
#trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
...
...
Cython/Compiler/PyrexTypes.py
View file @
fee03687
...
...
@@ -1423,7 +1423,7 @@ class CppClassType(CType):
name
=
self
.
name
else
:
name
=
self
.
cname
return
"%s
%s%s"
%
(
name
,
entity_code
,
templates
)
return
"%s
%s %s"
%
(
name
,
templates
,
entity_code
)
def
is_subclass
(
self
,
other_type
):
# TODO(danilo): Handle templates.
...
...
Cython/Compiler/Symtab.py
View file @
fee03687
...
...
@@ -393,6 +393,7 @@ class Scope(object):
entry.type.scope = scope
self.type_entries.append(entry)
if not scope and not entry.type.scope:
print pos
self.check_for_illegal_incomplete_ctypedef(typedef_flag, pos)
return entry
...
...
Cython/Includes/python_ref.pxd
View file @
fee03687
...
...
@@ -3,7 +3,8 @@ cdef extern from "Python.h":
ctypedef
struct
PyObject
:
Py_ssize_t
ob_refcnt
PyTypeObject
*
ob_type
ctypedef
struct
FILE
ctypedef
struct
FILE
:
pass
#####################################################################
...
...
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