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
300c37a4
Commit
300c37a4
authored
Feb 22, 2018
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! fixup! fixup! Added documentation on extension class instantiation from existing pointer
parent
e98b190f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
+4
-5
docs/src/userguide/extension_types.rst
docs/src/userguide/extension_types.rst
+4
-5
No files found.
docs/src/userguide/extension_types.rst
View file @
300c37a4
...
@@ -554,10 +554,8 @@ contructors, this necessitates the use of factory functions. For example, ::
...
@@ -554,10 +554,8 @@ contructors, this necessitates the use of factory functions. For example, ::
cdef my_c_struct *_ptr
cdef my_c_struct *_ptr
cdef bint ptr_owner
cdef bint ptr_owner
def __cinit__(self, owner=False):
def __cinit__(self):
# On cinit, do not create new structure but set pointer to NULL
self.ptr_owner = False
self._ptr = NULL
self.ptr_owner = owner
def __dealloc__(self):
def __dealloc__(self):
# De-allocate if not null and flag is set
# De-allocate if not null and flag is set
...
@@ -583,8 +581,9 @@ contructors, this necessitates the use of factory functions. For example, ::
...
@@ -583,8 +581,9 @@ contructors, this necessitates the use of factory functions. For example, ::
the extension type to ``free`` the structure pointed to by ``_ptr``
the extension type to ``free`` the structure pointed to by ``_ptr``
when the wrapper object is deallocated."""
when the wrapper object is deallocated."""
# Call to __new__ bypasses __init__ constructor
# Call to __new__ bypasses __init__ constructor
cdef WrapperClass wrapper = WrapperClass.__new__(WrapperClass
, owner=True
)
cdef WrapperClass wrapper = WrapperClass.__new__(WrapperClass)
wrapper._ptr = _ptr
wrapper._ptr = _ptr
wrapper.ptr_owner = owner
return wrapper
return wrapper
@staticmethod
@staticmethod
...
...
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