2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-30 20:12:37 +00:00

Add staticmethod support from Nikolay Mladenov <nickm-at-sitius.com>

[SVN r16946]
This commit is contained in:
Dave Abrahams
2003-01-19 19:12:30 +00:00
parent 571790097a
commit 399cf70b92
10 changed files with 233 additions and 38 deletions

View File

@@ -352,6 +352,11 @@ class class_ : public objects::class_base
return *this;
}
self& staticmethod(char const* name)
{
this->make_method_static(name);
return *this;
}
private: // helper functions
inline void register_() const;

View File

@@ -31,6 +31,12 @@ struct BOOST_PYTHON_DECL class_base : python::api::object
, char const* doc = 0 // Docstring, if any.
);
// Implementation detail. Hiding this in the private section would
// require use of template friend declarations.
void enable_pickling(bool getstate_manages_dict);
protected:
// Retrieve the underlying object
void add_property(char const* name, object const& fget);
void add_property(char const* name, object const& fget, object const& fset);
@@ -45,9 +51,9 @@ struct BOOST_PYTHON_DECL class_base : python::api::object
// for abstract classes.
void def_no_init();
// Implementation detail. Hiding this in the private section would
// require use of template friend declarations.
void enable_pickling(bool getstate_manages_dict);
// Effects:
// setattr(self, staticmethod(getattr(self, method_name)))
void make_method_static(const char *method_name);
};
}}} // namespace boost::python::objects