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

Use make_tuple()

[SVN r15062]
This commit is contained in:
Dave Abrahams
2002-08-22 19:08:16 +00:00
parent d779a94cfb
commit 0b02fd4e99
3 changed files with 8 additions and 22 deletions

View File

@@ -12,7 +12,6 @@
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#include <boost/python/list.hpp>
#include <boost/python/tuple.hpp>
#include <string>
@@ -39,9 +38,7 @@ namespace {
getinitargs(const world& w)
{
using namespace boost::python;
list result;
result.append(object(w.get_country()));
return tuple(result);
return make_tuple(w.get_country());
}
};

View File

@@ -24,7 +24,6 @@
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#include <boost/python/list.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/extract.hpp>
#include <boost/python/detail/api_placeholder.hpp>
@@ -54,9 +53,7 @@ namespace { // Avoid cluttering the global namespace.
getinitargs(const world& w)
{
using namespace boost::python;
list result;
result.append(object(w.get_country()));
return tuple(result);
return make_tuple(w.get_country());
}
static
@@ -64,9 +61,7 @@ namespace { // Avoid cluttering the global namespace.
getstate(const world& w)
{
using namespace boost::python;
list result;
result.append(object(w.get_secret_number()));
return tuple(result);
return make_tuple(w.get_secret_number());
}
static

View File

@@ -19,7 +19,6 @@
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#include <boost/python/list.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/dict.hpp>
#include <boost/python/extract.hpp>
@@ -50,9 +49,7 @@ namespace { // Avoid cluttering the global namespace.
getinitargs(const world& w)
{
using namespace boost::python;
list result;
result.append(object(w.get_country()));
return tuple(result);
return make_tuple(w.get_country());
}
static
@@ -61,12 +58,8 @@ namespace { // Avoid cluttering the global namespace.
{
using namespace boost::python;
world const& w = extract<world const&>(w_obj)();
list result;
// store the object's __dict__
result.append(w_obj.attr("__dict__"));
// store the internal state of the C++ object
result.append(object(w.get_secret_number()));
return tuple(result);
return make_tuple(w_obj.attr("__dict__"), w.get_secret_number());
}
static
@@ -76,7 +69,8 @@ namespace { // Avoid cluttering the global namespace.
using namespace boost::python;
world& w = extract<world&>(w_obj)();
extract<tuple> state_proxy(state);
if (!state_proxy.check() || len(state_proxy()) != 2) {
if (!state_proxy.check() || len(state_proxy()) != 2)
{
PyErr_SetString(PyExc_ValueError,
"Unexpected argument in call to __setstate__.");
throw_error_already_set();