2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-26 06:42:27 +00:00

Initial attempt to fix problems

[SVN r10158]
This commit is contained in:
Dave Abrahams
2001-05-19 23:29:04 +00:00
parent 9261e2a3d9
commit 4d3079293d
26 changed files with 339 additions and 316 deletions

View File

@@ -75,7 +75,7 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround
from_python(x, boost::python::type<long>()));
}
PyObject* to_python(MyEnumType x)
PyObject* to_python(boost::python::semantics, MyEnumType x)
{
return to_python(static_cast<long>(x));
}
@@ -91,8 +91,8 @@ initialization. These bind the corresponding enum values to the appropriate
names so they can be used from Python:
<blockquote><pre>
mymodule.add(boost::python::to_python(enum_value_1), "enum_value_1");
mymodule.add(boost::python::to_python(enum_value_2), "enum_value_2");
mymodule.add(boost::python::to_python(boost::python::search_namespace, enum_value_1), "enum_value_1");
mymodule.add(boost::python::to_python(boost::python::search_namespace, enum_value_2), "enum_value_2");
...
</pre></blockquote>
@@ -100,8 +100,8 @@ You can also add these to an extension class definition, if your enum happens to
be local to a class and you want the analogous interface in Python:
<blockquote><pre>
my_class_builder.add(boost::python::to_python(enum_value_1), "enum_value_1");
my_class_builder.add(boost::python::to_python(enum_value_2), "enum_value_2");
my_class_builder.add(boost::python::to_python(boost::python::search_namespace, enum_value_1), "enum_value_1");
my_class_builder.add(boost::python::to_python(boost::python::search_namespace, enum_value_2), "enum_value_2");
...
</pre></blockquote>
<p>

View File

@@ -65,9 +65,9 @@ wrapped <code>T</code>, you may want to provide an automatic
thin wrappers. You can do this simply as follows:
<blockquote><pre>
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround
PyObject* to_python(const Foo* p) {
return to_python(*p); // convert const Foo* in terms of const Foo&
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is an MSVC / gcc 2.95.2 bug workaround
PyObject* to_python(boost::python::semantics, const Foo* p) {
return to_python(boost::python::search_namespace, *p); // convert const Foo* in terms of const Foo&
}
BOOST_PYTHON_END_CONVERSION_NAMESPACE
</pre></blockquote>
@@ -83,12 +83,12 @@ code before the last Python reference to it disappears:
<blockquote><pre>
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE // this is a gcc 2.95.2 bug workaround
PyObject* to_python(Foo* p)
PyObject* to_python(boost::python::semantics, Foo* p)
{
return boost::python::python_extension_class_converters&ltFoo&gt::ptr_to_python(p);
}
PyObject* to_python(const Foo* p)
PyObject* to_python(boost::python::semantics, const Foo* p)
{
return to_python(const_cast&lt;Foo*&gt;(p));
}

View File

@@ -699,7 +699,7 @@ void throw_key_error_if_end(
{
if (p == m.end())
{
PyErr_SetObject(PyExc_KeyError, boost::python::converters::to_python(key));
PyErr_SetObject(PyExc_KeyError, to_python(boost::python::search_namespace, key));
throw boost::python::error_already_set();
}
}

View File

@@ -27,7 +27,7 @@
<a href="example1.html#Constructor_example">provide an argument list</a>
because they can't be named in C++). Then, it calls the appropriate
overloaded functions <code>PyObject*
to_python(</code><em>S</em><code>)</code> and <em>
to_python(boost::python::semantics, </code><em>S</em><code>)</code> and <em>
S'</em><code>from_python(PyObject*,
type&lt;</code><em>S</em><code>&gt;)</code> which convert between any C++
type <em>S</em> and a <code>PyObject*</code>, the type which represents a