From f994b747b2b766022b1518f42e2cbab49e7bfa1d Mon Sep 17 00:00:00 2001 From: Logan Johnson Date: Fri, 19 Sep 2003 22:05:08 +0000 Subject: [PATCH] Added a new test case for the std_pair.i library module. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5126 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Examples/test-suite/common.mk | 1 + SWIG/Examples/test-suite/lib_std_pair.i | 62 +++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 SWIG/Examples/test-suite/lib_std_pair.i diff --git a/SWIG/Examples/test-suite/common.mk b/SWIG/Examples/test-suite/common.mk index 761dc26a0..cb2745d74 100644 --- a/SWIG/Examples/test-suite/common.mk +++ b/SWIG/Examples/test-suite/common.mk @@ -131,6 +131,7 @@ CPP_TEST_CASES += \ lib_cdata \ lib_cpointer \ lib_std_deque \ + lib_std_pair \ lib_std_string \ lib_std_vector \ lib_typemaps \ diff --git a/SWIG/Examples/test-suite/lib_std_pair.i b/SWIG/Examples/test-suite/lib_std_pair.i new file mode 100644 index 000000000..ca694468c --- /dev/null +++ b/SWIG/Examples/test-suite/lib_std_pair.i @@ -0,0 +1,62 @@ +%module lib_std_pair + +%include "std_pair.i" + +namespace std { + %template(IntPair) pair; +} + +%inline %{ + +/* Test the "out" typemap for pair */ +std::pair makeIntPair(int a, int b) { + return std::make_pair(a, b); +} + +/** + * There is no "out" typemap for a pointer to a pair, so + * this should return a wrapped instance of a std::pair + * instead of the native "array" type for the target language. + */ +std::pair * makeIntPairPtr(int a, int b) { + static std::pair p = std::make_pair(a, b); + return &p; +} + +/** + * There is no "out" typemap for a non-const reference to a pair, so + * this should return a wrapped instance of a std::pair instead of + * the native "array" type for the target language. + */ +std::pair& makeIntPairRef(int a, int b) { + static std::pair p = std::make_pair(a, b); + return p; +} + +/** + * There is no "out" typemap for a const reference to a pair, so + * this should return a wrapped instance of a std::pair + * instead of the native "array" type for the target language. + */ +const std::pair & makeIntPairConstRef(int a, int b) { + static std::pair p = std::make_pair(a, b); + return p; +} + +/* Test the "in" typemap for pair */ +int product1(std::pair p) { + return p.first*p.second; +} + +/* Test the "in" typemap for const pair& */ +int product2(const std::pair& p) { + return p.first*p.second; +} + +/* Test the "in" typemap for const pair* */ +int product3(const std::pair *p) { + return p->first*p->second; +} + +%} +