summaryrefslogtreecommitdiff
path: root/libs/python/pyste/doc/policies.html
diff options
context:
space:
mode:
Diffstat (limited to 'libs/python/pyste/doc/policies.html')
-rw-r--r--libs/python/pyste/doc/policies.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/libs/python/pyste/doc/policies.html b/libs/python/pyste/doc/policies.html
new file mode 100644
index 000000000..3628093bd
--- /dev/null
+++ b/libs/python/pyste/doc/policies.html
@@ -0,0 +1,90 @@
+<html>
+<head>
+<!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc -->
+<title>Policies</title>
+<link rel="stylesheet" href="theme/style.css" type="text/css">
+<link rel="prev" href="renaming_and_excluding.html">
+<link rel="next" href="templates.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>Policies</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"><a href="renaming_and_excluding.html"><img src="theme/l_arr.gif" border="0"></a></td>
+ <td width="20"><a href="templates.html"><img src="theme/r_arr.gif" border="0"></a></td>
+ </tr>
+</table>
+<p>
+Even thought Pyste can identify various elements in the C++ code, like virtual
+member functions, attributes, and so on, one thing that it can't do is to
+guess the semantics of functions that return pointers or references. In this
+case, the user must manually specify the policy. Policies are explained in the
+<a href="../../doc/tutorial/doc/html/python/functions.html#python.call_policies">
+tutorial</a>.</p>
+<p>
+The policies in Pyste are named exactly as in <a href="../../index.html">
+Boost.Python</a>, only the syntax is
+slightly different. For instance, this policy:</p>
+<code><pre>
+ <span class=identifier>return_internal_reference</span><span class=special>&lt;</span><span class=number>1</span><span class=special>, </span><span class=identifier>with_custodian_and_ward</span><span class=special>&lt;</span><span class=number>1</span><span class=special>, </span><span class=number>2</span><span class=special>&gt; &gt;()
+</span></pre></code>
+<p>
+becomes in Pyste: </p>
+<code><pre>
+ <span class=identifier>return_internal_reference</span><span class=special>(</span><span class=number>1</span><span class=special>, </span><span class=identifier>with_custodian_and_ward</span><span class=special>(</span><span class=number>1</span><span class=special>, </span><span class=number>2</span><span class=special>))
+</span></pre></code>
+<p>
+The user can specify policies for functions and virtual member functions with
+the <tt>set_policy</tt> function:</p>
+<code><pre>
+ <span class=identifier>set_policy</span><span class=special>(</span><span class=identifier>f</span><span class=special>, </span><span class=identifier>return_internal_reference</span><span class=special>())
+ </span><span class=identifier>set_policy</span><span class=special>(</span><span class=identifier>C</span><span class=special>.</span><span class=identifier>foo</span><span class=special>, </span><span class=identifier>return_value_policy</span><span class=special>(</span><span class=identifier>manage_new_object</span><span class=special>))
+</span></pre></code>
+<table width="80%" border="0" align="center">
+ <tr>
+ <td class="note_box">
+
+<img src="theme/note.gif"></img> <b>What if a function or member function needs a policy and
+the user doesn't set one?</b><br><br> If a function needs a policy and one
+was not set, Pyste will issue a error. The user should then go in the
+interface file and set the policy for it, otherwise the generated cpp won't
+compile.
+ </td>
+ </tr>
+</table>
+<table width="80%" border="0" align="center">
+ <tr>
+ <td class="note_box">
+
+<img src="theme/note.gif"></img>
+Note that for functions that return <tt>const T&amp;</tt>, the policy
+<tt>return_value_policy&lt;copy_const_reference&gt;()</tt> wil be used by default, because
+that's normally what you want. You can change it to something else if you need
+to, though.
+ </td>
+ </tr>
+</table>
+<table border="0">
+ <tr>
+ <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td>
+ <td width="30"><a href="renaming_and_excluding.html"><img src="theme/l_arr.gif" border="0"></a></td>
+ <td width="20"><a href="templates.html"><img src="theme/r_arr.gif" border="0"></a></td>
+ </tr>
+</table>
+<br>
+<hr size="1"><p class="copyright">Copyright &copy; 2003 Bruno da Silva de Oliveira<br>Copyright &copy; 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>