diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-06-25 22:59:01 +0000 |
---|---|---|
committer | <> | 2013-09-27 11:49:28 +0000 |
commit | 8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch) | |
tree | c09e2ce80f47b90c85cc720f5139089ad9c8cfff /libs/python/pyste/doc/smart_pointers.html | |
download | boost-tarball-baserock/morph.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'libs/python/pyste/doc/smart_pointers.html')
-rw-r--r-- | libs/python/pyste/doc/smart_pointers.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/libs/python/pyste/doc/smart_pointers.html b/libs/python/pyste/doc/smart_pointers.html new file mode 100644 index 000000000..cddc96f2f --- /dev/null +++ b/libs/python/pyste/doc/smart_pointers.html @@ -0,0 +1,84 @@ +<html> +<head> +<!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc --> +<title>Smart Pointers</title> +<link rel="stylesheet" href="theme/style.css" type="text/css"> +<link rel="prev" href="exporting_an_entire_header.html"> +<link rel="next" href="global_variables.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>Smart Pointers</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="exporting_an_entire_header.html"><img src="theme/l_arr.gif" border="0"></a></td> + <td width="20"><a href="global_variables.html"><img src="theme/r_arr.gif" border="0"></a></td> + </tr> +</table> +<p> +Pyste for now has manual support for smart pointers. Suppose:</p> +<code><pre> + <span class=keyword>struct </span><span class=identifier>C + </span><span class=special>{ + </span><span class=keyword>int </span><span class=identifier>value</span><span class=special>; + }; + + </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>shared_ptr</span><span class=special><</span><span class=identifier>C</span><span class=special>> </span><span class=identifier>newC</span><span class=special>(</span><span class=keyword>int </span><span class=identifier>value</span><span class=special>) + { + </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>shared_ptr</span><span class=special><</span><span class=identifier>C</span><span class=special>> </span><span class=identifier>c</span><span class=special>( </span><span class=keyword>new </span><span class=identifier>C</span><span class=special>() ); + </span><span class=identifier>c</span><span class=special>-></span><span class=identifier>value </span><span class=special>= </span><span class=identifier>value</span><span class=special>; + </span><span class=keyword>return </span><span class=identifier>c</span><span class=special>; + } + + </span><span class=keyword>void </span><span class=identifier>printC</span><span class=special>(</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>shared_ptr</span><span class=special><</span><span class=identifier>C</span><span class=special>> </span><span class=identifier>c</span><span class=special>) + { + </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special><< </span><span class=identifier>c</span><span class=special>-></span><span class=identifier>value </span><span class=special><< </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>endl</span><span class=special>; + } +</span></pre></code> +<p> +To make <tt>newC</tt> and <tt>printC</tt> work correctly, you have to tell Pyste that a +convertor for <tt>boost::shared_ptr<C></tt> is needed.</p> +<code><pre> + <span class=identifier>C </span><span class=special>= </span><span class=identifier>Class</span><span class=special>(</span><span class=literal>'C'</span><span class=special>, </span><span class=literal>'C.h'</span><span class=special>) + </span><span class=identifier>use_shared_ptr</span><span class=special>(</span><span class=identifier>C</span><span class=special>) + </span><span class=identifier>Function</span><span class=special>(</span><span class=literal>'newC'</span><span class=special>, </span><span class=literal>'C.h'</span><span class=special>) + </span><span class=identifier>Function</span><span class=special>(</span><span class=literal>'printC'</span><span class=special>, </span><span class=literal>'C.h'</span><span class=special>) +</span></pre></code> +<p> +For <tt>std::auto_ptr</tt>'s, use the function <tt>use_auto_ptr</tt>.</p> +<p> +This system is temporary, and in the future the converters will automatically be +exported if needed, without the need to tell Pyste about them explicitly.</p> +<a name="holders"></a><h2>Holders</h2><p> +If only the converter for the smart pointers is not enough and you need to +specify the smart pointer as the holder for a class, use the functions +<tt>hold_with_shared_ptr</tt> and <tt>hold_with_auto_ptr</tt>:</p> +<code><pre> + <span class=identifier>C </span><span class=special>= </span><span class=identifier>Class</span><span class=special>(</span><span class=literal>'C'</span><span class=special>, </span><span class=literal>'C.h'</span><span class=special>) + </span><span class=identifier>hold_with_shared_ptr</span><span class=special>(</span><span class=identifier>C</span><span class=special>) + </span><span class=identifier>Function</span><span class=special>(</span><span class=literal>'newC'</span><span class=special>, </span><span class=literal>'C.h'</span><span class=special>) + </span><span class=identifier>Function</span><span class=special>(</span><span class=literal>'printC'</span><span class=special>, </span><span class=literal>'C.h'</span><span class=special>) +</span></pre></code> +<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="exporting_an_entire_header.html"><img src="theme/l_arr.gif" border="0"></a></td> + <td width="20"><a href="global_variables.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> |