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
d136c751
Commit
d136c751
authored
Jan 07, 2019
by
mattip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MAINT: refactor decorator analysis
parent
f58cc9a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+17
-16
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
d136c751
...
...
@@ -2243,23 +2243,24 @@ class ReplacePropertyNode(CythonTransform):
def
visit_CFuncDefNode
(
self
,
node
):
if
not
node
.
decorators
:
return
node
# transform @property decorators on ctypedef class functions
decorator
=
self
.
find_first_decorator
(
node
,
'property'
)
if
decorator
:
# transform class functions into c-getters
if
len
(
node
.
decorators
)
>
1
:
# raises
self
.
_reject_decorated_property
(
node
,
decorator_node
)
node
.
entry
.
is_cgetter
=
True
# Add a func_cname to be output instead of the attribute
node
.
entry
.
func_cname
=
node
.
body
.
stats
[
0
].
value
.
function
.
name
node
.
decorators
.
remove
(
decorator
)
return
node
def
find_first_decorator
(
self
,
node
,
name
):
for
decorator_node
in
node
.
decorators
[::
-
1
]:
if
self
.
find_decorator
(
decorator_node
.
decorator
,
'property'
):
if
len
(
node
.
decorators
)
>
1
:
# raises
self
.
_reject_decorated_property
(
node
,
decorator_node
)
node
.
entry
.
is_cgetter
=
True
# Add a func_cname to be output instead of the attribute
node
.
entry
.
func_cname
=
node
.
body
.
stats
[
0
].
value
.
function
.
name
node
.
decorators
.
remove
(
decorator_node
)
break
return
node
def
find_decorator
(
self
,
decorator
,
name
):
if
decorator
.
is_name
and
decorator
.
name
==
name
:
return
True
return
False
decorator
=
decorator_node
.
decorator
if
decorator
.
is_name
and
decorator
.
name
==
name
:
return
decorator_node
return
None
class
FindInvalidUseOfFusedTypes
(
CythonTransform
):
...
...
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