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 | struct BOOST_PYTHON_DECL function : PyObject
|
---|
18 | {
|
---|
19 | function(
|
---|
20 | py_function const&
|
---|
21 | , python::detail::keyword const* names_and_defaults
|
---|
22 | , unsigned num_keywords);
|
---|
23 |
|
---|
24 | ~function();
|
---|
25 |
|
---|
26 | PyObject* call(PyObject*, PyObject*) const;
|
---|
27 |
|
---|
28 | // Add an attribute to the name_space with the given name. If it is
|
---|
29 | // a function object (this class), and an existing function is
|
---|
30 | // already there, add it as an overload.
|
---|
31 | static void add_to_namespace(
|
---|
32 | object const& name_space, char const* name, object const& attribute);
|
---|
33 |
|
---|
34 | static void add_to_namespace(
|
---|
35 | object const& name_space, char const* name, object const& attribute, char const* doc);
|
---|
36 |
|
---|
37 | object const& doc() const;
|
---|
38 | void doc(object const& x);
|
---|
39 |
|
---|
40 | object const& name() const;
|
---|
41 |
|
---|
42 | private: // helper functions
|
---|
43 | void argument_error(PyObject* args, PyObject* keywords) const;
|
---|
44 | void add_overload(handle<function> const&);
|
---|
45 |
|
---|
46 | private: // data members
|
---|
47 | py_function m_fn;
|
---|
48 | handle<function> m_overloads;
|
---|
49 | object m_name;
|
---|
50 | object m_namespace;
|
---|
51 | object m_doc;
|
---|
52 | object m_arg_names;
|
---|
53 | unsigned m_nkeyword_values;
|
---|
54 | };
|
---|
55 |
|
---|
56 | //
|
---|
57 | // implementations
|
---|
58 | //
|
---|
59 | inline object const& function::doc() const
|
---|
60 | {
|
---|
61 | return this->m_doc;
|
---|
62 | }
|
---|
63 |
|
---|
64 | inline void function::doc(object const& x)
|
---|
65 | {
|
---|
66 | this->m_doc = x;
|
---|
67 | }
|
---|
68 |
|
---|
69 | inline object const& function::name() const
|
---|
70 | {
|
---|
71 | return this->m_name;
|
---|
72 | }
|
---|
73 |
|
---|
74 | }}} // namespace boost::python::objects
|
---|
75 |
|
---|
76 | #endif // FUNCTION_DWA20011214_HPP
|
---|