PySide Binding Generation Tutorial: Module 4 The Global Header: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:LanguageBindings::PySide::Shiboken::PySide Binding Generation Tutorial]]<br />[toc align_right=&quot;yes&amp;quot; depth=&quot;3&amp;quot;]
[[Category:LanguageBindings::PySide::Shiboken::PySide Binding Generation Tutorial]]
[toc align_right="yes" depth="3"]


'''English''' &quot;French&amp;quot;:http://qt-devnet.developpez.com/tutoriels/python/pyside/binding-shiboken/#LVI
'''English''' "French":http://qt-devnet.developpez.com/tutoriels/python/pyside/binding-shiboken/#LVI


* '''Note:''' this article is a member of the multipart &quot;PySide Binding Generation Tutorial&amp;quot;:http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Shiboken::PySide_Binding_Generation_Tutorial  
* '''Note:''' this article is a member of the multipart "PySide Binding Generation Tutorial":http://developer.qt.nokia.com/wiki/Category:LanguageBindings::PySide::Shiboken::PySide_Binding_Generation_Tutorial  


= The Global Header =
= The Global Header =
Line 9: Line 10:
In addition to the information provided by the type system, the generator needs to gather more data from the library headers containing the classes to be exported to Python. If there is a header that includes all the others (or just one, as is the case of '''libfoo''') this could be passed directly to the generator.
In addition to the information provided by the type system, the generator needs to gather more data from the library headers containing the classes to be exported to Python. If there is a header that includes all the others (or just one, as is the case of '''libfoo''') this could be passed directly to the generator.


If such a file is not available, or only a subset of the library is desired, or if some flags must be set through &lt;code&amp;gt;#define&amp;lt;/code&amp;gt; statements before parsing the library headers, then a &lt;code&amp;gt;global.h&amp;lt;/code&amp;gt; file must be provided. For example, if NULL is not defined and it is used as a default parameter for some constructor or method, the parser will not recognize it.
If such a file is not available, or only a subset of the library is desired, or if some flags must be set through <code>#define</code> statements before parsing the library headers, then a <code>global.h</code> file must be provided. For example, if NULL is not defined and it is used as a default parameter for some constructor or method, the parser will not recognize it.


== global.h ==
== global.h ==


<code><br />#undef QT_NO_STL<br />#undef QT_NO_STL_WCHAR
<code>
#undef QT_NO_STL
#undef QT_NO_STL_WCHAR


#ifndef NULL<br />#define NULL 0<br />#endif
#ifndef NULL
#define NULL 0
#endif


#include &quot;pyside_global.h&amp;quot;<br />#include &lt;foo.h&amp;gt;<br /></code>
#include "pyside_global.h"
#include <foo.h>
</code>


&lt;code&amp;gt;pyside_global.h&amp;lt;/code&amp;gt; contains includes and definitions needed to generate the PySide bindings. It was copied from the resulting file after processing of &lt;code&amp;gt;pyside/PySide/global.pc.in&amp;lt;/code&amp;gt;. At the moment the file is included in this tutorial's source code tarball, but the desirable situation is to have it provided by PySide itself. For the time being just copy it to your PySide based binding projects.
<code>pyside_global.h</code> contains includes and definitions needed to generate the PySide bindings. It was copied from the resulting file after processing of <code>pyside/PySide/global.pc.in</code>. At the moment the file is included in this tutorial's source code tarball, but the desirable situation is to have it provided by PySide itself. For the time being just copy it to your PySide based binding projects.

Revision as of 10:23, 25 February 2015

[toc align_right="yes" depth="3"]

English "French":http://qt-devnet.developpez.com/tutoriels/python/pyside/binding-shiboken/#LVI

The Global Header

In addition to the information provided by the type system, the generator needs to gather more data from the library headers containing the classes to be exported to Python. If there is a header that includes all the others (or just one, as is the case of libfoo) this could be passed directly to the generator.

If such a file is not available, or only a subset of the library is desired, or if some flags must be set through

#define

statements before parsing the library headers, then a

global.h

file must be provided. For example, if NULL is not defined and it is used as a default parameter for some constructor or method, the parser will not recognize it.

global.h

#undef QT_NO_STL
#undef QT_NO_STL_WCHAR

#ifndef NULL
#define NULL 0
#endif

#include "pyside_global.h"
#include <foo.h>
pyside_global.h

contains includes and definitions needed to generate the PySide bindings. It was copied from the resulting file after processing of

pyside/PySide/global.pc.in

. At the moment the file is included in this tutorial's source code tarball, but the desirable situation is to have it provided by PySide itself. For the time being just copy it to your PySide based binding projects.