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
eb702aa0
Commit
eb702aa0
authored
Apr 23, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
__new__ and __alloc__ management for cypclass
parent
ecab299e
Changes
1
Hide 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 @
eb702aa0
...
@@ -2448,6 +2448,35 @@ class CFuncDefNode(FuncDefNode):
...
@@ -2448,6 +2448,35 @@ class CFuncDefNode(FuncDefNode):
while
not
hasattr
(
declarator
,
'args'
):
while
not
hasattr
(
declarator
,
'args'
):
declarator
=
declarator
.
base
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
.
cfunc_declarator
=
declarator
self
.
args
=
declarator
.
args
self
.
args
=
declarator
.
args
...
@@ -2483,8 +2512,8 @@ class CFuncDefNode(FuncDefNode):
...
@@ -2483,8 +2512,8 @@ class CFuncDefNode(FuncDefNode):
self
.
_validate_type_visibility
(
typ
.
return_type
,
self
.
pos
,
env
)
self
.
_validate_type_visibility
(
typ
.
return_type
,
self
.
pos
,
env
)
name
=
name_declarator
.
name
#
name = name_declarator.name
cname
=
name_declarator
.
cname
#
cname = name_declarator.cname
typ
.
is_const_method
=
self
.
is_const_method
typ
.
is_const_method
=
self
.
is_const_method
typ
.
is_static_method
=
self
.
is_static_method
typ
.
is_static_method
=
self
.
is_static_method
...
@@ -2510,8 +2539,6 @@ class CFuncDefNode(FuncDefNode):
...
@@ -2510,8 +2539,6 @@ class CFuncDefNode(FuncDefNode):
# An error will be produced in the cdef function
# An error will be produced in the cdef function
self
.
overridable
=
False
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
\
if
env
.
is_cpp_class_scope
and
env
.
parent_type
.
is_cyp_class
\
and
not
declarator
.
skipped_self
and
not
self
.
is_static_method
:
and
not
declarator
.
skipped_self
and
not
self
.
is_static_method
:
# It means we have a cypclass method without the self argument
# 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