Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/voidptr.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 916 bytes
Line 
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}
Note: See TracBrowser for help on using the repository browser.