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
Boxiang Sun
cython
Commits
16bf4f76
Commit
16bf4f76
authored
Dec 15, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use C++ style constructor declarations rather than __init__.
parent
bcb70be9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
12 deletions
+13
-12
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-7
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-0
tests/compile/cpp_templates.pyx
tests/compile/cpp_templates.pyx
+2
-2
tests/run/cpp_classes.pyx
tests/run/cpp_classes.pyx
+3
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
16bf4f76
...
...
@@ -1095,12 +1095,12 @@ class NewExprNode(AtomicExprNode):
type
=
entry
.
type
.
specialize_here
(
self
.
pos
,
template_types
)
else
:
type
=
entry
.
type
constructor
=
type
.
scope
.
lookup
(
u'
__init__
'
)
constructor
=
type
.
scope
.
lookup
(
u'
<init>
'
)
if
constructor
is
None
:
return_type
=
PyrexTypes
.
CFuncType
(
type
,
[])
return_type
=
PyrexTypes
.
CPtrType
(
return_type
)
type
.
scope
.
declare_cfunction
(
u'
__init__
'
,
return_type
,
self
.
pos
)
constructor
=
type
.
scope
.
lookup
(
u'
__init__
'
)
type
.
scope
.
declare_cfunction
(
u'
<init>
'
,
return_type
,
self
.
pos
)
constructor
=
type
.
scope
.
lookup
(
u'
<init>
'
)
self
.
class_type
=
type
self
.
entry
=
constructor
self
.
type
=
constructor
.
type
...
...
@@ -4282,8 +4282,7 @@ class NumBinopNode(BinopNode):
entry
=
env
.
lookup
(
type1
.
name
)
function
=
entry
.
type
.
scope
.
lookup
(
"operator%s"
%
self
.
operator
)
if
not
function
:
error
(
self
.
pos
,
"'%s' operator not defined for '%s %s %s'"
%
(
self
.
operator
,
type1
,
self
.
operator
,
type2
))
self
.
type_error
()
return
entry
=
PyrexTypes
.
best_match
([
self
.
operand1
,
self
.
operand2
],
function
.
all_alternatives
(),
self
.
pos
)
if
entry
is
None
:
...
...
@@ -4981,8 +4980,8 @@ class PrimaryCmpNode(NewTempExprNode, CmpNode):
entry
=
env
.
lookup
(
type1
.
name
)
function
=
entry
.
type
.
scope
.
lookup
(
"operator%s"
%
self
.
operator
)
if
not
function
:
error
(
self
.
pos
,
"
'%s' operator not defined for '%s %s %s'"
%
(
self
.
operator
,
type1
,
self
.
operator
,
type2
))
error
(
self
.
pos
,
"
Invalid types for '%s' (%s, %s)"
%
(
self
.
operator
,
type1
,
type2
))
return
entry
=
PyrexTypes
.
best_match
([
self
.
operand1
,
self
.
operand2
],
function
.
all_alternatives
(),
self
.
pos
)
if
entry
is
None
:
...
...
Cython/Compiler/Symtab.py
View file @
16bf4f76
...
...
@@ -1634,6 +1634,8 @@ class CppClassScope(Scope):
def
declare_cfunction
(
self
,
name
,
type
,
pos
,
cname
=
None
,
visibility
=
'extern'
,
defining
=
0
,
api
=
0
,
in_pxd
=
0
,
modifiers
=
()):
if
name
==
self
.
name
.
split
(
'::'
)[
-
1
]
and
cname
is
None
:
name
=
'<init>'
entry
=
self
.
declare_var
(
name
,
type
,
pos
,
cname
,
visibility
)
def
declare_inherited_cpp_attributes
(
self
,
base_scope
):
...
...
tests/compile/cpp_templates.pyx
View file @
16bf4f76
cdef
extern
from
"templates.h"
:
cdef
cppclass
TemplateTest1
[
T
]:
__init__
()
TemplateTest1
()
T
value
int
t
T
getValue
()
cdef
cppclass
TemplateTest2
[
T
,
U
]:
__init__
()
TemplateTest2
()
T
value1
U
value2
T
getValue1
()
...
...
tests/run/cpp_classes.pyx
View file @
16bf4f76
...
...
@@ -14,16 +14,16 @@ cdef extern from "shapes.h" namespace shapes:
cdef
cppclass
Circle
(
Shape
):
int
radius
__init__
(
int
)
Circle
(
int
)
cdef
cppclass
Rectangle
(
Shape
):
int
width
int
height
__init__
(
int
,
int
)
Rectangle
(
int
,
int
)
cdef
cppclass
Square
(
Rectangle
):
int
side
__init__
(
int
)
Square
(
int
)
int
constructor_count
,
destructor_count
...
...
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