class.hpp 2.1 KB

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