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
1a1d49d7
Commit
1a1d49d7
authored
Sep 16, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept 'f(const self, ...)' syntax for cypclass methods
parent
dadb47f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+18
-6
No files found.
Cython/Compiler/Nodes.py
View file @
1a1d49d7
...
...
@@ -677,9 +677,12 @@ class CFuncDeclaratorNode(CDeclaratorNode):
# fix the type of self
type
=
env
.
parent_type
elif
env
.
is_cyp_class_scope
:
# Accept 'f(const self, ...)' syntax as equivalent to 'f(self, ...) const'
is_const_self
=
type
.
is_const
# XXX is this different from 'env.parent_type' ?
type
=
env
.
lookup_here
(
"this"
).
type
if
self
.
declared_name
()
!=
"__new__"
:
self
.
is_const_method
|=
is_const_self
if
self
.
is_const_method
:
type
=
PyrexTypes
.
cyp_class_const_type
(
type
)
# skip 'self' argument from the list of actual arguments
...
...
@@ -902,20 +905,29 @@ class CArgDeclNode(Node):
def
analyse
(
self
,
env
,
nonempty
=
0
,
is_self_arg
=
False
):
if
is_self_arg
:
self
.
base_type
.
is_self_arg
=
self
.
is_self_arg
=
True
self_base_type
=
self
.
base_type
if
isinstance
(
self_base_type
,
CConstOrVolatileTypeNode
):
self_base_type
=
self_base_type
.
base_type
self_base_type
.
is_self_arg
=
self
.
is_self_arg
=
True
if
self
.
type
is
None
:
# The parser may misinterpret names as types. We fix that here.
if
isinstance
(
self
.
declarator
,
CNameDeclaratorNode
)
and
self
.
declarator
.
name
==
''
:
name_as_type
=
self
.
base_type
# Support syntax like 'const self'
# XXX Generally, the code below assumes name_as_type is a CSimpleBaseTypeNode
# and crashes when that assumption is broken.
if
isinstance
(
name_as_type
,
CConstOrVolatileTypeNode
):
name_as_type
=
name_as_type
.
base_type
if
nonempty
:
if
self
.
base
_type
.
is_basic_c_type
:
if
name_as
_type
.
is_basic_c_type
:
# char, short, long called "int"
type
=
self
.
base
_type
.
analyse
(
env
,
could_be_name
=
True
)
type
=
name_as
_type
.
analyse
(
env
,
could_be_name
=
True
)
arg_name
=
type
.
empty_declaration_code
()
else
:
arg_name
=
self
.
base
_type
.
name
arg_name
=
name_as
_type
.
name
self
.
declarator
.
name
=
EncodedString
(
arg_name
)
self
.
base
_type
.
name
=
None
self
.
base
_type
.
is_basic_c_type
=
False
name_as
_type
.
name
=
None
name_as
_type
.
is_basic_c_type
=
False
could_be_name
=
True
else
:
could_be_name
=
False
...
...
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