mirror of
https://github.com/boostorg/parameter.git
synced 2026-01-30 08:02:33 +00:00
new Parameter.Python syntax
[SVN r34093]
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#include <boost/parameter/python.hpp>
|
||||
#include <boost/python.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
namespace test {
|
||||
|
||||
@@ -13,8 +14,31 @@ BOOST_PARAMETER_KEYWORD(tag, x)
|
||||
BOOST_PARAMETER_KEYWORD(tag, y)
|
||||
BOOST_PARAMETER_KEYWORD(tag, z)
|
||||
|
||||
struct X
|
||||
struct Xbase
|
||||
{
|
||||
// We need the disable_if part for VC7.1/8.0.
|
||||
template <class Args>
|
||||
Xbase(
|
||||
Args const& args
|
||||
, typename boost::disable_if<
|
||||
boost::is_base_and_derived<Xbase, Args>
|
||||
>::type* = 0
|
||||
)
|
||||
: value(std::string(args[x | "foo"]) + args[y | "bar"])
|
||||
{}
|
||||
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct X : Xbase
|
||||
{
|
||||
BOOST_PARAMETER_CONSTRUCTOR(X, (Xbase), tag,
|
||||
(optional
|
||||
(x, *)
|
||||
(y, *)
|
||||
)
|
||||
)
|
||||
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION((int), f, tag,
|
||||
(required
|
||||
(x, *)
|
||||
@@ -66,21 +90,31 @@ BOOST_PYTHON_MODULE(python_parameter)
|
||||
using namespace boost::python;
|
||||
|
||||
class_<X>("X")
|
||||
.def(
|
||||
boost::parameter::python::init<
|
||||
mpl::vector<
|
||||
tag::x*(std::string), tag::y*(std::string)
|
||||
>
|
||||
>()
|
||||
)
|
||||
.def(
|
||||
"f"
|
||||
, boost::parameter::python::function<
|
||||
f_fwd
|
||||
, mpl::vector3<tag::x, tag::y, tag::z*>
|
||||
, mpl::vector4<int, int, int, int>
|
||||
, mpl::vector<
|
||||
int, tag::x(int), tag::y(int), tag::z*(int)
|
||||
>
|
||||
>()
|
||||
)
|
||||
.def(
|
||||
"g"
|
||||
, boost::parameter::python::function<
|
||||
g_fwd
|
||||
, mpl::vector2<tag::x*, tag::y*>
|
||||
, mpl::vector3<std::string, std::string, std::string>
|
||||
, mpl::vector<
|
||||
std::string, tag::x*(std::string), tag::y*(std::string)
|
||||
>
|
||||
>()
|
||||
);
|
||||
)
|
||||
.def_readonly("value", &X::value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user