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
50bab2d6
Commit
50bab2d6
authored
Jan 17, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tp_new, etc. cleanup
parent
4a0ad3fb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
16 deletions
+23
-16
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+10
-16
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+13
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
50bab2d6
...
@@ -628,10 +628,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -628,10 +628,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"%s;"
"%s;"
%
scope
.
parent_type
.
declaration_code
(
"p"
))
%
scope
.
parent_type
.
declaration_code
(
"p"
))
if
base_type
:
if
base_type
:
entry
=
scope
.
parent_scope
.
lookup_here
(
scope
.
parent_type
.
base_type
.
name
)
tp_new
=
TypeSlots
.
get_base_slot_function
(
scope
,
tp_slot
)
if
scope
.
parent_scope
is
base_type
.
scope
.
parent_scope
and
entry
.
visibility
!=
'extern'
:
if
tp_new
is
None
:
tp_new
=
TypeSlots
.
InternalMethodSlot
(
"tp_new"
).
slot_code
(
base_type
.
scope
)
else
:
tp_new
=
"%s->tp_new"
%
base_type
.
typeptr_cname
tp_new
=
"%s->tp_new"
%
base_type
.
typeptr_cname
code
.
putln
(
code
.
putln
(
"PyObject *o = %s(t, a, k);"
%
tp_new
)
"PyObject *o = %s(t, a, k);"
%
tp_new
)
...
@@ -691,10 +689,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -691,10 +689,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
for
entry
in
py_attrs
:
for
entry
in
py_attrs
:
code
.
put_xdecref
(
"p->%s"
%
entry
.
cname
,
entry
.
type
)
code
.
put_xdecref
(
"p->%s"
%
entry
.
cname
,
entry
.
type
)
if
base_type
:
if
base_type
:
entry
=
scope
.
parent_scope
.
lookup_here
(
scope
.
parent_type
.
base_type
.
name
)
tp_dealloc
=
TypeSlots
.
get_base_slot_function
(
scope
,
tp_slot
)
if
scope
.
parent_scope
is
base_type
.
scope
.
parent_scope
and
entry
.
visibility
!=
'extern'
:
if
tp_dealloc
is
None
:
tp_dealloc
=
TypeSlots
.
InternalMethodSlot
(
"tp_dealloc"
).
slot_code
(
base_type
.
scope
)
else
:
tp_dealloc
=
"%s->tp_dealloc"
%
base_type
.
typeptr_cname
tp_dealloc
=
"%s->tp_dealloc"
%
base_type
.
typeptr_cname
code
.
putln
(
code
.
putln
(
"%s(o);"
%
tp_dealloc
)
"%s(o);"
%
tp_dealloc
)
...
@@ -747,10 +743,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -747,10 +743,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_self_cast
(
scope
,
code
)
self
.
generate_self_cast
(
scope
,
code
)
if
base_type
:
if
base_type
:
# want to call it explicitly if possible so inlining can be performed
# want to call it explicitly if possible so inlining can be performed
parent_slot
=
tp_slot
.
slot_code
(
base_type
.
scope
)
static_call
=
TypeSlots
.
get_base_slot_function
(
scope
,
tp_slot
)
entry
=
scope
.
parent_scope
.
lookup_here
(
scope
.
parent_type
.
base_type
.
name
)
if
static_call
:
if
scope
.
parent_scope
is
base_type
.
scope
.
parent_scope
and
parent_slot
!=
'0'
and
entry
.
visibility
!=
'extern'
:
code
.
putln
(
"e = %s(o, v, a); if (e) return e;"
%
static_call
)
code
.
putln
(
"e = %s(o, v, a); if (e) return e;"
%
parent_slot
)
else
:
else
:
code
.
putln
(
"if (%s->tp_traverse) {"
%
base_type
.
typeptr_cname
)
code
.
putln
(
"if (%s->tp_traverse) {"
%
base_type
.
typeptr_cname
)
code
.
putln
(
code
.
putln
(
...
@@ -791,10 +786,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -791,10 +786,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"PyObject* tmp;"
)
code
.
putln
(
"PyObject* tmp;"
)
if
base_type
:
if
base_type
:
# want to call it explicitly if possible so inlining can be performed
# want to call it explicitly if possible so inlining can be performed
parent_slot
=
tp_slot
.
slot_code
(
base_type
.
scope
)
static_call
=
TypeSlots
.
get_base_slot_function
(
scope
,
tp_slot
)
entry
=
scope
.
parent_scope
.
lookup_here
(
scope
.
parent_type
.
base_type
.
name
)
if
static_call
:
if
scope
.
parent_scope
is
base_type
.
scope
.
parent_scope
and
parent_slot
!=
'0'
and
entry
.
visibility
!=
'extern'
:
code
.
putln
(
"%s(o);"
%
static_call
)
code
.
putln
(
"%s(o);"
%
parent_slot
)
else
:
else
:
code
.
putln
(
"if (%s->tp_clear) {"
%
base_type
.
typeptr_cname
)
code
.
putln
(
"if (%s->tp_clear) {"
%
base_type
.
typeptr_cname
)
code
.
putln
(
"%s->tp_clear(o);"
%
base_type
.
typeptr_cname
)
code
.
putln
(
"%s->tp_clear(o);"
%
base_type
.
typeptr_cname
)
...
...
Cython/Compiler/TypeSlots.py
View file @
50bab2d6
...
@@ -398,6 +398,19 @@ def get_property_accessor_signature(name):
...
@@ -398,6 +398,19 @@ def get_property_accessor_signature(name):
# property, else None.
# property, else None.
return
property_accessor_signatures
.
get
(
name
)
return
property_accessor_signatures
.
get
(
name
)
def
get_base_slot_function
(
scope
,
slot
):
# Returns the function implementing this slot in the baseclass.
# This is useful for enabling the compiler to optimize calls
# that recursively climb the class hierarchy.
base_type
=
scope
.
parent_type
.
base_type
if
scope
.
parent_scope
is
base_type
.
scope
.
parent_scope
:
parent_slot
=
slot
.
slot_code
(
base_type
.
scope
)
if
parent_slot
!=
'0'
:
entry
=
scope
.
parent_scope
.
lookup_here
(
scope
.
parent_type
.
base_type
.
name
)
if
entry
.
visibility
!=
'extern'
:
return
parent_slot
return
None
#------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------
#
#
# Signatures for generic Python functions and methods.
# Signatures for generic Python functions and methods.
...
...
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