source: NonGTP/Boost/boost/python/object/class.hpp @ 857

Revision 857, 2.2 KB checked in by igarcia, 19 years ago (diff)
Line 
1// Copyright David Abrahams 2001.
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#ifndef CLASS_DWA20011214_HPP
6# define CLASS_DWA20011214_HPP
7
8# include <boost/python/detail/prefix.hpp>
9# include <boost/utility.hpp>
10# include <boost/python/object_core.hpp>
11# include <boost/python/type_id.hpp>
12# include <cstddef>
13
14namespace boost { namespace python {
15
16namespace objects {
17
18struct BOOST_PYTHON_DECL class_base : python::api::object
19{
20    // constructor
21    class_base(
22        char const* name              // The name of the class
23       
24        , std::size_t num_types         // A list of class_ids. The first is the type
25        , type_info const*const types    // this is wrapping. The rest are the types of
26                                        // any bases.
27       
28        , char const* doc = 0           // Docstring, if any.
29        );
30
31
32    // Implementation detail. Hiding this in the private section would
33    // require use of template friend declarations.
34    void enable_pickling_(bool getstate_manages_dict);
35
36 protected:
37    void add_property(
38        char const* name, object const& fget, char const* docstr);
39    void add_property(char const* name,
40        object const& fget, object const& fset, char const* docstr);
41
42    void add_static_property(char const* name, object const& fget);
43    void add_static_property(char const* name, object const& fget, object const& fset);
44   
45    // Retrieve the underlying object
46    void setattr(char const* name, object const&);
47
48    // Set a special attribute in the class which tells Boost.Python
49    // to allocate extra bytes for embedded C++ objects in Python
50    // instances.
51    void set_instance_size(std::size_t bytes);
52
53    // Set an __init__ function which throws an appropriate exception
54    // for abstract classes.
55    void def_no_init();
56
57    // Effects:
58    //  setattr(self, staticmethod(getattr(self, method_name)))
59    void make_method_static(const char *method_name);
60};
61
62}}} // namespace boost::python::objects
63
64#endif // CLASS_DWA20011214_HPP
Note: See TracBrowser for help on using the repository browser.