On Friday 12 August 2011 04:39:16 [email protected] wrote: > On 11 Aug 2011, at 20:48, ext Hugo Parente Lima wrote: > > I prefer start with a minimal set of functions then adding functions when > > needed/requested, i.e. when we get a good use case justifying the > > implementation. > > I'm not sure this is a good approach for developing public APIs. The > consistency of the module might easily suffer if new features are added. > Also, in this case, we have existing underlying functionality in shiboken > which we just need to expose to Python, and there exists an analogous > module in PyQt to get ideas from. > > So, I still strongly prefer reviewing the sip module API and proudly > borrowing relevant items. I quickly went through the doc [1] and many of > the methods would appear to be potentially very useful for PySide > developers as well. Not that I'm any expert, of course. > > [1] http://www.riverbankcomputing.co.uk/static/Docs/sip4/python_api.html
Version 2 attached. Changes: * objectInfo renamed to dump. * Arguments of wrapInstance swapped to avoid confusions with people used to sip.wrapinstance function. * hasOwnership renamed to isOwnedByPython. * Added function wasCreatedByPython. * Added function delete * Added function getCppPointer > > Cheers, > > ma. -- Hugo Parente Lima INdT - Instituto Nokia de Tecnologia
PSEP: XXXX Title: Shiboken helper module Version: $Revision$ Last-Modified: $Date$ Author: Hugo Parente Lima <[email protected]> Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 02-Aug-2011 Post-History: .. |maya| unicode:: Maya U+2122 Abstract ======== This PSEP describes a new module to access internal information related to our binding technology. Access to this internal information is required to e.g.: integrate PySide with Qt based programs that offer Python scripting like |maya| or just for debug purposes. Rationale ========= The Python module named "shiboken", will offer the following functions: Some function description refer to "Shiboken based objects", wich means Python objects instances of any Python Type created using Shiboken. ``isValid(obj)`` Given a Python object, returns True if the object methods can be called without an exception being thrown. A Python wrapper becomes invalid when the underlying C++ object is destroyed or unreachable. ``wrapInstance(address, type)`` Creates a Python wrapper for a C++ object instantiated at a given memory address - the returned object type will be the same given by the user. The type must be a Shiboken type, the C++ object will not be destroyed when the returned Python object reach zero references. If the address is invalid or doesn't point to a C++ object of given type the behavior is undefined. ``getCppPointer(obj)`` Returns a tuple of longs that is the memory addresses of the C++ instances wrapped by the given object. ``delete(obj)`` Deletes the C++ object wrapped by the given python object. ``isOwnedByPython(obj)`` Given a Python object, returns True if Python is responsible for deleting the underlying C++ object, False otherwise. If the object was not a Shiboken based object, a TypeError should be throw. ``wasCreatedByPython(obj)`` Returns true if the given Python object was created by Python. ``dump(obj)`` Returns a string with implementation defined information about the object, this method should be used **only** for debug purposes by developers creating their own bindings as this PSEP doesn't offer any guarantee that the string format will be the same across different versions. If the object was not a Shiboken based object, a TypeError should be throw. Discussion ========== Carlo Giesa wanted to do some integration of PySide with |maya| [#maya]_ and noticed that PySide doesn't have anything equivalent to PyQt4 ``sip.wrapinstance()``. David MartÃnez Martà filed a feature [#bug536]_ request for a function to return True or False if an object still valid or not. Thomas Pearl filed feature requests [#bug902]_ summarizing some functions that would appear in a helper module. References ========== .. [#bug536] `Bug 536 <http://bugs.pyside.org/show_bug.cgi?id=536>`_ - Add property to QObject that exposes if a C++ reference is still valid. .. [#bug902] `Bug 902 <http://bugs.pyside.org/show_bug.cgi?id=902>`_ - Expose Shiboken functionality through a Python module. .. [#maya] A 3D Animation, Visual Effects & Compositing Software - http://usa.autodesk.com/maya/ Copyright ========= This document has been placed in the public domain. .. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 coding: utf-8 End:
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PySide mailing list [email protected] http://lists.pyside.org/listinfo/pyside
