mirror of
https://github.com/boostorg/python.git
synced 2026-01-20 04:42:28 +00:00
merged from trunk
[SVN r21438]
This commit is contained in:
@@ -47,6 +47,21 @@ namespace detail
|
||||
}
|
||||
|
||||
keyword elements[nkeywords];
|
||||
|
||||
keywords<nkeywords+1> operator,(arg const &k) const
|
||||
{
|
||||
keywords<nkeywords> const& l = *static_cast<keywords<nkeywords> const*>(this);
|
||||
python::detail::keywords<nkeywords+1> res;
|
||||
std::copy(l.elements, l.elements+nkeywords, res.elements);
|
||||
res.elements[nkeywords] = k.elements[0];
|
||||
return res;
|
||||
}
|
||||
|
||||
keywords<nkeywords + 1>
|
||||
operator,(char const *name) const
|
||||
{
|
||||
return this->operator,(python::arg(name));
|
||||
}
|
||||
};
|
||||
|
||||
template <std::size_t nkeywords>
|
||||
@@ -76,15 +91,6 @@ namespace detail
|
||||
}
|
||||
};
|
||||
|
||||
template <std::size_t nkeywords>
|
||||
keywords<nkeywords+1> operator,(keywords<nkeywords> const& l, const keywords<1> &k)
|
||||
{
|
||||
python::detail::keywords<nkeywords+1> res;
|
||||
std::copy(l.elements, l.elements+nkeywords, res.elements);
|
||||
res.elements[nkeywords] = k.elements[0];
|
||||
return res;
|
||||
}
|
||||
|
||||
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template<typename T>
|
||||
struct is_keywords
|
||||
@@ -136,16 +142,6 @@ namespace detail
|
||||
# endif
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <std::size_t nkeywords>
|
||||
inline keywords<nkeywords + 1>
|
||||
operator,(keywords<nkeywords> const& l, char *name)
|
||||
{
|
||||
return l.operator,(arg(name));
|
||||
}
|
||||
}
|
||||
|
||||
inline detail::keywords<1> args(char const* name)
|
||||
{
|
||||
return detail::keywords<1>(name);
|
||||
|
||||
@@ -93,6 +93,8 @@ BOOST_PYTHON_MODULE(keywords)
|
||||
|
||||
.def("set", &Foo::set, (arg("a") = 0, arg("b") = 0.0, arg("n") = std::string()) )
|
||||
|
||||
.def("set2", &Foo::set, (arg("a"), "b", "n") )
|
||||
|
||||
.def("a", &Foo::geta)
|
||||
.def("b", &Foo::getb)
|
||||
.def("n", &Foo::getn)
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
>>> f.set(1,n="1")
|
||||
>>> f.a(), f.b(), f.n()
|
||||
(1, 0.0, '1')
|
||||
>>> f.set2(b=2.0,n="2",a=2)
|
||||
>>> f.a(), f.b(), f.n()
|
||||
(2, 2.0, '2')
|
||||
|
||||
# lets see how badly we've broken the 'regular' functions
|
||||
>>> f = Bar()
|
||||
|
||||
Reference in New Issue
Block a user