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
e9dadd66
Commit
e9dadd66
authored
May 23, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generate constructors even when unused
parent
f9ef0611
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
18 deletions
+3
-18
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+3
-18
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
e9dadd66
...
...
@@ -87,26 +87,12 @@ def generate_cypclass_typeobj_declarations(env, code, definition):
Generate declarations of global pointers to the PyTypeObject for each cypclass
"""
for
entry
,
scope
in
cypclass_iter_scopes
(
env
):
for
entry
in
cypclass_iter
(
env
):
if
definition
or
entry
.
defined_in_pxd
:
# the entry regrouping the constructors for this cypclass
c
=
scope
.
lookup_here
(
"<constructor>"
)
# Todo: determine whether the __new__ called in the constructor
# actually returns an instance of the cypclass type.
# and do this computation only once
# (cf generate_cyp_class_wrapper_definition)
#
# n = scope.lookup_here("<new>")
# # whether a user-defined __new__ actually returns another type
# is_new_return_type = not n or (n.type.return_type == entry.type)
# if a constructor is unused it will not be defined, and if none are
# defined the PyTypeObject pointer is never assigned to an instance,
# so no need to declare it.
if
entry
.
type
.
templates
or
any
(
map
(
lambda
e
:
e
.
used
,
c
.
all_alternatives
())):
code
.
putln
(
"static PyTypeObject *%s = 0;"
%
(
entry
.
type
.
typeptr_cname
))
...
...
@@ -136,7 +122,6 @@ def generate_cyp_class_deferred_definitions(env, code, definition):
new
=
scope
.
lookup_here
(
"__new__"
)
alloc
=
scope
.
lookup_here
(
"<alloc>"
)
for
wrapper_entry
in
wrapper
.
all_alternatives
():
if
wrapper_entry
.
used
or
entry
.
type
.
templates
:
generate_cyp_class_wrapper_definition
(
entry
.
type
,
wrapper_entry
,
constructor
,
new
,
alloc
,
code
)
def
generate_cyp_class_attrs_destructor_definition
(
entry
,
code
):
...
...
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