mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 04:22:16 +00:00
Also port some "glaringly obvious" bugfixes from HEAD. Hope it doesn't cause problems. [SVN r35237]
74 lines
4.0 KiB
HTML
74 lines
4.0 KiB
HTML
<html>
|
|
<head>
|
|
<!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc -->
|
|
<title>Introduction</title>
|
|
<link rel="stylesheet" href="theme/style.css" type="text/css">
|
|
<link rel="next" href="running_pyste.html">
|
|
</head>
|
|
<body>
|
|
<table width="100%" height="48" border="0" cellspacing="2">
|
|
<tr>
|
|
<td><img src="../../../../boost.png">
|
|
</td>
|
|
<td width="85%">
|
|
<font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Introduction</b></font>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<table border="0">
|
|
<tr>
|
|
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
|
|
<td width="30"><img src="theme/l_arr_disabled.gif" border="0"></td>
|
|
<td width="20"><a href="running_pyste.html"><img src="theme/r_arr.gif" border="0"></a></td>
|
|
</tr>
|
|
</table>
|
|
<a name="what_is_pyste_"></a><h2>What is Pyste?</h2><p>
|
|
Pyste is a <a href="../../index.html">
|
|
Boost.Python</a> code generator. The user specifies the classes and
|
|
functions to be exported using a simple <i>interface file</i>, which following the
|
|
<a href="../../index.html">
|
|
Boost.Python</a>'s philosophy, is simple Python code. Pyste then uses <a href="http://www.gccxml.org">
|
|
GCCXML</a> to
|
|
parse all the headers and extract the necessary information to automatically
|
|
generate C++ code.</p>
|
|
<a name="example"></a><h2>Example</h2><p>
|
|
Let's borrow the class <tt>World</tt> from the <a href="../../doc/tutorial/doc/html/python/exposing.html">
|
|
tutorial</a>: </p>
|
|
<code><pre>
|
|
<span class=keyword>struct </span><span class=identifier>World
|
|
</span><span class=special>{
|
|
</span><span class=keyword>void </span><span class=identifier>set</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=identifier>msg</span><span class=special>) { </span><span class=keyword>this</span><span class=special>-></span><span class=identifier>msg </span><span class=special>= </span><span class=identifier>msg</span><span class=special>; }
|
|
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=identifier>greet</span><span class=special>() { </span><span class=keyword>return </span><span class=identifier>msg</span><span class=special>; }
|
|
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=identifier>msg</span><span class=special>;
|
|
};
|
|
</span></pre></code>
|
|
<p>
|
|
Here's the interface file for it, named <tt>world.pyste</tt>:</p>
|
|
<code><pre>
|
|
<span class=identifier>Class</span><span class=special>(</span><span class=string>"World"</span><span class=special>, </span><span class=string>"world.h"</span><span class=special>)
|
|
</span></pre></code>
|
|
<p>
|
|
and that's it!</p>
|
|
<p>
|
|
The next step is invoke Pyste in the command-line:</p>
|
|
<code><pre>python pyste.py --module=hello world.pyste</pre></code><p>
|
|
this will create a file "<tt>hello.cpp</tt>" in the directory where the command was
|
|
run. </p>
|
|
<p>
|
|
Pyste supports the following features:</p>
|
|
<ul><li>Functions</li><li>Classes</li><li>Class Templates</li><li>Virtual Methods</li><li>Overloading</li><li>Attributes </li><li>Enums (both "free" enums and class enums)</li><li>Nested Classes</li><li>Support for <tt>boost::shared_ptr</tt> and <tt>std::auto_ptr</tt></li><li>Global Variables</li></ul><table border="0">
|
|
<tr>
|
|
<td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
|
|
<td width="30"><img src="theme/l_arr_disabled.gif" border="0"></td>
|
|
<td width="20"><a href="running_pyste.html"><img src="theme/r_arr.gif" border="0"></a></td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<hr size="1"><p class="copyright">Copyright © 2003 Bruno da Silva de Oliveira<br>Copyright © 2002-2003 Joel de Guzman<br><br>
|
|
<font size="2">Distributed under
|
|
the Boost Software License, Version 1.0. (See accompanying file
|
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
|
|
</body>
|
|
</html>
|