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
569bdff8
Commit
569bdff8
authored
May 25, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give CyObject reference to PyObject wrapper instead of inheriting from PyObject
parent
81fcb9c8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
Cython/Compiler/CypclassWrapper.py
Cython/Compiler/CypclassWrapper.py
+3
-3
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+13
-5
No files found.
Cython/Compiler/CypclassWrapper.py
View file @
569bdff8
...
...
@@ -593,9 +593,9 @@ def generate_cyp_class_wrapper_definition(type, wrapper_entry, constructor_entry
# initialise PyObject fields
if
(
is_new_return_type
):
code
.
putln
(
"if(self) {"
)
code
.
putln
(
"self->ob_
refcnt = 0;
"
)
# code.putln("self->ob_type = NULL
;")
code
.
putln
(
"self->ob_type = &%s;"
%
type
.
typeobj_cname
)
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
(
"}"
)
if
init_entry
:
...
...
Cython/Utility/CyObjects.cpp
View file @
569bdff8
...
...
@@ -56,12 +56,19 @@
int
trywlock
();
};
class
CyObject
:
public
PyObject
{
class
CyObject
;
struct
CyPyObject
:
public
PyObject
{
CyObject
*
nogil_cyobject
;
};
class
CyObject
{
private:
CyObject_ATOMIC_REFCOUNT_TYPE
nogil_ob_refcnt
;
//pthread_rwlock_t ob_lock;
RecursiveUpgradeableRWLock
ob_lock
;
public:
CyPyObject
*
ob_cypyobject
;
CyObject
()
:
nogil_ob_refcnt
(
1
)
{}
virtual
~
CyObject
()
{}
void
CyObject_INCREF
();
...
...
@@ -169,13 +176,14 @@
* are likely (certain even?) to be followed by a Cy_DECREF; stealing the
* reference would mean that Cy_DECREF should not be called after this.
*/
static
inline
PyObject
*
__Pyx_PyObject_FromCyObject
(
CyObject
*
ob
)
{
static
inline
PyObject
*
__Pyx_PyObject_FromCyObject
(
CyObject
*
cy
)
{
CyPyObject
*
ob
=
cy
->
ob_cypyobject
;
// artificial atomic increment the first time Python gets a reference
if
(
ob
->
ob_refcnt
==
0
)
ob
->
CyObject_INCREF
();
cy
->
CyObject_INCREF
();
// return a new Python reference
Py_INCREF
(
(
PyObject
*
)
ob
);
return
(
PyObject
*
)
ob
;
Py_INCREF
(
ob
);
return
ob
;
}
/* Cast argument to CyObject* type. */
...
...
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