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
Gwenaël Samain
cython
Commits
a845670d
Commit
a845670d
authored
Apr 23, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
__new__ and __alloc__ management for cypclass
parent
e8d61806
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
4 deletions
+31
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+31
-4
No files found.
Cython/Compiler/Nodes.py
View file @
a845670d
...
...
@@ -2446,6 +2446,35 @@ class CFuncDefNode(FuncDefNode):
while
not
hasattr
(
declarator
,
'args'
):
declarator
=
declarator
.
base
name
=
name_declarator
.
name
cname
=
name_declarator
.
cname
# HACK: if we have a __new__ function in a cypclass which is
# not declared as static, the first argument may be untyped.
# In this case, it will go through the self arg execution flow,
# and it will be skipped from the actual arguments.
# 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
:
self
.
is_static_method
=
1
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
)
typ
.
args
=
[
reinjected_arg
]
+
typ
.
args
declarator
.
args
=
[
_arg
]
+
declarator
.
args
elif
name
==
"__alloc__"
:
# Force __alloc__ to have the signature:
# {class_type} f() nogil
typ
.
return_type
=
_type
typ
.
args
=
[]
declarator
.
args
=
[]
declarator
.
skipped_self
=
None
self
.
cfunc_declarator
=
declarator
self
.
args
=
declarator
.
args
...
...
@@ -2481,8 +2510,8 @@ class CFuncDefNode(FuncDefNode):
self
.
_validate_type_visibility
(
typ
.
return_type
,
self
.
pos
,
env
)
name
=
name_declarator
.
name
cname
=
name_declarator
.
cname
#
name = name_declarator.name
#
cname = name_declarator.cname
typ
.
is_const_method
=
self
.
is_const_method
typ
.
is_static_method
=
self
.
is_static_method
...
...
@@ -2508,8 +2537,6 @@ class CFuncDefNode(FuncDefNode):
# An error will be produced in the cdef function
self
.
overridable
=
False
func_declarator
=
self
.
declarator
.
base
if
isinstance
(
self
.
declarator
,
CPtrDeclaratorNode
)
\
else
self
.
declarator
if
env
.
is_cpp_class_scope
and
env
.
parent_type
.
is_cyp_class
\
and
not
declarator
.
skipped_self
and
not
self
.
is_static_method
:
# It means we have a cypclass method without the self argument
...
...
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