mirror of
https://github.com/boostorg/python.git
synced 2026-01-25 06:22:15 +00:00
Lots of documentation updates, plus the associated code shuffling needed to expose the right things to users
[SVN r13975]
This commit is contained in:
71
doc/v2/HolderGenerator.html
Executable file
71
doc/v2/HolderGenerator.html
Executable file
@@ -0,0 +1,71 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
||||
<title>Boost.Python - Holder Concept</title>
|
||||
</head>
|
||||
<body link="#0000ff" vlink="#800080">
|
||||
<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">HolderGenerator Concept</h2>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#introduction">Introduction</a></dt>
|
||||
<dt><a href="#concept-requirements">Concept Requirements</a></dt>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#HolderGenerator-concept">HolderGenerator Concept</a></dt>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<h2><a name="introduction"></a>Introduction</h2>
|
||||
|
||||
<p>A HolderGenerator is a unary metafunction class which returns types
|
||||
suitable for holding instances of its argument in a wrapped C++ class
|
||||
instance.
|
||||
|
||||
<h2><a name="concept-requirements"></a>Concept Requirements</h2>
|
||||
<h3><a name="HolderGenerator-concept"></a>HolderGenerator Concept</h3>
|
||||
|
||||
<p>In the table below, <code><b>G</b></code> denotes an type which
|
||||
models HolderGenerator, and <code><b>X</b></code> denotes a class
|
||||
type.
|
||||
|
||||
<table summary="Holder expressions" border="1" cellpadding="5">
|
||||
|
||||
<tr>
|
||||
<td><b>Expression</b></td>
|
||||
<td><b>Requirements</b></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><code>G::apply<X>::type</code></td>
|
||||
<td>A concrete subclass of <a
|
||||
href="instance_holder.html#instance_holder-spec">instance_holder</a>
|
||||
which can hold objects of type <code>X</code>.
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
20 May, 2002
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||
</p>
|
||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||
Abrahams</a> 2002. All Rights Reserved.</i>
|
||||
|
||||
<p>Permission to copy, use, modify, sell
|
||||
and distribute this software is granted provided this copyright notice appears
|
||||
in all copies. This software is provided "as is" without express or implied
|
||||
warranty, and with no claim as to its suitability for any purpose.
|
||||
</body>
|
||||
</html>
|
||||
@@ -319,9 +319,9 @@ class_& def_init(Args const& argument_types, CallPolicies policies);
|
||||
<code><a href=
|
||||
"make_function.html#make_constructor-spec">make_constructor</a><Args,Holder>(policies)</code>,
|
||||
respectively, to the Boost.Python extension class being defined under the name
|
||||
"__init__". <code>Holder</code> is a model of <a
|
||||
href="Holder.html">Holder</a> which contains the
|
||||
<code>HeldType</code>. If the extension class
|
||||
"__init__". <code>Holder</code> is a concrete subclass of <a
|
||||
href="instance_holder.html#instance_holder-spec">instance_holder</a>
|
||||
which holds the <code>HeldType</code>. If the extension class
|
||||
already has an "__init__" attribute, the usual <a
|
||||
href="http:overloading.html">overloading procedure</a> applies.
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#class-spec">Class <code>error_already_set</code></a>
|
||||
<dt><a href="#error_already_set-spec">Class <code>error_already_set</code></a>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
@@ -44,6 +44,7 @@
|
||||
<dt><a href="#handle_exception-spec">handle_exception</a>
|
||||
|
||||
<dt><a href="#expect_non_null-spec">expect_non_null</a>
|
||||
<dt><a href="#throw_error_already_set-spec">throw_error_already_set</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="#examples">Examples</a>
|
||||
@@ -117,9 +118,7 @@ void handle_exception() throw();
|
||||
an enclosing <code>try</code> block.
|
||||
</dl>
|
||||
<pre>
|
||||
<a name="expect_non_null-spec">PyObject* expect_non_null(PyObject* x);</a>
|
||||
|
||||
template <class T> T* expect_non_null(T* x);
|
||||
<a name="expect_non_null-spec">template <class T> T* expect_non_null(T* x);</a>
|
||||
</pre>
|
||||
|
||||
<dl class="expect_non_null-semantics">
|
||||
@@ -135,6 +134,16 @@ template <class T> T* expect_non_null(T* x);
|
||||
return 0 on error.
|
||||
</dl>
|
||||
|
||||
<pre>
|
||||
<a name="throw_error_already_set-spec">void throw_error_already_set();</a>
|
||||
</pre>
|
||||
|
||||
<dl class="throw_error_already_set-semantics">
|
||||
|
||||
<dt><b>Effects:</b> <code>throw <a href=
|
||||
"#error_already_set-spec">error_already_set</a>();</code>
|
||||
</dl>
|
||||
|
||||
<h2><a name="examples"></a>Examples</h2>
|
||||
<pre>
|
||||
#include <string>
|
||||
|
||||
209
doc/v2/instance_holder.html
Executable file
209
doc/v2/instance_holder.html
Executable file
@@ -0,0 +1,209 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<meta name="generator" content="HTML Tidy, 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/instance_holder.hpp></title>
|
||||
<style type="text/css">
|
||||
p.c4 {font-style: italic}
|
||||
span.c3 {color: #ff0000}
|
||||
h2.c2 {text-align: center}
|
||||
h1.c1 {text-align: center}
|
||||
</style>
|
||||
|
||||
<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 valign="top">
|
||||
<h1 class="c1">Boost.Python</h1>
|
||||
|
||||
<h2 class="c2">Header <boost/python/instance_holder.hpp></h2>
|
||||
</table>
|
||||
<hr>
|
||||
|
||||
<h2>Contents</h2>
|
||||
|
||||
<dl class="page-index">
|
||||
<dt><a href="#introduction">Introduction</a>
|
||||
|
||||
<dt><a href="#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#instance_holder-spec">Class
|
||||
<code>instance_holder</code></a>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#instance_holder-spec-synopsis">Class
|
||||
<code>instance_holder</code> synopsis</a>
|
||||
|
||||
<dt><a href="#instance_holderspec-ctors">Class
|
||||
<code>instance_holder</code> destructor</a>
|
||||
|
||||
<dt><a href="#instance_holderspec-modifiers">Class
|
||||
<code>instance_holder</code> modifier functions</a>
|
||||
|
||||
<dt><a href="#instance_holderspec-observers">Class
|
||||
<code>instance_holder</code> observer functions</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="#examples">Example</a>
|
||||
</dl>
|
||||
<hr>
|
||||
|
||||
<h2><a name="introduction"></a>Introduction</h2>
|
||||
|
||||
<p><code><boost/python/instance_holder.hpp></code> provides
|
||||
<code>class instance_holder</code>, the base class for types
|
||||
which hold C++ instances of wrapped classes.
|
||||
|
||||
<h2><a name="classes"></a>Classes</h2>
|
||||
|
||||
<h3><a name="instance_holder-spec"></a>Class <code>instance_holder</code></h3>
|
||||
|
||||
<p><code>instance_holder</code> is an abstract base class whose
|
||||
concrete derived classes hold C++ class instances within their
|
||||
Python object wrappers. To allow multiple inheritance in Python
|
||||
from C++ class wrappers, each such Python object contains a chain
|
||||
of <code>instance_holder</code>s. When an <code>__init__</code>
|
||||
function for a wrapped C++ class is invoked, a new
|
||||
<code>instance_holder</code> instance is created and installed in
|
||||
the Python object using its <code><a
|
||||
href="#instance_holder-spec-modifiers">install</a></code>()
|
||||
function. Each concrete class derived from
|
||||
<code>instance_holder</code> must provide a <code><a
|
||||
href="#instance_holder-spec-observers">holds</a>()</code>
|
||||
implementation which allows Boost.Python to query it for the
|
||||
type(s) it is holding. In order to support the held type's wrapped
|
||||
constructor(s), the class must also provide constructors that can
|
||||
accept an initial <code>PyObject*</code> argument referring to the
|
||||
owning Python object, and which forward the rest of their
|
||||
arguments to the constructor of the held type. The initial
|
||||
argument is needed to enable virtual function overriding in
|
||||
Python, and may be ignored, depending on the specific
|
||||
<code>instance_holder</code> subclass.
|
||||
|
||||
<h4><a name="instance_holder-spec-synopsis"></a>Class instance_holder
|
||||
synopsis</h4>
|
||||
<pre>
|
||||
namespace boost { namespace python
|
||||
{
|
||||
class instance_holder : <a href="../../../utility/utility.htm#Class noncopyable">noncopyable</a>
|
||||
{
|
||||
public:
|
||||
// destructor
|
||||
virtual ~instance_holder();
|
||||
|
||||
// instance_holder modifiers
|
||||
void install(PyObject* inst) throw();
|
||||
|
||||
// instance_holder observers
|
||||
virtual void* holds(type_info) = 0;
|
||||
};
|
||||
}}
|
||||
</pre>
|
||||
|
||||
<h4><a name="instance_holderspec-ctors">Class <code>instance_holder</code>
|
||||
destructor</a></h4>
|
||||
<pre>
|
||||
virtual ~instance_holder();
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Effects:</b> destroys the object
|
||||
</dl>
|
||||
|
||||
<h4><a name="instance_holderspec-modifiers">Class
|
||||
<code>instance_holder</code> modifiers</a></h4>
|
||||
<pre>
|
||||
void install(PyObject* inst) throw();
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Requires:</b> <code>inst</code> is a Python instance of a
|
||||
wrapped C++ class type, or is a type derived from a wrapped C++
|
||||
class type.
|
||||
<dt><b>Effects:</b> installs the new instance at the head of the
|
||||
Python object's chain of held instances.
|
||||
<dt><b>Throws:</b> nothing
|
||||
</dl>
|
||||
|
||||
<h4><a name="instance_holderspec-observers">Class <code>instance_holder</code>
|
||||
observers</a></h4>
|
||||
<pre>
|
||||
virtual void* holds(type_info x) = 0;
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Returns:</b> A pointer to an object of the type described
|
||||
by <code>x</code> if <code>*this</code> contains such an object,
|
||||
0 otherwise.
|
||||
</dl>
|
||||
|
||||
<h2><a name="examples"></a>Example</h2>
|
||||
|
||||
The following is a simplified version of the instance holder template
|
||||
used by Boost.Python to wrap classes held by smart pointers:
|
||||
<pre>
|
||||
template <class SmartPtr, class Value>
|
||||
struct pointer_holder : instance_holder
|
||||
{
|
||||
// construct from the SmartPtr type
|
||||
pointer_holder(SmartPtr p)
|
||||
:m_p(p)
|
||||
|
||||
// Forwarding constructors for the held type
|
||||
pointer_holder(PyObject*)
|
||||
:m_p(new Value())
|
||||
{
|
||||
}
|
||||
|
||||
template<class A0>
|
||||
pointer_holder(PyObject*,A0 a0)
|
||||
:m_p(new Value(a0))
|
||||
{
|
||||
}
|
||||
|
||||
template<class A0,class A1>
|
||||
pointer_holder(PyObject*,A0 a0,A1 a1)
|
||||
:m_p(new Value(a0,a1))
|
||||
{
|
||||
}
|
||||
...
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(type_info dst_t)
|
||||
{
|
||||
// holds an instance of the SmartPtr type...
|
||||
if (dst_t == python::type_id<SmartPtr>())
|
||||
return &this->m_p;
|
||||
|
||||
// ...and an instance of the SmartPtr's element_type, if the
|
||||
// pointer is non-null
|
||||
return python::type_id<Value>() == dst_t ? &*this->m_p : 0;
|
||||
}
|
||||
|
||||
private: // data members
|
||||
SmartPtr m_p;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
19 November, 2002
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||
|
||||
|
||||
<p class="c4">© Copyright <a href=
|
||||
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
|
||||
Rights Reserved.
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<code>C</code> and creates a Python iterator that traverses
|
||||
[<code>c.begin()</code>,
|
||||
<code>c.end()</code>). The optional <a
|
||||
href="CallPolicies.html"><code>CallPolicies</code></a>
|
||||
href="CallPolicies.html">CallPolicies</a>
|
||||
<code>P</code> can be used to control how elements are returned
|
||||
during iteration.
|
||||
|
||||
|
||||
@@ -78,12 +78,17 @@ objects::function* make_function(F f, Policies const& policies)
|
||||
<a name=
|
||||
"make_constructor-spec">template <class T, class ArgList, class Generator>
|
||||
objects::function* make_constructor();</a>
|
||||
|
||||
template <class ArgList, class Generator, class Policies>
|
||||
objects::function* make_constructor(Policies const& policies)
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Requires:</b> <code>T</code> is a class type. <code>ArgList</code>
|
||||
is an <a href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++
|
||||
argument types (<i>A1, A2,... AN</i>) such that if
|
||||
<dt><b>Requires:</b> <code>T</code> is a class
|
||||
type. <code>Policies</code> is a model of <a
|
||||
href="CallPolicies.html">CallPolicies</a>. <code>ArgList</code>
|
||||
is an <a href="../../../mpl/doc/Sequences.html">MPL sequence</a>
|
||||
of C++ argument types (<i>A1, A2,... AN</i>) such that if
|
||||
<code>a1, a2</code>... <code>aN</code> are objects of type
|
||||
<i>A1, A2,... AN</i> respectively, the expression <code>new
|
||||
Generator::apply<T>::type(a1, a2</code>... <code>aN</code>) is
|
||||
@@ -94,8 +99,12 @@ objects::function* make_constructor();</a>
|
||||
from Python, expects its first argument to be a Boost.Python extension
|
||||
class object. It converts its remaining its arguments to C++ and passes
|
||||
them to the constructor of a dynamically-allocated
|
||||
<code>Generator::apply<T>::type</code> object. The result is
|
||||
installed in the extension class object.
|
||||
<code>Generator::apply<T>::type</code> object, which is
|
||||
then installed in the extension class object. In the second
|
||||
form, the <code>policies</code> are applied to the arguments and
|
||||
result (<a
|
||||
href="http://www.python.org/doc/current/lib/bltin-null-object.html">None</a>)
|
||||
of the Python callable object
|
||||
|
||||
<dt><b>Returns:</b> The new Python callable object
|
||||
</dl>
|
||||
|
||||
@@ -1,21 +1,29 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Type" content=
|
||||
"text/html; charset=iso-8859-1">
|
||||
<link rel="stylesheet" type="text/css" href="../boost.css">
|
||||
|
||||
<title>Boost.Python - Reference</title>
|
||||
<style type="text/css">
|
||||
p.c3 {font-style: italic}
|
||||
h2.c2 {text-align: center}
|
||||
h1.c1 {text-align: center}
|
||||
</style>
|
||||
|
||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
||||
"reference">
|
||||
<table border="0" cellpadding="7" cellspacing="0" width="100%"
|
||||
summary="reference">
|
||||
<tr>
|
||||
<td valign="top" width="300">
|
||||
<h3><a href="http://www.boost.org"><img height="86" width="277" alt=
|
||||
"C++ Boost" src="../c++boost.gif" border="0"></a></h3>
|
||||
<h3><a href="http://www.boost.org"><img height="86" width=
|
||||
"277" alt="C++ Boost" src="../../../../c++boost.gif" border="0">
|
||||
</a></h3>
|
||||
|
||||
<td valign="top">
|
||||
<h1 align="center">Boost.Python</h1>
|
||||
<h1 class="c1">Boost.Python</h1>
|
||||
|
||||
<h2 align="center">Reference</h2>
|
||||
<h2 class="c2">Reference</h2>
|
||||
</table>
|
||||
<hr>
|
||||
|
||||
@@ -23,209 +31,227 @@
|
||||
|
||||
<dl class="Reference">
|
||||
<dt><a href="#concepts">Concepts</a>
|
||||
<dl class="index">
|
||||
<dt><a href="CallPolicies.html#CallPolicies-concept">CallPolicies</a></dt>
|
||||
<dt><a href="Dereferenceable.html#Dereferenceable-concept">Dereferenceable</a></dt>
|
||||
<dt><a href="ResultConverter.html#ResultConverter-concept">ResultConverter</a></dt>
|
||||
<dt><a href="ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a></dt>
|
||||
</dl>
|
||||
|
||||
<dt><a href="#high_level">High Level Components</a>
|
||||
|
||||
<dt><a href="#models_of_call_policies">Models of CallPolicies</a>
|
||||
<dt><a href="#invocation">Function Invocation and Creation</a>
|
||||
|
||||
<dt><a href="#return_handler_generators">Models of ReturnHandlerGenerator</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="#models_of_call_policies">Models of
|
||||
CallPolicies</a>
|
||||
|
||||
<dt><a href="#result_converter_generators">Models of
|
||||
ResultConverterGenerator</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="#type_conversion">To/From Python Type Conversion</a>
|
||||
|
||||
<dt><a href="#by_name">Index By Name</a>
|
||||
</dl>
|
||||
<a name="high_level"></a>
|
||||
<dt><a href="#utility">Utility and Infrastructure</a>
|
||||
|
||||
<h2>High Level Components</h2>
|
||||
</dl>
|
||||
<hr>
|
||||
<!-- xxxxx -->
|
||||
|
||||
<h2><a name="concepts">Concepts</a></h2>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"CallPolicies.html#CallPolicies-concept">CallPolicies</a>
|
||||
|
||||
<dt><a href=
|
||||
"Dereferenceable.html#Dereferenceable-concept">Dereferenceable</a>
|
||||
|
||||
<dt><a href=
|
||||
"HolderGenerator.html#HolderGenerator-concept">HolderGenerator</a>
|
||||
|
||||
<dt><a href=
|
||||
"ResultConverter.html#ResultConverter-concept">ResultConverter</a>
|
||||
|
||||
<dt><a href=
|
||||
"ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a>
|
||||
</dl>
|
||||
|
||||
<h2><a name="high_level">High Level Components</a></h2>
|
||||
|
||||
<dl>
|
||||
<dt><a href="class.html">class.hpp/class_fwd.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="class.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="class.html#class_-spec">class_</a>
|
||||
|
||||
<dt><a href="class.html#bases-spec">bases</a>
|
||||
|
||||
<dt><a href="class.html#args-spec">args</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="errors.html">errors.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="errors.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"errors.html#error_already_set-spec">error_already_set</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="errors.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"errors.html#handle_exception-spec">handle_exception</a>
|
||||
|
||||
<dt><a href=
|
||||
"errors.html#expect_non_null-spec">expect_non_null</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="iterator.html">iterator.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="iterator.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="iterator.html#iterator-spec">iterator</a>
|
||||
|
||||
<dt><a href="iterator.html#iterators-spec">iterators</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="iterator.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="iterator.html#range-spec">range</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="module.html">module.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="module.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="module.html#module-spec">module</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="objects.html">objects.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="objects.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="objects.html#xxx-spec">not yet
|
||||
documented</a>
|
||||
</dl>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<h2><a name="invocation">Function Invocation and Creation</a></h2>
|
||||
|
||||
<dl class="index">
|
||||
<dt><a href="call.html">call.hpp</a>
|
||||
|
||||
<dd>
|
||||
<a name="general_purpose"></a>
|
||||
|
||||
<h3>General Purpose</h3>
|
||||
|
||||
<dl class="index">
|
||||
|
||||
<dt><a href="call.html">call.hpp</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="call.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"call.html#call-spec">call</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="call_method.html">call_method.hpp</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="call_method.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"call_method.html#call_method-spec">call_method</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="class.html">class.hpp/class_fwd.hpp</a>
|
||||
<dt><a href="call.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="class.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="class.html#class_-spec">class_</a>
|
||||
|
||||
<dt><a href="class.html#bases-spec">bases</a>
|
||||
|
||||
<dt><a href="class.html#args-spec">args</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="data_members.html">data_members.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="data_members.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"data_members.html#make_getter-spec">make_getter</a>
|
||||
|
||||
<dt><a href=
|
||||
"data_members.html#make_setter-spec">make_setter</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="errors.html">errors.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="errors.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"errors.html#error_already_set-spec">error_already_set</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="errors.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"errors.html#handle_exception-spec">handle_exception</a>
|
||||
|
||||
<dt><a href=
|
||||
"errors.html#expect_non_null-spec">expect_non_null</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
|
||||
<dt><a href="iterator.html">iterator.hpp</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="iterator.html#classes">Classes</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"iterator.html#iterator-spec">iterator</a>
|
||||
<dt><a href=
|
||||
"iterator.html#iterators-spec">iterators</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="iterator.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"iterator.html#range-spec">range</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="make_function.html">make_function.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="make_function.html#classes">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"make_function.html#make_function-spec">make_function</a>
|
||||
|
||||
<dt><a href=
|
||||
"make_function.html#make_constructor-spec">make_constructor</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="module.html">module.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="module.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="module.html#module-spec">module</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="objects.html">objects.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="objects.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="objects.html#xxx-spec">not yet documented</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="pointee.html">pointee.hpp</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="pointee.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt>class template <a href="pointee.html#pointee">pointee</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="reference_hpp.html">reference.hpp</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="reference_hpp.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="reference_hpp.html#reference-spec">reference</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="reference_hpp.html#types">Types</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="reference_hpp.html#ref-spec">ref</a>
|
||||
</dl>
|
||||
<dt><a href="call.html#call-spec">call</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="call_method.html">call_method.hpp</a>
|
||||
|
||||
<a name="models_of_call_policies"></a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="call_method.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"call_method.html#call_method-spec">call_method</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="data_members.html">data_members.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="data_members.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"data_members.html#make_getter-spec">make_getter</a>
|
||||
|
||||
<dt><a href=
|
||||
"data_members.html#make_setter-spec">make_setter</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="make_function.html">make_function.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="make_function.html#classes">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"make_function.html#make_function-spec">make_function</a>
|
||||
|
||||
<dt><a href=
|
||||
"make_function.html#make_constructor-spec">make_constructor</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="ptr.html">ptr.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="ptr.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="ptr.html#ptr-spec">ptr</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="ptr.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"ptr.html#pointer_wrapper-spec">pointer_wrapper</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="ptr.html#metafunctions">MetaFunctions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"ptr.html#is_pointer_wrapper-spec">is_pointer_wrapper</a>
|
||||
|
||||
<dt><a href=
|
||||
"ptr.html#unwrap_pointer-spec">unwrap_pointer</a>
|
||||
</dl>
|
||||
</dl>
|
||||
<a name="models_of_call_policies"></a>
|
||||
|
||||
<h3>Models of CallPolicies</h3>
|
||||
|
||||
@@ -235,15 +261,18 @@
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="default_call_policies.html#classes">Classes</a>
|
||||
<dt><a href=
|
||||
"default_call_policies.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"default_call_policies.html#default_call_policies-spec">default_call_policies</a>
|
||||
<dt><a href=
|
||||
"default_call_policies.html#default_call_policies-spec">
|
||||
default_call_policies</a>
|
||||
|
||||
<dt><a href=
|
||||
"default_call_policies.html#default_result_converter-spec">default_result_converter</a>
|
||||
<dt><a href=
|
||||
"default_call_policies.html#default_result_converter-spec">
|
||||
default_result_converter</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
@@ -252,25 +281,28 @@
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="return_internal_reference.html#classes">Classes</a>
|
||||
<dt><a href=
|
||||
"return_internal_reference.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
<dt><a href=
|
||||
"return_internal_reference.html#return_internal_reference-spec">
|
||||
return_internal_reference</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="return_value_policy.html">return_value_policy.hpp</a>
|
||||
<dt><a href=
|
||||
"return_value_policy.html">return_value_policy.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="return_value_policy.html#classes">Classes</a>
|
||||
<dt><a href=
|
||||
"return_value_policy.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
<dt><a href=
|
||||
"return_value_policy.html#return_value_policy-spec">return_value_policy</a>
|
||||
</dl>
|
||||
</dl>
|
||||
@@ -280,34 +312,39 @@
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="with_custodian_and_ward.html#classes">Classes</a>
|
||||
<dt><a href=
|
||||
"with_custodian_and_ward.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"with_custodian_and_ward.html#with_custodian_and_ward-spec">with_custodian_and_ward</a>
|
||||
<dt><a href=
|
||||
"with_custodian_and_ward.html#with_custodian_and_ward-spec">
|
||||
with_custodian_and_ward</a>
|
||||
|
||||
<dt><a href=
|
||||
<dt><a href=
|
||||
"with_custodian_and_ward.html#with_custodian_and_ward_postcall-spec">
|
||||
with_custodian_and_ward_postcall</a>
|
||||
</dl>
|
||||
</dl>
|
||||
</dl>
|
||||
<a name="return_handler_generators"></a>
|
||||
<a name="result_converter_generators"></a>
|
||||
|
||||
<h3>Models of ReturnHandlerGenerator</h3>
|
||||
<h3>Models of ResultConverterGenerator</h3>
|
||||
|
||||
<dl class="index">
|
||||
<dt><a href="copy_const_reference.html">copy_const_reference.hpp</a>
|
||||
<dt><a href=
|
||||
"copy_const_reference.html">copy_const_reference.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="copy_const_reference.html#classes">Classes</a>
|
||||
<dt><a href=
|
||||
"copy_const_reference.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"copy_const_reference.html#copy_const_reference-spec">copy_const_reference</a>
|
||||
<dt><a href=
|
||||
"copy_const_reference.html#copy_const_reference-spec">
|
||||
copy_const_reference</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
@@ -316,17 +353,19 @@
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="copy_non_const_reference.html#classes">Classes</a>
|
||||
<dt><a href=
|
||||
"copy_non_const_reference.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
<dt><a href=
|
||||
"copy_non_const_reference.html#copy_non_const_reference-spec">
|
||||
copy_non_const_reference</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="manage_new_object.html">manage_new_object.hpp</a>
|
||||
<dt><a href=
|
||||
"manage_new_object.html">manage_new_object.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
@@ -334,7 +373,7 @@
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
<dt><a href=
|
||||
"manage_new_object.html#manage_new_object-spec">manage_new_object</a>
|
||||
</dl>
|
||||
</dl>
|
||||
@@ -344,11 +383,12 @@
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="reference_existing_object.html#classes">Classes</a>
|
||||
<dt><a href=
|
||||
"reference_existing_object.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
<dt><a href=
|
||||
"reference_existing_object.html#reference_existing_object-spec">
|
||||
reference_existing_object</a>
|
||||
</dl>
|
||||
@@ -363,7 +403,7 @@
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
<dt><a href=
|
||||
"lvalue_from_python.html#reference_from_python-spec">reference_from_python</a>
|
||||
|
||||
<dt><a href=
|
||||
@@ -371,140 +411,188 @@
|
||||
</dl>
|
||||
</dl>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<a name="type_conversion"></a>
|
||||
<h2><a name="type_conversion">To/From Python Type
|
||||
Conversion</a></h2>
|
||||
|
||||
<h3>To/From Python Type Conversion</h3>
|
||||
<dl class="index">
|
||||
<dt><a href="from_python.html">from_python.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="from_python.html">from_python.hpp</a>
|
||||
<dt><a href="from_python.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="from_python.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"from_python.html#from_python-spec">from_python</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="has_back_reference.html">has_back_reference.hpp</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="has_back_reference.html#classes">Classes</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="has_back_reference.html#has_back_reference-spec">has_back_reference</a>
|
||||
</dl>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
<dt><a href="implicit.html">implicit.hpp</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="implicit.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"implicit.html#implicitly_convertible-spec">implicitly_convertible</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="ptr.html">ptr.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="ptr.html#functions">Functions</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="ptr.html#ptr-spec">ptr</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="ptr.html#classes">Classes</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="ptr.html#pointer_wrapper-spec">pointer_wrapper</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="ptr.html#metafunctions">MetaFunctions</a>
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="ptr.html#is_pointer_wrapper-spec">is_pointer_wrapper</a>
|
||||
<dt><a href="ptr.html#unwrap_pointer-spec">unwrap_pointer</a>
|
||||
</dl>
|
||||
|
||||
</dl>
|
||||
|
||||
<dt><a href="to_python_converter.html">to_python_converter.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="to_python_converter.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"to_python_converter.html#to_python_converter-spec">to_python_converter</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="to_python_indirect.html">to_python_indirect.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="to_python_indirect.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"to_python_indirect.html#to_python_indirect-spec">to_python_indirect</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="to_python_value.html">to_python_value.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="to_python_value.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"to_python_value.html#to_python_value-spec">to_python_value</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="type_from_python.html">type_from_python.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="type_from_python.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"type_from_python.html#type_from_python-spec">type_from_python</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="value_from_python.html">value_from_python.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="value_from_python.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"value_from_python.html#value_from_python-spec">value_from_python</a>
|
||||
</dl>
|
||||
<dt><a href=
|
||||
"from_python.html#from_python-spec">from_python</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="implicit.html">implicit.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="implicit.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"implicit.html#implicitly_convertible-spec">implicitly_convertible</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href=
|
||||
"to_python_converter.html">to_python_converter.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="to_python_converter.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"to_python_converter.html#to_python_converter-spec">to_python_converter</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="to_python_indirect.html">to_python_indirect.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="to_python_indirect.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"to_python_indirect.html#to_python_indirect-spec">to_python_indirect</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="to_python_value.html">to_python_value.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="to_python_value.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"to_python_value.html#to_python_value-spec">to_python_value</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="type_from_python.html">type_from_python.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="type_from_python.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"type_from_python.html#type_from_python-spec">type_from_python</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="value_from_python.html">value_from_python.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="value_from_python.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"value_from_python.html#value_from_python-spec">value_from_python</a>
|
||||
</dl>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<h2><a name="utility">Utility and Infrastructure</a></h2>
|
||||
|
||||
<dl>
|
||||
<dt><a href="has_back_reference.html">has_back_reference.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="has_back_reference.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"has_back_reference.html#has_back_reference-spec">has_back_reference</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href=
|
||||
"instance_holder.html">instance_holder.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"instance_holder.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"instance_holder.html#instance_holder-spec">
|
||||
instance_holder</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="pointee.html">pointee.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="pointee.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt>class template <a href=
|
||||
"pointee.html#pointee">pointee</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="reference_hpp.html">reference.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="reference_hpp.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href=
|
||||
"reference_hpp.html#reference-spec">reference</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="reference_hpp.html#types">Types</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="reference_hpp.html#ref-spec">ref</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="type_id.html">type_id.hpp</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="type_id.html#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="type_id.html#type_id-spec">type_id</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="type_id.html#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="index">
|
||||
<dt><a href="type_id.html#type_info-spec">type_info</a>
|
||||
</dl>
|
||||
</dl>
|
||||
</dl>
|
||||
<hr>
|
||||
|
||||
@@ -514,6 +602,7 @@
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||
|
||||
|
||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||
Abrahams</a> 2002. All Rights Reserved.</i>
|
||||
<p class="c3">© Copyright <a href=
|
||||
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
|
||||
Rights Reserved.
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<th>Default
|
||||
|
||||
<tr>
|
||||
<td><code><a href="ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a></code>
|
||||
<td><a href="ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator</a>
|
||||
|
||||
<td>A model of <a href=
|
||||
"ResultConverterGenerator.html">ResultConverterGenerator</a>.
|
||||
|
||||
219
doc/v2/type_id.html
Executable file
219
doc/v2/type_id.html
Executable file
@@ -0,0 +1,219 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<meta name="generator" content="HTML Tidy, 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/type_id.hpp></title>
|
||||
<style type="text/css">
|
||||
p.c4 {font-style: italic}
|
||||
span.c3 {color: #ff0000}
|
||||
h2.c2 {text-align: center}
|
||||
h1.c1 {text-align: center}
|
||||
</style>
|
||||
|
||||
<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 valign="top">
|
||||
<h1 class="c1">Boost.Python</h1>
|
||||
|
||||
<h2 class="c2">Header <boost/python/type_id.hpp></h2>
|
||||
</table>
|
||||
<hr>
|
||||
|
||||
<h2>Contents</h2>
|
||||
|
||||
<dl class="page-index">
|
||||
<dt><a href="#introduction">Introduction</a>
|
||||
|
||||
<dt><a href="#classes">Classes</a>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#type_info-spec">Class
|
||||
<code>type_info</code></a>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#type_info-spec-synopsis">Class
|
||||
<code>type_info</code> synopsis</a>
|
||||
|
||||
<dt><a href="#type_infospec-ctors">Class
|
||||
<code>type_info</code> constructor</a>
|
||||
|
||||
<dt><a href="#type_infospec-comparisons">Class
|
||||
<code>type_info</code> comparison functions</a>
|
||||
|
||||
<dt><a href="#type_infospec-observers">Class
|
||||
<code>type_info</code> observer functions</a>
|
||||
</dl>
|
||||
</dl>
|
||||
|
||||
<dt><a href="#functions">Functions</a>
|
||||
|
||||
<dd>
|
||||
<dl class="page-index">
|
||||
<dt><a href="#type_id-spec">type_id</a>
|
||||
</dl>
|
||||
|
||||
<dt><a href="#examples">Example</a>
|
||||
</dl>
|
||||
<hr>
|
||||
|
||||
<h2><a name="introduction"></a>Introduction</h2>
|
||||
|
||||
<p><code><boost/python/type_id.hpp></code> provides types and
|
||||
functions for runtime type identification like those of of
|
||||
<code><typeinfo></code>. It exists mostly to work around
|
||||
certain compiler bugs and platform-dependent interactions with
|
||||
shared libraries.
|
||||
|
||||
<h2><a name="classes"></a>Classes</h2>
|
||||
|
||||
<h3><a name="type_info-spec"></a>Class <code>type_info</code></h3>
|
||||
|
||||
<p><code>type_info</code> instances identify a type. As
|
||||
<code>std::type_info</code> is specified to (but unlike its
|
||||
implementation in some compilers),
|
||||
<code>boost::python::type_info</code> never represents top-level
|
||||
references or cv-qualification (see section 5.2.8 in the C++
|
||||
standard). Unlike <code>std::type_info</code>,
|
||||
<code>boost::python::type_info</code> instances are copyable, and
|
||||
comparisons always work reliably across shared library boundaries.
|
||||
|
||||
<h4><a name="type_info-spec-synopsis"></a>Class type_info
|
||||
synopsis</h4>
|
||||
<pre>
|
||||
namespace boost { namespace python
|
||||
{
|
||||
class type_info : <a href=
|
||||
"../../../utility/operators.htm#totally_ordered1">totally_ordered</a><type_info>
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
type_info(std::type_info const& = typeid(void));
|
||||
|
||||
// comparisons
|
||||
bool operator<(type_info const& rhs) const;
|
||||
bool operator==(type_info const& rhs) const;
|
||||
|
||||
// observers
|
||||
char const* name() const;
|
||||
};
|
||||
}}
|
||||
</pre>
|
||||
|
||||
<h4><a name="type_infospec-ctors">Class <code>type_info</code>
|
||||
constructor</a></h4>
|
||||
<pre>
|
||||
type_info(std::type_info const& = typeid(void));
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Effects:</b> constructs a <code>type_info</code> object
|
||||
which identifies the same type as its argument.
|
||||
|
||||
<dt><b>Rationale:</b> Since it is occasionally neccessary to make
|
||||
an array of <code>type_info</code> objects a benign default
|
||||
argument is supplied. <span class="c3"><b>Note:</b></span> this
|
||||
constructor does <i>not</i> correct for non-conformance of
|
||||
compiler <code>typeid()</code> implementations. See <code><a
|
||||
href="#type_id-spec">type_id</a></code>, below.
|
||||
</dl>
|
||||
|
||||
<h4><a name="type_infospec-comparisons">Class
|
||||
<code>type_info</code> comparisons</a></h4>
|
||||
<pre>
|
||||
bool operator<(type_info const& rhs) const;
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Effects:</b> yields a total order over
|
||||
<code>type_info</code> objects.
|
||||
</dl>
|
||||
<pre>
|
||||
bool operator==(type_info const& rhs) const;
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Returns:</b> <code>true</code> iff the two values describe
|
||||
the same type.
|
||||
</dl>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Note:</b> The use of <code><a href=
|
||||
"../../../utility/operators.htm#totally_ordered1">totally_ordered</a><type_info></code>
|
||||
as a private base class supplies operators <code><=</code>,
|
||||
<code>>=</code>, <code>></code>, and <code>!=</code>
|
||||
</dl>
|
||||
|
||||
<h4><a name="type_infospec-observers">Class <code>type_info</code>
|
||||
observers</a></h4>
|
||||
<pre>
|
||||
char const* name() const;
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Returns:</b> The result of calling <code>name()</code> on
|
||||
the argument used to construct the object.
|
||||
</dl>
|
||||
|
||||
<h2><a name="functions"></a>Functions</h2>
|
||||
<pre>
|
||||
std::ostream& operator<<(std::ostream&s, type_info const&x);
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Effects:</b> Writes a description of the type described by
|
||||
to <code>x</code> into <code>s</code>.
|
||||
|
||||
<dt><b>Rationale:</b> Not every C++ implementation provides a
|
||||
truly human-readable <code>type_info::name()</code> string, but
|
||||
for some we may be able to decode the string and produce a
|
||||
reasonable representation.
|
||||
</dl>
|
||||
<pre>
|
||||
<a name="type_id-spec">template <class T> type_info type_id</a>()
|
||||
</pre>
|
||||
|
||||
<dl class="function-semantics">
|
||||
<dt><b>Returns:</b> <code>type_info(typeid(T))</code>
|
||||
|
||||
<dt><b>Note:</b> On some non-conforming C++ implementations, the
|
||||
code is not actually as simple as described above; the semantics
|
||||
are adjusted to work <i>as-if</i> the C++ implementation were
|
||||
conforming.
|
||||
</dl>
|
||||
|
||||
<h2><a name="examples"></a>Example</h2>
|
||||
The following example, though silly, illustrates how the
|
||||
<code>type_id</code> facility might be used
|
||||
<pre>
|
||||
#include <boost/python/type_id.hpp>
|
||||
|
||||
// Returns true iff the user passes an int argument
|
||||
template <class T>
|
||||
bool is_int(T x)
|
||||
{
|
||||
using boost::python::type_id;
|
||||
return type_id<T>() == type_id<int>();
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||
18 November, 2002
|
||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||
|
||||
|
||||
<p class="c4">© Copyright <a href=
|
||||
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All
|
||||
Rights Reserved.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# include <boost/python/args.hpp>
|
||||
# include <boost/python/reference.hpp>
|
||||
# include <boost/python/object/class.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/detail/wrap_function.hpp>
|
||||
# include <boost/python/detail/member_function_cast.hpp>
|
||||
# include <boost/python/object/class_converters.hpp>
|
||||
@@ -194,7 +194,7 @@ class class_ : public objects::class_base
|
||||
id_vector()
|
||||
{
|
||||
// Stick the derived class id into the first element of the array
|
||||
ids[0] = converter::undecorated_type_id<T>();
|
||||
ids[0] = type_id<T>();
|
||||
|
||||
// Write the rest of the elements into succeeding positions.
|
||||
class_id* p = ids + 1;
|
||||
@@ -276,9 +276,9 @@ namespace detail
|
||||
typedef void type;
|
||||
|
||||
// Here's the runtime behavior
|
||||
static void execute(converter::undecorated_type_id_t** p)
|
||||
static void execute(type_info** p)
|
||||
{
|
||||
*(*p)++ = converter::undecorated_type_id<T>();
|
||||
*(*p)++ = type_id<T>();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef CALLBACK_DWA2002228_HPP
|
||||
# define CALLBACK_DWA2002228_HPP
|
||||
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/converter/to_python_function.hpp>
|
||||
# include <boost/python/converter/pointee_to_python_function.hpp>
|
||||
# include <boost/python/converter/from_python.hpp>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
# include <boost/python/converter/find_from_python.hpp>
|
||||
# include <boost/python/detail/wrap_python.hpp>
|
||||
# include <boost/python/detail/indirect_traits.hpp>
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/python/converter/from_python_data.hpp>
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
#ifndef LVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
|
||||
# define LVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/converter/pointer_type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/python/detail/indirect_traits.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
@@ -39,7 +41,7 @@ namespace detail
|
||||
template <class T>
|
||||
lvalue_from_python_registration*const&
|
||||
ref_lvalue_from_python_chain<T>::value
|
||||
= registry::lvalue_converters(undecorated_type_id<T>());
|
||||
= registry::lvalue_converters(type_id<T>());
|
||||
|
||||
template <class T, bool callback>
|
||||
struct select_lvalue_from_python_chain
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
# include <boost/python/detail/wrap_python.hpp>
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/python/converter/to_python_function_type.hpp>
|
||||
# include <boost/python/converter/pointer_type_id.hpp>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef POINTER_TYPE_ID_DWA2002222_HPP
|
||||
# define POINTER_TYPE_ID_DWA2002222_HPP
|
||||
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/type_traits/composite_traits.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
@@ -17,9 +17,9 @@ namespace detail
|
||||
struct pointer_typeid_select
|
||||
{
|
||||
template <class T>
|
||||
static inline undecorated_type_id_t execute(T*(*)() = 0)
|
||||
static inline type_info execute(T*(*)() = 0)
|
||||
{
|
||||
return undecorated_type_id<T>();
|
||||
return type_id<T>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,37 +27,37 @@ namespace detail
|
||||
struct pointer_typeid_select<true>
|
||||
{
|
||||
template <class T>
|
||||
static inline undecorated_type_id_t execute(T* const volatile&(*)() = 0)
|
||||
static inline type_info execute(T* const volatile&(*)() = 0)
|
||||
{
|
||||
return undecorated_type_id<T>();
|
||||
return type_id<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline undecorated_type_id_t execute(T*volatile&(*)() = 0)
|
||||
static inline type_info execute(T*volatile&(*)() = 0)
|
||||
{
|
||||
return undecorated_type_id<T>();
|
||||
return type_id<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline undecorated_type_id_t execute(T*const&(*)() = 0)
|
||||
static inline type_info execute(T*const&(*)() = 0)
|
||||
{
|
||||
return undecorated_type_id<T>();
|
||||
return type_id<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline undecorated_type_id_t execute(T*&(*)() = 0)
|
||||
static inline type_info execute(T*&(*)() = 0)
|
||||
{
|
||||
return undecorated_type_id<T>();
|
||||
return type_id<T>();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Usage: pointer_type_id<T>()
|
||||
//
|
||||
// Returns an undecorated_type_id_t associated with the type pointed
|
||||
// Returns a type_info associated with the type pointed
|
||||
// to by T, which may be a pointer or a reference to a pointer.
|
||||
template <class T>
|
||||
undecorated_type_id_t pointer_type_id(T(*)() = 0)
|
||||
type_info pointer_type_id(T(*)() = 0)
|
||||
{
|
||||
return detail::pointer_typeid_select<
|
||||
is_reference<T>::value
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// to its suitability for any purpose.
|
||||
#ifndef REGISTRY_DWA20011127_HPP
|
||||
# define REGISTRY_DWA20011127_HPP
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/detail/config.hpp>
|
||||
# include <boost/python/detail/wrap_python.hpp>
|
||||
# include <boost/python/converter/to_python_function_type.hpp>
|
||||
@@ -19,22 +19,22 @@ struct rvalue_from_python_registration;
|
||||
// This namespace acts as a sort of singleton
|
||||
namespace registry
|
||||
{
|
||||
BOOST_PYTHON_DECL lvalue_from_python_registration*& lvalue_converters(undecorated_type_id_t);
|
||||
BOOST_PYTHON_DECL rvalue_from_python_registration*& rvalue_converters(undecorated_type_id_t);
|
||||
BOOST_PYTHON_DECL lvalue_from_python_registration*& lvalue_converters(type_info);
|
||||
BOOST_PYTHON_DECL rvalue_from_python_registration*& rvalue_converters(type_info);
|
||||
|
||||
BOOST_PYTHON_DECL to_python_function_t const&
|
||||
get_to_python_function(undecorated_type_id_t);
|
||||
get_to_python_function(type_info);
|
||||
|
||||
BOOST_PYTHON_DECL void insert(to_python_function_t, undecorated_type_id_t);
|
||||
BOOST_PYTHON_DECL void insert(to_python_function_t, type_info);
|
||||
|
||||
// Insert an lvalue from_python converter
|
||||
BOOST_PYTHON_DECL void insert(void* (*convert)(PyObject*), undecorated_type_id_t);
|
||||
BOOST_PYTHON_DECL void insert(void* (*convert)(PyObject*), type_info);
|
||||
|
||||
// Insert an rvalue from_python converter
|
||||
BOOST_PYTHON_DECL void insert(
|
||||
void* (*convertible)(PyObject*)
|
||||
, constructor_function
|
||||
, undecorated_type_id_t
|
||||
, type_info
|
||||
);
|
||||
|
||||
// Insert an rvalue from_python converter at the tail of the
|
||||
@@ -42,10 +42,10 @@ namespace registry
|
||||
BOOST_PYTHON_DECL void push_back(
|
||||
void* (*convertible)(PyObject*)
|
||||
, constructor_function
|
||||
, undecorated_type_id_t
|
||||
, type_info
|
||||
);
|
||||
|
||||
BOOST_PYTHON_DECL PyTypeObject*& class_object(undecorated_type_id_t key);
|
||||
BOOST_PYTHON_DECL PyTypeObject*& class_object(type_info key);
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::converter
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// to its suitability for any purpose.
|
||||
#ifndef RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
|
||||
# define RVALUE_FROM_PYTHON_CHAIN_DWA200237_HPP
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
@@ -21,7 +22,7 @@ namespace detail
|
||||
|
||||
template <class T>
|
||||
rvalue_from_python_registration*const& rvalue_from_python_chain_impl<T>::value
|
||||
= registry::rvalue_converters(undecorated_type_id<T>());
|
||||
= registry::rvalue_converters(type_id<T>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# include <boost/python/detail/wrap_python.hpp>
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/python/converter/to_python_function_type.hpp>
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace detail
|
||||
template <class T>
|
||||
to_python_function_t const&
|
||||
to_python_function_base<T>::value
|
||||
= converter::registry::get_to_python_function(undecorated_type_id<T>());
|
||||
= converter::registry::get_to_python_function(type_id<T>());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
// Copyright David Abrahams 2001. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#ifndef TYPE_ID_DWA20011127_HPP
|
||||
# define TYPE_ID_DWA20011127_HPP
|
||||
# include <boost/python/detail/config.hpp>
|
||||
# include <boost/python/detail/indirect_traits.hpp>
|
||||
# include <boost/python/detail/msvc_typeinfo.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
# include <boost/type_traits/composite_traits.hpp>
|
||||
# include <boost/mpl/select_type.hpp>
|
||||
# include <boost/operators.hpp>
|
||||
# include <boost/type.hpp>
|
||||
# include <typeinfo>
|
||||
# include <iosfwd>
|
||||
# include <cstring>
|
||||
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
// for this compiler at least, cross-shared-library type_info
|
||||
// comparisons don't work, so use typeid(x).name() instead. It's not
|
||||
// yet clear what the best default strategy is.
|
||||
# if defined(__GNUC__) && __GNUC__ >= 3
|
||||
# define BOOST_PYTHON_TYPE_ID_NAME
|
||||
# endif
|
||||
|
||||
// type ids which represent the same information as std::type_info
|
||||
// (i.e. the top-level reference and cv-qualifiers are stripped), but
|
||||
// which works across shared libraries.
|
||||
struct undecorated_type_id_t : totally_ordered<undecorated_type_id_t>
|
||||
{
|
||||
undecorated_type_id_t(std::type_info const&);
|
||||
|
||||
// default constructor needed to build arrays, etc.
|
||||
undecorated_type_id_t();
|
||||
|
||||
bool operator<(undecorated_type_id_t const& rhs) const;
|
||||
bool operator==(undecorated_type_id_t const& rhs) const;
|
||||
|
||||
char const* name() const;
|
||||
friend BOOST_PYTHON_DECL std::ostream& operator<<(
|
||||
std::ostream&, undecorated_type_id_t const&);
|
||||
|
||||
private: // data members
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
typedef char const* base_id_t;
|
||||
# else
|
||||
typedef std::type_info const* base_id_t;
|
||||
# endif
|
||||
|
||||
base_id_t m_base_type;
|
||||
};
|
||||
|
||||
struct type_id_t : totally_ordered<type_id_t>
|
||||
{
|
||||
enum decoration { const_ = 0x1, volatile_ = 0x2, reference = 0x4 };
|
||||
|
||||
type_id_t(undecorated_type_id_t, decoration = decoration());
|
||||
|
||||
bool operator<(type_id_t const& rhs) const;
|
||||
bool operator==(type_id_t const& rhs) const;
|
||||
|
||||
friend BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, type_id_t const&);
|
||||
|
||||
operator undecorated_type_id_t const&() const;
|
||||
private: // type
|
||||
typedef undecorated_type_id_t base_id_t;
|
||||
|
||||
private: // data members
|
||||
decoration m_decoration;
|
||||
base_id_t m_base_type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline undecorated_type_id_t undecorated_type_id(boost::type<T>* = 0)
|
||||
{
|
||||
return undecorated_type_id_t(
|
||||
# if (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600)
|
||||
typeid(T)
|
||||
# else // strip the decoration which msvc and Intel mistakenly leave in
|
||||
python::detail::msvc_typeid<T>()
|
||||
# endif
|
||||
);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline type_id_t type_id(boost::type<T>* = 0)
|
||||
{
|
||||
return type_id_t(
|
||||
undecorated_type_id<T>()
|
||||
, type_id_t::decoration(
|
||||
(is_const<T>::value || python::detail::is_reference_to_const<T>::value
|
||||
? type_id_t::const_ : 0)
|
||||
| (is_volatile<T>::value || python::detail::is_reference_to_volatile<T>::value
|
||||
? type_id_t::volatile_ : 0)
|
||||
| (is_reference<T>::value ? type_id_t::reference : 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
inline undecorated_type_id_t::undecorated_type_id_t(std::type_info const& id)
|
||||
: m_base_type(
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
id.name()
|
||||
# else
|
||||
&id
|
||||
# endif
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
inline undecorated_type_id_t::undecorated_type_id_t()
|
||||
: m_base_type()
|
||||
{
|
||||
}
|
||||
|
||||
inline type_id_t::type_id_t(undecorated_type_id_t base_t, decoration decoration)
|
||||
: m_decoration(decoration)
|
||||
, m_base_type(base_t)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool undecorated_type_id_t::operator<(undecorated_type_id_t const& rhs) const
|
||||
{
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
return std::strcmp(m_base_type, rhs.m_base_type) < 0;
|
||||
# else
|
||||
return m_base_type->before(*rhs.m_base_type);
|
||||
# endif
|
||||
}
|
||||
|
||||
inline bool type_id_t::operator<(type_id_t const& rhs) const
|
||||
{
|
||||
return m_decoration < rhs.m_decoration
|
||||
|| m_decoration == rhs.m_decoration
|
||||
&& m_base_type < rhs.m_base_type;
|
||||
}
|
||||
|
||||
inline bool undecorated_type_id_t::operator==(undecorated_type_id_t const& rhs) const
|
||||
{
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
return !std::strcmp(m_base_type, rhs.m_base_type);
|
||||
# else
|
||||
return *m_base_type == *rhs.m_base_type;
|
||||
# endif
|
||||
}
|
||||
|
||||
inline bool type_id_t::operator==(type_id_t const& rhs) const
|
||||
{
|
||||
return m_decoration == rhs.m_decoration && m_base_type == rhs.m_base_type;
|
||||
}
|
||||
|
||||
inline type_id_t::operator undecorated_type_id_t const&() const
|
||||
{
|
||||
return m_base_type;
|
||||
}
|
||||
|
||||
inline char const* undecorated_type_id_t::name() const
|
||||
{
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
return m_base_type;
|
||||
# else
|
||||
return m_base_type->name();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, undecorated_type_id_t const&);
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, type_id_t const&);
|
||||
|
||||
}}} // namespace boost::python::converter
|
||||
|
||||
#endif // TYPE_ID_DWA20011127_HPP
|
||||
77
include/boost/python/detail/decorated_type_id.hpp
Executable file
77
include/boost/python/detail/decorated_type_id.hpp
Executable file
@@ -0,0 +1,77 @@
|
||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#ifndef DECORATED_TYPE_ID_DWA2002517_HPP
|
||||
# define DECORATED_TYPE_ID_DWA2002517_HPP
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/detail/indirect_traits.hpp>
|
||||
# include <boost/type_traits/cv_traits.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
struct decorated_type_info : totally_ordered<decorated_type_info>
|
||||
{
|
||||
enum decoration { const_ = 0x1, volatile_ = 0x2, reference = 0x4 };
|
||||
|
||||
decorated_type_info(type_info, decoration = decoration());
|
||||
|
||||
bool operator<(decorated_type_info const& rhs) const;
|
||||
bool operator==(decorated_type_info const& rhs) const;
|
||||
|
||||
friend BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, decorated_type_info const&);
|
||||
|
||||
operator type_info const&() const;
|
||||
private: // type
|
||||
typedef type_info base_id_t;
|
||||
|
||||
private: // data members
|
||||
decoration m_decoration;
|
||||
base_id_t m_base_type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline decorated_type_info decorated_type_id(boost::type<T>* = 0)
|
||||
{
|
||||
return decorated_type_info(
|
||||
type_id<T>()
|
||||
, decorated_type_info::decoration(
|
||||
(is_const<T>::value || python::detail::is_reference_to_const<T>::value
|
||||
? decorated_type_info::const_ : 0)
|
||||
| (is_volatile<T>::value || python::detail::is_reference_to_volatile<T>::value
|
||||
? decorated_type_info::volatile_ : 0)
|
||||
| (is_reference<T>::value ? decorated_type_info::reference : 0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
inline decorated_type_info::decorated_type_info(type_info base_t, decoration decoration)
|
||||
: m_decoration(decoration)
|
||||
, m_base_type(base_t)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool decorated_type_info::operator<(decorated_type_info const& rhs) const
|
||||
{
|
||||
return m_decoration < rhs.m_decoration
|
||||
|| m_decoration == rhs.m_decoration
|
||||
&& m_base_type < rhs.m_base_type;
|
||||
}
|
||||
|
||||
inline bool decorated_type_info::operator==(decorated_type_info const& rhs) const
|
||||
{
|
||||
return m_decoration == rhs.m_decoration && m_base_type == rhs.m_base_type;
|
||||
}
|
||||
|
||||
inline decorated_type_info::operator type_info const&() const
|
||||
{
|
||||
return m_base_type;
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, decorated_type_info const&);
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
#endif // DECORATED_TYPE_ID_DWA2002517_HPP
|
||||
@@ -8,7 +8,7 @@
|
||||
# include <boost/type.hpp>
|
||||
# include <boost/python/converter/implicit.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
@@ -20,7 +20,7 @@ void implicitly_convertible(boost::type<Source>* = 0, boost::type<Target>* = 0)
|
||||
converter::registry::push_back(
|
||||
&functions::convertible
|
||||
, &functions::construct
|
||||
, converter::undecorated_type_id<Target>());
|
||||
, type_id<Target>());
|
||||
}
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
43
include/boost/python/instance_holder.hpp
Executable file
43
include/boost/python/instance_holder.hpp
Executable file
@@ -0,0 +1,43 @@
|
||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#ifndef INSTANCE_HOLDER_DWA2002517_HPP
|
||||
# define INSTANCE_HOLDER_DWA2002517_HPP
|
||||
|
||||
# include <boost/python/detail/config.hpp>
|
||||
# include <boost/utility.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
// Base class for all holders
|
||||
struct BOOST_PYTHON_DECL instance_holder : private noncopyable
|
||||
{
|
||||
public:
|
||||
instance_holder();
|
||||
virtual ~instance_holder();
|
||||
|
||||
// return the next holder in a chain
|
||||
instance_holder* next() const;
|
||||
|
||||
virtual void* holds(type_info) = 0;
|
||||
|
||||
void install(PyObject* inst) throw();
|
||||
private:
|
||||
instance_holder* m_next;
|
||||
};
|
||||
// This macro is needed for implementation of derived holders
|
||||
# define BOOST_PYTHON_UNFORWARD(N,ignored) (typename unforward<A##N>::type)(a##N)
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
inline instance_holder* instance_holder::next() const
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // INSTANCE_HOLDER_DWA2002517_HPP
|
||||
@@ -35,8 +35,8 @@ objects::function* make_function(F f, Policies const& policies)
|
||||
, detail::arg_tuple_size<F>::value);
|
||||
}
|
||||
|
||||
template <class ArgList, class Holder>
|
||||
objects::function* make_constructor(Holder* = 0, ArgList* = 0)
|
||||
template <class ArgList, class HolderGenerator>
|
||||
objects::function* make_constructor(HolderGenerator* = 0, ArgList* = 0)
|
||||
{
|
||||
enum { nargs = mpl::size<ArgList>::value };
|
||||
|
||||
@@ -44,13 +44,13 @@ objects::function* make_constructor(Holder* = 0, ArgList* = 0)
|
||||
objects::py_function(
|
||||
::boost::bind<PyObject*>(detail::caller(),
|
||||
objects::make_holder<nargs>
|
||||
::template apply<Holder,ArgList>::execute
|
||||
::template apply<HolderGenerator,ArgList>::execute
|
||||
, _1, _2, default_call_policies()))
|
||||
, nargs + 1);
|
||||
}
|
||||
|
||||
template <class ArgList, class Holder, class Policies>
|
||||
objects::function* make_constructor(Policies const& policies, Holder* = 0, ArgList* = 0)
|
||||
template <class ArgList, class HolderGenerator, class Policies>
|
||||
objects::function* make_constructor(Policies const& policies, HolderGenerator* = 0, ArgList* = 0)
|
||||
{
|
||||
enum { nargs = mpl::size<ArgList>::value };
|
||||
|
||||
@@ -58,7 +58,7 @@ objects::function* make_constructor(Policies const& policies, Holder* = 0, ArgLi
|
||||
objects::py_function(
|
||||
::boost::bind<PyObject*>(detail::caller(),
|
||||
objects::make_holder<nargs>
|
||||
::template apply<Holder,ArgList>::execute
|
||||
::template apply<HolderGenerator,ArgList>::execute
|
||||
, _1, _2, policies))
|
||||
, nargs + 1);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
# include <boost/python/detail/wrap_python.hpp>
|
||||
# include <boost/python/detail/config.hpp>
|
||||
# include <boost/utility.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/reference.hpp>
|
||||
# include <boost/python/instance_holder.hpp>
|
||||
# include <cstddef>
|
||||
|
||||
namespace boost { namespace python {
|
||||
@@ -19,10 +20,8 @@ class module;
|
||||
|
||||
namespace objects {
|
||||
|
||||
template <class T> struct holder;
|
||||
|
||||
// To identify a class, we don't need cv/reference decorations
|
||||
typedef converter::undecorated_type_id_t class_id;
|
||||
typedef type_info class_id;
|
||||
|
||||
struct BOOST_PYTHON_DECL class_base : private noncopyable
|
||||
{
|
||||
@@ -46,25 +45,6 @@ struct BOOST_PYTHON_DECL class_base : private noncopyable
|
||||
|
||||
BOOST_PYTHON_DECL ref registered_class_object(class_id id);
|
||||
|
||||
// Base class for all holders
|
||||
struct BOOST_PYTHON_DECL instance_holder : private noncopyable
|
||||
{
|
||||
public:
|
||||
instance_holder();
|
||||
virtual ~instance_holder();
|
||||
|
||||
// return the next holder in a chain
|
||||
instance_holder* next() const;
|
||||
|
||||
virtual void* holds(converter::undecorated_type_id_t) = 0;
|
||||
|
||||
void install(PyObject* inst) throw();
|
||||
private:
|
||||
instance_holder* m_next;
|
||||
};
|
||||
// This macro is needed for implementation of derived holders
|
||||
# define BOOST_PYTHON_UNFORWARD(N,ignored) (typename unforward<A##N>::type)(a##N)
|
||||
|
||||
// Each extension instance will be one of these
|
||||
struct instance
|
||||
{
|
||||
@@ -75,14 +55,6 @@ struct instance
|
||||
BOOST_PYTHON_DECL ref class_metatype();
|
||||
BOOST_PYTHON_DECL ref class_type();
|
||||
|
||||
//
|
||||
// implementation
|
||||
//
|
||||
inline instance_holder* instance_holder::next() const
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
#endif // CLASS_DWA20011214_HPP
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef CLASS_OBJECT_DWA200222_HPP
|
||||
# define CLASS_OBJECT_DWA200222_HPP
|
||||
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
@@ -18,8 +18,8 @@ struct class_object
|
||||
};
|
||||
|
||||
template <class T>
|
||||
PyTypeObject*& class_object<T>::reference = converter::registry::class_object(
|
||||
converter::undecorated_type_id<T>());
|
||||
PyTypeObject*& class_object<T>::reference
|
||||
= converter::registry::class_object(python::type_id<T>());
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
#ifndef FIND_INSTANCE_DWA2002312_HPP
|
||||
# define FIND_INSTANCE_DWA2002312_HPP
|
||||
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
// Given an undecorated type_id, find the instance data which
|
||||
// corresponds to it, or return 0 in case no such type is held.
|
||||
BOOST_PYTHON_DECL void* find_instance_impl(PyObject*, converter::undecorated_type_id_t);
|
||||
// Given a type_id, find the instance data which corresponds to it, or
|
||||
// return 0 in case no such type is held.
|
||||
BOOST_PYTHON_DECL void* find_instance_impl(PyObject*, type_info);
|
||||
|
||||
// This produces a function with the right signature for use in from_python conversions
|
||||
template <class T>
|
||||
@@ -21,14 +21,14 @@ struct instance_finder
|
||||
{
|
||||
instance_finder()
|
||||
{
|
||||
converter::registry::insert(&execute, converter::undecorated_type_id<T>());
|
||||
converter::registry::insert(&execute, python::type_id<T>());
|
||||
}
|
||||
|
||||
static instance_finder const registration;
|
||||
private:
|
||||
static inline void* execute(PyObject* p)
|
||||
{
|
||||
return find_instance_impl(p, converter::undecorated_type_id<T>());
|
||||
return find_instance_impl(p, python::type_id<T>());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
#ifndef INHERITANCE_DWA200216_HPP
|
||||
# define INHERITANCE_DWA200216_HPP
|
||||
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/mpl/select_type.hpp>
|
||||
# include <boost/type_traits/object_traits.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
typedef converter::undecorated_type_id_t class_id;
|
||||
using converter::undecorated_type_id;
|
||||
typedef type_info class_id;
|
||||
using python::type_id;
|
||||
|
||||
// Types used to get address and id of most derived type
|
||||
typedef std::pair<void*,class_id> dynamic_id_t;
|
||||
@@ -70,7 +72,7 @@ struct non_polymorphic_id_generator
|
||||
{
|
||||
static dynamic_id_t execute(void* p_)
|
||||
{
|
||||
return std::make_pair(p_, converter::undecorated_type_id<T>());
|
||||
return std::make_pair(p_, python::type_id<T>());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -91,7 +93,7 @@ void register_dynamic_id(T* = 0)
|
||||
{
|
||||
typedef typename dynamic_id_generator<T>::type generator;
|
||||
register_dynamic_id_aux(
|
||||
converter::undecorated_type_id<T>(), &generator::execute);
|
||||
python::type_id<T>(), &generator::execute);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -154,8 +156,8 @@ inline void register_conversion(
|
||||
{
|
||||
typedef typename cast_generator<Source,Target>::type generator;
|
||||
|
||||
add_cast(converter::undecorated_type_id<Source>()
|
||||
, converter::undecorated_type_id<Target>()
|
||||
add_cast(python::type_id<Source>()
|
||||
, python::type_id<Target>()
|
||||
, &generator::execute
|
||||
, is_downcast);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# define POINTER_HOLDER_DWA20011215_HPP
|
||||
|
||||
# include <boost/python/object/class.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/object/inheritance.hpp>
|
||||
# include <boost/python/object/find_instance.hpp>
|
||||
# include <boost/python/object/forward.hpp>
|
||||
@@ -46,7 +46,7 @@ struct pointer_holder : instance_holder
|
||||
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER,nil)
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(converter::undecorated_type_id_t);
|
||||
void* holds(type_info);
|
||||
|
||||
private: // data members
|
||||
Pointer m_p;
|
||||
@@ -84,45 +84,45 @@ struct pointer_holder_back_reference : instance_holder
|
||||
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_POINTER_HOLDER_BACK_REFERENCE,nil)
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(converter::undecorated_type_id_t);
|
||||
void* holds(type_info);
|
||||
|
||||
private: // data members
|
||||
Pointer m_p;
|
||||
};
|
||||
|
||||
template <class Pointer, class Value>
|
||||
pointer_holder<Pointer,Value>::pointer_holder(Pointer p)
|
||||
inline pointer_holder<Pointer,Value>::pointer_holder(Pointer p)
|
||||
: m_p(p)
|
||||
{
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
pointer_holder_back_reference<Pointer,Value>::pointer_holder_back_reference(Pointer p)
|
||||
inline pointer_holder_back_reference<Pointer,Value>::pointer_holder_back_reference(Pointer p)
|
||||
: m_p(p)
|
||||
{
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
void* pointer_holder<Pointer, Value>::holds(converter::undecorated_type_id_t dst_t)
|
||||
void* pointer_holder<Pointer, Value>::holds(type_info dst_t)
|
||||
{
|
||||
if (dst_t == converter::undecorated_type_id<Pointer>())
|
||||
if (dst_t == python::type_id<Pointer>())
|
||||
return &this->m_p;
|
||||
|
||||
converter::type_id_t src_t = converter::undecorated_type_id<Value>();
|
||||
type_info src_t = python::type_id<Value>();
|
||||
return src_t == dst_t ? &*this->m_p
|
||||
: find_dynamic_type(&*this->m_p, src_t, dst_t);
|
||||
}
|
||||
|
||||
template <class Pointer, class Value>
|
||||
void* pointer_holder_back_reference<Pointer, Value>::holds(converter::undecorated_type_id_t dst_t)
|
||||
void* pointer_holder_back_reference<Pointer, Value>::holds(type_info dst_t)
|
||||
{
|
||||
if (dst_t == converter::undecorated_type_id<Pointer>())
|
||||
if (dst_t == python::type_id<Pointer>())
|
||||
return &this->m_p;
|
||||
|
||||
if (dst_t == converter::undecorated_type_id<held_type>())
|
||||
if (dst_t == python::type_id<held_type>())
|
||||
return &*this->m_p;
|
||||
|
||||
converter::type_id_t src_t = converter::undecorated_type_id<Value>();
|
||||
type_info src_t = python::type_id<Value>();
|
||||
Value* p = &*this->m_p;
|
||||
return src_t == dst_t ? p : find_dynamic_type(p, src_t, dst_t);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
# include <boost/python/object/value_holder_fwd.hpp>
|
||||
# include <boost/python/object/class.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/object/inheritance.hpp>
|
||||
# include <boost/python/object/find_instance.hpp>
|
||||
# include <boost/python/object/forward.hpp>
|
||||
@@ -40,7 +40,7 @@ struct value_holder : instance_holder
|
||||
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER,nil)
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(converter::undecorated_type_id_t);
|
||||
void* holds(type_info);
|
||||
|
||||
private: // data members
|
||||
Held m_held;
|
||||
@@ -72,32 +72,32 @@ struct value_holder_back_reference : instance_holder
|
||||
BOOST_PYTHON_REPEAT_ARITY_2ND(BOOST_PYTHON_CONSTRUCT_VALUE_HOLDER_BACK_REFERENCE,nil)
|
||||
|
||||
private: // required holder implementation
|
||||
void* holds(converter::undecorated_type_id_t);
|
||||
void* holds(type_info);
|
||||
|
||||
private: // data members
|
||||
BackReferenceType m_held;
|
||||
};
|
||||
|
||||
template <class Held>
|
||||
void* value_holder<Held>::holds(converter::undecorated_type_id_t dst_t)
|
||||
void* value_holder<Held>::holds(type_info dst_t)
|
||||
{
|
||||
converter::undecorated_type_id_t src_t = converter::undecorated_type_id<Held>();
|
||||
type_info src_t = python::type_id<Held>();
|
||||
return src_t == dst_t ? &m_held
|
||||
: find_static_type(&m_held, src_t, dst_t);
|
||||
}
|
||||
|
||||
template <class Held, class BackReferenceType>
|
||||
void* value_holder_back_reference<Held,BackReferenceType>::holds(
|
||||
converter::undecorated_type_id_t dst_t)
|
||||
type_info dst_t)
|
||||
{
|
||||
converter::undecorated_type_id_t src_t = converter::undecorated_type_id<Held>();
|
||||
type_info src_t = python::type_id<Held>();
|
||||
if (src_t == dst_t)
|
||||
{
|
||||
Held* x = &m_held;
|
||||
return x;
|
||||
}
|
||||
|
||||
src_t = converter::undecorated_type_id<BackReferenceType>();
|
||||
src_t = python::type_id<BackReferenceType>();
|
||||
return src_t == dst_t
|
||||
? &m_held
|
||||
: find_static_type(&m_held, src_t, dst_t);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/python/converter/to_python_function.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/type_id.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
@@ -31,7 +31,7 @@ to_python_converter<T,Conversion>::to_python_converter()
|
||||
|
||||
converter::registry::insert(
|
||||
&normalized::convert
|
||||
, converter::undecorated_type_id<T>());
|
||||
, type_id<T>());
|
||||
}
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
# define TO_PYTHON_VALUE_DWA200221_HPP
|
||||
|
||||
# include <boost/type_traits/transform_traits.hpp>
|
||||
# include <boost/python/converter/type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/python/converter/to_python_function.hpp>
|
||||
# include <boost/python/converter/builtin_converters.hpp>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifndef TYPE_FROM_PYTHON_DWA2002130_HPP
|
||||
# define TYPE_FROM_PYTHON_DWA2002130_HPP
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/python/converter/registry.hpp>
|
||||
# include <boost/python/detail/void_ptr.hpp>
|
||||
|
||||
@@ -16,9 +17,9 @@ namespace detail
|
||||
// Given a pointer-to-function of 1 parameter returning a reference
|
||||
// type, return the type_id of the function's return type.
|
||||
template <class T, class U>
|
||||
inline converter::undecorated_type_id_t extractor_type_id(T&(*)(U))
|
||||
inline type_info extractor_type_id(T&(*)(U))
|
||||
{
|
||||
return converter::undecorated_type_id<T>();
|
||||
return type_id<T>();
|
||||
}
|
||||
|
||||
// A function generator whose static execute() function is an lvalue
|
||||
|
||||
102
include/boost/python/type_id.hpp
Executable file
102
include/boost/python/type_id.hpp
Executable file
@@ -0,0 +1,102 @@
|
||||
// Copyright David Abrahams 2002. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#ifndef TYPE_ID_DWA2002517_HPP
|
||||
# define TYPE_ID_DWA2002517_HPP
|
||||
|
||||
# include <boost/python/detail/config.hpp>
|
||||
# include <boost/python/detail/msvc_typeinfo.hpp>
|
||||
# include <boost/operators.hpp>
|
||||
# include <typeinfo>
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
// for this compiler at least, cross-shared-library type_info
|
||||
// comparisons don't work, so use typeid(x).name() instead. It's not
|
||||
// yet clear what the best default strategy is.
|
||||
# if defined(__GNUC__) && __GNUC__ >= 3
|
||||
# define BOOST_PYTHON_TYPE_ID_NAME
|
||||
# endif
|
||||
|
||||
// type ids which represent the same information as std::type_info
|
||||
// (i.e. the top-level reference and cv-qualifiers are stripped), but
|
||||
// which works across shared libraries.
|
||||
struct type_info : private totally_ordered<type_info>
|
||||
{
|
||||
type_info(std::type_info const& = typeid(void));
|
||||
|
||||
bool operator<(type_info const& rhs) const;
|
||||
bool operator==(type_info const& rhs) const;
|
||||
|
||||
char const* name() const;
|
||||
friend BOOST_PYTHON_DECL std::ostream& operator<<(
|
||||
std::ostream&, type_info const&);
|
||||
|
||||
private: // data members
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
typedef char const* base_id_t;
|
||||
# else
|
||||
typedef std::type_info const* base_id_t;
|
||||
# endif
|
||||
|
||||
base_id_t m_base_type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline type_info type_id(boost::type<T>* = 0)
|
||||
{
|
||||
return type_info(
|
||||
# if (!defined(BOOST_MSVC) || BOOST_MSVC > 1300) && (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600)
|
||||
typeid(T)
|
||||
# else // strip the decoration which msvc and Intel mistakenly leave in
|
||||
python::detail::msvc_typeid<T>()
|
||||
# endif
|
||||
);
|
||||
}
|
||||
|
||||
inline type_info::type_info(std::type_info const& id)
|
||||
: m_base_type(
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
id.name()
|
||||
# else
|
||||
&id
|
||||
# endif
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool type_info::operator<(type_info const& rhs) const
|
||||
{
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
return std::strcmp(m_base_type, rhs.m_base_type) < 0;
|
||||
# else
|
||||
return m_base_type->before(*rhs.m_base_type);
|
||||
# endif
|
||||
}
|
||||
|
||||
inline bool type_info::operator==(type_info const& rhs) const
|
||||
{
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
return !std::strcmp(m_base_type, rhs.m_base_type);
|
||||
# else
|
||||
return *m_base_type == *rhs.m_base_type;
|
||||
# endif
|
||||
}
|
||||
|
||||
inline char const* type_info::name() const
|
||||
{
|
||||
# ifdef BOOST_PYTHON_TYPE_ID_NAME
|
||||
return m_base_type;
|
||||
# else
|
||||
return m_base_type->name();
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream&, type_info const&);
|
||||
|
||||
}} // namespace boost::python
|
||||
|
||||
#endif // TYPE_ID_DWA2002517_HPP
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <boost/python/converter/from_python_data.hpp>
|
||||
#include <boost/python/converter/registry.hpp>
|
||||
#include <boost/python/reference.hpp>
|
||||
#include <boost/python/type_id.hpp>
|
||||
#include <boost/python/errors.hpp>
|
||||
#include <boost/cast.hpp>
|
||||
#include <string>
|
||||
@@ -38,7 +39,7 @@ namespace
|
||||
registry::insert(
|
||||
&slot_rvalue_from_python<T,SlotPolicy>::convertible
|
||||
, &slot_rvalue_from_python<T,SlotPolicy>::construct
|
||||
, undecorated_type_id<T>()
|
||||
, type_id<T>()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -280,7 +281,7 @@ void initialize_builtin_converters()
|
||||
slot_rvalue_from_python<std::complex<long double>,complex_rvalue_from_python>();
|
||||
|
||||
// Add an lvalue converter for char which gets us char const*
|
||||
registry::insert(convert_to_cstring,undecorated_type_id<char>());
|
||||
registry::insert(convert_to_cstring,type_id<char>());
|
||||
|
||||
// Register by-value converters to std::string
|
||||
slot_rvalue_from_python<std::string, string_rvalue_from_python>();
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace // <unnamed>
|
||||
PyTypeObject* m_class_object;
|
||||
};
|
||||
|
||||
typedef std::map<undecorated_type_id_t, entry> registry_t;
|
||||
typedef std::map<type_info, entry> registry_t;
|
||||
|
||||
registry_t& entries()
|
||||
{
|
||||
@@ -50,7 +50,7 @@ namespace // <unnamed>
|
||||
return registry;
|
||||
}
|
||||
|
||||
entry* find(undecorated_type_id_t type)
|
||||
entry* find(type_info type)
|
||||
{
|
||||
return &entries()[type];
|
||||
}
|
||||
@@ -67,12 +67,12 @@ namespace // <unnamed>
|
||||
namespace registry
|
||||
{
|
||||
to_python_function_t const& get_to_python_function(
|
||||
undecorated_type_id_t key)
|
||||
type_info key)
|
||||
{
|
||||
return find(key)->m_to_python_converter;
|
||||
}
|
||||
|
||||
void insert(to_python_function_t f, undecorated_type_id_t source_t)
|
||||
void insert(to_python_function_t f, type_info source_t)
|
||||
{
|
||||
to_python_function_t& slot = find(source_t)->m_to_python_converter;
|
||||
assert(slot == 0); // we have a problem otherwise
|
||||
@@ -85,7 +85,7 @@ namespace registry
|
||||
}
|
||||
|
||||
// Insert an lvalue from_python converter
|
||||
void insert(void* (*convert)(PyObject*), undecorated_type_id_t key)
|
||||
void insert(void* (*convert)(PyObject*), type_info key)
|
||||
{
|
||||
entry* found = find(key);
|
||||
lvalue_from_python_registration *registration = new lvalue_from_python_registration;
|
||||
@@ -99,7 +99,7 @@ namespace registry
|
||||
// Insert an rvalue from_python converter
|
||||
void insert(void* (*convertible)(PyObject*)
|
||||
, constructor_function construct
|
||||
, undecorated_type_id_t key)
|
||||
, type_info key)
|
||||
{
|
||||
entry* found = find(key);
|
||||
rvalue_from_python_registration *registration = new rvalue_from_python_registration;
|
||||
@@ -112,7 +112,7 @@ namespace registry
|
||||
// Insert an rvalue from_python converter
|
||||
void push_back(void* (*convertible)(PyObject*)
|
||||
, constructor_function construct
|
||||
, undecorated_type_id_t key)
|
||||
, type_info key)
|
||||
{
|
||||
rvalue_from_python_registration** found = &find(key)->m_rvalue_from_python;
|
||||
while (*found != 0)
|
||||
@@ -125,17 +125,17 @@ namespace registry
|
||||
*found = registration;
|
||||
}
|
||||
|
||||
PyTypeObject*& class_object(undecorated_type_id_t key)
|
||||
PyTypeObject*& class_object(type_info key)
|
||||
{
|
||||
return find(key)->m_class_object;
|
||||
}
|
||||
|
||||
lvalue_from_python_registration*& lvalue_converters(undecorated_type_id_t key)
|
||||
lvalue_from_python_registration*& lvalue_converters(type_info key)
|
||||
{
|
||||
return find(key)->m_lvalue_from_python;
|
||||
}
|
||||
|
||||
rvalue_from_python_registration*& rvalue_converters(undecorated_type_id_t key)
|
||||
rvalue_from_python_registration*& rvalue_converters(type_info key)
|
||||
{
|
||||
return find(key)->m_rvalue_from_python;
|
||||
}
|
||||
|
||||
@@ -4,30 +4,33 @@
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
#include <boost/python/converter/type_id.hpp>
|
||||
#include <boost/python/type_id.hpp>
|
||||
#include <boost/python/detail/decorated_type_id.hpp>
|
||||
#if !defined(__GNUC__) || __GNUC__ >= 3 || __SGI_STL_PORT
|
||||
# include <ostream>
|
||||
#else
|
||||
# include <ostream.h>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
namespace boost { namespace python {
|
||||
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream& os, undecorated_type_id_t const& x)
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream& os, type_info const& x)
|
||||
{
|
||||
return os << x.name();
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream& os, type_id_t const& x)
|
||||
namespace detail
|
||||
{
|
||||
os << x.m_base_type;
|
||||
if (x.m_decoration & type_id_t::const_)
|
||||
os << " const";
|
||||
if (x.m_decoration & type_id_t::volatile_)
|
||||
os << " volatile";
|
||||
if (x.m_decoration & type_id_t::reference)
|
||||
os << "&";
|
||||
return os;
|
||||
BOOST_PYTHON_DECL std::ostream& operator<<(std::ostream& os, detail::decorated_type_info const& x)
|
||||
{
|
||||
os << x.m_base_type;
|
||||
if (x.m_decoration & decorated_type_info::const_)
|
||||
os << " const";
|
||||
if (x.m_decoration & decorated_type_info::volatile_)
|
||||
os << " volatile";
|
||||
if (x.m_decoration & decorated_type_info::reference)
|
||||
os << "&";
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::converter
|
||||
}} // namespace boost::python::converter
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
namespace boost { namespace python {
|
||||
|
||||
instance_holder::instance_holder()
|
||||
: m_next(0)
|
||||
@@ -35,269 +35,272 @@ type_is_gc(PyTypeObject *python_type)
|
||||
return python_type->tp_flags & Py_TPFLAGS_HEAPTYPE;
|
||||
}
|
||||
|
||||
PyTypeObject class_metatype_object = {
|
||||
static PyTypeObject class_metatype_object = {
|
||||
PyObject_HEAD_INIT(0)//&PyType_Type)
|
||||
0,
|
||||
"Boost.Python.class",
|
||||
PyType_Type.tp_basicsize,
|
||||
0,
|
||||
0, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
0,
|
||||
"Boost.Python.class",
|
||||
PyType_Type.tp_basicsize,
|
||||
0,
|
||||
0, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
|
||||
| Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
0, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, //&PyType_Type, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
0, // filled in with type_new /* tp_new */
|
||||
0, // filled in with __PyObject_GC_Del /* tp_free */
|
||||
(inquiry)type_is_gc, /* tp_is_gc */
|
||||
| Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
0, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, //&PyType_Type, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
0, /* tp_alloc */
|
||||
0, // filled in with type_new /* tp_new */
|
||||
0, // filled in with __PyObject_GC_Del /* tp_free */
|
||||
(inquiry)type_is_gc, /* tp_is_gc */
|
||||
};
|
||||
|
||||
// Get the metatype object for all extension classes.
|
||||
BOOST_PYTHON_DECL ref class_metatype()
|
||||
{
|
||||
if (class_metatype_object.tp_dict == 0)
|
||||
{
|
||||
class_metatype_object.ob_type = &PyType_Type;
|
||||
class_metatype_object.tp_base = &PyType_Type;
|
||||
if (PyType_Ready(&class_metatype_object))
|
||||
return ref();
|
||||
}
|
||||
return ref((PyObject*)&class_metatype_object, ref::increment_count);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
static void instance_dealloc(PyObject* inst)
|
||||
{
|
||||
instance* kill_me = (instance*)inst;
|
||||
|
||||
for (instance_holder* p = kill_me->objects, *next; p != 0; p = next)
|
||||
{
|
||||
next = p->next();
|
||||
delete p;
|
||||
}
|
||||
|
||||
inst->ob_type->tp_free(inst);
|
||||
}
|
||||
}
|
||||
|
||||
// Do we really need this? I'm beginning to think we don't!
|
||||
PyTypeObject class_type_object = {
|
||||
PyObject_HEAD_INIT(0) //&class_metatype_object)
|
||||
0,
|
||||
"Boost.Python.instance",
|
||||
sizeof(instance),
|
||||
0,
|
||||
instance_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
|
||||
| Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
0, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, //&PyBaseObject_Type, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
PyType_GenericAlloc, /* tp_alloc */
|
||||
PyType_GenericNew
|
||||
};
|
||||
|
||||
BOOST_PYTHON_DECL ref class_type()
|
||||
{
|
||||
if (class_type_object.tp_dict == 0)
|
||||
{
|
||||
class_type_object.ob_type = (PyTypeObject*)class_metatype().release();
|
||||
class_type_object.tp_base = &PyBaseObject_Type;
|
||||
if (PyType_Ready(&class_type_object))
|
||||
return ref();
|
||||
}
|
||||
return ref((PyObject*)&class_type_object, ref::increment_count);
|
||||
}
|
||||
|
||||
// Install the instance data for a C++ object into a Python instance
|
||||
// object.
|
||||
void instance_holder::install(PyObject* self) throw()
|
||||
{
|
||||
assert(self->ob_type->ob_type == &class_metatype_object);
|
||||
m_next = ((instance*)self)->objects;
|
||||
((instance*)self)->objects = this;
|
||||
m_next = ((objects::instance*)self)->objects;
|
||||
((objects::instance*)self)->objects = this;
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL void*
|
||||
find_instance_impl(PyObject* inst, converter::undecorated_type_id_t type)
|
||||
{
|
||||
if (inst->ob_type->ob_type != &class_metatype_object)
|
||||
return 0;
|
||||
|
||||
instance* self = reinterpret_cast<instance*>(inst);
|
||||
|
||||
for (instance_holder* match = self->objects; match != 0; match = match->next())
|
||||
{
|
||||
void* const found = match->holds(type);
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace
|
||||
namespace objects
|
||||
{
|
||||
struct class_registry
|
||||
// Get the metatype object for all extension classes.
|
||||
BOOST_PYTHON_DECL ref class_metatype()
|
||||
{
|
||||
public:
|
||||
ref get(class_id id) const;
|
||||
ref query(class_id id) const;
|
||||
void set(class_id, ref class_object);
|
||||
private:
|
||||
typedef detail::map_entry<class_id,ref> entry;
|
||||
std::vector<entry> m_impl;
|
||||
if (class_metatype_object.tp_dict == 0)
|
||||
{
|
||||
class_metatype_object.ob_type = &PyType_Type;
|
||||
class_metatype_object.tp_base = &PyType_Type;
|
||||
if (PyType_Ready(&class_metatype_object))
|
||||
return ref();
|
||||
}
|
||||
return ref((PyObject*)&class_metatype_object, ref::increment_count);
|
||||
}
|
||||
extern "C"
|
||||
{
|
||||
static void instance_dealloc(PyObject* inst)
|
||||
{
|
||||
instance* kill_me = (instance*)inst;
|
||||
|
||||
for (instance_holder* p = kill_me->objects, *next; p != 0; p = next)
|
||||
{
|
||||
next = p->next();
|
||||
delete p;
|
||||
}
|
||||
|
||||
inst->ob_type->tp_free(inst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static PyTypeObject class_type_object = {
|
||||
PyObject_HEAD_INIT(0) //&class_metatype_object)
|
||||
0,
|
||||
"Boost.Python.instance",
|
||||
sizeof(instance),
|
||||
0,
|
||||
instance_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT // | Py_TPFLAGS_HAVE_GC
|
||||
| Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
0, /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, //&PyBaseObject_Type, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
0, /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
PyType_GenericAlloc, /* tp_alloc */
|
||||
PyType_GenericNew
|
||||
};
|
||||
|
||||
class_registry& registry()
|
||||
BOOST_PYTHON_DECL ref class_type()
|
||||
{
|
||||
static class_registry x;
|
||||
return x;
|
||||
}
|
||||
|
||||
inline ref class_registry::query(class_id id) const
|
||||
{
|
||||
std::vector<entry>::const_iterator start = m_impl.begin();
|
||||
std::vector<entry>::const_iterator finish = m_impl.end();
|
||||
|
||||
std::vector<entry>::const_iterator p
|
||||
= boost::detail::lower_bound(start, finish, id);
|
||||
|
||||
return (p == finish || p->key != id) ? ref() : p->value;
|
||||
}
|
||||
|
||||
inline ref class_registry::get(class_id id) const
|
||||
{
|
||||
ref result(this->query(id));
|
||||
|
||||
if (result.get() == 0)
|
||||
if (class_type_object.tp_dict == 0)
|
||||
{
|
||||
string report("extension class wrapper for base class ");
|
||||
(report += id.name()) += " has not been created yet";
|
||||
PyErr_SetObject(PyExc_RuntimeError, report.get());
|
||||
throw_error_already_set();
|
||||
class_type_object.ob_type = (PyTypeObject*)class_metatype().release();
|
||||
class_type_object.tp_base = &PyBaseObject_Type;
|
||||
if (PyType_Ready(&class_type_object))
|
||||
return ref();
|
||||
}
|
||||
return result;
|
||||
return ref((PyObject*)&class_type_object, ref::increment_count);
|
||||
}
|
||||
|
||||
inline void class_registry::set(class_id id, ref object)
|
||||
BOOST_PYTHON_DECL void*
|
||||
find_instance_impl(PyObject* inst, type_info type)
|
||||
{
|
||||
std::vector<entry>::iterator start = m_impl.begin();
|
||||
std::vector<entry>::iterator finish = m_impl.end();
|
||||
m_impl.insert(
|
||||
boost::detail::lower_bound(start, finish, id)
|
||||
, entry(id, object));
|
||||
converter::registry::class_object(id) = (PyTypeObject*)object.get();
|
||||
if (inst->ob_type->ob_type != &class_metatype_object)
|
||||
return 0;
|
||||
|
||||
instance* self = reinterpret_cast<instance*>(inst);
|
||||
|
||||
for (instance_holder* match = self->objects; match != 0; match = match->next())
|
||||
{
|
||||
void* const found = match->holds(type);
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class_base::class_base(
|
||||
char const* name, std::size_t num_types, class_id const* const types)
|
||||
{
|
||||
class_registry& r = registry();
|
||||
assert(num_types >= 1);
|
||||
tuple bases(std::max(num_types - 1, static_cast<std::size_t>(1)));
|
||||
if (num_types > 1)
|
||||
namespace
|
||||
{
|
||||
struct class_registry
|
||||
{
|
||||
for (std::size_t i = 1; i < num_types; ++i)
|
||||
bases.set_item(i - 1, r.get(types[i]));
|
||||
}
|
||||
else
|
||||
public:
|
||||
ref get(class_id id) const;
|
||||
ref query(class_id id) const;
|
||||
void set(class_id, ref class_object);
|
||||
private:
|
||||
typedef detail::map_entry<class_id,ref> entry;
|
||||
std::vector<entry> m_impl;
|
||||
};
|
||||
|
||||
class_registry& registry()
|
||||
{
|
||||
bases.set_item(0, class_type());
|
||||
static class_registry x;
|
||||
return x;
|
||||
}
|
||||
|
||||
inline ref class_registry::query(class_id id) const
|
||||
{
|
||||
std::vector<entry>::const_iterator start = m_impl.begin();
|
||||
std::vector<entry>::const_iterator finish = m_impl.end();
|
||||
|
||||
std::vector<entry>::const_iterator p
|
||||
= boost::detail::lower_bound(start, finish, id);
|
||||
|
||||
return (p == finish || p->key != id) ? ref() : p->value;
|
||||
}
|
||||
|
||||
inline ref class_registry::get(class_id id) const
|
||||
{
|
||||
ref result(this->query(id));
|
||||
|
||||
if (result.get() == 0)
|
||||
{
|
||||
string report("extension class wrapper for base class ");
|
||||
(report += id.name()) += " has not been created yet";
|
||||
PyErr_SetObject(PyExc_RuntimeError, report.get());
|
||||
throw_error_already_set();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void class_registry::set(class_id id, ref object)
|
||||
{
|
||||
std::vector<entry>::iterator start = m_impl.begin();
|
||||
std::vector<entry>::iterator finish = m_impl.end();
|
||||
m_impl.insert(
|
||||
boost::detail::lower_bound(start, finish, id)
|
||||
, entry(id, object));
|
||||
converter::registry::class_object(id) = (PyTypeObject*)object.get();
|
||||
}
|
||||
}
|
||||
|
||||
class_base::class_base(
|
||||
char const* name, std::size_t num_types, class_id const* const types)
|
||||
{
|
||||
class_registry& r = registry();
|
||||
assert(num_types >= 1);
|
||||
tuple bases(std::max(num_types - 1, static_cast<std::size_t>(1)));
|
||||
if (num_types > 1)
|
||||
{
|
||||
for (std::size_t i = 1; i < num_types; ++i)
|
||||
bases.set_item(i - 1, r.get(types[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
bases.set_item(0, class_type());
|
||||
}
|
||||
|
||||
tuple args(3);
|
||||
args.set_item(0, string(name).reference());
|
||||
args.set_item(1, bases.reference());
|
||||
args.set_item(2, dictionary().reference());
|
||||
tuple args(3);
|
||||
args.set_item(0, string(name).reference());
|
||||
args.set_item(1, bases.reference());
|
||||
args.set_item(2, dictionary().reference());
|
||||
|
||||
m_object = ref(PyObject_CallObject(class_metatype().get(), args.get()));
|
||||
r.set(types[0], m_object);
|
||||
}
|
||||
m_object = ref(PyObject_CallObject(class_metatype().get(), args.get()));
|
||||
r.set(types[0], m_object);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// This declaration needed due to broken Python 2.2 headers
|
||||
extern DL_IMPORT(PyTypeObject) PyProperty_Type;
|
||||
}
|
||||
extern "C"
|
||||
{
|
||||
// This declaration needed due to broken Python 2.2 headers
|
||||
extern DL_IMPORT(PyTypeObject) PyProperty_Type;
|
||||
}
|
||||
|
||||
void class_base::add_property(char const* name, ref const& fget)
|
||||
{
|
||||
ref property(PyObject_CallFunction((PyObject*)&PyProperty_Type, "O", fget.get()));
|
||||
setattr(name, property);
|
||||
}
|
||||
void class_base::add_property(char const* name, ref const& fget)
|
||||
{
|
||||
ref property(PyObject_CallFunction((PyObject*)&PyProperty_Type, "O", fget.get()));
|
||||
setattr(name, property);
|
||||
}
|
||||
|
||||
void class_base::add_property(char const* name, ref const& fget, ref const& fset)
|
||||
{
|
||||
ref property(PyObject_CallFunction((PyObject*)&PyProperty_Type, "OO", fget.get(), fset.get()));
|
||||
setattr(name, property);
|
||||
}
|
||||
void class_base::add_property(char const* name, ref const& fget, ref const& fset)
|
||||
{
|
||||
ref property(PyObject_CallFunction((PyObject*)&PyProperty_Type, "OO", fget.get(), fset.get()));
|
||||
setattr(name, property);
|
||||
}
|
||||
|
||||
void class_base::setattr(char const* name, ref const& x)
|
||||
{
|
||||
if (PyObject_SetAttrString(object().get(), const_cast<char*>(name), x.get()) < 0)
|
||||
throw_error_already_set();
|
||||
}
|
||||
void class_base::setattr(char const* name, ref const& x)
|
||||
{
|
||||
if (PyObject_SetAttrString(object().get(), const_cast<char*>(name), x.get()) < 0)
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL ref registered_class_object(class_id id)
|
||||
{
|
||||
return registry().query(id);
|
||||
}
|
||||
BOOST_PYTHON_DECL ref registered_class_object(class_id id)
|
||||
{
|
||||
return registry().query(id);
|
||||
}
|
||||
} // namespace objects
|
||||
|
||||
}}} // namespace boost::python::objects
|
||||
}} // namespace boost::python
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
#include <boost/python/object/inheritance.hpp>
|
||||
#include <boost/python/converter/type_id.hpp>
|
||||
#include <boost/python/type_id.hpp>
|
||||
#include <boost/graph/breadth_first_search.hpp>
|
||||
#include <boost/graph/adjacency_list.hpp>
|
||||
#include <boost/graph/reverse_graph.hpp>
|
||||
@@ -45,7 +45,7 @@ namespace
|
||||
// Here we put together the low-level data structures of the
|
||||
// casting graph representation.
|
||||
//
|
||||
typedef python::converter::undecorated_type_id_t class_id;
|
||||
typedef python::type_info class_id;
|
||||
|
||||
// represents a graph of available casts
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <boost/python/converter/type_id.hpp>
|
||||
#include <boost/python/type_id.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/python/converter/pointer_type_id.hpp>
|
||||
|
||||
@@ -6,8 +6,8 @@ int main()
|
||||
{
|
||||
using namespace boost::python::converter;
|
||||
|
||||
undecorated_type_id_t x
|
||||
= undecorated_type_id<int>();
|
||||
boost::python::type_info x
|
||||
= boost::python::type_id<int>();
|
||||
|
||||
|
||||
assert(pointer_type_id<int*>() == x);
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
#include <boost/python/converter/from_python.hpp>
|
||||
//#include <cassert>
|
||||
//#include <boost/type_traits.hpp>
|
||||
#include <boost/python/converter/type_id.hpp>
|
||||
#include <boost/python/type_id.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ < 3 // 2.95.x linker seems to demand this definition
|
||||
namespace boost { namespace python {
|
||||
BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}}
|
||||
#endif
|
||||
|
||||
int result;
|
||||
|
||||
#define ASSERT_SAME(T1,T2) \
|
||||
if (!is_same< T1, T2 >::value) { \
|
||||
std::cout << "*********************\n"; \
|
||||
std::cout << type_id< T1 >() << " != " << type_id< T2 >() << "\n"; \
|
||||
std::cout << python::type_id< T1 >() << " != " << python::type_id< T2 >() << "\n"; \
|
||||
std::cout << "*********************\n"; \
|
||||
result = 1; \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user