1 | <html> |
---|
2 | <head> |
---|
3 | <!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc --> |
---|
4 | <title>Inserting Code</title> |
---|
5 | <link rel="stylesheet" href="theme/style.css" type="text/css"> |
---|
6 | <link rel="prev" href="adding_new_methods.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>Inserting Code</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"><a href="adding_new_methods.html"><img src="theme/l_arr.gif" border="0"></a></td> |
---|
23 | <td width="20"><img src="theme/r_arr_disabled.gif" border="0"></td> |
---|
24 | </tr> |
---|
25 | </table> |
---|
26 | <p> |
---|
27 | You can insert arbitrary code in the generated cpps, just use the functions |
---|
28 | <tt>declaration_code</tt> and <tt>module_code</tt>. This will insert the given string in the |
---|
29 | respective sections. Example:</p> |
---|
30 | <code><pre> |
---|
31 | ##<span class=identifier>file </span><span class=identifier>A</span><span class=special>.</span><span class=identifier>pyste |
---|
32 | </span><span class=identifier>Class</span><span class=special>(</span><span class=string>"A"</span><span class=special>, </span><span class=string>"A.h"</span><span class=special>) |
---|
33 | </span><span class=identifier>declaration_code</span><span class=special>(</span><span class=string>"/* declaration_code() comes here */\n"</span><span class=special>) |
---|
34 | </span><span class=identifier>module_code</span><span class=special>(</span><span class=string>"/* module_code() comes here */\n"</span><span class=special>) |
---|
35 | </span></pre></code> |
---|
36 | <p> |
---|
37 | Will generate:</p> |
---|
38 | <code><pre> |
---|
39 | <span class=comment>// Includes ==================================================================== |
---|
40 | </span><span class=preprocessor>#include </span><span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>python</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>> |
---|
41 | |
---|
42 | // </span><span class=identifier>Using </span><span class=special>======================================================================= |
---|
43 | </span><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>python</span><span class=special>; |
---|
44 | |
---|
45 | // </span><span class=identifier>Declarations </span><span class=special>================================================================ |
---|
46 | |
---|
47 | /* </span><span class=identifier>declaration_code</span><span class=special>() </span><span class=identifier>comes </span><span class=identifier>here </span><span class=special>*/ |
---|
48 | |
---|
49 | // </span><span class=identifier>Module </span><span class=special>====================================================================== |
---|
50 | </span><span class=identifier>BOOST_PYTHON_MODULE</span><span class=special>(</span><span class=identifier>A</span><span class=special>) |
---|
51 | { |
---|
52 | </span><span class=identifier>class_</span><span class=special>< </span><span class=identifier>A </span><span class=special>>(</span><span class=string>"A"</span><span class=special>, </span><span class=identifier>init</span><span class=special>< >()) |
---|
53 | .</span><span class=identifier>def</span><span class=special>(</span><span class=identifier>init</span><span class=special>< </span><span class=keyword>const </span><span class=identifier>A</span><span class=special>& >()) |
---|
54 | ; |
---|
55 | |
---|
56 | /* </span><span class=identifier>module_code</span><span class=special>() </span><span class=identifier>comes </span><span class=identifier>here </span><span class=special>*/ |
---|
57 | } |
---|
58 | </span></pre></code> |
---|
59 | <table border="0"> |
---|
60 | <tr> |
---|
61 | <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td> |
---|
62 | <td width="30"><a href="adding_new_methods.html"><img src="theme/l_arr.gif" border="0"></a></td> |
---|
63 | <td width="20"><img src="theme/r_arr_disabled.gif" border="0"></td> |
---|
64 | </tr> |
---|
65 | </table> |
---|
66 | <br> |
---|
67 | <hr size="1"><p class="copyright">Copyright © 2003 Bruno da Silva de Oliveira<br>Copyright © 2002-2003 Joel de Guzman<br><br> |
---|
68 | <font size="2">Distributed under |
---|
69 | the Boost Software License, Version 1.0. (See accompanying file |
---|
70 | LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) </font> </p> |
---|
71 | </body> |
---|
72 | </html> |
---|