2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Quickbook: Copy trunk libs into quickbook-dev branch.

[SVN r75213]
This commit is contained in:
Daniel James
2011-11-01 13:04:29 +00:00
13 changed files with 38 additions and 35 deletions

View File

@@ -27,7 +27,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Somerville, MA 02143
:Contact: dave@boost-consulting.com
:organization: `Boost Consulting`_
:date: $Date$
:status: This is a "work in progress"
:version: 1
:copyright: Copyright David Abrahams 2002. All rights reserved

View File

@@ -1,8 +1,6 @@
/*
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:date: $Date$
:version: $Revision$
:copyright: This stylesheet has been placed in the public domain.
boostinspect:nolicense

View File

@@ -124,7 +124,7 @@
<p>
</p>
<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="keyword">import</span> <span class="identifier">hello_ext</span>
<span class="special">&gt;&gt;&gt;</span> <span class="keyword">print</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">greet</span><span class="special">()</span>
<span class="special">&gt;&gt;&gt;</span> <span class="keyword">print</span> <span class="identifier">hello_ext</span><span class="special">.</span><span class="identifier">greet</span><span class="special">()</span>
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span>
</pre>
<p>

View File

@@ -62,7 +62,7 @@ resulting DLL is now visible to Python. Here's a sample Python session:
[python]
>>> import hello_ext
>>> print hello.greet()
>>> print hello_ext.greet()
hello, world
[c++]

View File

@@ -85,7 +85,7 @@ namespace boost { namespace python
object stop();
object step();
// The return type of slice::get_indicies()
// The return type of slice::get_indices()
template &lt;typename RandomAccessIterator&gt;
struct range
{
@@ -96,7 +96,7 @@ namespace boost { namespace python
template &lt;typename RandomAccessIterator&gt;
range&lt;RandomAccessIterator&gt;
get_indicies(
get_indices(
RandomAccessIterator const&amp; begin,
RandomAccessIterator const&amp; end);
};
@@ -164,7 +164,7 @@ slice object, but in practice they are usually integers.</dt>
<pre>
template &lt;typename RandomAccessIterator&gt;
slice::range&lt;RandomAccessIterator&gt;
slice::get_indicies(
slice::get_indices(
RandomAccessIterator const&amp; begin,
RandomAccessIterator const&amp; end) const;
</pre>
@@ -173,8 +173,8 @@ slice::get_indicies(
Iterators that form a half-open range.</dt>
<dt><b>Effects:</b> Create a RandomAccessIterator pair that defines a
fully-closed range within the [begin,end) range of its arguments.&nbsp;
This function translates this slice's indicies while accounting for the
effects of any PyNone or negative indicies, and non-singular step sizes.</dt>
This function translates this slice's indices while accounting for the
effects of any PyNone or negative indices, and non-singular step sizes.</dt>
<dt><b>Returns:</b> a slice::range
that has been initialized with a non-zero value of step and a pair of
RandomAccessIterators that point within the range of this functions
@@ -182,7 +182,7 @@ arguments and define a closed interval.</dt>
<dt><b>Throws:</b> <a href="definitions.html#raise">Raises</a> a Python <code>TypeError</code> exception if any of this slice's arguments
are neither references to <code>PyNone</code> nor convertible to <code>int</code>.&nbsp; Throws
<code>std::invalid_argument</code> if the resulting range would be empty.&nbsp; You
should always wrap calls to <code>slice::get_indicies()</code>
should always wrap calls to <code>slice::get_indices()</code>
within <code>try { ...; } catch (std::invalid_argument) {}</code> to
handle this case and take appropriate action.</dt>
<dt><b>Rationale</b>: closed-interval: If
@@ -221,7 +221,7 @@ double partial_sum(std::vector&lt;double&gt; const&amp; Foo, const slice index)
{
slice::range&lt;std::vector&lt;double&gt;::const_iterator&gt; bounds;
try {
bounds = index.get_indicies&lt;&gt;(Foo.begin(), Foo.end());
bounds = index.get_indices&lt;&gt;(Foo.begin(), Foo.end());
}
catch (std::invalid_argument) {
return 0.0;

View File

@@ -91,7 +91,7 @@
<hr>
<h2>
<a name="introduction">Introduction</a>
</h2>This header provides faciliites for establishing a lifetime
</h2>This header provides facilities for establishing a lifetime
dependency between two of a function's Python argument or result objects.
The <i>ward</i> object will not be destroyed until after the custodian as
long as the <i>custodian</i> object supports <a href=

View File

@@ -366,7 +366,9 @@ namespace
static PyTypeObject const* get_pytype() { return &PyFloat_Type;}
};
#if PY_VERSION_HEX >= 0x03000000
unaryfunc py_unicode_as_string_unaryfunc = PyUnicode_AsUTF8String;
#endif
// A SlotPolicy for extracting C++ strings from Python objects.
struct string_rvalue_from_python
@@ -431,7 +433,10 @@ namespace
if (!result.empty())
{
int err = PyUnicode_AsWideChar(
(PyUnicodeObject *)intermediate
#if PY_VERSION_HEX < 0x03020000
(PyUnicodeObject *)
#endif
intermediate
, &result[0]
, result.size());

View File

@@ -44,11 +44,8 @@ BOOST_PYTHON_DECL rvalue_from_python_stage1_data rvalue_from_python_stage1(
// First check to see if it's embedded in an extension class
// instance, as a special case.
data.convertible = objects::find_instance_impl(source, converters.target_type, converters.is_shared_ptr);
if (data.convertible)
{
data.construct = 0;
}
else
if (!data.convertible)
{
for (rvalue_from_python_chain const* chain = converters.rvalue_chain;
chain != 0;

View File

@@ -76,11 +76,11 @@ extern "C"
static int property_init(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL;
static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0};
static const char *kwlist[] = {"fget", "fset", "fdel", "doc", 0};
propertyobject *prop = (propertyobject *)self;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property",
kwlist, &get, &set, &del, &doc))
const_cast<char **>(kwlist), &get, &set, &del, &doc))
return -1;
if (get == Py_None)

View File

@@ -433,23 +433,23 @@ void function::add_to_namespace(
if (attribute.ptr()->ob_type == &function_type)
{
function* new_func = downcast<function>(attribute.ptr());
PyObject* dict = 0;
handle<> dict;
#if PY_VERSION_HEX < 0x03000000
// Old-style class gone in Python 3
if (PyClass_Check(ns))
dict = ((PyClassObject*)ns)->cl_dict;
dict = handle<>(borrowed(((PyClassObject*)ns)->cl_dict));
else
#endif
if (PyType_Check(ns))
dict = ((PyTypeObject*)ns)->tp_dict;
dict = handle<>(borrowed(((PyTypeObject*)ns)->tp_dict));
else
dict = PyObject_GetAttrString(ns, const_cast<char*>("__dict__"));
dict = handle<>(PyObject_GetAttrString(ns, const_cast<char*>("__dict__")));
if (dict == 0)
throw_error_already_set();
handle<> existing(allow_null(::PyObject_GetItem(dict, name.ptr())));
handle<> existing(allow_null(::PyObject_GetItem(dict.get(), name.ptr())));
if (existing)
{

View File

@@ -3,11 +3,15 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import python ;
import os ;
lib socket ;
use-project /boost/python : ../build ;
project /boost/python/test
: requirements
<toolset>gcc:<cxxflags>-Wextra
<target-os>qnxnto:<library>socket
;
local PY = ;

View File

@@ -98,9 +98,9 @@ bool accept_slice( slice) { return true; }
#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1400)) \
|| BOOST_WORKAROUND( BOOST_INTEL_WIN, == 710)
int check_slice_get_indicies(slice index);
int check_slice_get_indices(slice index);
#endif
int check_slice_get_indicies(
int check_slice_get_indices(
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
const
#endif
@@ -116,7 +116,7 @@ int check_slice_get_indicies(
slice::range<std::vector<int>::iterator> bounds;
try {
bounds = index.get_indicies(coll.begin(), coll.end());
bounds = index.get_indices(coll.begin(), coll.end());
}
catch (std::invalid_argument) {
return 0;
@@ -136,5 +136,5 @@ BOOST_PYTHON_MODULE(slice_ext)
def( "accept_slice", accept_slice);
def( "check_numeric_array_rich_slice", check_numeric_array_rich_slice);
def( "check_string_rich_slice", check_string_rich_slice);
def( "check_slice_get_indicies", check_slice_get_indicies);
def( "check_slice_get_indices", check_slice_get_indices);
}

View File

@@ -37,17 +37,17 @@ test passed
... print 1
...
1
>>> check_slice_get_indicies( slice(None))
>>> check_slice_get_indices( slice(None))
0
>>> check_slice_get_indicies( slice(2,-2))
>>> check_slice_get_indices( slice(2,-2))
0
>>> check_slice_get_indicies( slice(2, None, 2))
>>> check_slice_get_indices( slice(2, None, 2))
5
>>> check_slice_get_indicies( slice(2, None, -1))
>>> check_slice_get_indices( slice(2, None, -1))
-12
>>> check_slice_get_indicies( slice( 20, None))
>>> check_slice_get_indices( slice( 20, None))
0
>>> check_slice_get_indicies( slice( -2, -5, -2))
>>> check_slice_get_indices( slice( -2, -5, -2))
6
"""