boost/python/default_call_policies.hpp

クラス

default_call_policies クラス

struct default_call_policies

default_call_policiesprecall および postcall の振る舞いを持たない CallPolicies のモデルであり、値返しを行う result_converter である。ラップする C++ の関数およびメンバ関数は、特に指定しなければ default_call_policies を使用する。新規の CallPoliciesdefault_call_policies から派生すると便利である。

default_call_policies クラスの概要

namespace boost { namespace python
{
    struct default_call_policies
    {
        static bool precall(PyObject*);
        static PyObject* postcall(PyObject*, PyObject* result);
        typedef default_result_converter result_converter;
        template <class Sig> struct extract_return_type : mpl::front<Sig>{};
    };
}}

default_call_policies クラスの静的関数

bool precall(PyObject*)
戻り値

true

例外

なし

PyObject *postcall(PyObject*, PyObject *result)
戻り値

result

例外

なし

default_result_converter クラス

struct default_result_converter

default_result_converter クラスの概要

namespace boost { namespace python
{
    struct default_result_converter
    {
        template <class T> struct apply;
    };
}}

default_result_converter クラスのメタ関数

template<class T>
struct apply
要件

T が参照型でない。T がポインタ型の場合、Tconst char*PyObject*

typedef to_python_value<T const&> type

この例は Boost.Python の実装そのものからとった。return_value_policy クラステンプレートは precall および postcall に対する振る舞いの実装を持たないので、その基底クラスは default_call_policies となっている。

template <class Handler, class Base = default_call_policies>
struct return_value_policy : Base
{
   typedef Handler result_converter;
};