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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
937a8991
Commit
937a8991
authored
May 23, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve declaration analysis of cypclass methods
parent
9cdaa0e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-3
No files found.
Cython/Compiler/Nodes.py
View file @
937a8991
...
...
@@ -2532,6 +2532,7 @@ class CFuncDefNode(FuncDefNode):
# is_const_method whether this is a const method
# is_static_method whether this is a static method
# is_c_class_method whether this is a cclass method
# is_cyp_class_method whether this is a cypclass method
child_attrs
=
[
"base_type"
,
"declarator"
,
"body"
,
"decorators"
,
"py_func_stat"
]
outer_attrs
=
[
"decorators"
,
"py_func_stat"
]
...
...
@@ -2558,6 +2559,7 @@ class CFuncDefNode(FuncDefNode):
def
analyse_declarations
(
self
,
env
):
self
.
is_c_class_method
=
env
.
is_c_class_scope
self
.
is_cyp_class_method
=
env
.
is_cpp_class_scope
and
env
.
parent_type
.
is_cyp_class
if
self
.
directive_locals
is
None
:
self
.
directive_locals
=
{}
self
.
directive_locals
.
update
(
env
.
directives
.
get
(
'locals'
,
{}))
...
...
@@ -2599,8 +2601,7 @@ class CFuncDefNode(FuncDefNode):
# It is reinserted here, as __new__ MUST be static in a cypclass,
# so there is no self arg (the first arg is actually the allocator).
if
env
.
is_cpp_class_scope
and
env
.
parent_type
.
is_cyp_class
\
and
name
in
(
"__new__"
,
"__alloc__"
)
and
not
self
.
is_static_method
:
if
self
.
is_cyp_class_method
and
name
in
(
"__new__"
,
"__alloc__"
)
and
not
self
.
is_static_method
:
self
.
is_static_method
=
1
if
declarator
.
skipped_self
:
_name
,
_type
,
_pos
,
_arg
=
declarator
.
skipped_self
...
...
@@ -2676,7 +2677,7 @@ class CFuncDefNode(FuncDefNode):
# An error will be produced in the cdef function
self
.
overridable
=
False
if
env
.
is_cpp_class_scope
and
env
.
parent_type
.
is_cyp_class
and
not
declarator
.
skipped_self
and
not
self
.
is_static_method
:
if
self
.
is_cyp_class_method
and
not
declarator
.
skipped_self
and
not
self
.
is_static_method
:
# It means we have a cypclass method without the self argument
# => shout
error
(
self
.
pos
,
"Cypclass methods must have a self argument"
)
...
...
@@ -2695,6 +2696,7 @@ class CFuncDefNode(FuncDefNode):
self_locking_state
.
is_rlocked
=
self
.
is_const_method
self_locking_state
.
is_wlocked
=
not
self
.
is_const_method
def
declare_cpdef_wrapper
(
self
,
env
):
if
self
.
overridable
:
if
self
.
is_static_method
:
...
...
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