]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/test/voidptr.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / python / test / voidptr.cpp
CommitLineData
7c673cae
FG
1// Copyright Niall Douglas 2005.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6# include <boost/python/return_opaque_pointer.hpp>
7# include <boost/python/def.hpp>
8# include <boost/python/module.hpp>
9# include <boost/python/return_value_policy.hpp>
10
11static void *test=(void *) 78;
12
13void *get()
14{
15 return test;
16}
17
18void *getnull()
19{
20 return 0;
21}
22
23void use(void *a)
24{
25 if(a!=test)
26 throw std::runtime_error(std::string("failed"));
27}
28
29int useany(void *a)
30{
31 return a ? 1 : 0;
32}
33
34
35namespace bpl = boost::python;
36
37BOOST_PYTHON_MODULE(voidptr_ext)
38{
39 bpl::def("get", &::get, bpl::return_value_policy<bpl::return_opaque_pointer>());
40 bpl::def("getnull", &::getnull, bpl::return_value_policy<bpl::return_opaque_pointer>());
41 bpl::def("use", &::use);
42 bpl::def("useany", &::useany);
43}