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
953d754d
Commit
953d754d
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
255c4e25
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
22 deletions
+13
-22
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+1
-14
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-5
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 @
953d754d
...
...
@@ -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 @
953d754d
...
...
@@ -633,7 +633,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env
.
c_class_entries
[:]
=
self
.
sort_types_by_inheritance
(
entry_dict
,
entry_order
,
key_func
)
def
generate_type_definitions
(
self
,
env
,
modules
,
vtab_list
,
vtabslot_list
,
code
):
def
generate_type_definitions
(
self
,
env
,
modules
,
vtab_list
,
vtabslot_list
,
code
,
globalstate
):
# TODO: Why are these separated out?
for
entry
in
vtabslot_list
:
self
.
generate_objstruct_predeclaration
(
entry
.
type
,
code
)
...
...
@@ -652,11 +652,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
,
globalstate
)
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
)
...
...
@@ -679,13 +680,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
typecode
.
putln
(
'#endif'
)
vtab_list
,
vtabslot_list
=
self
.
sort_type_hierarchy
(
modules
,
env
)
self
.
generate_type_definitions
(
env
,
modules
,
vtab_list
,
vtabslot_list
,
typecode
)
env
,
modules
,
vtab_list
,
vtabslot_list
,
typecode
,
globalstate
)
modulecode
=
globalstate
[
'module_declarations'
]
for
module
in
modules
:
defined_here
=
module
is
env
modulecode
.
putln
(
""
)
modulecode
.
putln
(
"/* Module declarations from %s */"
%
module
.
qualified_name
.
as_c_string_literal
())
self
.
generate_c_class_declarations
(
module
,
modulecode
,
defined_here
,
globalstate
)
self
.
generate_cvariable_declarations
(
module
,
modulecode
,
defined_here
)
self
.
generate_cfunction_declarations
(
module
,
modulecode
,
defined_here
)
...
...
Cython/Compiler/Nodes.py
View file @
953d754d
...
...
@@ -1663,6 +1663,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 @
953d754d
...
...
@@ -1498,10 +1498,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
...
...
@@ -4173,6 +4175,8 @@ def compute_mro_generic(cls):
class
CypClassType
(
CppClassType
):
# lock_mode string (tri-state: "nolock"/"checklock"/"autolock")
# _mro [CppClassType] or None The Method Resolution Order of this cypclass according to Python
# wrapper_type PyExtensionType the type of the cclass wrapper
is_cyp_class
=
1
to_py_function
=
"__Pyx_PyObject_FromCyObject"
...
...
@@ -4182,7 +4186,7 @@ class CypClassType(CppClassType):
self
.
lock_mode
=
lock_mode
if
lock_mode
else
"autolock"
self
.
activable
=
activable
self
.
_mro
=
None
self
.
typeobj_cname
=
None
# set externally
self
.
wrapper_type
=
None
# set during
# Return the MRO for this cypclass
# Compute all the mro needed when a previous computation is not available
...
...
Cython/Compiler/Symtab.py
View file @
953d754d
...
...
@@ -737,8 +737,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