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