PageRenderTime 67ms CodeModel.GetById 1ms app.highlight 52ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/rel-1.3.35/Examples/test-suite/mixed_types.i

#
Swig | 164 lines | 121 code | 42 blank | 1 comment | 0 complexity | 82f8e123dcd8bab1f60631ee5d503fb8 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1%module mixed_types
  2
  3%warnfilter(SWIGWARN_RUBY_WRONG_NAME) hi; /* Ruby, wrong constant name */
  4%warnfilter(SWIGWARN_RUBY_WRONG_NAME) 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
133typedef enum {One, Two, Three, Four, Five} finger;
134
135typedef struct {
136    double         double_field;
137} SimpleStruct;
138
139char           array_c [ARRAY_LEN_X][ARRAY_LEN_Y];
140signed char    array_sc[ARRAY_LEN_X][ARRAY_LEN_Y];
141unsigned char  array_uc[ARRAY_LEN_X][ARRAY_LEN_Y];
142short          array_s [ARRAY_LEN_X][ARRAY_LEN_Y];
143unsigned short array_us[ARRAY_LEN_X][ARRAY_LEN_Y];
144int            array_i [ARRAY_LEN_X][ARRAY_LEN_Y];
145unsigned int   array_ui[ARRAY_LEN_X][ARRAY_LEN_Y];
146long           array_l [ARRAY_LEN_X][ARRAY_LEN_Y];
147unsigned long  array_ul[ARRAY_LEN_X][ARRAY_LEN_Y];
148long long      array_ll[ARRAY_LEN_X][ARRAY_LEN_Y];
149float          array_f [ARRAY_LEN_X][ARRAY_LEN_Y];
150double         array_d [ARRAY_LEN_X][ARRAY_LEN_Y];
151SimpleStruct   array_struct[ARRAY_LEN_X][ARRAY_LEN_Y];
152SimpleStruct*  array_structpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
153int*           array_ipointers [ARRAY_LEN_X][ARRAY_LEN_Y];
154finger         array_enum[ARRAY_LEN_X][ARRAY_LEN_Y];
155finger*        array_enumpointers[ARRAY_LEN_X][ARRAY_LEN_Y];
156const int      array_const_i[ARRAY_LEN_X][ARRAY_LEN_Y] = { {10, 11, 12, 13}, {14, 15, 16, 17} };
157
158void fn_taking_arrays(SimpleStruct array_struct[ARRAY_LEN_X][ARRAY_LEN_Y]) {}
159
160int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){
161    return array[x][y];
162}
163%}
164