Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xavier Thompson
cython
Commits
31d83cc3
Commit
31d83cc3
authored
4 years ago
by
Xavier Thompson
Browse files
Options
Download
Email Patches
Plain Diff
Improve handling of self argument in cypclass methods
parent
f410b12d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+10
-6
No files found.
Cython/Compiler/Nodes.py
View file @
31d83cc3
...
@@ -672,13 +672,17 @@ class CFuncDeclaratorNode(CDeclaratorNode):
...
@@ -672,13 +672,17 @@ class CFuncDeclaratorNode(CDeclaratorNode):
type
=
other_type
type
=
other_type
if
name_declarator
.
cname
:
if
name_declarator
.
cname
:
error
(
self
.
pos
,
"Function argument cannot have C name specification"
)
error
(
self
.
pos
,
"Function argument cannot have C name specification"
)
if
i
==
0
and
(
env
.
is_c_class_scope
or
env
.
is_cyp_class_scope
)
and
type
.
is_unspecified
:
if
i
==
0
and
type
.
is_unspecified
:
if
env
.
is_cyp_class_scope
:
if
env
.
is_c_class_scope
:
# fix the type of self
type
=
env
.
parent_type
elif
env
.
is_cyp_class_scope
:
# XXX is this different from 'env.parent_type' ?
type
=
env
.
lookup_here
(
"this"
).
type
type
=
env
.
lookup_here
(
"this"
).
type
if
self
.
is_const_method
:
type
=
PyrexTypes
.
cyp_class_const_type
(
type
)
self
.
skipped_self
=
(
name
,
type
,
arg_node
.
pos
,
arg_node
)
self
.
skipped_self
=
(
name
,
type
,
arg_node
.
pos
,
arg_node
)
continue
continue
# fix the type of self
type
=
env
.
parent_type
# Turn *[] argument into **
# Turn *[] argument into **
if
type
.
is_array
:
if
type
.
is_array
:
type
=
PyrexTypes
.
c_ptr_type
(
type
.
base_type
)
type
=
PyrexTypes
.
c_ptr_type
(
type
.
base_type
)
...
@@ -1029,6 +1033,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
...
@@ -1029,6 +1033,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
elif
self
.
name
is
None
:
elif
self
.
name
is
None
:
if
self
.
is_self_arg
and
(
env
.
is_c_class_scope
or
env
.
is_cyp_class_scope
):
if
self
.
is_self_arg
and
(
env
.
is_c_class_scope
or
env
.
is_cyp_class_scope
):
#print "CSimpleBaseTypeNode.analyse: defaulting to parent type" ###
#print "CSimpleBaseTypeNode.analyse: defaulting to parent type" ###
# For cypclass methods, the type of 'self' is always determined in CFuncDeclaratorNode
type
=
env
.
parent_type
if
env
.
is_c_class_scope
else
PyrexTypes
.
unspecified_type
type
=
env
.
parent_type
if
env
.
is_c_class_scope
else
PyrexTypes
.
unspecified_type
## elif self.is_type_arg and env.is_c_class_scope:
## elif self.is_type_arg and env.is_c_class_scope:
## type = Builtin.type_type
## type = Builtin.type_type
...
@@ -1061,6 +1066,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
...
@@ -1061,6 +1066,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
pass
pass
elif
could_be_name
:
elif
could_be_name
:
if
self
.
is_self_arg
and
(
env
.
is_c_class_scope
or
env
.
is_cyp_class_scope
):
if
self
.
is_self_arg
and
(
env
.
is_c_class_scope
or
env
.
is_cyp_class_scope
):
# For cypclass methods, the type of 'self' is always determined in CFuncDeclaratorNode
type
=
env
.
parent_type
if
env
.
is_c_class_scope
else
PyrexTypes
.
unspecified_type
type
=
env
.
parent_type
if
env
.
is_c_class_scope
else
PyrexTypes
.
unspecified_type
## elif self.is_type_arg and env.is_c_class_scope:
## elif self.is_type_arg and env.is_c_class_scope:
## type = Builtin.type_type
## type = Builtin.type_type
...
@@ -2733,8 +2739,6 @@ class CFuncDefNode(FuncDefNode):
...
@@ -2733,8 +2739,6 @@ class CFuncDefNode(FuncDefNode):
if
declarator
.
skipped_self
:
if
declarator
.
skipped_self
:
_name
,
_type
,
_pos
,
_
=
declarator
.
skipped_self
_name
,
_type
,
_pos
,
_
=
declarator
.
skipped_self
_cname
=
"this"
_cname
=
"this"
if
self
.
is_const_method
:
_type
=
PyrexTypes
.
cyp_class_const_type
(
_type
)
entry
=
self
.
local_scope
.
declare
(
_name
,
_cname
,
_type
,
_pos
,
'private'
)
entry
=
self
.
local_scope
.
declare
(
_name
,
_cname
,
_type
,
_pos
,
'private'
)
entry
.
is_variable
=
1
entry
.
is_variable
=
1
entry
.
is_self_arg
=
1
entry
.
is_self_arg
=
1
...
...
This diff is collapsed.
Click to expand it.
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