Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76260 - in trunk: . libs/python/doc/tutorial/doc libs/python/doc/tutorial/doc/html libs/python/doc/tutorial/doc/html/python tools/quickbook tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2012-01-01 09:51:33


Author: danieljames
Date: 2012-01-01 09:51:32 EST (Sun, 01 Jan 2012)
New Revision: 76260
URL: http://svn.boost.org/trac/boost/changeset/76260

Log:
Quickbook: Merge escape change from quickbook-dev branch.

Only changes 'raw_escape' which is only used in 1.6

Properties modified:
   trunk/ (props changed)
   trunk/tools/quickbook/ (props changed)
Text files modified:
   trunk/libs/python/doc/tutorial/doc/html/index.html | 3 ++-
   trunk/libs/python/doc/tutorial/doc/html/python/object.html | 27 +++++++++++++++++++++++++++
   trunk/libs/python/doc/tutorial/doc/tutorial.qbk | 17 +++++++++++++++++
   trunk/tools/quickbook/src/main_grammar.cpp | 2 ++
   4 files changed, 48 insertions(+), 1 deletions(-)

Modified: trunk/libs/python/doc/tutorial/doc/html/index.html
==============================================================================
--- trunk/libs/python/doc/tutorial/doc/html/index.html (original)
+++ trunk/libs/python/doc/tutorial/doc/html/index.html 2012-01-01 09:51:32 EST (Sun, 01 Jan 2012)
@@ -66,6 +66,7 @@
 <dt><span class="section">Derived Object types</span></dt>
 <dt><span class="section">Extracting C++ objects</span></dt>
 <dt><span class="section">Enums</span></dt>
+<dt><span class="section">Creating boost::python::object from PyObject*</span></dt>
 </dl></dd>
 <dt><span class="section">Embedding</span></dt>
 <dd><dl><dt><span class="section">Using the interpreter</span></dt></dl></dd>
@@ -132,7 +133,7 @@
 </div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: December 26, 2011 at 21:51:27 GMT</small></p></td>
+<td align="left"><p><small>Last revised: December 26, 2011 at 21:58:39 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: trunk/libs/python/doc/tutorial/doc/html/python/object.html
==============================================================================
--- trunk/libs/python/doc/tutorial/doc/html/python/object.html (original)
+++ trunk/libs/python/doc/tutorial/doc/html/python/object.html 2012-01-01 09:51:32 EST (Sun, 01 Jan 2012)
@@ -30,6 +30,7 @@
 <dt><span class="section">Derived Object types</span></dt>
 <dt><span class="section">Extracting C++ objects</span></dt>
 <dt><span class="section">Enums</span></dt>
+<dt><span class="section">Creating boost::python::object from PyObject*</span></dt>
 </dl></div>
 <p>
       Python is dynamically typed, unlike C++ which is statically typed. Python variables
@@ -314,6 +315,32 @@
     <span class="special">;</span>
 </pre>
 </div>
+<div class="section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="python.creating_python_object"></a>Creating <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span></code> from <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code>
+</h3></div></div></div>
+<p>
+ When you want a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span></code> to manage a pointer to <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code>
+ pyobj one does:
+ </p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span> <span class="identifier">o</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">handle</span><span class="special">&lt;&gt;(</span><span class="identifier">pyobj</span><span class="special">));</span>
+</pre>
+<p>
+ In this case, the <code class="computeroutput"><span class="identifier">o</span></code> object,
+ manages the <code class="computeroutput"><span class="identifier">pyobj</span></code>, it won&#8217;t
+ increase the reference count on construction.
+ </p>
+<p>
+ Otherwise, to use a borrowed reference:
+ </p>
+<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">object</span> <span class="identifier">o</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">handle</span><span class="special">&lt;&gt;(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">borrowed</span><span class="special">(</span><span class="identifier">pyobj</span><span class="special">)));</span>
+</pre>
+<p>
+ In this case, <code class="computeroutput"><span class="identifier">Py_INCREF</span></code> is
+ called, so <code class="computeroutput"><span class="identifier">pyobj</span></code> is not destructed
+ when object o goes out of scope.
+ </p>
+</div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>

Modified: trunk/libs/python/doc/tutorial/doc/tutorial.qbk
==============================================================================
--- trunk/libs/python/doc/tutorial/doc/tutorial.qbk (original)
+++ trunk/libs/python/doc/tutorial/doc/tutorial.qbk 2012-01-01 09:51:32 EST (Sun, 01 Jan 2012)
@@ -1302,6 +1302,23 @@
 [def PyModule_GetDict [@http://www.python.org/doc/current/api/moduleObjects.html#l2h-594 PyModule_GetDict]]
 
 [endsect]
+
+[section:creating_python_object Creating `boost::python::object` from `PyObject*`]
+
+When you want a `boost::python::object` to manage a pointer to `PyObject*` pyobj one does:
+
+ boost::python::object o(boost::python::handle<>(pyobj));
+
+In this case, the `o` object, manages the `pyobj`, it won’t increase the reference count on construction.
+
+Otherwise, to use a borrowed reference:
+
+ boost::python::object o(boost::python::handle<>(boost::python::borrowed(pyobj)));
+
+In this case, `Py_INCREF` is called, so `pyobj` is not destructed when object o goes out of scope.
+
+[endsect] [/ creating_python_object ]
+
 [endsect] [/ Object Interface]
 
 [section Embedding]

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2012-01-01 09:51:32 EST (Sun, 01 Jan 2012)
@@ -667,6 +667,8 @@
                                                 [actions.escape_unicode]
             | "\\U" >> cl::repeat_p(8) [cl::chset<>("0-9a-fA-F")]
                                                 [actions.escape_unicode]
+ | ('\\' >> cl::anychar_p) [actions.error("Invalid escape.")]
+ [actions.raw_char]
             | ("'''" >> !eol) [actions.error("Boostbook escape invalid here.")]
>> (*(cl::anychar_p - "'''"))
>> ( cl::str_p("'''")


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk