]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/python/object/function.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / python / object / function.hpp
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
7
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>
14
15 namespace boost { namespace python { namespace objects {
16
17
18 struct BOOST_PYTHON_DECL function : PyObject
19 {
20 function(
21 py_function const&
22 , python::detail::keyword const* names_and_defaults
23 , unsigned num_keywords);
24
25 ~function();
26
27 PyObject* call(PyObject*, PyObject*) const;
28
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);
34
35 static void add_to_namespace(
36 object const& name_space, char const* name, object const& attribute, char const* doc);
37
38 object const& doc() const;
39 void doc(object const& x);
40
41 object const& name() const;
42
43 object const& get_namespace() const { return m_namespace; }
44
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&);
50
51 private: // data members
52 py_function m_fn;
53 handle<function> m_overloads;
54 object m_name;
55 object m_namespace;
56 object m_doc;
57 object m_arg_names;
58 unsigned m_nkeyword_values;
59 friend class function_doc_signature_generator;
60 };
61
62 //
63 // implementations
64 //
65 inline object const& function::doc() const
66 {
67 return this->m_doc;
68 }
69
70 inline void function::doc(object const& x)
71 {
72 this->m_doc = x;
73 }
74
75 inline object const& function::name() const
76 {
77 return this->m_name;
78 }
79
80 }}} // namespace boost::python::objects
81
82 #endif // FUNCTION_DWA20011214_HPP