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
f0ef8c92
Commit
f0ef8c92
authored
May 29, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cypclass self management for declared but-not-defined methods
parent
da819b90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+26
-0
No files found.
Cython/Compiler/Nodes.py
View file @
f0ef8c92
...
...
@@ -1397,6 +1397,26 @@ class CVarDefNode(StatNode):
if
type
.
is_cfunction
:
if
'staticmethod'
in
env
.
directives
:
type
.
is_static_method
=
True
elif
name
in
(
"__new__"
,
"__alloc__"
)
and
\
env
.
is_cpp_class_scope
and
env
.
parent_type
.
is_cyp_class
:
type
.
is_static_method
=
True
if
declarator
.
skipped_self
:
_name
,
_type
,
_pos
,
_arg
=
declarator
.
skipped_self
if
name
==
"__new__"
:
_type
=
PyrexTypes
.
CPtrType
(
PyrexTypes
.
CFuncType
(
_type
,
[],
nogil
=
1
))
# aka _type = {class_type} (*f)() nogil
reinjected_arg
=
PyrexTypes
.
CFuncTypeArg
(
_name
,
_type
,
_pos
)
type
.
args
=
[
reinjected_arg
]
+
type
.
args
declarator
.
args
=
[
_arg
]
+
declarator
.
args
elif
name
==
"__alloc__"
:
# Force __alloc__ to have the signature:
# {class_type} f() nogil
type
.
return_type
=
_type
type
.
args
=
[]
declarator
.
args
=
[]
declarator
.
skipped_self
=
None
self
.
entry
=
dest_scope
.
declare_cfunction
(
name
,
type
,
declarator
.
pos
,
cname
=
cname
,
visibility
=
self
.
visibility
,
in_pxd
=
self
.
in_pxd
,
...
...
@@ -1406,6 +1426,12 @@ class CVarDefNode(StatNode):
if
create_extern_wrapper
:
self
.
entry
.
type
.
create_to_py_utility_code
(
env
)
self
.
entry
.
create_wrapper
=
True
if
env
.
is_cpp_class_scope
and
env
.
parent_type
.
is_cyp_class
\
and
not
declarator
.
skipped_self
and
not
type
.
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"
)
else
:
if
self
.
directive_locals
:
error
(
self
.
pos
,
"Decorators can only be followed by functions"
)
...
...
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