diff options
author | Timothy Pearson <[email protected]> | 2011-11-22 03:12:38 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-22 03:12:38 -0600 |
commit | 7d27356bafd5670adcc8753ab5437b3bf8ffa4be (patch) | |
tree | 959eb3757b9dc41290c81c022e45c955573e9a59 /doc/html/directives.html | |
parent | 6c4cc3653e8dd7668295f3e659b7eb4dc571b67c (diff) | |
download | sip4-tqt-7d27356bafd5670adcc8753ab5437b3bf8ffa4be.tar.gz sip4-tqt-7d27356bafd5670adcc8753ab5437b3bf8ffa4be.zip |
Initial TQt conversion
Diffstat (limited to 'doc/html/directives.html')
-rw-r--r-- | doc/html/directives.html | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/doc/html/directives.html b/doc/html/directives.html index eab1185..102bf61 100644 --- a/doc/html/directives.html +++ b/doc/html/directives.html @@ -100,7 +100,7 @@ Klass *klassInstance; version number must be greater than or equal to 1.</p> <p>See <a class="reference external" href="using.html#ref-incompat-apis"><em>Managing Incompatible APIs</em></a> for more detail.</p> <p>For example:</p> -<div class="highlight-python"><pre>%API PyQt4 1</pre> +<div class="highlight-python"><pre>%API PyTQt4 1</pre> </div> <dl class="directive"> <dt id="directive-%BIGetBufferCode"> @@ -313,9 +313,9 @@ same name.</p> subsequent <a class="reference internal" href="#directive-%CModule"><tt class="xref docutils literal"><span class="pre">%CModule</span></tt></a> or <a class="reference internal" href="#directive-%Module"><tt class="xref docutils literal"><span class="pre">%Module</span></tt></a> directive is interpreted as defining a component module.</p> <p>For example:</p> -<div class="highlight-python"><pre>%CompositeModule PyQt4.Qt -%Include QtCore/QtCoremod.sip -%Include QtGui/QtGuimod.sip</pre> +<div class="highlight-python"><pre>%CompositeModule PyTQt4.TQt +%Include TQtCore/TQtCoremod.sip +%Include TQtGui/TQtGuimod.sip</pre> </div> <p>The main purpose of a composite module is as a programmer convenience as they don’t have to remember which which individual module an object is defined in.</p> @@ -333,9 +333,9 @@ SIP generated modules (refered to as component modules in this context).</p> subsequent <a class="reference internal" href="#directive-%CModule"><tt class="xref docutils literal"><span class="pre">%CModule</span></tt></a> or <a class="reference internal" href="#directive-%Module"><tt class="xref docutils literal"><span class="pre">%Module</span></tt></a> directive is interpreted as defining a component module.</p> <p>For example:</p> -<div class="highlight-python"><pre>%ConsolidatedModule PyQt4._qt -%Include QtCore/QtCoremod.sip -%Include QtGui/QtGuimod.sip</pre> +<div class="highlight-python"><pre>%ConsolidatedModule PyTQt4._qt +%Include TQtCore/TQtCoremod.sip +%Include TQtGui/TQtGuimod.sip</pre> </div> <p>A consolidated module is not intended to be explicitly imported by an application. Instead it is imported by its component modules when they @@ -380,8 +380,8 @@ made to each element of the list.</dd> </dl> <p>The handwritten code must explicitly return a <tt class="docutils literal"><span class="pre">PyObject</span> <span class="pre">*</span></tt>. If there was an error then a Python exception must be raised and <tt class="docutils literal"><span class="pre">NULL</span></tt> returned.</p> -<p>The following example converts a <tt class="docutils literal"><span class="pre">QList<QWidget</span> <span class="pre">*></span></tt> instance to a Python -list of <tt class="docutils literal"><span class="pre">QWidget</span></tt> instances:</p> +<p>The following example converts a <tt class="docutils literal"><span class="pre">TQList<TQWidget</span> <span class="pre">*></span></tt> instance to a Python +list of <tt class="docutils literal"><span class="pre">TQWidget</span></tt> instances:</p> <div class="highlight-python"><pre>%ConvertFromTypeCode PyObject *l; @@ -390,15 +390,15 @@ list of <tt class="docutils literal"><span class="pre">QWidget</span></tt> insta return NULL; // Go through each element in the C++ instance and convert it to a - // wrapped QWidget. + // wrapped TQWidget. for (int i = 0; i < sipCpp->size(); ++i) { - QWidget *w = sipCpp->at(i); + TQWidget *w = sipCpp->at(i); PyObject *wobj; - // Get the Python wrapper for the QWidget instance, creating a new + // Get the Python wrapper for the TQWidget instance, creating a new // one if necessary, and handle any ownership transfer. - if ((wobj = sipConvertFromType(w, sipType_QWidget, sipTransferObj)) == NULL) + if ((wobj = sipConvertFromType(w, sipType_TQWidget, sipTransferObj)) == NULL) { // There was an error so garbage collect the Python list. Py_DECREF(l); @@ -469,21 +469,21 @@ it can.</p> </dd> </dl> <p>The handwritten code must not explicitly return.</p> -<p>The following example shows the sub-class conversion code for <tt class="docutils literal"><span class="pre">QEvent</span></tt> based -class hierarchy in PyQt:</p> -<div class="highlight-python"><pre>class QEvent +<p>The following example shows the sub-class conversion code for <tt class="docutils literal"><span class="pre">TQEvent</span></tt> based +class hierarchy in PyTQt:</p> +<div class="highlight-python"><pre>class TQEvent { %ConvertToSubClassCode - // QEvent sub-classes provide a unique type ID. + // TQEvent sub-classes provide a unique type ID. switch (sipCpp->type()) { - case QEvent::Timer: - sipType = sipType_QTimerEvent; + case TQEvent::Timer: + sipType = sipType_TQTimerEvent; break; - case QEvent::KeyPress: - case QEvent::KeyRelease: - sipType = sipType_QKeyEvent; + case TQEvent::KeyPress: + case TQEvent::KeyRelease: + sipType = sipType_TQKeyEvent; break; // Skip the remaining event types to keep the example short. @@ -514,9 +514,9 @@ used as part of the <a class="reference internal" href="#directive-%MappedType"> specification. The code is also called to determine if the Python object is of the correct type prior to conversion.</p> <p>When used as part of a class specification it can automatically convert -additional types of Python object. For example, PyQt uses it in the -specification of the <tt class="docutils literal"><span class="pre">QString</span></tt> class to allow Python string objects and -unicode objects to be used wherever <tt class="docutils literal"><span class="pre">QString</span></tt> instances are expected.</p> +additional types of Python object. For example, PyTQt uses it in the +specification of the <tt class="docutils literal"><span class="pre">TQString</span></tt> class to allow Python string objects and +tqunicode objects to be used wherever <tt class="docutils literal"><span class="pre">TQString</span></tt> instances are expected.</p> <p>The following variables are made available to the handwritten code:</p> <dl class="docutils"> <dt>int *sipIsErr</dt> @@ -554,8 +554,8 @@ returned instance is a derived class. See <a class="reference external" href="c_api.html#ref-derived-classes"><em>Generated Derived Classes</em></a>.</li> </ul> </blockquote> -<p>The following example converts a Python list of <tt class="docutils literal"><span class="pre">QPoint</span></tt> instances to a -<tt class="docutils literal"><span class="pre">QList<QPoint></span></tt> instance:</p> +<p>The following example converts a Python list of <tt class="docutils literal"><span class="pre">TQPoint</span></tt> instances to a +<tt class="docutils literal"><span class="pre">TQList<TQPoint></span></tt> instance:</p> <div class="highlight-python"><pre>%ConvertToTypeCode // See if we are just being asked to check the type of the Python // object. @@ -567,11 +567,11 @@ returned instance is a derived class. See return 0; // Check the type of each element. We specify SIP_NOT_NONE to - // disallow None because it is a list of QPoint, not of a pointer - // to a QPoint, so None isn't appropriate. + // disallow None because it is a list of TQPoint, not of a pointer + // to a TQPoint, so None isn't appropriate. for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) if (!sipCanConvertToType(PyList_GET_ITEM(sipPy, i), - sipType_QPoint, SIP_NOT_NONE)) + sipType_TQPoint, SIP_NOT_NONE)) return 0; // The type is valid. @@ -579,26 +579,26 @@ returned instance is a derived class. See } // Create the instance on the heap. - QList<QPoint> *ql = new QList<QPoint>; + TQList<TQPoint> *ql = new TQList<TQPoint>; for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) { - QPoint *qp; + TQPoint *qp; int state; // Get the address of the element's C++ instance. Note that, in // this case, we don't apply any ownership changes to the list // elements, only to the list itself. - qp = reinterpret_cast<QPoint *>(sipConvertToType( + qp = reinterpret_cast<TQPoint *>(sipConvertToType( PyList_GET_ITEM(sipPy, i), - sipType_QPoint, 0, + sipType_TQPoint, 0, SIP_NOT_NONE, &state, sipIsErr)); // Deal with any errors. if (*sipIsErr) { - sipReleaseType(qp, sipType_QPoint, state); + sipReleaseType(qp, sipType_TQPoint, state); // Tidy up. delete ql; @@ -609,11 +609,11 @@ returned instance is a derived class. See ql->append(*qp); - // A copy of the QPoint was appended to the list so we no longer + // A copy of the TQPoint was appended to the list so we no longer // need it. It may be a temporary instance that should be // destroyed, or a wrapped instance that should not be destroyed. // sipReleaseType() will do the right thing. - sipReleaseType(qp, sipType_QPoint, state); + sipReleaseType(qp, sipType_TQPoint, state); } // Return the instance. @@ -685,7 +685,7 @@ modules, that doesn’t have an explicit meta-type.</p> meta-type used by a particular C/C++ type.</p> <p>See the section <a class="reference external" href="using.html#ref-types-metatypes"><em>Types and Meta-types</em></a> for more details.</p> <p>For example:</p> -<div class="highlight-python"><pre>%DefaultMetatype PyQt4.QtCore.pyqtWrapperType</pre> +<div class="highlight-python"><pre>%DefaultMetatype PyTQt4.TQtCore.pyqtWrapperType</pre> </div> <dl class="directive"> <dt id="directive-%DefaultSupertype"> @@ -916,8 +916,8 @@ pointer to the structure or class.</dd> <dt>int sipRes</dt> <dd>The handwritten code should set this to the result to be returned.</dd> </dl> -<p>The following simplified example is taken from PyQt. The <tt class="docutils literal"><span class="pre">QCustomEvent</span></tt> -class allows arbitary data to be attached to the event. In PyQt this data is +<p>The following simplified example is taken from PyTQt. The <tt class="docutils literal"><span class="pre">TQCustomEvent</span></tt> +class allows arbitary data to be attached to the event. In PyTQt this data is always a Python object and so should be handled by the garbage collector:</p> <div class="highlight-python"><pre>%GCClearCode PyObject *obj; @@ -961,7 +961,7 @@ collector.</dd> <dt>int sipRes</dt> <dd>The handwritten code should set this to the result to be returned.</dd> </dl> -<p>The following simplified example is taken from PyQt’s <tt class="docutils literal"><span class="pre">QCustomEvent</span></tt> class:</p> +<p>The following simplified example is taken from PyTQt’s <tt class="docutils literal"><span class="pre">TQCustomEvent</span></tt> class:</p> <div class="highlight-python"><pre>%GCTraverseCode PyObject *obj; @@ -1245,7 +1245,7 @@ the handwritten code that converts an instance of the mapped type to a Python object.</p> <p>For example:</p> <div class="highlight-python"><pre>template<Type *> -%MappedType QList +%MappedType TQList { %TypeHeaderCode // Include the library interface to the type being mapped. @@ -1272,7 +1272,7 @@ object.</p> } // Create the instance on the heap. - QList<Type *> *ql = new QList<Type *>; + TQList<Type *> *ql = new TQList<Type *>; for (int i = 0; i < PyList_GET_SIZE(sipPy); ++i) { @@ -1333,9 +1333,9 @@ object.</p> %End }</pre> </div> -<p>Using this we can use, for example, <tt class="docutils literal"><span class="pre">QList<QObject</span> <span class="pre">*></span></tt> throughout the +<p>Using this we can use, for example, <tt class="docutils literal"><span class="pre">TQList<TQObject</span> <span class="pre">*></span></tt> throughout the module’s specification files (and in any module that imports this one). The -generated code will automatically map this to and from a Python list of QObject +generated code will automatically map this to and from a Python list of TQObject instances when appropriate.</p> <dl class="directive"> <dt id="directive-%MethodCode"> |