From dcb94e7d4aa455cc97336e41d804654c60465529 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Thu, 10 Jul 2003 12:42:42 +0000 Subject: [PATCH] std::pair added (but not very much tested) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4959 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 + Lib/guile/std_pair.i | 845 ++++++++++++++++++++++++++++++++ Lib/java/std_pair.i | 31 ++ Lib/mzscheme/std_pair.i | 845 ++++++++++++++++++++++++++++++++ Lib/ocaml/std_pair.i | 31 ++ Lib/perl5/std_pair.i | 31 ++ Lib/php4/std_pair.i | 31 ++ Lib/python/std_pair.i | 1006 +++++++++++++++++++++++++++++++++++++++ Lib/ruby/std_pair.i | 925 +++++++++++++++++++++++++++++++++++ Lib/stl.i | 1 + Lib/swig.swg | 1 + Lib/tcl/std_pair.i | 31 ++ 12 files changed, 3782 insertions(+) create mode 100644 Lib/guile/std_pair.i create mode 100644 Lib/java/std_pair.i create mode 100644 Lib/mzscheme/std_pair.i create mode 100644 Lib/ocaml/std_pair.i create mode 100644 Lib/perl5/std_pair.i create mode 100644 Lib/php4/std_pair.i create mode 100644 Lib/python/std_pair.i create mode 100644 Lib/ruby/std_pair.i create mode 100644 Lib/tcl/std_pair.i diff --git a/CHANGES.current b/CHANGES.current index 341a96fc7..ed647a451 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.20 (In progress) ============================ +07/10/2003: ballabio (Luigi Ballabio) + [Almost all languages] Wrappers for std::pair added. + Typemaps for Python, Ruby, Guile and MzScheme. + 07/01/2003: mkoeppe (Matthias Koeppe) [Chicken] Handle the case of more than one argout typemap per function. diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i new file mode 100644 index 000000000..6a1ab7318 --- /dev/null +++ b/Lib/guile/std_pair.i @@ -0,0 +1,845 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Guile implementation + +%include std_common.i + + +// ------------------------------------------------------------------------ +// std::pair +// +// See std_vector.i for the rationale of typemap application +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + %typemap(in) pair (std::pair* m) { + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(x,y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(x,y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + T* x = new T($1.first); + U* y = new U($1.second); + SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = gh_cons(first,second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + + + // specializations for built-ins + + %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) + template struct pair { + %typemap(in) pair (std::pair* m) { + if (gh_pair_p($input)) { + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(CONVERT_FROM(first),y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (gh_pair_p($input)) { + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(CONVERT_FROM(first),y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + U* y = new U($1.second); + SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = gh_cons(CONVERT_TO($1.first),second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (gh_pair_p($input)) { + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (gh_pair_p($input)) { + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) + template struct pair { + %typemap(in) pair (std::pair* m) { + if (gh_pair_p($input)) { + T* x; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + $1 = std::make_pair(x,CONVERT_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (gh_pair_p($input)) { + T* x; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + temp = std::make_pair(x,CONVERT_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + T* x = new T($1.first); + SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + $result = gh_cons(first,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, + U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) + template<> struct pair { + %typemap(in) pair (std::pair* m) { + if (gh_pair_p($input)) { + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + $1 = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (gh_pair_p($input)) { + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + temp = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + $result = gh_cons(CONVERT_T_TO($1.first), + CONVERT_U_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (gh_pair_p($input)) { + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (gh_pair_p($input)) { + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + + specialize_std_pair_on_first(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_first(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_first(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_first(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_second(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_second(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_second(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_second(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); +} diff --git a/Lib/java/std_pair.i b/Lib/java/std_pair.i new file mode 100644 index 000000000..f34bfc512 --- /dev/null +++ b/Lib/java/std_pair.i @@ -0,0 +1,31 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Common implementation + +%include std_common.i +%include exception.i + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + // add typemaps here + T first; + U second; + }; + + // add specializations here + +} diff --git a/Lib/mzscheme/std_pair.i b/Lib/mzscheme/std_pair.i new file mode 100644 index 000000000..bccd9f0b0 --- /dev/null +++ b/Lib/mzscheme/std_pair.i @@ -0,0 +1,845 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// MzScheme implementation + +%include std_common.i + + +// ------------------------------------------------------------------------ +// std::pair +// +// See std_vector.i for the rationale of typemap application +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + %typemap(in) pair (std::pair* m) { + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = make_pair(x,y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = make_pair(x,y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + T* x = new T($1.first); + U* y = new U($1.second); + Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = scheme_make_pair(first,second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + + // specializations for built-ins + + %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) + template struct pair { + %typemap(in) pair (std::pair* m) { + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = make_pair(CONVERT_FROM(first),y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = make_pair(CONVERT_FROM(first),y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + U* y = new U($1.second); + Scheme_Object* second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = scheme_make_pair(CONVERT_TO($1.first),second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + U* y; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) + template struct pair { + %typemap(in) pair (std::pair* m) { + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + $1 = make_pair(x,CONVERT_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = make_pair(x,CONVERT_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + T* x = new T($1.first); + Scheme_Object* first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + $result = scheme_make_pair(first,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + T* x; + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) != -1 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, + U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) + template<> struct pair { + %typemap(in) pair (std::pair* m) { + if (SCHEME_PAIRP($input)) { + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + $1 = make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* m), + const pair* (std::pair temp, + std::pair* m) { + if (SCHEME_PAIRP($input)) { + Scheme_Object *first, *second; + first = scheme_car($input); + second = scheme_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair { + $result = scheme_make_pair(CONVERT_T_TO($1.first), + CONVERT_U_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native pair? */ + if (SCHEME_PAIRP($input)) { + Scheme_Object* first = scheme_car($input); + Scheme_Object* second = scheme_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + + specialize_std_pair_on_first(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_first(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_first(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_first(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_first(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + + specialize_std_pair_on_second(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_second(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_second(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_second(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_second(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + bool,SCHEME_BOOLP, + SCHEME_TRUEP,swig_make_boolean); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned int,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned short,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + unsigned long,SCHEME_INTP, + SCHEME_INT_VAL,scheme_make_integer_value); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + double,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + float,SCHEME_REALP, + scheme_real_to_double,scheme_make_double); + specialize_std_pair_on_both(std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string, + std::string,SCHEME_STRINGP, + swig_scm_to_string,swig_make_string); +} diff --git a/Lib/ocaml/std_pair.i b/Lib/ocaml/std_pair.i new file mode 100644 index 000000000..f34bfc512 --- /dev/null +++ b/Lib/ocaml/std_pair.i @@ -0,0 +1,31 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Common implementation + +%include std_common.i +%include exception.i + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + // add typemaps here + T first; + U second; + }; + + // add specializations here + +} diff --git a/Lib/perl5/std_pair.i b/Lib/perl5/std_pair.i new file mode 100644 index 000000000..f34bfc512 --- /dev/null +++ b/Lib/perl5/std_pair.i @@ -0,0 +1,31 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Common implementation + +%include std_common.i +%include exception.i + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + // add typemaps here + T first; + U second; + }; + + // add specializations here + +} diff --git a/Lib/php4/std_pair.i b/Lib/php4/std_pair.i new file mode 100644 index 000000000..f34bfc512 --- /dev/null +++ b/Lib/php4/std_pair.i @@ -0,0 +1,31 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Common implementation + +%include std_common.i +%include exception.i + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + // add typemaps here + T first; + U second; + }; + + // add specializations here + +} diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i new file mode 100644 index 000000000..2381c0b87 --- /dev/null +++ b/Lib/python/std_pair.i @@ -0,0 +1,1006 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Python implementation + +%include std_common.i + + +// ------------------------------------------------------------------------ +// std::pair +// +// See std_vector.i for the rationale of typemap application +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + %typemap(in) pair (std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + T* x; + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + $1 = std::make_pair(x,y); + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) { + $1 = *p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + T* x; + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + temp = std::make_pair(x,y); + $1 = &temp; + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) { + $1 = p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(out) pair { + $result = PyTuple_New(2); + T* x = new T($1.first); + U* y = new U($1.second); + PyTuple_SetItem($result,0, + SWIG_NewPointerObj((void *) x, + $descriptor(T *), 1)); + PyTuple_SetItem($result,1, + SWIG_NewPointerObj((void *) y, + $descriptor(U *), 1)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + T* x; + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + T* x; + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + + + // specializations for built-ins + + %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) + template struct pair { + %typemap(in) pair (std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + $1 = std::make_pair(CONVERT_FROM(first),y); + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) { + $1 = *p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + temp = std::make_pair(CONVERT_FROM(first),y); + $1 = &temp; + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) { + $1 = p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(out) pair { + $result = PyTuple_New(2); + U* y = new U($1.second); + PyTuple_SetItem($result,0,CONVERT_TO($1.first)); + PyTuple_SetItem($result,1, + SWIG_NewPointerObj((void *) y, + $descriptor(U *), 1)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + U* y; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) + template struct pair { + %typemap(in) pair (std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + T* x; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + CHECK(second)) { + $1 = std::make_pair(x,CONVERT_FROM(second)); + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) { + $1 = *p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + T* x; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + CHECK(second)) { + temp = std::make_pair(x,CONVERT_FROM(second)); + $1 = &temp; + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) { + $1 = p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(out) pair { + $result = PyTuple_New(2); + T* x = new T($1.first); + PyTuple_SetItem($result,0, + SWIG_NewPointerObj((void *) x, + $descriptor(T *), 1)); + PyTuple_SetItem($result,1,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + T* x; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + T* x; + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, + U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) + template<> struct pair { + %typemap(in) pair (std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) { + $1 = *p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK_T(first) && CHECK_U(second)) { + temp = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + $1 = &temp; + Py_DECREF(first); + Py_DECREF(second); + } else { + Py_DECREF(first); + Py_DECREF(second); + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } else if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) { + $1 = p; + } else { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + } + %typemap(out) pair { + $result = PyTuple_New(2); + PyTuple_SetItem($result,0,CONVERT_T_FROM($1.first)); + PyTuple_SetItem($result,1,CONVERT_U_FROM($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native sequence? */ + if (PyTuple_Check($input)) { + if (PyTuple_Size($input) != 2) { + /* not a pair anyway */ + $1 = 0; + } else { + PyObject* first = PySequence_GetItem($input,0); + PyObject* second = PySequence_GetItem($input,1); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + specialize_std_pair_on_first(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_first(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_first(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_first(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_first(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_first(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_first(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong, + PyLong_FromUnsignedLong); + specialize_std_pair_on_first(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_first(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_first(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + + specialize_std_pair_on_second(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_second(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_second(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_second(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_second(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_second(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_second(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong, + PyLong_FromUnsignedLong); + specialize_std_pair_on_second(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_second(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_second(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + bool,PyInt_Check, + PyInt_AsLong,SwigInt_FromBool); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + long,PyLong_Check, + PyLong_AsLong,PyLong_FromLong); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + unsigned int,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + unsigned short,PyInt_Check, + PyInt_AsLong,PyInt_FromLong); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + unsigned long,PyLong_Check, + PyLong_AsUnsignedLong,PyLong_FromUnsignedLong); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + double,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + float,SwigNumber_Check, + SwigNumber_AsDouble,PyFloat_FromDouble); + specialize_std_pair_on_both(std::string,PyString_Check, + SwigString_AsString,SwigString_FromString, + std::string,PyString_Check, + SwigString_AsString,SwigString_FromString); + +} diff --git a/Lib/ruby/std_pair.i b/Lib/ruby/std_pair.i new file mode 100644 index 000000000..e73887f0b --- /dev/null +++ b/Lib/ruby/std_pair.i @@ -0,0 +1,925 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Ruby implementation + +%include std_common.i + + +// ------------------------------------------------------------------------ +// std::pair +// +// See std_vector.i for the rationale of typemap application +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + %typemap(in) pair (std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + T* x; + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1); + SWIG_ConvertPtr(second, (void **) &y, $descriptor(U *), 1); + $1 = std::make_pair(x,y); + } else { + SWIG_ConvertPtr($input, (void **) &p, $&1_descriptor, 1); + $1 = *p; + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + T* x; + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1); + SWIG_ConvertPtr(second, (void **) &y, $descriptor(U *), 1); + temp = std::make_pair(x,y); + $1 = &temp; + } else { + SWIG_ConvertPtr($input, (void **) &p, $1_descriptor, 1); + $1 = p; + } + } + %typemap(out) pair { + $result = rb_ary_new2(2); + T* x = new T($1.first); + U* y = new U($1.second); + rb_ary_store($result,0, + SWIG_NewPointerObj((void *) x, + $descriptor(T *), 1)); + rb_ary_store($result,1, + SWIG_NewPointerObj((void *) y, + $descriptor(U *), 1)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + T* x; + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cHash)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + T* x; + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped map? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + + // specializations for built-ins + + %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) + + template struct pair { + %typemap(in) pair (std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + SWIG_ConvertPtr(second, (void **) &y, $descriptor(U *), 1); + $1 = std::make_pair(CONVERT_FROM(first),y); + } else { + SWIG_ConvertPtr($input, (void **) &p, $&1_descriptor, 1); + $1 = *p; + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + SWIG_ConvertPtr(second, (void **) &y, $descriptor(U *), 1); + temp = std::make_pair(CONVERT_FROM(first),y); + $1 = &temp; + } else { + SWIG_ConvertPtr($input, (void **) &p, $1_descriptor, 1); + $1 = p; + } + } + %typemap(out) pair { + $result = rb_ary_new2(2); + U* y = new U($1.second); + rb_ary_store($result,0,CONVERT_TO($1.first)); + rb_ary_store($result,1, + SWIG_NewPointerObj((void *) y, + $descriptor(U *), 1)); + } + %typecheck(SWIG_TYPECHECK_MAP) pair { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (CHECK(first) && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const pair&, + const pair* { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cHash)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + U* y; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (CHECK(first) && + SWIG_ConvertPtr(second,(void **) &y, + $descriptor(U *),0) != -1) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped map? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) + + template struct pair { + %typemap(in) pair (std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + T* x; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + $1 = std::make_pair(x,CONVERT_FROM(second)); + } else { + SWIG_ConvertPtr($input, (void **) &p, $&1_descriptor, 1); + $1 = *p; + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + T* x; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = std::make_pair(x,CONVERT_FROM(second)); + $1 = &temp; + } else { + SWIG_ConvertPtr($input, (void **) &p, $1_descriptor, 1); + $1 = p; + } + } + %typemap(out) pair { + $result = rb_ary_new2(2); + T* x = new T($1.first); + rb_ary_store($result,0, + SWIG_NewPointerObj((void *) x, + $descriptor(T *), 1)); + rb_ary_store($result,1,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + T* x; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + CHECK(second)) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cHash)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + T* x; + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (SWIG_ConvertPtr(first,(void **) &x, + $descriptor(T *),0) != -1 && + CHECK(second)) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped map? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + %define specialize_std_map_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, + U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) + template<> struct pair { + %typemap(in) pair (std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + $1 = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + } else { + SWIG_ConvertPtr($input, (void **) &p, $&1_descriptor, 1); + $1 = *p; + } + } + %typemap(in) const pair& (std::pair temp, + std::pair* p), + const pair* (std::pair temp, + std::pair* p) { + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + } + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + $1 = &temp; + } else { + SWIG_ConvertPtr($input, (void **) &p, $1_descriptor, 1); + $1 = p; + } + } + %typemap(out) pair { + $result = rb_ary_new2(2); + rb_ary_store($result,0,CONVERT_T_TO($1.first)); + rb_ary_store($result,1,CONVERT_U_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cArray)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (CHECK_T(first) && CHECK_U(second)) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $&1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair&, + const pair* { + /* native sequence? */ + if (rb_obj_is_kind_of($input,rb_cHash)) { + unsigned int size = RARRAY($input)->len; + if (size != 2) { + /* not a pair */ + $1 = 0; + } else { + VALUE first = RARRAY($input)->ptr[0]; + VALUE second = RARRAY($input)->ptr[1]; + if (CHECK_T(first) && CHECK_U(second)) + $1 = 1; + else + $1 = 0; + } + } else { + /* wrapped map? */ + std::pair* p; + if (SWIG_ConvertPtr($input,(void **) &p, + $1_descriptor,0) != -1) + $1 = 1; + else + $1 = 0; + } + } + T first; + U second; + }; + %enddef + + + specialize_std_pair_on_first(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_first(int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_first(short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_first(long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_first(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_first(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_first(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_first(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_first(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_first(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + + specialize_std_pair_on_second(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_second(int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_second(short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_second(long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_second(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_second(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_second(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_second(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_second(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_second(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(int,FIXNUM_P, + FIX2INT,INT2NUM, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(short,FIXNUM_P, + FIX2INT,INT2NUM, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(long,FIXNUM_P, + FIX2INT,INT2NUM, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(unsigned int,FIXNUM_P, + FIX2INT,INT2NUM, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(unsigned short,FIXNUM_P, + FIX2INT,INT2NUM, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(unsigned long,FIXNUM_P, + FIX2INT,INT2NUM, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + bool,SWIG_BOOL_P, + SWIG_RB2BOOL,SWIG_BOOL2RB); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + unsigned int,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + unsigned short,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + unsigned long,FIXNUM_P, + FIX2INT,INT2NUM); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + double,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + float,SWIG_FLOAT_P, + SWIG_NUM2DBL,rb_float_new); + specialize_std_pair_on_both(std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB, + std::string,SWIG_STRING_P, + SWIG_RB2STR,SWIG_STR2RB); +} diff --git a/Lib/stl.i b/Lib/stl.i index 3cf0ef797..a11218efb 100644 --- a/Lib/stl.i +++ b/Lib/stl.i @@ -9,4 +9,5 @@ %include std_string.i %include std_vector.i %include std_map.i +%include std_pair.i diff --git a/Lib/swig.swg b/Lib/swig.swg index a454a28d7..9e1fe888f 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -240,6 +240,7 @@ namespace std { %define SWIG_TYPECHECK_STRING 140 %enddef %define SWIG_TYPECHECK_VECTOR 150 %enddef %define SWIG_TYPECHECK_MAP 160 %enddef +%define SWIG_TYPECHECK_PAIR 170 %enddef %define SWIG_TYPECHECK_BOOL_ARRAY 1015 %enddef %define SWIG_TYPECHECK_INT8_ARRAY 1025 %enddef diff --git a/Lib/tcl/std_pair.i b/Lib/tcl/std_pair.i new file mode 100644 index 000000000..f34bfc512 --- /dev/null +++ b/Lib/tcl/std_pair.i @@ -0,0 +1,31 @@ +// +// SWIG typemaps for std::pair +// Luigi Ballabio +// July 2003 +// +// Common implementation + +%include std_common.i +%include exception.i + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include +%} + +// exported class + +namespace std { + + template struct pair { + // add typemaps here + T first; + U second; + }; + + // add specializations here + +}