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 FUNCTION_DWA20011214_HPP
6 # define FUNCTION_DWA20011214_HPP
8 # include <boost/python/detail/prefix.hpp>
9 # include <boost/python/args_fwd.hpp>
10 # include <boost/python/handle.hpp>
11 # include <boost/function/function2.hpp>
12 # include <boost/python/object_core.hpp>
13 # include <boost/python/object/py_function.hpp>
15 namespace boost { namespace python { namespace objects {
18 struct BOOST_PYTHON_DECL function : PyObject
22 , python::detail::keyword const* names_and_defaults
23 , unsigned num_keywords);
27 PyObject* call(PyObject*, PyObject*) const;
29 // Add an attribute to the name_space with the given name. If it is
30 // a function object (this class), and an existing function is
31 // already there, add it as an overload.
32 static void add_to_namespace(
33 object const& name_space, char const* name, object const& attribute);
35 static void add_to_namespace(
36 object const& name_space, char const* name, object const& attribute, char const* doc);
38 object const& doc() const;
39 void doc(object const& x);
41 object const& name() const;
43 object const& get_namespace() const { return m_namespace; }
45 private: // helper functions
46 object signature(bool show_return_type=false) const;
47 object signatures(bool show_return_type=false) const;
48 void argument_error(PyObject* args, PyObject* keywords) const;
49 void add_overload(handle<function> const&);
51 private: // data members
53 handle<function> m_overloads;
58 unsigned m_nkeyword_values;
59 friend class function_doc_signature_generator;
65 inline object const& function::doc() const
70 inline void function::doc(object const& x)
75 inline object const& function::name() const
80 }}} // namespace boost::python::objects
82 #endif // FUNCTION_DWA20011214_HPP