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
300c37a4
Commit
300c37a4
authored
6 years ago
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
Show 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, ::
cdef my_c_struct *_ptr
cdef bint ptr_owner
def __cinit__(self, owner=False):
# On cinit, do not create new structure but set pointer to NULL
self._ptr = NULL
self.ptr_owner = owner
def __cinit__(self):
self.ptr_owner = False
def __dealloc__(self):
# De-allocate if not null and flag is set
...
...
@@ -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``
when the wrapper object is deallocated."""
# 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_owner = owner
return wrapper
@staticmethod
...
...
This diff is collapsed.
Click to expand it.
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