Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/cltree.cpp @ 45

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

updated boost from 1_33_1 to 1_34_1

File size: 1.7 KB
Line 
1// Copyright David Abrahams 2005. Distributed under the Boost
2// Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5#include <boost/python/module.hpp>
6#include <boost/python/def.hpp>
7#include <boost/python/class.hpp>
8#include <boost/utility.hpp>
9
10/*  Non-modifiable definitions */
11
12class basic {
13public:
14  basic() { name = "cltree.basic"; }
15  std::string repr() { return name+"()"; }
16protected:
17  std::string name;
18};
19
20class constant: public basic {
21public:
22  constant() { name = "cltree.constant"; }
23};
24
25class symbol: public basic {
26public:
27  symbol() { name = "cltree.symbol"; }
28};
29
30class variable: public basic {
31public:
32  variable() { name = "cltree.variable"; }
33};
34
35/*  EOF: Non-modifiable definitions */
36
37class symbol_wrapper: public symbol {
38public:
39  symbol_wrapper(PyObject* /*self*/): symbol() { 
40    name = "cltree.wrapped_symbol"; 
41  }
42};
43
44class variable_wrapper: public variable {
45public:
46  variable_wrapper(PyObject* /*self*/): variable() { 
47    name = "cltree.wrapped_variable";
48  }
49
50  // This constructor is introduced only because cannot use
51  // boost::noncopyable, see below.
52  variable_wrapper(PyObject* /*self*/,variable v): variable(v) {} 
53
54};
55
56BOOST_PYTHON_MODULE(cltree)
57{
58    boost::python::class_<basic>("basic")
59        .def("__repr__",&basic::repr)
60        ;
61
62    boost::python::class_<constant, boost::python::bases<basic>, boost::noncopyable>("constant")
63        ;
64
65
66    boost::python::class_<symbol, symbol_wrapper, boost::noncopyable>("symbol")
67        ;
68
69    boost::python::class_<variable, boost::python::bases<basic>, variable_wrapper>("variable")
70        ;
71}
72
73#include "module_tail.cpp"
74
Note: See TracBrowser for help on using the repository browser.