2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-27 19:12:16 +00:00

Tons of changes to improve error reporting

Added attributes function.__name__ and function.__signature__ and dir(function) feature


[SVN r8311]
This commit is contained in:
Ullrich Köthe
2000-11-23 22:48:51 +00:00
parent 4d7b6fe92a
commit ec4bc0382f
18 changed files with 1153 additions and 1134 deletions

View File

@@ -133,6 +133,39 @@ class class_registry
static std::vector<derived_class_info> static_derived_class_info;
};
template <class T, class H>
no_t* is_plain_aux(type<instance_value_holder<T, H> >);
template <class T, class H>
string forward_python_type_name(python::type<instance_value_holder<T, H> >)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
}
template <class T, class H>
no_t* is_plain_aux(type<instance_ptr_holder<T, H> >);
template <class T, class H>
string forward_python_type_name(python::type<instance_ptr_holder<T, H> >)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
}
template <class T>
string python_type_name(type<T>)
{
if(class_registry<T>::class_object() == 0)
{
return string("UnknownType");
}
else
{
return class_registry<T>::class_object()->complete_class_name();
}
}
}} // namespace python::detail
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
@@ -314,7 +347,9 @@ class read_only_setattr_function : public function
public:
read_only_setattr_function(const char* name);
PyObject* do_call(PyObject* args, PyObject* keywords) const;
const char* description() const;
PyObject* description() const;
string function_name() const
{ return m_name; }
private:
string m_name;
};
@@ -428,7 +463,7 @@ class extension_class
template <class Fn>
inline void def_raw(Fn fn, const char* name)
{
this->add_method(new_raw_arguments_function(fn), name);
this->add_method(new_raw_arguments_function(fn, name), name);
}
// define member functions. In fact this works for free functions, too -
@@ -438,7 +473,7 @@ class extension_class
template <class Fn>
inline void def(Fn fn, const char* name)
{
this->add_method(new_wrapped_function(fn), name);
this->add_method(new_wrapped_function(fn, name), name);
}
// Define a virtual member function with a default implementation.
@@ -447,7 +482,7 @@ class extension_class
template <class Fn, class DefaultFn>
inline void def(Fn fn, const char* name, DefaultFn default_fn)
{
this->add_method(new_virtual_function(type<T>(), fn, default_fn), name);
this->add_method(new_virtual_function(type<T>(), fn, default_fn, name), name);
}
// Provide a function which implements x.<name>, reading from the given
@@ -455,7 +490,7 @@ class extension_class
template <class MemberType>
inline void def_getter(MemberType T::*pm, const char* name)
{
this->add_getter_method(new getter_function<T, MemberType>(pm), name);
this->add_getter_method(new getter_function<T, MemberType>(pm, name), name);
}
// Provide a function which implements assignment to x.<name>, writing to
@@ -463,7 +498,7 @@ class extension_class
template <class MemberType>
inline void def_setter(MemberType T::*pm, const char* name)
{
this->add_setter_method(new setter_function<T, MemberType>(pm), name);
this->add_setter_method(new setter_function<T, MemberType>(pm, name), name);
}
// Expose the given member (pm) of the T obj as a read-only attribute