summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/parameter_python
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/parameter_python
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/parameter_python')
-rw-r--r--src/boost/libs/parameter_python/README.md2
-rwxr-xr-xsrc/boost/libs/parameter_python/index.html12
-rw-r--r--src/boost/libs/parameter_python/meta/libraries.json17
-rw-r--r--src/boost/libs/parameter_python/test/Jamfile.v210
-rwxr-xr-xsrc/boost/libs/parameter_python/test/python_test.cpp172
-rw-r--r--src/boost/libs/parameter_python/test/python_test.py41
6 files changed, 254 insertions, 0 deletions
diff --git a/src/boost/libs/parameter_python/README.md b/src/boost/libs/parameter_python/README.md
new file mode 100644
index 00000000..13a05b2a
--- /dev/null
+++ b/src/boost/libs/parameter_python/README.md
@@ -0,0 +1,2 @@
+# parameter_python
+Boost.Parameter Python bindings
diff --git a/src/boost/libs/parameter_python/index.html b/src/boost/libs/parameter_python/index.html
new file mode 100755
index 00000000..672aaab7
--- /dev/null
+++ b/src/boost/libs/parameter_python/index.html
@@ -0,0 +1,12 @@
+<!-- Copyright David Abrahams 2005. Distributed under the Boost -->
+<!-- Software License, Version 1.0. (See accompanying -->
+<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
+</head>
+<body>
+Automatically loading index page... if nothing happens, please go to
+<a href="doc/html/index.html">doc/html/index.html</a>.
+</body>
+</html>
diff --git a/src/boost/libs/parameter_python/meta/libraries.json b/src/boost/libs/parameter_python/meta/libraries.json
new file mode 100644
index 00000000..f958120d
--- /dev/null
+++ b/src/boost/libs/parameter_python/meta/libraries.json
@@ -0,0 +1,17 @@
+{
+ "key": "parameter_python",
+ "name": "Parameter Python bindings",
+ "authors": [
+ "David Abrahams",
+ "Daniel Wallin"
+ ],
+ "description": "Boost.Parameter Library Python bindings.",
+ "category": [
+ "Emulation",
+ "Programming"
+ ],
+ "maintainers": [
+ "David Abrahams <dave -at- boost-consulting.com>",
+ "Daniel Wallin <daniel -at- boostpro.com>"
+ ]
+}
diff --git a/src/boost/libs/parameter_python/test/Jamfile.v2 b/src/boost/libs/parameter_python/test/Jamfile.v2
new file mode 100644
index 00000000..ea8d618c
--- /dev/null
+++ b/src/boost/libs/parameter_python/test/Jamfile.v2
@@ -0,0 +1,10 @@
+# Copyright David Abrahams, Daniel Wallin 2006. Distributed under the
+# Boost Software License, Version 1.0. (See accompanying file
+# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+# Boost Parameter Library Python bindings test Jamfile
+
+import testing ;
+import python ;
+
+bpl-test python_test ;
diff --git a/src/boost/libs/parameter_python/test/python_test.cpp b/src/boost/libs/parameter_python/test/python_test.cpp
new file mode 100755
index 00000000..12c0c315
--- /dev/null
+++ b/src/boost/libs/parameter_python/test/python_test.cpp
@@ -0,0 +1,172 @@
+// Copyright Daniel Wallin 2006. Use, modification and distribution is
+// subject to the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <math.h>
+#include <boost/python.hpp>
+#include <boost/parameter/preprocessor.hpp>
+#include <boost/parameter/keyword.hpp>
+#include <boost/parameter/python.hpp>
+#include <boost/utility/enable_if.hpp>
+
+namespace test {
+
+BOOST_PARAMETER_KEYWORD(tags, x)
+BOOST_PARAMETER_KEYWORD(tags, y)
+BOOST_PARAMETER_KEYWORD(tags, z)
+
+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), tags,
+ (optional
+ (x, *)
+ (y, *)
+ )
+ )
+
+ BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f, tags,
+ (required
+ (x, *)
+ (y, *)
+ )
+ (optional
+ (z, *)
+ )
+ )
+ {
+ return args[x] + args[y] + args[z | 0];
+ }
+
+ BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((std::string), g, tags,
+ (optional
+ (x, *)
+ (y, *)
+ )
+ )
+ {
+ return std::string(args[x | "foo"]) + args[y | "bar"];
+ }
+
+ BOOST_PARAMETER_MEMBER_FUNCTION((X&), h, tags,
+ (optional (x, *, "") (y, *, ""))
+ )
+ {
+ return *this;
+ }
+
+ template <class A0>
+ X& operator()(A0 const& a0)
+ {
+ return *this;
+ }
+};
+
+} // namespace test
+
+struct f_fwd
+{
+ template <class R, class T, class A0, class A1, class A2>
+ R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1, A2 const& a2)
+ {
+ return self.f(a0,a1,a2);
+ }
+};
+
+struct g_fwd
+{
+ template <class R, class T, class A0, class A1>
+ R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1)
+ {
+ return self.g(a0,a1);
+ }
+};
+
+struct h_fwd
+{
+ template <class R, class T>
+ R operator()(boost::type<R>, T& self)
+ {
+ return self.h();
+ }
+
+ template <class R, class T, class A0>
+ R operator()(boost::type<R>, T& self, A0 const& a0)
+ {
+ return self.h(a0);
+ }
+
+ template <class R, class T, class A0, class A1>
+ R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1)
+ {
+ return self.h(a0,a1);
+ }
+};
+
+BOOST_PYTHON_MODULE(python_test_ext)
+{
+ namespace mpl = boost::mpl;
+ using namespace test;
+ using namespace boost::python;
+
+ class_<X>("X")
+ .def(
+ boost::parameter::python::init<
+ mpl::vector<
+ tags::x*(std::string), tags::y*(std::string)
+ >
+ >()
+ )
+ .def(
+ "f"
+ , boost::parameter::python::function<
+ f_fwd
+ , mpl::vector<
+ int, tags::x(int), tags::y(int), tags::z*(int)
+ >
+ >()
+ )
+ .def(
+ "g"
+ , boost::parameter::python::function<
+ g_fwd
+ , mpl::vector<
+ std::string, tags::x*(std::string), tags::y*(std::string)
+ >
+ >()
+ )
+ .def(
+ "h"
+ , boost::parameter::python::function<
+ h_fwd
+ , mpl::vector<
+ X&, tags::x**(std::string), tags::y**(std::string)
+ >
+ >()
+ , return_arg<>()
+ )
+ .def(
+ boost::parameter::python::call<
+ mpl::vector<
+ X&, tags::x(int)
+ >
+ >() [ return_arg<>() ]
+ )
+ .def_readonly("value", &X::value);
+}
+
diff --git a/src/boost/libs/parameter_python/test/python_test.py b/src/boost/libs/parameter_python/test/python_test.py
new file mode 100644
index 00000000..ce3b81c2
--- /dev/null
+++ b/src/boost/libs/parameter_python/test/python_test.py
@@ -0,0 +1,41 @@
+# Copyright Daniel Wallin 2006. Distributed under the
+# Boost Software License, Version 1.0. (See accompanying file
+# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+'''
+>>> from python_test_ext import X
+>>> x = X(y = 'baz')
+>>> x.value
+'foobaz'
+>>> x.f(1,2)
+3
+>>> x.f(1,2,3)
+6
+>>> x.f(1,2, z = 3)
+6
+>>> x.f(z = 3, y = 2, x = 1)
+6
+>>> x.g()
+'foobar'
+>>> x.g(y = "baz")
+'foobaz'
+>>> x.g(x = "baz")
+'bazbar'
+>>> x.g(y = "foo", x = "bar")
+'barfoo'
+>>> y = x.h(x = "bar", y = "foo")
+>>> assert x == y
+>>> y = x(0)
+>>> assert x == y
+'''
+
+def run(args = None):
+ if args is not None:
+ import sys
+ sys.argv = args
+ import doctest, python_test
+ return doctest.testmod(python_test)
+
+if __name__ == '__main__':
+ import sys
+ sys.exit(run()[0])