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
9c4ff39b
Commit
9c4ff39b
authored
May 25, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assign cclass PyTypeObject pointer to underlying cypclass's wrapper instance
parent
0ec4fba9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
20 deletions
+11
-20
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+1
-14
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+3
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+5
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+0
-2
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
9c4ff39b
...
...
@@ -82,19 +82,6 @@ def cypclass_iter_scopes(scope):
for
e
,
s
in
cypclass_iter_scopes
(
cypclass_scope
):
yield
e
,
s
def
generate_cypclass_typeobj_declarations
(
env
,
code
,
definition
):
"""
Generate pre-declarations of the PyTypeObject for each cypclass
"""
for
entry
in
cypclass_iter
(
env
):
if
definition
or
entry
.
defined_in_pxd
:
# 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)
code
.
putln
(
"static PyTypeObject %s;"
%
(
entry
.
type
.
typeobj_cname
))
...
...
@@ -595,7 +582,7 @@ def generate_cyp_class_wrapper_definition(type, wrapper_entry, constructor_entry
code
.
putln
(
"if(self) {"
)
code
.
putln
(
"self->ob_cypyobject = new CyPyObject(); // for now"
)
code
.
putln
(
"self->ob_cypyobject->ob_refcnt = 0;"
)
code
.
putln
(
"self->ob_cypyobject->ob_type =
&%s;"
%
type
.
typeobj
_cname
)
code
.
putln
(
"self->ob_cypyobject->ob_type =
%s;"
%
type
.
wrapper_type
.
typeptr
_cname
)
code
.
putln
(
"}"
)
if
init_entry
:
...
...
Cython/Compiler/ModuleNode.py
View file @
9c4ff39b
...
...
@@ -587,11 +587,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
type_entries
=
[
t
for
t
in
type_entries
if
t
not
in
vtabslot_entries
]
self
.
generate_type_header_code
(
type_entries
,
code
)
code
.
putln
(
""
)
code
.
putln
(
"/* PyTypeObject pointer declarations for
cyp
classes */"
)
CypclassWrapper
.
generate_cypclass_typeobj
_declarations
(
module
,
code
,
definition
)
code
.
putln
(
"/* PyTypeObject pointer declarations for
all c
classes */"
)
self
.
generate_c_class
_declarations
(
module
,
code
,
definition
)
code
.
putln
(
""
)
code
.
putln
(
"/* Deferred definitions for cypclasses */"
)
CypclassWrapper
.
generate_cyp_class_deferred_definitions
(
env
,
code
,
definition
)
for
entry
in
vtabslot_list
:
self
.
generate_objstruct_definition
(
entry
.
type
,
code
)
self
.
generate_typeobj_predeclaration
(
entry
,
code
)
...
...
@@ -620,7 +621,6 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
defined_here
=
module
is
env
modulecode
.
putln
(
""
)
modulecode
.
putln
(
"/* Module declarations from '%s' */"
%
module
.
qualified_name
)
self
.
generate_c_class_declarations
(
module
,
modulecode
,
defined_here
)
self
.
generate_cvariable_declarations
(
module
,
modulecode
,
defined_here
)
self
.
generate_cfunction_declarations
(
module
,
modulecode
,
defined_here
)
...
...
Cython/Compiler/Nodes.py
View file @
9c4ff39b
...
...
@@ -1638,6 +1638,8 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
wrapper
.
declare
(
module_scope
)
if
self
.
scope
:
wrapper
.
analyse_declarations
(
module_scope
)
self
.
entry
.
type
.
wrapper_type
=
wrapper
.
entry
.
type
wrapper
.
entry
.
type
.
is_cyp_wrapper
=
1
self
.
cyp_wrapper
=
wrapper
...
...
Cython/Compiler/PyrexTypes.py
View file @
9c4ff39b
...
...
@@ -1361,10 +1361,12 @@ class PyExtensionType(PyObjectType):
# early_init boolean Whether to initialize early (as opposed to during module execution).
# defered_declarations [thunk] Used to declare class hierarchies in order
# check_size 'warn', 'error', 'ignore' What to do if tp_basicsize does not match
# is_cyp_wrapper boolean Whether this extension type wraps a cypclass
is_extension_type
=
1
has_attributes
=
1
early_init
=
1
is_cyp_wrapper
=
0
objtypedef_cname
=
None
...
...
@@ -3897,6 +3899,8 @@ class CppClassType(CType):
class
CypClassType
(
CppClassType
):
# lock_mode string (tri-state: "nolock"/"checklock"/"autolock")
# wrapper_type PyExtensionType the type of the cclass wrapper
is_cyp_class
=
1
to_py_function
=
"__Pyx_PyObject_FromCyObject"
...
...
@@ -3905,7 +3909,7 @@ class CypClassType(CppClassType):
CppClassType
.
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
,
template_type
,
nogil
)
self
.
lock_mode
=
lock_mode
if
lock_mode
else
"autolock"
self
.
activable
=
activable
self
.
typeobj_cname
=
None
# set externally
self
.
wrapper_type
=
None
# set during
def
empty_declaration_code
(
self
):
...
...
Cython/Compiler/Symtab.py
View file @
9c4ff39b
...
...
@@ -672,8 +672,6 @@ class Scope(object):
if
cypclass
:
type
=
PyrexTypes
.
CypClassType
(
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
,
lock_mode
=
lock_mode
,
activable
=
activable
)
# generate PyTypeObject cname for cypclass
type
.
typeobj_cname
=
self
.
c_mangle
(
Naming
.
typeobj_prefix
,
name
)
else
:
type
=
PyrexTypes
.
CppClassType
(
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
)
...
...
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