mirror of
https://github.com/boostorg/python.git
synced 2026-01-27 07:02:15 +00:00
doc update
[SVN r15680]
This commit is contained in:
153
doc/v2/scope.html
Normal file
153
doc/v2/scope.html
Normal file
@@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="generator" content=
|
||||
"HTML Tidy for Windows (vers 1st August 2002), see www.w3.org">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" type="text/css" href="../boost.css">
|
||||
|
||||
<title>Boost.Python - <boost/python/scope.hpp></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
||||
"header">
|
||||
<tr>
|
||||
<td valign="top" width="300">
|
||||
<h3><a href="../../../../index.htm"><img height="86" width="277"
|
||||
alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
|
||||
</td>
|
||||
|
||||
<td valign="top">
|
||||
<h1 align="center">Boost.Python</h1>
|
||||
|
||||
<h2 align="center">Header <boost/python/scope.hpp></h2>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
|
||||
<h2>Contents</h2>
|
||||
|
||||
<dl class="page-index">
|
||||
<dt><a href="#introduction">Introduction</a></dt>
|
||||
|
||||
<dt><a href="#classes">Classes</a></dt>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#scope-spec">Class <code>scope</code></a></dt>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#scope-spec-synopsis">Class <code>scope</code>
|
||||
synopsis</a></dt>
|
||||
|
||||
<dt><a href="#scope-spec-ctors">Class <code>scope</code>
|
||||
constructors and destructor</a></dt>
|
||||
</dl>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
|
||||
<dt><a href="#examples">Example</a></dt>
|
||||
</dl>
|
||||
<hr>
|
||||
|
||||
<h2><a name="introduction"></a>Introduction</h2>
|
||||
|
||||
<p>Defines facilities for querying and controlling the Python scope
|
||||
(namespace) which will contain new wrapped classes and functions.</p>
|
||||
|
||||
<h2><a name="classes"></a>Classes</h2>
|
||||
|
||||
<h3><a name="scope-spec"></a>Class <code>scope</code></h3>
|
||||
|
||||
<p>The <code>scope</code> class has an associated global Python object
|
||||
which controls the Python namespace in which new extension classes and
|
||||
wrapped functions will be defined as attributes. Default-constructing a
|
||||
new <code>scope</code> object binds that object to the associated Python
|
||||
object. Constructing a is associated with , and</p>
|
||||
|
||||
<h4><a name="scope-spec-synopsis"></a>Class <code>scope</code>
|
||||
synopsis</h4>
|
||||
<pre>
|
||||
namespace boost { namespace python
|
||||
{
|
||||
class scope : public <a href=
|
||||
"object.html#object-spec">object</a>, private <a href=
|
||||
"../../../utility/utility.htm#Class noncopyable">noncopyable</a>
|
||||
{
|
||||
public:
|
||||
scope(object const&);
|
||||
scope();
|
||||
~scope()
|
||||
};
|
||||
}}
|
||||
</pre>
|
||||
|
||||
<h4><a name="scope-spec-ctors"></a>Class <code>scope</code> constructors
|
||||
and destructor</h4>
|
||||
<pre>
|
||||
scope(object const& x);
|
||||
</pre>
|
||||
Stores a reference to the current associated scope object, and sets the
|
||||
associated scope object to the one referred to by <code>x.ptr()</code>.
|
||||
The <code>object</code> base class is initialized with <code>x</code>.
|
||||
<pre>
|
||||
scope();
|
||||
</pre>
|
||||
Stores a reference to the current associated scope object. The
|
||||
<code>object</code> base class is initialized with the current associated
|
||||
scope object. Outside any module initialization function, the current
|
||||
associated Python object is <code>None</code>.
|
||||
<pre>
|
||||
~scope()
|
||||
</pre>
|
||||
Sets the current associated Python object to the stored object.
|
||||
|
||||
<h2><a name="examples"></a>Example</h2>
|
||||
The following example shows how scope setting can be used to define
|
||||
nested classes.
|
||||
|
||||
<p>C++ Module definition:</p>
|
||||
<pre>
|
||||
#include <boost/python/class.hpp>
|
||||
#include <boost/python/scope.hpp>
|
||||
using namespace boost::python;
|
||||
|
||||
struct X
|
||||
{
|
||||
void f();
|
||||
|
||||
struct Y { int g() { return 0; } };
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MODULE(nested)
|
||||
{
|
||||
scope outer
|
||||
= class_<X>("X")
|
||||
.def("f", &X::f)
|
||||
;
|
||||
class_<Y>("Y")
|
||||
.def("g", &Y::g)
|
||||
;
|
||||
}
|
||||
</pre>
|
||||
Interactive Python:
|
||||
<pre>
|
||||
>>> import nested
|
||||
>>> y = nested.X.Y()
|
||||
>>> y.g()
|
||||
0
|
||||
</pre>
|
||||
|
||||
<p>Revised 03 October, 2002</p>
|
||||
|
||||
<p><i>© Copyright <a href=
|
||||
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All Rights
|
||||
Reserved.</i></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user