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

« back to all changes in this revision

Viewing changes to Examples/test-suite/mixed_types.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 mixed_types
 
2
 
 
3
%warnfilter(801) hi; /* Ruby, wrong constant name */
 
4
%warnfilter(801) hello; /* Ruby, wrong constant name */
 
5
 
 
6
%inline 
 
7
{
 
8
  const void* ref_pointer(const void*& a) {
 
9
    return a;
 
10
  }
 
11
 
 
12
  struct A
 
13
  {
 
14
  };
 
15
  
 
16
  const A* ref_pointer(A* const& a) {
 
17
    return a;
 
18
  }
 
19
 
 
20
  const A** ref_pointer_1(const A**& a) {
 
21
    return a;
 
22
  }
 
23
 
 
24
  A* pointer_1(A* a) {
 
25
    return a;
 
26
  }
 
27
 
 
28
  const A& ref_const(const A& a) {
 
29
    return a;
 
30
  }
 
31
 
 
32
  enum Hello { hi,hello };
 
33
 
 
34
  int sint(int a) {
 
35
    return a;
 
36
  }
 
37
 
 
38
  const int& ref_int(const int& a) {
 
39
    return a;
 
40
  }
 
41
 
 
42
  Hello senum(Hello a) {
 
43
    return a;
 
44
  }
 
45
  
 
46
  const Hello& ref_enum(const Hello& a) {
 
47
    return a;
 
48
  }  
 
49
 
 
50
  typedef A *Aptr;
 
51
  const Aptr& rptr_const(const Aptr& a) {
 
52
    return a;
 
53
  }
 
54
 
 
55
  const Aptr& rptr_const2(const Aptr& a) {
 
56
    return a;
 
57
  }
 
58
 
 
59
  const void*& rptr_void(const void*& a) {
 
60
    return a;
 
61
  }
 
62
 
 
63
  const A& cref_a(const A& a) {
 
64
    return a;
 
65
  }
 
66
 
 
67
  A& ref_a(A& a) {
 
68
    return a;
 
69
  }
 
70
 
 
71
 
 
72
  template <class T> struct NameT {
 
73
  };
 
74
  
 
75
  
 
76
  typedef char name[8];
 
77
  typedef char namea[];
 
78
 
 
79
  typedef NameT<char> name_t[8];
 
80
  
 
81
  char* test_a(char hello[8],
 
82
               char hi[],
 
83
               const char chello[8],
 
84
               const char chi[]) {
 
85
    return hi;
 
86
  }
 
87
 
 
88
  int test_b(name n2) {
 
89
    return 1;
 
90
  }
 
91
 
 
92
/* gcc doesn't like this one. Removing until reason resolved.*/
 
93
  int test_c(const name& n1) {
 
94
    return 1;
 
95
  }
 
96
 
 
97
  int test_d(name* n1) {
 
98
    return 1;
 
99
  }
 
100
 
 
101
  int test_e(const name_t& n1) {
 
102
    return 1;
 
103
  }
 
104
 
 
105
  int test_f(name_t n1) {
 
106
    return 1;
 
107
  }
 
108
 
 
109
  int test_g(name_t* n1) {
 
110
    return 1;
 
111
  }
 
112
 
 
113
  struct Foo 
 
114
  {
 
115
    int foo(const Aptr&a);
 
116
    int foon(const char (&a)[8]);
 
117
  };
 
118
 
 
119
  inline int Foo::foo(A* const& a) { return 1; }
 
120
 
 
121
}
 
122
 
 
123
%{
 
124
  inline int Foo::foon(const name& a) { return a[0]; }
 
125
%}
 
126
 
 
127
 
 
128
 
 
129
%inline %{
 
130
#define ARRAY_LEN_X 2
 
131
#define ARRAY_LEN_Y 4
 
132
 
 
133
typedef enum {One, Two, Three, Four, Five} finger;
 
134
 
 
135
typedef struct {
 
136
    double         double_field;
 
137
} SimpleStruct;
 
138
 
 
139
char           array_c [ARRAY_LEN_X][ARRAY_LEN_Y];
 
140
signed char    array_sc[ARRAY_LEN_X][ARRAY_LEN_Y];
 
141
unsigned char  array_uc[ARRAY_LEN_X][ARRAY_LEN_Y];
 
142
short          array_s [ARRAY_LEN_X][ARRAY_LEN_Y];
 
143
unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y];
 
144
int            array_i [ARRAY_LEN_X][ARRAY_LEN_Y];
 
145
unsigned int   array_ui[ARRAY_LEN_X][ARRAY_LEN_Y];
 
146
long           array_l [ARRAY_LEN_X][ARRAY_LEN_Y];
 
147
unsigned long  array_ul[ARRAY_LEN_X][ARRAY_LEN_Y];
 
148
long long      array_ll[ARRAY_LEN_X][ARRAY_LEN_Y];
 
149
float          array_f [ARRAY_LEN_X][ARRAY_LEN_Y];
 
150
double         array_d [ARRAY_LEN_X][ARRAY_LEN_Y];
 
151
SimpleStruct   array_struct[ARRAY_LEN_X][ARRAY_LEN_Y];
 
152
SimpleStruct*  array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
 
153
int*           array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y];
 
154
finger         array_enum[ARRAY_LEN_X][ARRAY_LEN_Y];
 
155
finger*        array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
 
156
const int      array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} };
 
157
 
 
158
void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {}
 
159
 
 
160
int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){
 
161
    return array[x][y];
 
162
}
 
163
%}
 
164