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
Xavier Thompson
cython
Commits
ca89bbbb
Commit
ca89bbbb
authored
Dec 27, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix C++ const method declarations.
parent
26badc7c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
10 deletions
+17
-10
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+3
-1
tests/run/cpp_classes_def.pyx
tests/run/cpp_classes_def.pyx
+4
-4
tests/run/shapes.h
tests/run/shapes.h
+4
-4
No files found.
Cython/Compiler/Nodes.py
View file @
ca89bbbb
...
@@ -575,11 +575,13 @@ class CFuncDeclaratorNode(CDeclaratorNode):
...
@@ -575,11 +575,13 @@ class CFuncDeclaratorNode(CDeclaratorNode):
# exception_check boolean True if PyErr_Occurred check needed
# exception_check boolean True if PyErr_Occurred check needed
# nogil boolean Can be called without gil
# nogil boolean Can be called without gil
# with_gil boolean Acquire gil around function body
# with_gil boolean Acquire gil around function body
# is_const_method boolean Whether this is a const method
child_attrs
=
[
"base"
,
"args"
,
"exception_value"
]
child_attrs
=
[
"base"
,
"args"
,
"exception_value"
]
overridable
=
0
overridable
=
0
optional_arg_count
=
0
optional_arg_count
=
0
is_const_method
=
0
templates
=
None
templates
=
None
def
analyse_templates
(
self
):
def
analyse_templates
(
self
):
...
@@ -688,6 +690,7 @@ class CFuncDeclaratorNode(CDeclaratorNode):
...
@@ -688,6 +690,7 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exception_value
=
exc_val
,
exception_check
=
exc_check
,
exception_value
=
exc_val
,
exception_check
=
exc_check
,
calling_convention
=
self
.
base
.
calling_convention
,
calling_convention
=
self
.
base
.
calling_convention
,
nogil
=
self
.
nogil
,
with_gil
=
self
.
with_gil
,
is_overridable
=
self
.
overridable
,
nogil
=
self
.
nogil
,
with_gil
=
self
.
with_gil
,
is_overridable
=
self
.
overridable
,
is_const_method
=
self
.
is_const_method
,
templates
=
self
.
templates
)
templates
=
self
.
templates
)
if
self
.
optional_arg_count
:
if
self
.
optional_arg_count
:
...
...
Cython/Compiler/Parsing.py
View file @
ca89bbbb
...
@@ -2827,6 +2827,8 @@ def p_c_func_or_var_declaration(s, pos, ctx):
...
@@ -2827,6 +2827,8 @@ def p_c_func_or_var_declaration(s, pos, ctx):
else
:
else
:
#if api:
#if api:
# s.error("'api' not allowed with variable declaration")
# s.error("'api' not allowed with variable declaration")
if
is_const_method
:
declarator
.
is_const_method
=
is_const_method
declarators
=
[
declarator
]
declarators
=
[
declarator
]
while
s
.
sy
==
','
:
while
s
.
sy
==
','
:
s
.
next
()
s
.
next
()
...
...
Cython/Compiler/PyrexTypes.py
View file @
ca89bbbb
...
@@ -2336,7 +2336,7 @@ class CFuncType(CType):
...
@@ -2336,7 +2336,7 @@ class CFuncType(CType):
def
__init__
(
self
,
return_type
,
args
,
has_varargs
=
0
,
def
__init__
(
self
,
return_type
,
args
,
has_varargs
=
0
,
exception_value
=
None
,
exception_check
=
0
,
calling_convention
=
""
,
exception_value
=
None
,
exception_check
=
0
,
calling_convention
=
""
,
nogil
=
0
,
with_gil
=
0
,
is_overridable
=
0
,
optional_arg_count
=
0
,
nogil
=
0
,
with_gil
=
0
,
is_overridable
=
0
,
optional_arg_count
=
0
,
templates
=
None
,
is_strict_signature
=
False
):
is_const_method
=
False
,
templates
=
None
,
is_strict_signature
=
False
):
self
.
return_type
=
return_type
self
.
return_type
=
return_type
self
.
args
=
args
self
.
args
=
args
self
.
has_varargs
=
has_varargs
self
.
has_varargs
=
has_varargs
...
@@ -2347,6 +2347,7 @@ class CFuncType(CType):
...
@@ -2347,6 +2347,7 @@ class CFuncType(CType):
self
.
nogil
=
nogil
self
.
nogil
=
nogil
self
.
with_gil
=
with_gil
self
.
with_gil
=
with_gil
self
.
is_overridable
=
is_overridable
self
.
is_overridable
=
is_overridable
self
.
is_const_method
=
is_const_method
self
.
templates
=
templates
self
.
templates
=
templates
self
.
is_strict_signature
=
is_strict_signature
self
.
is_strict_signature
=
is_strict_signature
...
@@ -2572,6 +2573,7 @@ class CFuncType(CType):
...
@@ -2572,6 +2573,7 @@ class CFuncType(CType):
with_gil
=
self
.
with_gil
,
with_gil
=
self
.
with_gil
,
is_overridable
=
self
.
is_overridable
,
is_overridable
=
self
.
is_overridable
,
optional_arg_count
=
self
.
optional_arg_count
,
optional_arg_count
=
self
.
optional_arg_count
,
is_const_method
=
self
.
is_const_method
,
templates
=
self
.
templates
)
templates
=
self
.
templates
)
result
.
from_fused
=
self
.
is_fused
result
.
from_fused
=
self
.
is_fused
...
...
tests/run/cpp_classes_def.pyx
View file @
ca89bbbb
...
@@ -7,7 +7,7 @@ from libc.math cimport sin, cos
...
@@ -7,7 +7,7 @@ from libc.math cimport sin, cos
cdef
extern
from
"shapes.h"
namespace
"shapes"
:
cdef
extern
from
"shapes.h"
namespace
"shapes"
:
cdef
cppclass
Shape
:
cdef
cppclass
Shape
:
float
area
()
float
area
()
const
cdef
cppclass
RegularPolygon
(
Shape
):
cdef
cppclass
RegularPolygon
(
Shape
):
float
radius
# major
float
radius
# major
...
@@ -15,7 +15,7 @@ cdef cppclass RegularPolygon(Shape):
...
@@ -15,7 +15,7 @@ cdef cppclass RegularPolygon(Shape):
__init__
(
int
n
,
float
radius
):
__init__
(
int
n
,
float
radius
):
this
.
n
=
n
this
.
n
=
n
this
.
radius
=
radius
this
.
radius
=
radius
float
area
():
float
area
()
const
:
cdef
double
theta
=
pi
/
this
.
n
cdef
double
theta
=
pi
/
this
.
n
return
this
.
radius
*
this
.
radius
*
sin
(
theta
)
*
cos
(
theta
)
*
this
.
n
return
this
.
radius
*
this
.
radius
*
sin
(
theta
)
*
cos
(
theta
)
*
this
.
n
...
...
tests/run/shapes.h
View file @
ca89bbbb
...
@@ -9,7 +9,7 @@ namespace shapes {
...
@@ -9,7 +9,7 @@ namespace shapes {
class
Shape
class
Shape
{
{
public:
public:
virtual
float
area
()
=
0
;
virtual
float
area
()
const
=
0
;
Shape
()
{
constructor_count
++
;
}
Shape
()
{
constructor_count
++
;
}
virtual
~
Shape
()
{
destructor_count
++
;
}
virtual
~
Shape
()
{
destructor_count
++
;
}
};
};
...
@@ -24,7 +24,7 @@ namespace shapes {
...
@@ -24,7 +24,7 @@ namespace shapes {
this
->
height
=
height
;
this
->
height
=
height
;
}
}
float
area
()
{
return
width
*
height
;
}
float
area
()
const
{
return
width
*
height
;
}
int
width
;
int
width
;
int
height
;
int
height
;
...
@@ -44,13 +44,13 @@ namespace shapes {
...
@@ -44,13 +44,13 @@ namespace shapes {
class
Circle
:
public
Shape
{
class
Circle
:
public
Shape
{
public:
public:
Circle
(
int
radius
)
{
this
->
radius
=
radius
;
}
Circle
(
int
radius
)
{
this
->
radius
=
radius
;
}
float
area
()
{
return
3.1415926535897931
f
*
radius
;
}
float
area
()
const
{
return
3.1415926535897931
f
*
radius
;
}
int
radius
;
int
radius
;
};
};
class
Empty
:
public
Shape
{
class
Empty
:
public
Shape
{
public:
public:
float
area
()
{
return
0
;
}
float
area
()
const
{
return
0
;
}
};
};
}
}
...
...
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