2
0
mirror of https://github.com/boostorg/python.git synced 2026-02-07 22:52:22 +00:00

optimizations to reduce reulting object code size

[SVN r8314]
This commit is contained in:
Ullrich Köthe
2000-11-24 11:05:20 +00:00
parent e3fe2d02ee
commit 517b307622
9 changed files with 350 additions and 326 deletions

351
caller.h
View File

@@ -543,260 +543,225 @@ struct caller<void>
namespace detail
{
// create signature tuples
inline
PyObject* function_signature() {
tuple result(0);
return result.reference().release();
}
template <class A1>
PyObject* function_signature(type<A1>) {
static const bool is_plain_A1 = BOOST_PYTHON_IS_PLAIN(A1);
tuple result(1);
result.set_item(0, python_type_name_selector<is_plain_A1>::get(type<A1>()));
return result.reference().release();
}
template <class A1, class A2>
PyObject* function_signature(type<A1>, type<A2>) {
static const bool is_plain_A1 = BOOST_PYTHON_IS_PLAIN(A1);
static const bool is_plain_A2 = BOOST_PYTHON_IS_PLAIN(A2);
tuple result(2);
result.set_item(0, python_type_name_selector<is_plain_A1>::get(type<A1>()));
result.set_item(1, python_type_name_selector<is_plain_A2>::get(type<A2>()));
return result.reference().release();
}
template <class A1, class A2, class A3>
PyObject* function_signature(type<A1>, type<A2>, type<A3>) {
static const bool is_plain_A1 = BOOST_PYTHON_IS_PLAIN(A1);
static const bool is_plain_A2 = BOOST_PYTHON_IS_PLAIN(A2);
static const bool is_plain_A3 = BOOST_PYTHON_IS_PLAIN(A3);
tuple result(3);
result.set_item(0, python_type_name_selector<is_plain_A1>::get(type<A1>()));
result.set_item(1, python_type_name_selector<is_plain_A2>::get(type<A2>()));
result.set_item(2, python_type_name_selector<is_plain_A3>::get(type<A3>()));
return result.reference().release();
}
template <class A1, class A2, class A3, class A4>
PyObject* function_signature(type<A1>, type<A2>, type<A3>, type<A4>) {
static const bool is_plain_A1 = BOOST_PYTHON_IS_PLAIN(A1);
static const bool is_plain_A2 = BOOST_PYTHON_IS_PLAIN(A2);
static const bool is_plain_A3 = BOOST_PYTHON_IS_PLAIN(A3);
static const bool is_plain_A4 = BOOST_PYTHON_IS_PLAIN(A4);
tuple result(4);
result.set_item(0, python_type_name_selector<is_plain_A1>::get(type<A1>()));
result.set_item(1, python_type_name_selector<is_plain_A2>::get(type<A2>()));
result.set_item(2, python_type_name_selector<is_plain_A3>::get(type<A3>()));
result.set_item(3, python_type_name_selector<is_plain_A4>::get(type<A4>()));
return result.reference().release();
}
template <class A1, class A2, class A3, class A4, class A5>
PyObject* function_signature(type<A1>, type<A2>, type<A3>, type<A4>, type<A5>) {
static const bool is_plain_A1 = BOOST_PYTHON_IS_PLAIN(A1);
static const bool is_plain_A2 = BOOST_PYTHON_IS_PLAIN(A2);
static const bool is_plain_A3 = BOOST_PYTHON_IS_PLAIN(A3);
static const bool is_plain_A4 = BOOST_PYTHON_IS_PLAIN(A4);
static const bool is_plain_A5 = BOOST_PYTHON_IS_PLAIN(A5);
tuple result(5);
result.set_item(0, python_type_name_selector<is_plain_A1>::get(type<A1>()));
result.set_item(1, python_type_name_selector<is_plain_A2>::get(type<A2>()));
result.set_item(2, python_type_name_selector<is_plain_A3>::get(type<A3>()));
result.set_item(3, python_type_name_selector<is_plain_A4>::get(type<A4>()));
result.set_item(4, python_type_name_selector<is_plain_A5>::get(type<A5>()));
return result.reference().release();
}
template <class A1, class A2, class A3, class A4, class A5, class A6>
PyObject* function_signature(type<A1>, type<A2>, type<A3>, type<A4>, type<A5>, type<A6>) {
static const bool is_plain_A1 = BOOST_PYTHON_IS_PLAIN(A1);
static const bool is_plain_A2 = BOOST_PYTHON_IS_PLAIN(A2);
static const bool is_plain_A3 = BOOST_PYTHON_IS_PLAIN(A3);
static const bool is_plain_A4 = BOOST_PYTHON_IS_PLAIN(A4);
static const bool is_plain_A5 = BOOST_PYTHON_IS_PLAIN(A5);
static const bool is_plain_A6 = BOOST_PYTHON_IS_PLAIN(A6);
tuple result(6);
result.set_item(0, python_type_name_selector<is_plain_A1>::get(type<A1>()));
result.set_item(1, python_type_name_selector<is_plain_A2>::get(type<A2>()));
result.set_item(2, python_type_name_selector<is_plain_A3>::get(type<A3>()));
result.set_item(3, python_type_name_selector<is_plain_A4>::get(type<A4>()));
result.set_item(4, python_type_name_selector<is_plain_A5>::get(type<A5>()));
result.set_item(5, python_type_name_selector<is_plain_A6>::get(type<A6>()));
return result.reference().release();
}
// member functions
template <class R, class T>
inline PyObject* function_signature(R (T::*pmf)()) {
return function_signature(
python::type<T>());
PyObject* function_signature(R (T::*pmf)()) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
return result;
}
template <class R, class T, class A1>
inline PyObject* function_signature(R (T::*pmf)(A1)) {
return function_signature(
python::type<T>(),
python::type<A1>());
PyObject* function_signature(R (T::*pmf)(A1)) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
return result;
}
template <class R, class T, class A1, class A2>
inline PyObject* function_signature(R (T::*pmf)(A1, A2)) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>());
PyObject* function_signature(R (T::*pmf)(A1, A2)) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
return result;
}
template <class R, class T, class A1, class A2, class A3>
inline PyObject* function_signature(R (T::*pmf)(A1, A2, A3)) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>());
PyObject* function_signature(R (T::*pmf)(A1, A2, A3)) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
return result;
}
template <class R, class T, class A1, class A2, class A3, class A4>
inline PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4)) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>());
PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4)) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
result = function_signature_append(result, get_python_type_name(type<A4>()));
return result;
}
template <class R, class T, class A1, class A2, class A3, class A4, class A5>
inline PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4, A5)) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>(),
python::type<A5>());
PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4, A5)) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
result = function_signature_append(result, get_python_type_name(type<A4>()));
result = function_signature_append(result, get_python_type_name(type<A5>()));
return result;
}
// const member functions
template <class R, class T>
inline PyObject* function_signature(R (T::*pmf)() const) {
return function_signature(
python::type<T>());
PyObject* function_signature(R (T::*pmf)() const) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
return result;
}
template <class R, class T, class A1>
inline PyObject* function_signature(R (T::*pmf)(A1) const) {
return function_signature(
python::type<T>(),
python::type<A1>());
PyObject* function_signature(R (T::*pmf)(A1) const) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
return result;
}
template <class R, class T, class A1, class A2>
inline PyObject* function_signature(R (T::*pmf)(A1, A2) const) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>());
PyObject* function_signature(R (T::*pmf)(A1, A2) const) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
return result;
}
template <class R, class T, class A1, class A2, class A3>
inline PyObject* function_signature(R (T::*pmf)(A1, A2, A3) const) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>());
PyObject* function_signature(R (T::*pmf)(A1, A2, A3) const) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
return result;
}
template <class R, class T, class A1, class A2, class A3, class A4>
inline PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4) const) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>());
PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4) const) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
result = function_signature_append(result, get_python_type_name(type<A4>()));
return result;
}
template <class R, class T, class A1, class A2, class A3, class A4, class A5>
inline PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4, A5) const) {
return function_signature(
python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>(),
python::type<A5>());
PyObject* function_signature(R (T::*pmf)(A1, A2, A3, A4, A5) const) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
result = function_signature_append(result, get_python_type_name(type<A4>()));
result = function_signature_append(result, get_python_type_name(type<A5>()));
return result;
}
// free functions
template <class R>
inline PyObject* function_signature(R (*f)()) {
return function_signature();
PyObject* function_signature(R (*f)()) {
tuple s(0);
PyObject * result = s.reference().release();
return result;
}
template <class R, class A1>
inline PyObject* function_signature(R (*f)(A1)) {
return function_signature(
python::type<A1>());
PyObject* function_signature(R (*f)(A1)) {
tuple s(0);
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
return result;
}
template <class R, class A1, class A2>
inline PyObject* function_signature(R (*f)(A1, A2)) {
return function_signature(
python::type<A1>(),
python::type<A2>());
PyObject* function_signature(R (*f)(A1, A2)) {
tuple s(0);
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
return result;
}
template <class R, class A1, class A2, class A3>
inline PyObject* function_signature(R (*f)(A1, A2, A3)) {
return function_signature(
python::type<A1>(),
python::type<A2>(),
python::type<A3>());
PyObject* function_signature(R (*f)(A1, A2, A3)) {
tuple s(0);
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
return result;
}
template <class R, class A1, class A2, class A3, class A4>
inline PyObject* function_signature(R (*f)(A1, A2, A3, A4)) {
return function_signature(
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>());
PyObject* function_signature(R (*f)(A1, A2, A3, A4)) {
tuple s(0);
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
result = function_signature_append(result, get_python_type_name(type<A4>()));
return result;
}
template <class R, class A1, class A2, class A3, class A4, class A5>
inline PyObject* function_signature(R (*f)(A1, A2, A3, A4, A5)) {
return function_signature(
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>(),
python::type<A5>());
PyObject* function_signature(R (*f)(A1, A2, A3, A4, A5)) {
tuple s(0);
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
result = function_signature_append(result, get_python_type_name(type<A4>()));
result = function_signature_append(result, get_python_type_name(type<A5>()));
return result;
}
template <class R, class A1, class A2, class A3, class A4, class A5, class A6>
inline PyObject* function_signature(R (*f)(A1, A2, A3, A4, A5, A6)) {
return function_signature(
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>(),
python::type<A5>(),
python::type<A6>());
PyObject* function_signature(R (*f)(A1, A2, A3, A4, A5, A6)) {
tuple s(0);
PyObject * result = s.reference().release();
result = function_signature_append(result, get_python_type_name(type<A1>()));
result = function_signature_append(result, get_python_type_name(type<A2>()));
result = function_signature_append(result, get_python_type_name(type<A3>()));
result = function_signature_append(result, get_python_type_name(type<A4>()));
result = function_signature_append(result, get_python_type_name(type<A5>()));
result = function_signature_append(result, get_python_type_name(type<A6>()));
return result;
}
} // namespace detail

View File

@@ -134,27 +134,25 @@ class class_registry
};
template <class T, class H>
no_t* is_plain_aux(type<instance_value_holder<T, H> >);
inline is_not_plain_t* is_plain_aux(type<instance_value_holder<T, H> >) { return 0; }
template <class T, class H>
string forward_python_type_name(python::type<instance_value_holder<T, H> >)
inline is_not_plain_t* is_plain_aux(type<instance_ptr_holder<T, H> >) { return 0; }
template <class T, class H>
inline string get_python_type_name(python::type<instance_value_holder<T, H> >, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(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> >)
inline string get_python_type_name(python::type<instance_ptr_holder<T, H> >, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string python_type_name(type<T>)
string get_python_type_name(type<T>, is_plain_t*)
{
if(class_registry<T>::class_object() == 0)
{

View File

@@ -60,8 +60,7 @@ struct caller<void>
namespace detail
{
// create signature tuples
inline''',
''',
'''
// member functions
''',
@@ -106,9 +105,8 @@ free_function = '''%{ template <%(class A%n%:, %)>
function_signature = '''%{template <%}%(class A%n%:, %)%{>%}
PyObject* function_signature(%(type<A%n>%:, %)) {
%( static const bool is_plain_A%n = BOOST_PYTHON_IS_PLAIN(A%n);
%) tuple result(%x);
%( result.set_item(%N, python_type_name_selector<is_plain_A%n>::get(type<A%n>()));
tuple result(%x);
%( result.set_item(%N, get_python_type_name(type<A%n>()));
%)
return result.reference().release();
}
@@ -116,18 +114,24 @@ PyObject* function_signature(%(type<A%n>%:, %)) {
'''
member_function_signature = '''template <class R, class T%(, class A%n%)>
inline PyObject* function_signature(R (T::*pmf)(%(A%n%:, %))%1) {
return function_signature(
python::type<T>()%(,
python::type<A%n>()%));
PyObject* function_signature(R (T::*pmf)(%(A%n%:, %))%1) {
tuple s(1);
s.set_item(0, get_python_type_name(type<T>()));
PyObject * result = s.reference().release();
%( result = function_signature_append(result, get_python_type_name(type<A%n>()));
%)
return result;
}
'''
free_function_signature = '''template <class R%(, class A%n%)>
inline PyObject* function_signature(R (*f)(%(A%n%:, %))) {
return function_signature(%(
python::type<A%n>()%:,%));
PyObject* function_signature(R (*f)(%(A%n%:, %))) {
tuple s(0);
PyObject * result = s.reference().release();
%( result = function_signature_append(result, get_python_type_name(type<A%n>()));
%)
return result;
}
'''
@@ -165,7 +169,7 @@ def gen_caller(member_function_args, free_function_args = None):
+ body_sections[6]
# create lists describing the function signatures
+ gen_functions(function_signature, free_function_args)
# + gen_functions(function_signature, free_function_args)
+ body_sections[7]
+ gen_functions(member_function_signature, member_function_args, '')
+ body_sections[8]

View File

@@ -139,27 +139,25 @@ class class_registry
};
template <class T, class H>
no_t* is_plain_aux(type<instance_value_holder<T, H> >);
inline is_not_plain_t* is_plain_aux(type<instance_value_holder<T, H> >) { return 0; }
template <class T, class H>
string forward_python_type_name(python::type<instance_value_holder<T, H> >)
inline is_not_plain_t* is_plain_aux(type<instance_ptr_holder<T, H> >) { return 0; }
template <class T, class H>
inline string get_python_type_name(python::type<instance_value_holder<T, H> >, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(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> >)
inline string get_python_type_name(python::type<instance_ptr_holder<T, H> >, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string python_type_name(type<T>)
string get_python_type_name(type<T>, is_plain_t*)
{
if(class_registry<T>::class_object() == 0)
{

View File

@@ -150,14 +150,13 @@ struct init%x : init
PyObject* description() const
{
return function_signature(python::type<T>()%(,
python::type<A%n>()%));
return function_signature(get_python_type_name(python::type<T>())%(,
get_python_type_name(python::type<A%n>())%));
}
string function_name() const
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
string result(python_type_name_selector<is_plain>::get(python::type<T>()));
string result(get_python_type_name(python::type<T>()));
result += ".__init__";
return result;
}

View File

@@ -183,13 +183,12 @@ struct init0 : init
PyObject* description() const
{
return function_signature(python::type<T>());
return function_signature(get_python_type_name(python::type<T>()));
}
string function_name() const
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
string result(python_type_name_selector<is_plain>::get(python::type<T>()));
string result(get_python_type_name(python::type<T>()));
result += ".__init__";
return result;
}
@@ -210,14 +209,13 @@ struct init1 : init
PyObject* description() const
{
return function_signature(python::type<T>(),
python::type<A1>());
return function_signature(get_python_type_name(python::type<T>()),
get_python_type_name(python::type<A1>()));
}
string function_name() const
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
string result(python_type_name_selector<is_plain>::get(python::type<T>()));
string result(get_python_type_name(python::type<T>()));
result += ".__init__";
return result;
}
@@ -240,15 +238,14 @@ struct init2 : init
PyObject* description() const
{
return function_signature(python::type<T>(),
python::type<A1>(),
python::type<A2>());
return function_signature(get_python_type_name(python::type<T>()),
get_python_type_name(python::type<A1>()),
get_python_type_name(python::type<A2>()));
}
string function_name() const
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
string result(python_type_name_selector<is_plain>::get(python::type<T>()));
string result(get_python_type_name(python::type<T>()));
result += ".__init__";
return result;
}
@@ -273,16 +270,15 @@ struct init3 : init
PyObject* description() const
{
return function_signature(python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>());
return function_signature(get_python_type_name(python::type<T>()),
get_python_type_name(python::type<A1>()),
get_python_type_name(python::type<A2>()),
get_python_type_name(python::type<A3>()));
}
string function_name() const
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
string result(python_type_name_selector<is_plain>::get(python::type<T>()));
string result(get_python_type_name(python::type<T>()));
result += ".__init__";
return result;
}
@@ -309,17 +305,16 @@ struct init4 : init
PyObject* description() const
{
return function_signature(python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>());
return function_signature(get_python_type_name(python::type<T>()),
get_python_type_name(python::type<A1>()),
get_python_type_name(python::type<A2>()),
get_python_type_name(python::type<A3>()),
get_python_type_name(python::type<A4>()));
}
string function_name() const
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
string result(python_type_name_selector<is_plain>::get(python::type<T>()));
string result(get_python_type_name(python::type<T>()));
result += ".__init__";
return result;
}
@@ -348,18 +343,17 @@ struct init5 : init
PyObject* description() const
{
return function_signature(python::type<T>(),
python::type<A1>(),
python::type<A2>(),
python::type<A3>(),
python::type<A4>(),
python::type<A5>());
return function_signature(get_python_type_name(python::type<T>()),
get_python_type_name(python::type<A1>()),
get_python_type_name(python::type<A2>()),
get_python_type_name(python::type<A3>()),
get_python_type_name(python::type<A4>()),
get_python_type_name(python::type<A5>()));
}
string function_name() const
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
string result(python_type_name_selector<is_plain>::get(python::type<T>()));
string result(get_python_type_name(python::type<T>()));
result += ".__init__";
return result;
}

View File

@@ -482,4 +482,67 @@ list::slice_proxy::slice_proxy(const ref& list, int low, int high)
{
}
namespace detail
{
PyObject* function_signature_append(PyObject * sig, string type_name)
{
ref rsig(sig);
tuple old_signature(rsig);
tuple new_signature(old_signature.size()+1);
int i;
for(i=0; i<old_signature.size(); ++i)
{
new_signature.set_item(i, old_signature[i]);
}
new_signature.set_item(i, type_name);
return new_signature.reference().release();
}
PyObject* function_signature(string arg0,
string arg1,
string arg2,
string arg3,
string arg4,
string arg5,
string arg6,
string arg7,
string arg8,
string arg9)
{
int count = 0;
if(arg0.size() != 0) ++count;
if(arg1.size() != 0) ++count;
if(arg2.size() != 0) ++count;
if(arg3.size() != 0) ++count;
if(arg4.size() != 0) ++count;
if(arg5.size() != 0) ++count;
if(arg6.size() != 0) ++count;
if(arg7.size() != 0) ++count;
if(arg8.size() != 0) ++count;
if(arg9.size() != 0) ++count;
tuple result(count);
switch(count - 1)
{
case 9: result.set_item(9, arg9);
case 8: result.set_item(8, arg8);
case 7: result.set_item(7, arg7);
case 6: result.set_item(6, arg6);
case 5: result.set_item(5, arg5);
case 4: result.set_item(4, arg4);
case 3: result.set_item(3, arg3);
case 2: result.set_item(2, arg2);
case 1: result.set_item(1, arg1);
case 0: result.set_item(0, arg0);
}
return result.reference().release();
}
} // namespace detail
}

View File

@@ -295,8 +295,13 @@ struct list::slice_proxy
namespace detail
{
typedef char is_not_plain_t[1];
typedef char is_plain_t[2];
#define BOOST_PYTHON_OVERLOAD_TYPENAME_FUNCTION(T, name) \
inline string python_type_name(python::type<T >) \
inline string get_python_type_name(python::type<T >, is_plain_t *) \
{ return string(#name); } \
inline string get_python_type_name(python::type<T >, is_not_plain_t *) \
{ return string(#name); }
#if 0
@@ -343,100 +348,90 @@ namespace detail
BOOST_PYTHON_OVERLOAD_TYPENAME_FUNCTION(dictionary, dictionary);
BOOST_PYTHON_OVERLOAD_TYPENAME_FUNCTION(string, string);
typedef char no_t[1];
typedef char yes_t[2];
yes_t* is_plain_aux(...);
inline is_plain_t* is_plain_aux(...) { return 0; }
template <class T>
no_t* is_plain_aux(type<T *>);
inline is_not_plain_t* is_plain_aux(type<T *>) { return 0; }
template <class T>
no_t* is_plain_aux(type<T const *>);
inline is_not_plain_t* is_plain_aux(type<T const *>) { return 0; }
template <class T>
no_t* is_plain_aux(type<T &>);
inline is_not_plain_t* is_plain_aux(type<T &>) { return 0; }
template <class T>
no_t* is_plain_aux(type<T const &>);
inline is_not_plain_t* is_plain_aux(type<T const &>) { return 0; }
template <class T>
no_t* is_plain_aux(type<std::auto_ptr<T> >);
inline is_not_plain_t* is_plain_aux(type<std::auto_ptr<T> >) { return 0; }
template <class T>
no_t* is_plain_aux(type<boost::shared_ptr<T> >);
inline is_not_plain_t* is_plain_aux(type<boost::shared_ptr<T> >) { return 0; }
template <class T>
no_t* is_plain_aux(type<reference<T> >);
inline is_not_plain_t* is_plain_aux(type<reference<T> >) { return 0; }
#define BOOST_PYTHON_IS_PLAIN(T) \
(sizeof(*python::detail::is_plain_aux(python::type<T>())) == \
sizeof(python::detail::yes_t))
template <bool is_plain>
struct python_type_name_selector
template <class T>
inline string get_python_type_name(type<T> t)
{
template <class T>
static string get(python::type<T> t)
{ return python_type_name(t); }
};
return get_python_type_name(t, is_plain_aux(t));
}
template <class T>
string forward_python_type_name(python::type<T&>)
inline string get_python_type_name(python::type<T&>, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string forward_python_type_name(python::type<const T&>)
inline string get_python_type_name(python::type<const T&>, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string forward_python_type_name(python::type<T*>)
inline string get_python_type_name(python::type<T*>, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string forward_python_type_name(python::type<const T*>)
inline string get_python_type_name(python::type<const T*>, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string forward_python_type_name(python::type<std::auto_ptr<T> >)
inline string get_python_type_name(python::type<std::auto_ptr<T> >, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string forward_python_type_name(python::type<boost::shared_ptr<T> >)
inline string get_python_type_name(python::type<boost::shared_ptr<T> >, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <class T>
string forward_python_type_name(python::type<reference<T> >)
inline string get_python_type_name(python::type<reference<T> >, is_not_plain_t*)
{
static const bool is_plain = BOOST_PYTHON_IS_PLAIN(T);
return python_type_name_selector<is_plain>::get(python::type<T>());
return get_python_type_name(python::type<T>());
}
template <>
struct python_type_name_selector<false>
{
template <class T>
static string get(python::type<T> t)
{ return forward_python_type_name(t); }
};
PyObject* function_signature_append(PyObject * sig, string type_name);
PyObject* function_signature(string arg0,
string arg1 = string(""),
string arg2 = string(""),
string arg3 = string(""),
string arg4 = string(""),
string arg5 = string(""),
string arg6 = string(""),
string arg7 = string(""),
string arg8 = string(""),
string arg9 = string(""));
} // namespace detail
} // namespace python

View File

@@ -225,7 +225,8 @@ namespace detail
\
PyObject* description() const \
{ \
return function_signature(python::type<Left>(), python::type<Right>()); \
return function_signature(get_python_type_name(python::type<Left>()), \
get_python_type_name(python::type<Right>())); \
} \
}; \
\
@@ -246,7 +247,8 @@ namespace detail
\
PyObject* description() const \
{ \
return function_signature(python::type<Left>(), python::type<Right>()); \
return function_signature(get_python_type_name(python::type<Left>()), \
get_python_type_name(python::type<Right>())); \
} \
\
}; \
@@ -271,11 +273,11 @@ namespace detail
} \
\
string function_name() const \
{ return string(name()); } \
{ return string(name()); } \
\
PyObject* description() const \
{ \
return function_signature(python::type<operand>()); \
return function_signature(get_python_type_name(python::type<operand>())); \
} \
}; \
\
@@ -336,7 +338,8 @@ namespace detail
PyObject* description() const
{
return function_signature(python::type<Left>(), python::type<Right>());
return function_signature(get_python_type_name(python::type<Left>()),
get_python_type_name(python::type<Right>()));
}
};
@@ -364,7 +367,8 @@ namespace detail
PyObject* description() const
{
return function_signature(python::type<Left>(), python::type<Right>());
return function_signature(get_python_type_name(python::type<Left>()),
get_python_type_name(python::type<Right>()));
}
};
@@ -403,7 +407,8 @@ namespace detail
PyObject* description() const
{
return function_signature(python::type<Left>(), python::type<Right>());
return function_signature(get_python_type_name(python::type<Left>()),
get_python_type_name(python::type<Right>()));
}
};
@@ -433,7 +438,8 @@ namespace detail
PyObject* description() const
{
return function_signature(python::type<Left>(), python::type<Right>());
return function_signature(get_python_type_name(python::type<Left>()),
get_python_type_name(python::type<Right>()));
}
};
@@ -468,7 +474,8 @@ namespace detail
PyObject* description() const
{
return function_signature(python::type<Left>(), python::type<Right>());
return function_signature(get_python_type_name(python::type<Left>()),
get_python_type_name(python::type<Right>()));
}
};
@@ -495,7 +502,8 @@ namespace detail
PyObject* description() const
{
return function_signature(python::type<Left>(), python::type<Right>());
return function_signature(get_python_type_name(python::type<Left>()),
get_python_type_name(python::type<Right>()));
}
};
@@ -536,7 +544,7 @@ namespace detail
PyObject* description() const
{
return function_signature(python::type<operand>());
return function_signature(get_python_type_name(python::type<operand>()));
}
};