Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/nested.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: 1009 bytes
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#include <boost/python/module.hpp>
6#include <boost/python/class.hpp>
7#include <boost/python/operators.hpp>
8#include <boost/python/scope.hpp>
9#include "test_class.hpp"
10#if __GNUC__ != 2
11# include <ostream>
12#else
13# include <ostream.h>
14#endif
15
16typedef test_class<> X;
17typedef test_class<1> Y;
18
19std::ostream& operator<<(std::ostream& s, X const& x)
20{
21    return s << x.value();
22}
23
24std::ostream& operator<<(std::ostream& s, Y const& x)
25{
26    return s << x.value();
27}
28
29
30BOOST_PYTHON_MODULE(nested_ext)
31{
32    using namespace boost::python;
33
34    // Establish X as the current scope.
35    scope x_class
36        = class_<X>("X", init<int>())
37          .def(str(self))
38        ;
39
40
41    // Y will now be defined in the current scope
42    class_<Y>("Y", init<int>())
43        .def(str(self))
44        ;
45}
46
47
48#include "module_tail.cpp"
49
50
51
Note: See TracBrowser for help on using the repository browser.