Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/pyste/tests/virtual.cpp @ 47

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

updated boost from 1_33_1 to 1_34_1

File size: 1.9 KB
Line 
1/* Copyright Bruno da Silva de Oliveira 2003. Use, modification and
2 distribution is subject to 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
7// Includes ====================================================================
8#include <boost/python.hpp>
9#include <virtual.h>
10
11// Using =======================================================================
12using namespace boost::python;
13
14// Declarations ================================================================
15
16
17namespace  {
18
19
20struct virtual_C_Wrapper: virtual_::C
21{
22    virtual_C_Wrapper(PyObject* self_, const virtual_::C & p0):
23        virtual_::C(p0), self(self_) {}
24
25    virtual_C_Wrapper(PyObject* self_):
26        virtual_::C(), self(self_) {}
27
28    int f() {
29        return call_method< int >(self, "f");
30    }
31
32    int default_f() {
33        return virtual_::C::f();
34    }
35
36    void bar(int p0) {
37        call_method< void >(self, "bar", p0);
38    }
39
40    void default_bar(int p0) {
41        virtual_::C::bar(p0);
42    }
43
44    void bar(char * p0) {
45        call_method< void >(self, "bar", p0);
46    }
47
48    void default_bar(char * p0) {
49        virtual_::C::bar(p0);
50    }
51
52    int f_abs() {
53        return call_method< int >(self, "f_abs");
54    }
55
56    PyObject* self;
57};
58
59
60
61}// namespace
62
63
64// Module ======================================================================
65BOOST_PYTHON_MODULE(virtual)
66{
67    class_< virtual_::C, boost::noncopyable, virtual_C_Wrapper >("C", init<  >())
68        .def("get_name", &virtual_::C::get_name)
69        .def("f", &virtual_::C::f, &virtual_C_Wrapper::default_f)
70        .def("bar", (void (virtual_::C::*)(int) )&virtual_::C::bar, (void (virtual_C_Wrapper::*)(int))&virtual_C_Wrapper::default_bar)
71        .def("bar", (void (virtual_::C::*)(char *) )&virtual_::C::bar, (void (virtual_C_Wrapper::*)(char *))&virtual_C_Wrapper::default_bar)
72    ;
73
74    def("call_f", &virtual_::call_f);
75}
Note: See TracBrowser for help on using the repository browser.