Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/pyste/doc/introduction.html @ 69

Last change on this file since 69 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.0 KB
Line 
1<html>
2<head>
3<!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc -->
4<title>Introduction</title>
5<link rel="stylesheet" href="theme/style.css" type="text/css">
6<link rel="next" href="running_pyste.html">
7</head>
8<body>
9<table width="100%" height="48" border="0" cellspacing="2">
10  <tr>
11    <td><img src="../../../../boost.png">
12    </td>
13    <td width="85%">
14      <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Introduction</b></font>
15    </td>
16  </tr>
17</table>
18<br>
19<table border="0">
20  <tr>
21    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
22    <td width="30"><img src="theme/l_arr_disabled.gif" border="0"></td>
23    <td width="20"><a href="running_pyste.html"><img src="theme/r_arr.gif" border="0"></a></td>
24   </tr>
25</table>
26<a name="what_is_pyste_"></a><h2>What is Pyste?</h2><p>
27Pyste is a <a href="../../index.html">
28Boost.Python</a> code generator. The user specifies the classes and
29functions to be exported using a simple <i>interface file</i>, which following the
30<a href="../../index.html">
31Boost.Python</a>'s philosophy, is simple Python code. Pyste then uses <a href="http://www.gccxml.org">
32GCCXML</a> to
33parse all the headers and extract the necessary information to automatically
34generate C++ code.</p>
35<a name="example"></a><h2>Example</h2><p>
36Let's borrow the class <tt>World</tt> from the <a href="../../doc/tutorial/doc/html/python/exposing.html">
37tutorial</a>: </p>
38<code><pre>
39    <span class=keyword>struct </span><span class=identifier>World
40    </span><span class=special>{
41        </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>-&gt;</span><span class=identifier>msg </span><span class=special>= </span><span class=identifier>msg</span><span class=special>; }
42        </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>; }
43        </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>string </span><span class=identifier>msg</span><span class=special>;
44    };
45</span></pre></code>
46<p>
47Here's the interface file for it, named <tt>world.pyste</tt>:</p>
48<code><pre>
49    <span class=identifier>Class</span><span class=special>(</span><span class=string>&quot;World&quot;</span><span class=special>, </span><span class=string>&quot;world.h&quot;</span><span class=special>)
50</span></pre></code>
51<p>
52and that's it!</p>
53<p>
54The next step is invoke Pyste in the command-line:</p>
55<code><pre>python pyste.py --module=hello world.pyste</pre></code><p>
56this will create a file &quot;<tt>hello.cpp</tt>&quot; in the directory where the command was
57run. </p>
58<p>
59Pyste supports the following features:</p>
60<ul><li>Functions</li><li>Classes</li><li>Class Templates</li><li>Virtual Methods</li><li>Overloading</li><li>Attributes </li><li>Enums (both &quot;free&quot; 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">
61  <tr>
62    <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
63    <td width="30"><img src="theme/l_arr_disabled.gif" border="0"></td>
64    <td width="20"><a href="running_pyste.html"><img src="theme/r_arr.gif" border="0"></a></td>
65   </tr>
66</table>
67<br>
68<hr size="1"><p class="copyright">Copyright &copy; 2003 Bruno da Silva de Oliveira<br>Copyright &copy; 2002-2003 Joel de Guzman<br><br>
69<font size="2">Distributed under
70  the Boost Software License, Version 1.0. (See accompanying file
71  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p>
72</body>
73</html>
Note: See TracBrowser for help on using the repository browser.