Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/long.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: 1.2 KB
Line 
1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6#include <boost/python/module.hpp>
7#include <boost/python/def.hpp>
8#include <boost/python/long.hpp>
9#include <boost/python/class.hpp>
10#define BOOST_ENABLE_ASSERT_HANDLER
11#include <boost/assert.hpp>
12
13using namespace boost::python;
14
15object new_long()
16{
17    return long_();
18}
19
20long_ longify(object x)
21{
22    return long_(x);
23}
24
25object longify_string(char const* s)
26{
27    return long_(s);
28}
29
30char const* is_long1(long_& x)
31{
32    long_ y = x;
33    x += 50;
34    BOOST_ASSERT(x == y + 50);
35    return "yes";
36}
37
38int is_long2(char const*)
39{
40    return 0;
41}
42
43// tests for accepting objects (and derived classes) in constructors
44// from "Milind Patil" <milind_patil-at-hotmail.com>
45
46struct Y
47{
48    Y(boost::python::long_) {}
49};
50
51BOOST_PYTHON_MODULE(long_ext)
52{
53    def("new_long", new_long);
54    def("longify", longify);
55    def("longify_string", longify_string);
56    def("is_long", is_long1);
57    def("is_long", is_long2);
58   
59    class_< Y >("Y", init< boost::python::long_ >())
60        ;
61}
62
63#include "module_tail.cpp"
Note: See TracBrowser for help on using the repository browser.