~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Examples/test-suite/li_std_pair.i

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-09-01 18:35:55 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050901183555-eq59uwhq8b62e44c
Tags: 1.3.24-1ubuntu4
* Use php5-dev instead of php4-dev, to kick php4 out of main.
* Drop support for generation of pike bindings, as nothing uses it,
  and swig is the only thing keeping pike7.6 in main (Ubuntu #13796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%module li_std_pair
 
2
 
 
3
%include "std_pair.i"
 
4
 
 
5
namespace std {
 
6
    %template(IntPair) pair<int, int>;
 
7
}
 
8
 
 
9
%inline %{
 
10
 
 
11
/* Test the "out" typemap for pair<T, U> */
 
12
std::pair<int, int> makeIntPair(int a, int b) {
 
13
    return std::make_pair(a, b);
 
14
}
 
15
 
 
16
/**
 
17
 * There is no "out" typemap for a pointer to a pair, so
 
18
 * this should return a wrapped instance of a std::pair
 
19
 * instead of the native "array" type for the target language.
 
20
 */
 
21
std::pair<int, int> * makeIntPairPtr(int a, int b) {
 
22
    static std::pair<int, int> p = std::make_pair(a, b);
 
23
    return &p;
 
24
}
 
25
 
 
26
/**
 
27
 * There is no "out" typemap for a non-const reference to a pair, so
 
28
 * this should return a wrapped instance of a std::pair instead of
 
29
 * the native "array" type for the target language.
 
30
 */
 
31
std::pair<int, int>& makeIntPairRef(int a, int b) {
 
32
    static std::pair<int, int> p = std::make_pair(a, b);
 
33
    return p;
 
34
}
 
35
 
 
36
/**
 
37
 * There is no "out" typemap for a const reference to a pair, so
 
38
 * this should return a wrapped instance of a std::pair
 
39
 * instead of the native "array" type for the target language.
 
40
 */
 
41
const std::pair<int, int> & makeIntPairConstRef(int a, int b) {
 
42
    static std::pair<int, int> p = std::make_pair(a, b);
 
43
    return p;
 
44
}
 
45
 
 
46
/* Test the "in" typemap for pair<T, U> */
 
47
int product1(std::pair<int, int> p) {
 
48
    return p.first*p.second;
 
49
}
 
50
 
 
51
/* Test the "in" typemap for const pair<T, U>& */
 
52
int product2(const std::pair<int, int>& p) {
 
53
    return p.first*p.second;
 
54
}
 
55
 
 
56
/* Test the "in" typemap for const pair<T, U>* */
 
57
int product3(const std::pair<int, int> *p) {
 
58
    return p->first*p->second;
 
59
}
 
60
 
 
61
%}
 
62