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
This commit is contained in:
Logan Johnson 2003-09-19 22:05:08 +00:00
commit f994b747b2
2 changed files with 63 additions and 0 deletions

View file

@ -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 \

View file

@ -0,0 +1,62 @@
%module lib_std_pair
%include "std_pair.i"
namespace std {
%template(IntPair) pair<int, int>;
}
%inline %{
/* Test the "out" typemap for pair<T, U> */
std::pair<int, int> 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<int, int> * makeIntPairPtr(int a, int b) {
static std::pair<int, int> 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<int, int>& makeIntPairRef(int a, int b) {
static std::pair<int, int> 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<int, int> & makeIntPairConstRef(int a, int b) {
static std::pair<int, int> p = std::make_pair(a, b);
return p;
}
/* Test the "in" typemap for pair<T, U> */
int product1(std::pair<int, int> p) {
return p.first*p.second;
}
/* Test the "in" typemap for const pair<T, U>& */
int product2(const std::pair<int, int>& p) {
return p.first*p.second;
}
/* Test the "in" typemap for const pair<T, U>* */
int product3(const std::pair<int, int> *p) {
return p->first*p->second;
}
%}