miriad 4.1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/miriad_ruby.i ADDED
@@ -0,0 +1,443 @@
1
+ /* Ruby specific typemaps for MIRIAD Swig wrapper */
2
+
3
+ #if defined SWIGRUBY
4
+
5
+ %{
6
+ VALUE mirlib_eMirlibError;
7
+ %}
8
+
9
+ %init %{
10
+ mirlib_eMirlibError = rb_define_class("MirlibError", rb_eStandardError);
11
+ %}
12
+
13
+ // Requires NArray Ruby extension
14
+ %include "narray_ruby.swg"
15
+
16
+ // Typemaps for preamble
17
+ %typemap(in) (double *preamble) {
18
+ // If FIXNUM allocate NA_DFLOAT array that many
19
+ // This only makes sense for reads (or writing zeros)
20
+ if(TYPE($input) == T_FIXNUM) {
21
+ int rank = 1;
22
+ int shape = FIX2INT($input);
23
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
24
+ $input = na_make_object(NA_DFLOAT,rank,&shape,naclass);
25
+ }
26
+ // If NArray
27
+ if(NA_IsNArray($input)) {
28
+ Check_NArrayType($input,NA_DFLOAT);
29
+ $1 = NA_PTR_TYPE($input,$1_type);
30
+ } else {
31
+ int i;
32
+ Check_Type($input, T_ARRAY);
33
+ // Get the length of the array
34
+ // TODO Bounds checking somehow?
35
+ int n = RARRAY($input)->len;
36
+ $1 = ALLOCA_N(double, n);
37
+ // Get the first element in array
38
+ VALUE *ptr = RARRAY($input)->ptr;
39
+ for (i=0; i < n; i++) {
40
+ // Convert Ruby Object to double
41
+ $1[i] = NUM2DBL(ptr[i]);
42
+ }
43
+ }
44
+ }
45
+
46
+ %typemap(argout) (double *preamble) {
47
+ // If NArray, data are already in place
48
+ if(TYPE($input) == T_ARRAY) {
49
+ int i;
50
+ // Get the length of the array
51
+ // TODO Bounds checking somehow?
52
+ int n = RARRAY($input)->len;
53
+ // Get the first element in array
54
+ VALUE *ptr = RARRAY($input)->ptr;
55
+ for (i=0; i < n; i++) {
56
+ // Store or convert doubles to Ruby Objects
57
+ if(TYPE(ptr[i]) == T_FLOAT) {
58
+ // TODO Is this legit?
59
+ RFLOAT(ptr[i])->value = $1[i];
60
+ } else {
61
+ ptr[i] = rb_float_new($1[i]);
62
+ }
63
+ }
64
+ }
65
+ $result = SWIG_AppendOutput($result,$input);
66
+ }
67
+
68
+ // Typemaps for visibility data/flags/n
69
+ // Length of complex data must be twice the length of flags
70
+ %typemap(in) (float * data) (int ndata) {
71
+ int i;
72
+ // If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
73
+ // This only makes sense for reads (or writing zeros)
74
+ if(TYPE($input) == T_FIXNUM || TYPE($input) == T_BIGNUM) {
75
+ ndata = NUM2INT($input);
76
+ int rank = 1;
77
+ int shape = ndata;
78
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
79
+ $input = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
80
+ }
81
+ // If NArray
82
+ if(NA_IsNArray($input)) {
83
+ Check_NArrayType2($input,NA_SFLOAT,NA_SCOMPLEX);
84
+ $1 = NA_PTR_TYPE($input,$1_type);
85
+ ndata = NA_TOTAL($input);
86
+ if(NA_TYPE($input) == NA_SFLOAT) {
87
+ ndata /= 2;
88
+ }
89
+ } else {
90
+ Check_Type($input, T_ARRAY);
91
+ // Allocate C array on stack
92
+ ndata = RARRAY($input)->len;
93
+ $1 = ALLOCA_N(float,ndata);
94
+ VALUE * ptr = RARRAY($input)->ptr;
95
+ // TODO Use $symname in #if to avoid copying on read?
96
+ for(i=0; i < ndata; i++) {
97
+ $1[i] = NUM2DBL(ptr[i]);
98
+ }
99
+ ndata /= 2;
100
+ }
101
+ }
102
+
103
+ %typemap(argout) (float * data) {
104
+ int ndata;
105
+ int i;
106
+ // If NArray, data are already in place
107
+ if(TYPE($input) == T_ARRAY) {
108
+ ndata = RARRAY($input)->len;
109
+ VALUE * ptr = RARRAY($input)->ptr;
110
+ for(i=0; i < ndata; i++) {
111
+ // Store or convert doubles to Ruby Objects
112
+ if(TYPE(ptr[i]) == T_FLOAT) {
113
+ // TODO Is this legit?
114
+ RFLOAT(ptr[i])->value = $1[i];
115
+ } else {
116
+ ptr[i] = rb_float_new($1[i]);
117
+ }
118
+ }
119
+ }
120
+ $result = SWIG_AppendOutput($result,$input);
121
+ }
122
+
123
+ // Typemaps for visibility data/flags/n
124
+ // Passed as a two arguments
125
+ // Length of complex data must be twice the length of flags
126
+ %typemap(in) (int * flags, int n) (int nflag) {
127
+ int i;
128
+ // If FIXNUM or BIGNUM, allocate NA_LINT array that many
129
+ // This only makes sense for reads (or writing zeros)
130
+ if(TYPE($input) == T_FIXNUM || TYPE($input) == T_BIGNUM) {
131
+ nflag = NUM2INT($input);
132
+ int rank = 1;
133
+ int shape = nflag;
134
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
135
+ $input = na_make_object(NA_LINT,rank,&shape,naclass);
136
+ }
137
+ // If NArray
138
+ if(NA_IsNArray($input)) {
139
+ Check_NArrayType($input,NA_LINT);
140
+ $1 = NA_PTR_TYPE($input,$1_type);
141
+ nflag = NA_TOTAL($input);
142
+ } else {
143
+ Check_Type($input, T_ARRAY);
144
+ nflag = RARRAY($input)->len;
145
+ $1 = ALLOCA_N(int,nflag);
146
+ VALUE * ptr = RARRAY($input)->ptr;
147
+ for(i=0; i < nflag; i++) {
148
+ $1[i] = FIX2INT(ptr[i]);
149
+ }
150
+ }
151
+
152
+ $2 = nflag;
153
+ }
154
+
155
+ %typemap(argout) (int * flags, int n) {
156
+ int nflag;
157
+ int i;
158
+ // If NArray, data are already in place
159
+ if(TYPE($input) == T_ARRAY) {
160
+ nflag = RARRAY($input)->len;
161
+ VALUE * ptr = RARRAY($input)->ptr;
162
+ for(i=0; i < nflag; i++) {
163
+ ptr[i] = INT2FIX($1[i]);
164
+ }
165
+ }
166
+ $result = SWIG_AppendOutput($result,$input);
167
+ }
168
+
169
+ %typemap(check) (double * preamble, float * data, int * flags, int n) {
170
+ if(ndata3 != nflag4) {
171
+ rb_raise(rb_eArgError,
172
+ "lengths of complex data (%d) and flags (%d) do not match", ndata3, nflag4);
173
+ }
174
+ }
175
+
176
+ // Typemaps for "nread" parameter
177
+ // Set the input argument to point to a temporary variable
178
+ %typemap(in, numinputs=0) (int *nread) (int temp) {
179
+ $1 = &temp;
180
+ }
181
+
182
+ %typemap(argout) (int *nread) {
183
+ rb_ary_unshift($result,INT2NUM(*$1));
184
+ }
185
+
186
+ #if 0
187
+ // Maybe ($*1_ltype temp)?
188
+ %define PUTVRX_TYPEMAP(type_code, type, converter)
189
+ %typemap(in) (type * value, int n) (type temp)
190
+ {
191
+ // If NArray
192
+ if(NA_IsNArray($input)) {
193
+ Check_NArrayType($input,type_code);
194
+ $1 = NA_PTR_TYPE($input,$1_type);
195
+ $2 = NA_TOTAL($input);
196
+ } else if(TYPE($input) == T_ARRAY) {
197
+ int i;
198
+ // Get the length of the array
199
+ $2 = RARRAY($input)->len;
200
+ $1 = ALLOCA_N(type, $2);
201
+ // Get the first element in array
202
+ VALUE *ptr = RARRAY($input)->ptr;
203
+ for (i=0; i < $2; i++) {
204
+ // Convert Ruby Object to int
205
+ $1[i]= (type)converter(ptr[i]);
206
+ }
207
+ } else {
208
+ temp = ($*1_type)converter($input);
209
+ $1 = &temp;
210
+ $2 = 1;
211
+ }
212
+ }
213
+ %enddef
214
+
215
+ PUTVRX_TYPEMAP(NA_LINT,int,NUM2INT);
216
+ PUTVRX_TYPEMAP(NA_SFLOAT,float,NUM2DBL);
217
+ PUTVRX_TYPEMAP(NA_DFLOAT,double,NUM2DBL);
218
+ #endif
219
+
220
+ // putvr typemap. Converts from NArray or Ruby type
221
+ %typemap(in) (char * data, int n) (VALUE vinput, int datatype) {
222
+ // If NArray
223
+ if(NA_IsNArray($input)) {
224
+ int type_code = NA_TYPE($input);
225
+ switch(type_code) {
226
+ case NA_SINT:
227
+ case NA_LINT: datatype = H_INT; break;
228
+ case NA_SFLOAT: datatype = H_REAL; break;
229
+ case NA_DFLOAT: datatype = H_DBLE; break;
230
+ default:
231
+ rb_raise(rb_eTypeError, "unsupported type code '%s'",
232
+ na_typestring[type_code]);
233
+ }
234
+ $1 = NA_PTR_TYPE($input,char *);
235
+ $2 = NA_TOTAL($input);
236
+
237
+ // Else, treat as Ruby type
238
+ } else {
239
+ VALUE elem0 = $input;
240
+ if(TYPE($input) == T_ARRAY) {
241
+ $2 = RARRAY($input)->len;
242
+ elem0 = rb_ary_entry($input,0);
243
+ } else {
244
+ // Convert into one element array
245
+ $2 = 1;
246
+ $input = rb_ary_new3(1,$input);
247
+ }
248
+ // Autodetect Miriad type from Ruby type
249
+ // (Convenient, but not always a good idea)
250
+ switch(TYPE(elem0)) {
251
+ case T_FIXNUM:
252
+ case T_BIGNUM: datatype = H_INT; break;
253
+ case T_FLOAT: datatype = H_DBLE; break;
254
+ case T_STRING: datatype = H_BYTE; break;
255
+ default:
256
+ rb_raise(rb_eArgError,
257
+ "invalid or unsupported type for uv variable (%d)", TYPE(elem0));
258
+ }
259
+ }
260
+ vinput = $input;
261
+ }
262
+
263
+ // putvr typemap.
264
+ %typemap(in) (int type) {
265
+ $1 = NUM2INT($input);
266
+ switch($1) {
267
+ case 'a': $1 = H_BYTE; break;
268
+ case 'i': $1 = H_INT; break;
269
+ case 'd': $1 = H_DBLE; break;
270
+ case 'r': $1 = H_REAL; break;
271
+ }
272
+ }
273
+
274
+ // References "vinput" and "datatype" locals from previous typemap as "vinput3"
275
+ // and "datatype3"
276
+ %typemap(check) (char * data, int n, int type) {
277
+ int i;
278
+ if($3 == -1) {
279
+ // Autodetect from Ruby type
280
+ $3 = datatype3;
281
+ }
282
+ // NArray input will have already set pointer
283
+ if(TYPE(vinput3) == T_ARRAY) {
284
+ switch($3) {
285
+ case H_INT:
286
+ $1 = (char *)ALLOCA_N(int,$2);
287
+ for(i=0;i<$2;i++) {
288
+ ((int *)$1)[i] = NUM2INT(rb_ary_entry(vinput3,i));
289
+ }
290
+ break;
291
+ case H_REAL:
292
+ $1 = (char *)ALLOCA_N(double,$2);
293
+ for(i=0;i<$2;i++) {
294
+ ((float *)$1)[i] = NUM2DBL(rb_ary_entry(vinput3,i));
295
+ }
296
+ break;
297
+ case H_DBLE:
298
+ $1 = (char *)ALLOCA_N(double,$2);
299
+ for(i=0;i<$2;i++) {
300
+ ((double *)$1)[i] = NUM2DBL(rb_ary_entry(vinput3,i));
301
+ }
302
+ break;
303
+ case H_BYTE:
304
+ $1 = RSTRING(rb_ary_entry(vinput3,0))->ptr;
305
+ $2 = RSTRING(rb_ary_entry(vinput3,0))->len;
306
+ break;
307
+ default:
308
+ rb_raise(rb_eArgError,
309
+ "invalid or unsupported type for uv variable (%d)", $3);
310
+ }
311
+ }
312
+ }
313
+
314
+ // Typemap for getvr
315
+ %typemap(in) (char * name) {
316
+ $1 = StringValuePtr($input);
317
+ }
318
+
319
+ %typemap(in, numinputs=0) (void ** value, int * n, char * type) (void * value, int n, char type) {
320
+ value = NULL;
321
+ $1 = &value;
322
+ $2 = &n;
323
+ $3 = &type;
324
+ }
325
+
326
+ %typemap(argout) (void ** value, int * n, char * type) {
327
+ int i;
328
+ $result = Qnil;
329
+ if(n$argnum == 1 || type$argnum == 'a') {
330
+ switch(type$argnum) {
331
+ case 'a': $result = rb_tainted_str_new((char *)value$argnum, n$argnum);
332
+ break;
333
+ case 'i': $result = INT2NUM(*(int *)value$argnum);
334
+ break;
335
+ case 'r': $result = rb_float_new((double)*(float *)value$argnum);
336
+ break;
337
+ case 'd': $result = rb_float_new(*(double *)value$argnum);
338
+ break;
339
+ case ' ': // Variable not present
340
+ case 'j': // Unsuported
341
+ // Return NULL, but don't raise exception
342
+ break;
343
+ default: // TODO Raise exception
344
+ break;
345
+ }
346
+ } else if(n$argnum > 1) {
347
+ VALUE * elems = ALLOCA_N(VALUE,n$argnum);
348
+ switch(type$argnum) {
349
+ case 'i':
350
+ for(i = 0; i < n$argnum; i++) {
351
+ elems[i] = INT2NUM(((int *)value$argnum)[i]);
352
+ }
353
+ $result = rb_ary_new4(n$argnum,elems);
354
+ break;
355
+ case 'r':
356
+ for(i = 0; i < n$argnum; i++) {
357
+ elems[i] = rb_float_new((double)(((float *)value$argnum)[i]));
358
+ }
359
+ $result = rb_ary_new4(n$argnum,elems);
360
+ break;
361
+ case 'd':
362
+ for(i = 0; i < n$argnum; i++) {
363
+ elems[i] = rb_float_new(((double *)value$argnum)[i]);
364
+ }
365
+ $result = rb_ary_new4(n$argnum,elems);
366
+ break;
367
+ case ' ': // Variable not present
368
+ case 'j': // Unsuported
369
+ // Return NULL, but don't raise exception
370
+ break;
371
+ default: // TODO Raise exception
372
+ break;
373
+ }
374
+ }
375
+ // Free buffer allocated by getvr
376
+ free(value$argnum);
377
+ }
378
+
379
+ // Typemaps for probvr
380
+ %typemap(in, numinputs=0) (char *type, int *length, int *updated) (char type, int length, int updated) {
381
+ $1 = &type;
382
+ $2 = &length;
383
+ $3 = &updated;
384
+ }
385
+
386
+ %typemap(argout) (char *type, int *length, int *updated) {
387
+ if($1[0] == ' ') {
388
+ $result = Qnil;
389
+ } else {
390
+ $result = SWIG_AppendOutput($result, rb_str_new($1,1));
391
+ $result = SWIG_AppendOutput($result, INT2NUM(*$2));
392
+ $result = SWIG_AppendOutput($result, *$3 ? Qtrue : Qfalse);
393
+ }
394
+ }
395
+
396
+ // Make updated() a predicate method
397
+ %predicate updated();
398
+
399
+ // Typemaps for flagwr "flags" parameter
400
+ %typemap(in) (int * flags) {
401
+ // If NArray
402
+ if(NA_IsNArray($input)) {
403
+ Check_NArrayType($input,NA_LINT);
404
+ $1 = NA_PTR_TYPE($input,$1_type);
405
+ } else {
406
+ int i;
407
+ int nflag;
408
+ Check_Type($input, T_ARRAY);
409
+ nflag = RARRAY($input)->len;
410
+ $1 = ALLOCA_N(int,nflag);
411
+ VALUE * ptr = RARRAY($input)->ptr;
412
+ for(i=0; i < nflag; i++) {
413
+ $1[i] = FIX2INT(ptr[i]);
414
+ }
415
+ }
416
+ }
417
+
418
+ // Typemaps for hreadln
419
+ %typemap(in, numinputs=0) (char *linein, size_t length, int *iostat) (int iostat) {
420
+ $2 = 100;
421
+ $1 = ALLOCA_N(char,$2);
422
+ $3 = &iostat;
423
+ }
424
+
425
+ %typemap(argout) (char *linein, size_t length, int *iostat) {
426
+ if(*$3 == 0) {
427
+ $result = rb_str_new2($1);
428
+ } else if(*$3 != -1) {
429
+ SWIG_exception(SWIG_IOError, "error reading item");
430
+ } else {
431
+ // EOF
432
+ $result = Qnil;
433
+ }
434
+ }
435
+
436
+ // Typemaps for hwriteln
437
+ %typemap(in) (char *linein, size_t length) {
438
+ $1 = StringValue($input)->ptr;
439
+ $2 = StringValue($input)->len;
440
+ }
441
+
442
+ // vim: set expandtab ts=2 sw=2 smarttab syntax=c cindent:
443
+ #endif // SWIGRUBY
data/ext/miriad_wrap.c ADDED
@@ -0,0 +1,4210 @@
1
+ /* ----------------------------------------------------------------------------
2
+ * This file was automatically generated by SWIG (http://www.swig.org).
3
+ * Version 1.3.35
4
+ *
5
+ * This file is not intended to be easily readable and contains a number of
6
+ * coding conventions designed to improve portability and efficiency. Do not make
7
+ * changes to this file unless you know what you are doing--modify the SWIG
8
+ * interface file instead.
9
+ * ----------------------------------------------------------------------------- */
10
+
11
+ #define SWIGRUBY
12
+ /* -----------------------------------------------------------------------------
13
+ * This section contains generic SWIG labels for method/variable
14
+ * declarations/attributes, and other compiler dependent labels.
15
+ * ----------------------------------------------------------------------------- */
16
+
17
+ /* template workaround for compilers that cannot correctly implement the C++ standard */
18
+ #ifndef SWIGTEMPLATEDISAMBIGUATOR
19
+ # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
20
+ # define SWIGTEMPLATEDISAMBIGUATOR template
21
+ # elif defined(__HP_aCC)
22
+ /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
23
+ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
24
+ # define SWIGTEMPLATEDISAMBIGUATOR template
25
+ # else
26
+ # define SWIGTEMPLATEDISAMBIGUATOR
27
+ # endif
28
+ #endif
29
+
30
+ /* inline attribute */
31
+ #ifndef SWIGINLINE
32
+ # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
33
+ # define SWIGINLINE inline
34
+ # else
35
+ # define SWIGINLINE
36
+ # endif
37
+ #endif
38
+
39
+ /* attribute recognised by some compilers to avoid 'unused' warnings */
40
+ #ifndef SWIGUNUSED
41
+ # if defined(__GNUC__)
42
+ # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
43
+ # define SWIGUNUSED __attribute__ ((__unused__))
44
+ # else
45
+ # define SWIGUNUSED
46
+ # endif
47
+ # elif defined(__ICC)
48
+ # define SWIGUNUSED __attribute__ ((__unused__))
49
+ # else
50
+ # define SWIGUNUSED
51
+ # endif
52
+ #endif
53
+
54
+ #ifndef SWIGUNUSEDPARM
55
+ # ifdef __cplusplus
56
+ # define SWIGUNUSEDPARM(p)
57
+ # else
58
+ # define SWIGUNUSEDPARM(p) p SWIGUNUSED
59
+ # endif
60
+ #endif
61
+
62
+ /* internal SWIG method */
63
+ #ifndef SWIGINTERN
64
+ # define SWIGINTERN static SWIGUNUSED
65
+ #endif
66
+
67
+ /* internal inline SWIG method */
68
+ #ifndef SWIGINTERNINLINE
69
+ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
70
+ #endif
71
+
72
+ /* exporting methods */
73
+ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
74
+ # ifndef GCC_HASCLASSVISIBILITY
75
+ # define GCC_HASCLASSVISIBILITY
76
+ # endif
77
+ #endif
78
+
79
+ #ifndef SWIGEXPORT
80
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
81
+ # if defined(STATIC_LINKED)
82
+ # define SWIGEXPORT
83
+ # else
84
+ # define SWIGEXPORT __declspec(dllexport)
85
+ # endif
86
+ # else
87
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
88
+ # define SWIGEXPORT __attribute__ ((visibility("default")))
89
+ # else
90
+ # define SWIGEXPORT
91
+ # endif
92
+ # endif
93
+ #endif
94
+
95
+ /* calling conventions for Windows */
96
+ #ifndef SWIGSTDCALL
97
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
98
+ # define SWIGSTDCALL __stdcall
99
+ # else
100
+ # define SWIGSTDCALL
101
+ # endif
102
+ #endif
103
+
104
+ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
105
+ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
106
+ # define _CRT_SECURE_NO_DEPRECATE
107
+ #endif
108
+
109
+ /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
110
+ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
111
+ # define _SCL_SECURE_NO_DEPRECATE
112
+ #endif
113
+
114
+
115
+ /* -----------------------------------------------------------------------------
116
+ * This section contains generic SWIG labels for method/variable
117
+ * declarations/attributes, and other compiler dependent labels.
118
+ * ----------------------------------------------------------------------------- */
119
+
120
+ /* template workaround for compilers that cannot correctly implement the C++ standard */
121
+ #ifndef SWIGTEMPLATEDISAMBIGUATOR
122
+ # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
123
+ # define SWIGTEMPLATEDISAMBIGUATOR template
124
+ # elif defined(__HP_aCC)
125
+ /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
126
+ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
127
+ # define SWIGTEMPLATEDISAMBIGUATOR template
128
+ # else
129
+ # define SWIGTEMPLATEDISAMBIGUATOR
130
+ # endif
131
+ #endif
132
+
133
+ /* inline attribute */
134
+ #ifndef SWIGINLINE
135
+ # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
136
+ # define SWIGINLINE inline
137
+ # else
138
+ # define SWIGINLINE
139
+ # endif
140
+ #endif
141
+
142
+ /* attribute recognised by some compilers to avoid 'unused' warnings */
143
+ #ifndef SWIGUNUSED
144
+ # if defined(__GNUC__)
145
+ # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
146
+ # define SWIGUNUSED __attribute__ ((__unused__))
147
+ # else
148
+ # define SWIGUNUSED
149
+ # endif
150
+ # elif defined(__ICC)
151
+ # define SWIGUNUSED __attribute__ ((__unused__))
152
+ # else
153
+ # define SWIGUNUSED
154
+ # endif
155
+ #endif
156
+
157
+ #ifndef SWIGUNUSEDPARM
158
+ # ifdef __cplusplus
159
+ # define SWIGUNUSEDPARM(p)
160
+ # else
161
+ # define SWIGUNUSEDPARM(p) p SWIGUNUSED
162
+ # endif
163
+ #endif
164
+
165
+ /* internal SWIG method */
166
+ #ifndef SWIGINTERN
167
+ # define SWIGINTERN static SWIGUNUSED
168
+ #endif
169
+
170
+ /* internal inline SWIG method */
171
+ #ifndef SWIGINTERNINLINE
172
+ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
173
+ #endif
174
+
175
+ /* exporting methods */
176
+ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
177
+ # ifndef GCC_HASCLASSVISIBILITY
178
+ # define GCC_HASCLASSVISIBILITY
179
+ # endif
180
+ #endif
181
+
182
+ #ifndef SWIGEXPORT
183
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
184
+ # if defined(STATIC_LINKED)
185
+ # define SWIGEXPORT
186
+ # else
187
+ # define SWIGEXPORT __declspec(dllexport)
188
+ # endif
189
+ # else
190
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
191
+ # define SWIGEXPORT __attribute__ ((visibility("default")))
192
+ # else
193
+ # define SWIGEXPORT
194
+ # endif
195
+ # endif
196
+ #endif
197
+
198
+ /* calling conventions for Windows */
199
+ #ifndef SWIGSTDCALL
200
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
201
+ # define SWIGSTDCALL __stdcall
202
+ # else
203
+ # define SWIGSTDCALL
204
+ # endif
205
+ #endif
206
+
207
+ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
208
+ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
209
+ # define _CRT_SECURE_NO_DEPRECATE
210
+ #endif
211
+
212
+ /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
213
+ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
214
+ # define _SCL_SECURE_NO_DEPRECATE
215
+ #endif
216
+
217
+
218
+ /* -----------------------------------------------------------------------------
219
+ * swigrun.swg
220
+ *
221
+ * This file contains generic CAPI SWIG runtime support for pointer
222
+ * type checking.
223
+ * ----------------------------------------------------------------------------- */
224
+
225
+ /* This should only be incremented when either the layout of swig_type_info changes,
226
+ or for whatever reason, the runtime changes incompatibly */
227
+ #define SWIG_RUNTIME_VERSION "4"
228
+
229
+ /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
230
+ #ifdef SWIG_TYPE_TABLE
231
+ # define SWIG_QUOTE_STRING(x) #x
232
+ # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
233
+ # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
234
+ #else
235
+ # define SWIG_TYPE_TABLE_NAME
236
+ #endif
237
+
238
+ /*
239
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
240
+ creating a static or dynamic library from the swig runtime code.
241
+ In 99.9% of the cases, swig just needs to declare them as 'static'.
242
+
243
+ But only do this if is strictly necessary, ie, if you have problems
244
+ with your compiler or so.
245
+ */
246
+
247
+ #ifndef SWIGRUNTIME
248
+ # define SWIGRUNTIME SWIGINTERN
249
+ #endif
250
+
251
+ #ifndef SWIGRUNTIMEINLINE
252
+ # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
253
+ #endif
254
+
255
+ /* Generic buffer size */
256
+ #ifndef SWIG_BUFFER_SIZE
257
+ # define SWIG_BUFFER_SIZE 1024
258
+ #endif
259
+
260
+ /* Flags for pointer conversions */
261
+ #define SWIG_POINTER_DISOWN 0x1
262
+ #define SWIG_CAST_NEW_MEMORY 0x2
263
+
264
+ /* Flags for new pointer objects */
265
+ #define SWIG_POINTER_OWN 0x1
266
+
267
+
268
+ /*
269
+ Flags/methods for returning states.
270
+
271
+ The swig conversion methods, as ConvertPtr, return and integer
272
+ that tells if the conversion was successful or not. And if not,
273
+ an error code can be returned (see swigerrors.swg for the codes).
274
+
275
+ Use the following macros/flags to set or process the returning
276
+ states.
277
+
278
+ In old swig versions, you usually write code as:
279
+
280
+ if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
281
+ // success code
282
+ } else {
283
+ //fail code
284
+ }
285
+
286
+ Now you can be more explicit as:
287
+
288
+ int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
289
+ if (SWIG_IsOK(res)) {
290
+ // success code
291
+ } else {
292
+ // fail code
293
+ }
294
+
295
+ that seems to be the same, but now you can also do
296
+
297
+ Type *ptr;
298
+ int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
299
+ if (SWIG_IsOK(res)) {
300
+ // success code
301
+ if (SWIG_IsNewObj(res) {
302
+ ...
303
+ delete *ptr;
304
+ } else {
305
+ ...
306
+ }
307
+ } else {
308
+ // fail code
309
+ }
310
+
311
+ I.e., now SWIG_ConvertPtr can return new objects and you can
312
+ identify the case and take care of the deallocation. Of course that
313
+ requires also to SWIG_ConvertPtr to return new result values, as
314
+
315
+ int SWIG_ConvertPtr(obj, ptr,...) {
316
+ if (<obj is ok>) {
317
+ if (<need new object>) {
318
+ *ptr = <ptr to new allocated object>;
319
+ return SWIG_NEWOBJ;
320
+ } else {
321
+ *ptr = <ptr to old object>;
322
+ return SWIG_OLDOBJ;
323
+ }
324
+ } else {
325
+ return SWIG_BADOBJ;
326
+ }
327
+ }
328
+
329
+ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
330
+ more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
331
+ swig errors code.
332
+
333
+ Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
334
+ allows to return the 'cast rank', for example, if you have this
335
+
336
+ int food(double)
337
+ int fooi(int);
338
+
339
+ and you call
340
+
341
+ food(1) // cast rank '1' (1 -> 1.0)
342
+ fooi(1) // cast rank '0'
343
+
344
+ just use the SWIG_AddCast()/SWIG_CheckState()
345
+
346
+
347
+ */
348
+ #define SWIG_OK (0)
349
+ #define SWIG_ERROR (-1)
350
+ #define SWIG_IsOK(r) (r >= 0)
351
+ #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
352
+
353
+ /* The CastRankLimit says how many bits are used for the cast rank */
354
+ #define SWIG_CASTRANKLIMIT (1 << 8)
355
+ /* The NewMask denotes the object was created (using new/malloc) */
356
+ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
357
+ /* The TmpMask is for in/out typemaps that use temporal objects */
358
+ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
359
+ /* Simple returning values */
360
+ #define SWIG_BADOBJ (SWIG_ERROR)
361
+ #define SWIG_OLDOBJ (SWIG_OK)
362
+ #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
363
+ #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
364
+ /* Check, add and del mask methods */
365
+ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
366
+ #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
367
+ #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
368
+ #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
369
+ #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
370
+ #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
371
+
372
+
373
+ /* Cast-Rank Mode */
374
+ #if defined(SWIG_CASTRANK_MODE)
375
+ # ifndef SWIG_TypeRank
376
+ # define SWIG_TypeRank unsigned long
377
+ # endif
378
+ # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
379
+ # define SWIG_MAXCASTRANK (2)
380
+ # endif
381
+ # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
382
+ # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
383
+ SWIGINTERNINLINE int SWIG_AddCast(int r) {
384
+ return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
385
+ }
386
+ SWIGINTERNINLINE int SWIG_CheckState(int r) {
387
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
388
+ }
389
+ #else /* no cast-rank mode */
390
+ # define SWIG_AddCast
391
+ # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
392
+ #endif
393
+
394
+
395
+
396
+
397
+ #include <string.h>
398
+
399
+ #ifdef __cplusplus
400
+ extern "C" {
401
+ #endif
402
+
403
+ typedef void *(*swig_converter_func)(void *, int *);
404
+ typedef struct swig_type_info *(*swig_dycast_func)(void **);
405
+
406
+ /* Structure to store information on one type */
407
+ typedef struct swig_type_info {
408
+ const char *name; /* mangled name of this type */
409
+ const char *str; /* human readable name of this type */
410
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
411
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
412
+ void *clientdata; /* language specific type data */
413
+ int owndata; /* flag if the structure owns the clientdata */
414
+ } swig_type_info;
415
+
416
+ /* Structure to store a type and conversion function used for casting */
417
+ typedef struct swig_cast_info {
418
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
419
+ swig_converter_func converter; /* function to cast the void pointers */
420
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
421
+ struct swig_cast_info *prev; /* pointer to the previous cast */
422
+ } swig_cast_info;
423
+
424
+ /* Structure used to store module information
425
+ * Each module generates one structure like this, and the runtime collects
426
+ * all of these structures and stores them in a circularly linked list.*/
427
+ typedef struct swig_module_info {
428
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
429
+ size_t size; /* Number of types in this module */
430
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
431
+ swig_type_info **type_initial; /* Array of initially generated type structures */
432
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
433
+ void *clientdata; /* Language specific module data */
434
+ } swig_module_info;
435
+
436
+ /*
437
+ Compare two type names skipping the space characters, therefore
438
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
439
+
440
+ Return 0 when the two name types are equivalent, as in
441
+ strncmp, but skipping ' '.
442
+ */
443
+ SWIGRUNTIME int
444
+ SWIG_TypeNameComp(const char *f1, const char *l1,
445
+ const char *f2, const char *l2) {
446
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
447
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
448
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
449
+ if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
450
+ }
451
+ return (int)((l1 - f1) - (l2 - f2));
452
+ }
453
+
454
+ /*
455
+ Check type equivalence in a name list like <name1>|<name2>|...
456
+ Return 0 if not equal, 1 if equal
457
+ */
458
+ SWIGRUNTIME int
459
+ SWIG_TypeEquiv(const char *nb, const char *tb) {
460
+ int equiv = 0;
461
+ const char* te = tb + strlen(tb);
462
+ const char* ne = nb;
463
+ while (!equiv && *ne) {
464
+ for (nb = ne; *ne; ++ne) {
465
+ if (*ne == '|') break;
466
+ }
467
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
468
+ if (*ne) ++ne;
469
+ }
470
+ return equiv;
471
+ }
472
+
473
+ /*
474
+ Check type equivalence in a name list like <name1>|<name2>|...
475
+ Return 0 if equal, -1 if nb < tb, 1 if nb > tb
476
+ */
477
+ SWIGRUNTIME int
478
+ SWIG_TypeCompare(const char *nb, const char *tb) {
479
+ int equiv = 0;
480
+ const char* te = tb + strlen(tb);
481
+ const char* ne = nb;
482
+ while (!equiv && *ne) {
483
+ for (nb = ne; *ne; ++ne) {
484
+ if (*ne == '|') break;
485
+ }
486
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
487
+ if (*ne) ++ne;
488
+ }
489
+ return equiv;
490
+ }
491
+
492
+
493
+ /* think of this as a c++ template<> or a scheme macro */
494
+ #define SWIG_TypeCheck_Template(comparison, ty) \
495
+ if (ty) { \
496
+ swig_cast_info *iter = ty->cast; \
497
+ while (iter) { \
498
+ if (comparison) { \
499
+ if (iter == ty->cast) return iter; \
500
+ /* Move iter to the top of the linked list */ \
501
+ iter->prev->next = iter->next; \
502
+ if (iter->next) \
503
+ iter->next->prev = iter->prev; \
504
+ iter->next = ty->cast; \
505
+ iter->prev = 0; \
506
+ if (ty->cast) ty->cast->prev = iter; \
507
+ ty->cast = iter; \
508
+ return iter; \
509
+ } \
510
+ iter = iter->next; \
511
+ } \
512
+ } \
513
+ return 0
514
+
515
+ /*
516
+ Check the typename
517
+ */
518
+ SWIGRUNTIME swig_cast_info *
519
+ SWIG_TypeCheck(const char *c, swig_type_info *ty) {
520
+ SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
521
+ }
522
+
523
+ /* Same as previous function, except strcmp is replaced with a pointer comparison */
524
+ SWIGRUNTIME swig_cast_info *
525
+ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
526
+ SWIG_TypeCheck_Template(iter->type == from, into);
527
+ }
528
+
529
+ /*
530
+ Cast a pointer up an inheritance hierarchy
531
+ */
532
+ SWIGRUNTIMEINLINE void *
533
+ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
534
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
535
+ }
536
+
537
+ /*
538
+ Dynamic pointer casting. Down an inheritance hierarchy
539
+ */
540
+ SWIGRUNTIME swig_type_info *
541
+ SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
542
+ swig_type_info *lastty = ty;
543
+ if (!ty || !ty->dcast) return ty;
544
+ while (ty && (ty->dcast)) {
545
+ ty = (*ty->dcast)(ptr);
546
+ if (ty) lastty = ty;
547
+ }
548
+ return lastty;
549
+ }
550
+
551
+ /*
552
+ Return the name associated with this type
553
+ */
554
+ SWIGRUNTIMEINLINE const char *
555
+ SWIG_TypeName(const swig_type_info *ty) {
556
+ return ty->name;
557
+ }
558
+
559
+ /*
560
+ Return the pretty name associated with this type,
561
+ that is an unmangled type name in a form presentable to the user.
562
+ */
563
+ SWIGRUNTIME const char *
564
+ SWIG_TypePrettyName(const swig_type_info *type) {
565
+ /* The "str" field contains the equivalent pretty names of the
566
+ type, separated by vertical-bar characters. We choose
567
+ to print the last name, as it is often (?) the most
568
+ specific. */
569
+ if (!type) return NULL;
570
+ if (type->str != NULL) {
571
+ const char *last_name = type->str;
572
+ const char *s;
573
+ for (s = type->str; *s; s++)
574
+ if (*s == '|') last_name = s+1;
575
+ return last_name;
576
+ }
577
+ else
578
+ return type->name;
579
+ }
580
+
581
+ /*
582
+ Set the clientdata field for a type
583
+ */
584
+ SWIGRUNTIME void
585
+ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
586
+ swig_cast_info *cast = ti->cast;
587
+ /* if (ti->clientdata == clientdata) return; */
588
+ ti->clientdata = clientdata;
589
+
590
+ while (cast) {
591
+ if (!cast->converter) {
592
+ swig_type_info *tc = cast->type;
593
+ if (!tc->clientdata) {
594
+ SWIG_TypeClientData(tc, clientdata);
595
+ }
596
+ }
597
+ cast = cast->next;
598
+ }
599
+ }
600
+ SWIGRUNTIME void
601
+ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
602
+ SWIG_TypeClientData(ti, clientdata);
603
+ ti->owndata = 1;
604
+ }
605
+
606
+ /*
607
+ Search for a swig_type_info structure only by mangled name
608
+ Search is a O(log #types)
609
+
610
+ We start searching at module start, and finish searching when start == end.
611
+ Note: if start == end at the beginning of the function, we go all the way around
612
+ the circular list.
613
+ */
614
+ SWIGRUNTIME swig_type_info *
615
+ SWIG_MangledTypeQueryModule(swig_module_info *start,
616
+ swig_module_info *end,
617
+ const char *name) {
618
+ swig_module_info *iter = start;
619
+ do {
620
+ if (iter->size) {
621
+ register size_t l = 0;
622
+ register size_t r = iter->size - 1;
623
+ do {
624
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
625
+ register size_t i = (l + r) >> 1;
626
+ const char *iname = iter->types[i]->name;
627
+ if (iname) {
628
+ register int compare = strcmp(name, iname);
629
+ if (compare == 0) {
630
+ return iter->types[i];
631
+ } else if (compare < 0) {
632
+ if (i) {
633
+ r = i - 1;
634
+ } else {
635
+ break;
636
+ }
637
+ } else if (compare > 0) {
638
+ l = i + 1;
639
+ }
640
+ } else {
641
+ break; /* should never happen */
642
+ }
643
+ } while (l <= r);
644
+ }
645
+ iter = iter->next;
646
+ } while (iter != end);
647
+ return 0;
648
+ }
649
+
650
+ /*
651
+ Search for a swig_type_info structure for either a mangled name or a human readable name.
652
+ It first searches the mangled names of the types, which is a O(log #types)
653
+ If a type is not found it then searches the human readable names, which is O(#types).
654
+
655
+ We start searching at module start, and finish searching when start == end.
656
+ Note: if start == end at the beginning of the function, we go all the way around
657
+ the circular list.
658
+ */
659
+ SWIGRUNTIME swig_type_info *
660
+ SWIG_TypeQueryModule(swig_module_info *start,
661
+ swig_module_info *end,
662
+ const char *name) {
663
+ /* STEP 1: Search the name field using binary search */
664
+ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
665
+ if (ret) {
666
+ return ret;
667
+ } else {
668
+ /* STEP 2: If the type hasn't been found, do a complete search
669
+ of the str field (the human readable name) */
670
+ swig_module_info *iter = start;
671
+ do {
672
+ register size_t i = 0;
673
+ for (; i < iter->size; ++i) {
674
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
675
+ return iter->types[i];
676
+ }
677
+ iter = iter->next;
678
+ } while (iter != end);
679
+ }
680
+
681
+ /* neither found a match */
682
+ return 0;
683
+ }
684
+
685
+ /*
686
+ Pack binary data into a string
687
+ */
688
+ SWIGRUNTIME char *
689
+ SWIG_PackData(char *c, void *ptr, size_t sz) {
690
+ static const char hex[17] = "0123456789abcdef";
691
+ register const unsigned char *u = (unsigned char *) ptr;
692
+ register const unsigned char *eu = u + sz;
693
+ for (; u != eu; ++u) {
694
+ register unsigned char uu = *u;
695
+ *(c++) = hex[(uu & 0xf0) >> 4];
696
+ *(c++) = hex[uu & 0xf];
697
+ }
698
+ return c;
699
+ }
700
+
701
+ /*
702
+ Unpack binary data from a string
703
+ */
704
+ SWIGRUNTIME const char *
705
+ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
706
+ register unsigned char *u = (unsigned char *) ptr;
707
+ register const unsigned char *eu = u + sz;
708
+ for (; u != eu; ++u) {
709
+ register char d = *(c++);
710
+ register unsigned char uu;
711
+ if ((d >= '0') && (d <= '9'))
712
+ uu = ((d - '0') << 4);
713
+ else if ((d >= 'a') && (d <= 'f'))
714
+ uu = ((d - ('a'-10)) << 4);
715
+ else
716
+ return (char *) 0;
717
+ d = *(c++);
718
+ if ((d >= '0') && (d <= '9'))
719
+ uu |= (d - '0');
720
+ else if ((d >= 'a') && (d <= 'f'))
721
+ uu |= (d - ('a'-10));
722
+ else
723
+ return (char *) 0;
724
+ *u = uu;
725
+ }
726
+ return c;
727
+ }
728
+
729
+ /*
730
+ Pack 'void *' into a string buffer.
731
+ */
732
+ SWIGRUNTIME char *
733
+ SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
734
+ char *r = buff;
735
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
736
+ *(r++) = '_';
737
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
738
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
739
+ strcpy(r,name);
740
+ return buff;
741
+ }
742
+
743
+ SWIGRUNTIME const char *
744
+ SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
745
+ if (*c != '_') {
746
+ if (strcmp(c,"NULL") == 0) {
747
+ *ptr = (void *) 0;
748
+ return name;
749
+ } else {
750
+ return 0;
751
+ }
752
+ }
753
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
754
+ }
755
+
756
+ SWIGRUNTIME char *
757
+ SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
758
+ char *r = buff;
759
+ size_t lname = (name ? strlen(name) : 0);
760
+ if ((2*sz + 2 + lname) > bsz) return 0;
761
+ *(r++) = '_';
762
+ r = SWIG_PackData(r,ptr,sz);
763
+ if (lname) {
764
+ strncpy(r,name,lname+1);
765
+ } else {
766
+ *r = 0;
767
+ }
768
+ return buff;
769
+ }
770
+
771
+ SWIGRUNTIME const char *
772
+ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
773
+ if (*c != '_') {
774
+ if (strcmp(c,"NULL") == 0) {
775
+ memset(ptr,0,sz);
776
+ return name;
777
+ } else {
778
+ return 0;
779
+ }
780
+ }
781
+ return SWIG_UnpackData(++c,ptr,sz);
782
+ }
783
+
784
+ #ifdef __cplusplus
785
+ }
786
+ #endif
787
+
788
+ /* Errors in SWIG */
789
+ #define SWIG_UnknownError -1
790
+ #define SWIG_IOError -2
791
+ #define SWIG_RuntimeError -3
792
+ #define SWIG_IndexError -4
793
+ #define SWIG_TypeError -5
794
+ #define SWIG_DivisionByZero -6
795
+ #define SWIG_OverflowError -7
796
+ #define SWIG_SyntaxError -8
797
+ #define SWIG_ValueError -9
798
+ #define SWIG_SystemError -10
799
+ #define SWIG_AttributeError -11
800
+ #define SWIG_MemoryError -12
801
+ #define SWIG_NullReferenceError -13
802
+
803
+
804
+
805
+ #include <ruby.h>
806
+
807
+ /* Remove global macros defined in Ruby's win32.h */
808
+ #ifdef write
809
+ # undef write
810
+ #endif
811
+ #ifdef read
812
+ # undef read
813
+ #endif
814
+
815
+
816
+ /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
817
+ #ifndef NUM2LL
818
+ #define NUM2LL(x) NUM2LONG((x))
819
+ #endif
820
+ #ifndef LL2NUM
821
+ #define LL2NUM(x) INT2NUM((long) (x))
822
+ #endif
823
+ #ifndef ULL2NUM
824
+ #define ULL2NUM(x) UINT2NUM((unsigned long) (x))
825
+ #endif
826
+
827
+ /* Ruby 1.7 doesn't (yet) define NUM2ULL() */
828
+ #ifndef NUM2ULL
829
+ #ifdef HAVE_LONG_LONG
830
+ #define NUM2ULL(x) rb_num2ull((x))
831
+ #else
832
+ #define NUM2ULL(x) NUM2ULONG(x)
833
+ #endif
834
+ #endif
835
+
836
+ /* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */
837
+ /* Define these for older versions so we can just write code the new way */
838
+ #ifndef RSTRING_LEN
839
+ # define RSTRING_LEN(x) RSTRING(x)->len
840
+ #endif
841
+ #ifndef RSTRING_PTR
842
+ # define RSTRING_PTR(x) RSTRING(x)->ptr
843
+ #endif
844
+ #ifndef RSTRING_END
845
+ # define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x))
846
+ #endif
847
+ #ifndef RARRAY_LEN
848
+ # define RARRAY_LEN(x) RARRAY(x)->len
849
+ #endif
850
+ #ifndef RARRAY_PTR
851
+ # define RARRAY_PTR(x) RARRAY(x)->ptr
852
+ #endif
853
+ #ifndef RFLOAT_VALUE
854
+ # define RFLOAT_VALUE(x) RFLOAT(x)->value
855
+ #endif
856
+ #ifndef DOUBLE2NUM
857
+ # define DOUBLE2NUM(x) rb_float_new(x)
858
+ #endif
859
+ #ifndef RHASH_TBL
860
+ # define RHASH_TBL(x) (RHASH(x)->tbl)
861
+ #endif
862
+ #ifndef RHASH_ITER_LEV
863
+ # define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev)
864
+ #endif
865
+ #ifndef RHASH_IFNONE
866
+ # define RHASH_IFNONE(x) (RHASH(x)->ifnone)
867
+ #endif
868
+ #ifndef RHASH_SIZE
869
+ # define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries)
870
+ #endif
871
+ #ifndef RHASH_EMPTY_P
872
+ # define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0)
873
+ #endif
874
+ #ifndef RSTRUCT_LEN
875
+ # define RSTRUCT_LEN(x) RSTRUCT(x)->len
876
+ #endif
877
+ #ifndef RSTRUCT_PTR
878
+ # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
879
+ #endif
880
+
881
+
882
+
883
+ /*
884
+ * Need to be very careful about how these macros are defined, especially
885
+ * when compiling C++ code or C code with an ANSI C compiler.
886
+ *
887
+ * VALUEFUNC(f) is a macro used to typecast a C function that implements
888
+ * a Ruby method so that it can be passed as an argument to API functions
889
+ * like rb_define_method() and rb_define_singleton_method().
890
+ *
891
+ * VOIDFUNC(f) is a macro used to typecast a C function that implements
892
+ * either the "mark" or "free" stuff for a Ruby Data object, so that it
893
+ * can be passed as an argument to API functions like Data_Wrap_Struct()
894
+ * and Data_Make_Struct().
895
+ */
896
+
897
+ #ifdef __cplusplus
898
+ # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
899
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
900
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
901
+ # define VOIDFUNC(f) ((void (*)()) f)
902
+ # else
903
+ # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
904
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
905
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
906
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
907
+ # else /* These definitions should work for Ruby 1.7+ */
908
+ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
909
+ # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
910
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
911
+ # endif
912
+ # endif
913
+ #else
914
+ # define VALUEFUNC(f) (f)
915
+ # define VOIDFUNC(f) (f)
916
+ #endif
917
+
918
+ /* Don't use for expressions have side effect */
919
+ #ifndef RB_STRING_VALUE
920
+ #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
921
+ #endif
922
+ #ifndef StringValue
923
+ #define StringValue(s) RB_STRING_VALUE(s)
924
+ #endif
925
+ #ifndef StringValuePtr
926
+ #define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s))
927
+ #endif
928
+ #ifndef StringValueLen
929
+ #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
930
+ #endif
931
+ #ifndef SafeStringValue
932
+ #define SafeStringValue(v) do {\
933
+ StringValue(v);\
934
+ rb_check_safe_str(v);\
935
+ } while (0)
936
+ #endif
937
+
938
+ #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
939
+ #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1)
940
+ #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new")
941
+ #endif
942
+
943
+ static VALUE _mSWIG = Qnil;
944
+
945
+ /* -----------------------------------------------------------------------------
946
+ * error manipulation
947
+ * ----------------------------------------------------------------------------- */
948
+
949
+
950
+ /* Define some additional error types */
951
+ #define SWIG_ObjectPreviouslyDeletedError -100
952
+
953
+
954
+ /* Define custom exceptions for errors that do not map to existing Ruby
955
+ exceptions. Note this only works for C++ since a global cannot be
956
+ initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/
957
+
958
+ SWIGINTERN VALUE
959
+ getNullReferenceError(void) {
960
+ static int init = 0;
961
+ static VALUE rb_eNullReferenceError ;
962
+ if (!init) {
963
+ init = 1;
964
+ rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError);
965
+ }
966
+ return rb_eNullReferenceError;
967
+ }
968
+
969
+ SWIGINTERN VALUE
970
+ getObjectPreviouslyDeletedError(void) {
971
+ static int init = 0;
972
+ static VALUE rb_eObjectPreviouslyDeleted ;
973
+ if (!init) {
974
+ init = 1;
975
+ rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError);
976
+ }
977
+ return rb_eObjectPreviouslyDeleted;
978
+ }
979
+
980
+
981
+ SWIGINTERN VALUE
982
+ SWIG_Ruby_ErrorType(int SWIG_code) {
983
+ VALUE type;
984
+ switch (SWIG_code) {
985
+ case SWIG_MemoryError:
986
+ type = rb_eNoMemError;
987
+ break;
988
+ case SWIG_IOError:
989
+ type = rb_eIOError;
990
+ break;
991
+ case SWIG_RuntimeError:
992
+ type = rb_eRuntimeError;
993
+ break;
994
+ case SWIG_IndexError:
995
+ type = rb_eIndexError;
996
+ break;
997
+ case SWIG_TypeError:
998
+ type = rb_eTypeError;
999
+ break;
1000
+ case SWIG_DivisionByZero:
1001
+ type = rb_eZeroDivError;
1002
+ break;
1003
+ case SWIG_OverflowError:
1004
+ type = rb_eRangeError;
1005
+ break;
1006
+ case SWIG_SyntaxError:
1007
+ type = rb_eSyntaxError;
1008
+ break;
1009
+ case SWIG_ValueError:
1010
+ type = rb_eArgError;
1011
+ break;
1012
+ case SWIG_SystemError:
1013
+ type = rb_eFatal;
1014
+ break;
1015
+ case SWIG_AttributeError:
1016
+ type = rb_eRuntimeError;
1017
+ break;
1018
+ case SWIG_NullReferenceError:
1019
+ type = getNullReferenceError();
1020
+ break;
1021
+ case SWIG_ObjectPreviouslyDeletedError:
1022
+ type = getObjectPreviouslyDeletedError();
1023
+ break;
1024
+ case SWIG_UnknownError:
1025
+ type = rb_eRuntimeError;
1026
+ break;
1027
+ default:
1028
+ type = rb_eRuntimeError;
1029
+ }
1030
+ return type;
1031
+ }
1032
+
1033
+
1034
+ /* This function is called when a user inputs a wrong argument to
1035
+ a method.
1036
+ */
1037
+ SWIGINTERN
1038
+ const char* Ruby_Format_TypeError( const char* msg,
1039
+ const char* type,
1040
+ const char* name,
1041
+ const int argn,
1042
+ VALUE input )
1043
+ {
1044
+ char buf[128];
1045
+ VALUE str;
1046
+ VALUE asStr;
1047
+ if ( msg && *msg )
1048
+ {
1049
+ str = rb_str_new2(msg);
1050
+ }
1051
+ else
1052
+ {
1053
+ str = rb_str_new(NULL, 0);
1054
+ }
1055
+
1056
+ str = rb_str_cat2( str, "Expected argument " );
1057
+ sprintf( buf, "%d of type ", argn-1 );
1058
+ str = rb_str_cat2( str, buf );
1059
+ str = rb_str_cat2( str, type );
1060
+ str = rb_str_cat2( str, ", but got " );
1061
+ str = rb_str_cat2( str, rb_obj_classname(input) );
1062
+ str = rb_str_cat2( str, " " );
1063
+ asStr = rb_inspect(input);
1064
+ if ( RSTRING_LEN(asStr) > 30 )
1065
+ {
1066
+ str = rb_str_cat( str, StringValuePtr(asStr), 30 );
1067
+ str = rb_str_cat2( str, "..." );
1068
+ }
1069
+ else
1070
+ {
1071
+ str = rb_str_append( str, asStr );
1072
+ }
1073
+
1074
+ if ( name )
1075
+ {
1076
+ str = rb_str_cat2( str, "\n\tin SWIG method '" );
1077
+ str = rb_str_cat2( str, name );
1078
+ str = rb_str_cat2( str, "'" );
1079
+ }
1080
+
1081
+ return StringValuePtr( str );
1082
+ }
1083
+
1084
+ /* This function is called when an overloaded method fails */
1085
+ SWIGINTERN
1086
+ void Ruby_Format_OverloadedError(
1087
+ const int argc,
1088
+ const int maxargs,
1089
+ const char* method,
1090
+ const char* prototypes
1091
+ )
1092
+ {
1093
+ const char* msg = "Wrong # of arguments";
1094
+ if ( argc <= maxargs ) msg = "Wrong arguments";
1095
+ rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n"
1096
+ "Possible C/C++ prototypes are:\n%s",
1097
+ msg, method, prototypes);
1098
+ }
1099
+
1100
+ /* -----------------------------------------------------------------------------
1101
+ * See the LICENSE file for information on copyright, usage and redistribution
1102
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
1103
+ *
1104
+ * rubytracking.swg
1105
+ *
1106
+ * This file contains support for tracking mappings from
1107
+ * Ruby objects to C++ objects. This functionality is needed
1108
+ * to implement mark functions for Ruby's mark and sweep
1109
+ * garbage collector.
1110
+ * ----------------------------------------------------------------------------- */
1111
+
1112
+ #ifdef __cplusplus
1113
+ extern "C" {
1114
+ #endif
1115
+
1116
+ /* Ruby 1.8 actually assumes the first case. */
1117
+ #if SIZEOF_VOIDP == SIZEOF_LONG
1118
+ # define SWIG2NUM(v) LONG2NUM((unsigned long)v)
1119
+ # define NUM2SWIG(x) (unsigned long)NUM2LONG(x)
1120
+ #elif SIZEOF_VOIDP == SIZEOF_LONG_LONG
1121
+ # define SWIG2NUM(v) LL2NUM((unsigned long long)v)
1122
+ # define NUM2SWIG(x) (unsigned long long)NUM2LL(x)
1123
+ #else
1124
+ # error sizeof(void*) is not the same as long or long long
1125
+ #endif
1126
+
1127
+
1128
+ /* Global Ruby hash table to store Trackings from C/C++
1129
+ structs to Ruby Objects.
1130
+ */
1131
+ static VALUE swig_ruby_trackings = Qnil;
1132
+
1133
+ /* Global variable that stores a reference to the ruby
1134
+ hash table delete function. */
1135
+ static ID swig_ruby_hash_delete;
1136
+
1137
+ /* Setup a Ruby hash table to store Trackings */
1138
+ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1139
+ /* Create a ruby hash table to store Trackings from C++
1140
+ objects to Ruby objects. */
1141
+
1142
+ /* Try to see if some other .so has already created a
1143
+ tracking hash table, which we keep hidden in an instance var
1144
+ in the SWIG module.
1145
+ This is done to allow multiple DSOs to share the same
1146
+ tracking table.
1147
+ */
1148
+ ID trackings_id = rb_intern( "@__trackings__" );
1149
+ VALUE verbose = rb_gv_get("VERBOSE");
1150
+ rb_gv_set("VERBOSE", Qfalse);
1151
+ swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
1152
+ rb_gv_set("VERBOSE", verbose);
1153
+
1154
+ /* No, it hasn't. Create one ourselves */
1155
+ if ( swig_ruby_trackings == Qnil )
1156
+ {
1157
+ swig_ruby_trackings = rb_hash_new();
1158
+ rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
1159
+ }
1160
+
1161
+ /* Now store a reference to the hash table delete function
1162
+ so that we only have to look it up once.*/
1163
+ swig_ruby_hash_delete = rb_intern("delete");
1164
+ }
1165
+
1166
+ /* Get a Ruby number to reference a pointer */
1167
+ SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
1168
+ /* We cast the pointer to an unsigned long
1169
+ and then store a reference to it using
1170
+ a Ruby number object. */
1171
+
1172
+ /* Convert the pointer to a Ruby number */
1173
+ return SWIG2NUM(ptr);
1174
+ }
1175
+
1176
+ /* Get a Ruby number to reference an object */
1177
+ SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
1178
+ /* We cast the object to an unsigned long
1179
+ and then store a reference to it using
1180
+ a Ruby number object. */
1181
+
1182
+ /* Convert the Object to a Ruby number */
1183
+ return SWIG2NUM(object);
1184
+ }
1185
+
1186
+ /* Get a Ruby object from a previously stored reference */
1187
+ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
1188
+ /* The provided Ruby number object is a reference
1189
+ to the Ruby object we want.*/
1190
+
1191
+ /* Convert the Ruby number to a Ruby object */
1192
+ return NUM2SWIG(reference);
1193
+ }
1194
+
1195
+ /* Add a Tracking from a C/C++ struct to a Ruby object */
1196
+ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1197
+ /* In a Ruby hash table we store the pointer and
1198
+ the associated Ruby object. The trick here is
1199
+ that we cannot store the Ruby object directly - if
1200
+ we do then it cannot be garbage collected. So
1201
+ instead we typecast it as a unsigned long and
1202
+ convert it to a Ruby number object.*/
1203
+
1204
+ /* Get a reference to the pointer as a Ruby number */
1205
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1206
+
1207
+ /* Get a reference to the Ruby object as a Ruby number */
1208
+ VALUE value = SWIG_RubyObjectToReference(object);
1209
+
1210
+ /* Store the mapping to the global hash table. */
1211
+ rb_hash_aset(swig_ruby_trackings, key, value);
1212
+ }
1213
+
1214
+ /* Get the Ruby object that owns the specified C/C++ struct */
1215
+ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1216
+ /* Get a reference to the pointer as a Ruby number */
1217
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1218
+
1219
+ /* Now lookup the value stored in the global hash table */
1220
+ VALUE value = rb_hash_aref(swig_ruby_trackings, key);
1221
+
1222
+ if (value == Qnil) {
1223
+ /* No object exists - return nil. */
1224
+ return Qnil;
1225
+ }
1226
+ else {
1227
+ /* Convert this value to Ruby object */
1228
+ return SWIG_RubyReferenceToObject(value);
1229
+ }
1230
+ }
1231
+
1232
+ /* Remove a Tracking from a C/C++ struct to a Ruby object. It
1233
+ is very important to remove objects once they are destroyed
1234
+ since the same memory address may be reused later to create
1235
+ a new object. */
1236
+ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1237
+ /* Get a reference to the pointer as a Ruby number */
1238
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1239
+
1240
+ /* Delete the object from the hash table by calling Ruby's
1241
+ do this we need to call the Hash.delete method.*/
1242
+ rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
1243
+ }
1244
+
1245
+ /* This is a helper method that unlinks a Ruby object from its
1246
+ underlying C++ object. This is needed if the lifetime of the
1247
+ Ruby object is longer than the C++ object */
1248
+ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1249
+ VALUE object = SWIG_RubyInstanceFor(ptr);
1250
+
1251
+ if (object != Qnil) {
1252
+ DATA_PTR(object) = 0;
1253
+ }
1254
+ }
1255
+
1256
+
1257
+ #ifdef __cplusplus
1258
+ }
1259
+ #endif
1260
+
1261
+ /* -----------------------------------------------------------------------------
1262
+ * Ruby API portion that goes into the runtime
1263
+ * ----------------------------------------------------------------------------- */
1264
+
1265
+ #ifdef __cplusplus
1266
+ extern "C" {
1267
+ #endif
1268
+
1269
+ SWIGINTERN VALUE
1270
+ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1271
+ if (NIL_P(target)) {
1272
+ target = o;
1273
+ } else {
1274
+ if (TYPE(target) != T_ARRAY) {
1275
+ VALUE o2 = target;
1276
+ target = rb_ary_new();
1277
+ rb_ary_push(target, o2);
1278
+ }
1279
+ rb_ary_push(target, o);
1280
+ }
1281
+ return target;
1282
+ }
1283
+
1284
+ /* For ruby1.8.4 and earlier. */
1285
+ #ifndef RUBY_INIT_STACK
1286
+ RUBY_EXTERN void Init_stack(VALUE* addr);
1287
+ # define RUBY_INIT_STACK \
1288
+ VALUE variable_in_this_stack_frame; \
1289
+ Init_stack(&variable_in_this_stack_frame);
1290
+ #endif
1291
+
1292
+
1293
+ #ifdef __cplusplus
1294
+ }
1295
+ #endif
1296
+
1297
+
1298
+ /* -----------------------------------------------------------------------------
1299
+ * See the LICENSE file for information on copyright, usage and redistribution
1300
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
1301
+ *
1302
+ * rubyrun.swg
1303
+ *
1304
+ * This file contains the runtime support for Ruby modules
1305
+ * and includes code for managing global variables and pointer
1306
+ * type checking.
1307
+ * ----------------------------------------------------------------------------- */
1308
+
1309
+ /* For backward compatibility only */
1310
+ #define SWIG_POINTER_EXCEPTION 0
1311
+
1312
+ /* for raw pointers */
1313
+ #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
1314
+ #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own)
1315
+ #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags)
1316
+ #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own)
1317
+ #define swig_owntype ruby_owntype
1318
+
1319
+ /* for raw packed data */
1320
+ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
1321
+ #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
1322
+
1323
+ /* for class or struct pointers */
1324
+ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
1325
+ #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
1326
+
1327
+ /* for C or C++ function pointers */
1328
+ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0)
1329
+ #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0)
1330
+
1331
+ /* for C++ member pointers, ie, member methods */
1332
+ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty)
1333
+ #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
1334
+
1335
+
1336
+ /* Runtime API */
1337
+
1338
+ #define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
1339
+ #define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
1340
+
1341
+
1342
+ /* Error manipulation */
1343
+
1344
+ #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
1345
+ #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg)
1346
+ #define SWIG_fail goto fail
1347
+
1348
+
1349
+ /* Ruby-specific SWIG API */
1350
+
1351
+ #define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
1352
+ #define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
1353
+ #define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
1354
+ #define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
1355
+ #define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
1356
+
1357
+ #include "assert.h"
1358
+
1359
+ /* -----------------------------------------------------------------------------
1360
+ * pointers/data manipulation
1361
+ * ----------------------------------------------------------------------------- */
1362
+
1363
+ #ifdef __cplusplus
1364
+ extern "C" {
1365
+ #endif
1366
+
1367
+ typedef struct {
1368
+ VALUE klass;
1369
+ VALUE mImpl;
1370
+ void (*mark)(void *);
1371
+ void (*destroy)(void *);
1372
+ int trackObjects;
1373
+ } swig_class;
1374
+
1375
+
1376
+ /* Global pointer used to keep some internal SWIG stuff */
1377
+ static VALUE _cSWIG_Pointer = Qnil;
1378
+ static VALUE swig_runtime_data_type_pointer = Qnil;
1379
+
1380
+ /* Global IDs used to keep some internal SWIG stuff */
1381
+ static ID swig_arity_id = 0;
1382
+ static ID swig_call_id = 0;
1383
+
1384
+ /*
1385
+ If your swig extension is to be run within an embedded ruby and has
1386
+ director callbacks, you should set -DRUBY_EMBEDDED during compilation.
1387
+ This will reset ruby's stack frame on each entry point from the main
1388
+ program the first time a virtual director function is invoked (in a
1389
+ non-recursive way).
1390
+ If this is not done, you run the risk of Ruby trashing the stack.
1391
+ */
1392
+
1393
+ #ifdef RUBY_EMBEDDED
1394
+
1395
+ # define SWIG_INIT_STACK \
1396
+ if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \
1397
+ ++swig_virtual_calls;
1398
+ # define SWIG_RELEASE_STACK --swig_virtual_calls;
1399
+ # define Ruby_DirectorTypeMismatchException(x) \
1400
+ rb_raise( rb_eTypeError, x ); return c_result;
1401
+
1402
+ static unsigned int swig_virtual_calls = 0;
1403
+
1404
+ #else /* normal non-embedded extension */
1405
+
1406
+ # define SWIG_INIT_STACK
1407
+ # define SWIG_RELEASE_STACK
1408
+ # define Ruby_DirectorTypeMismatchException(x) \
1409
+ throw Swig::DirectorTypeMismatchException( x );
1410
+
1411
+ #endif /* RUBY_EMBEDDED */
1412
+
1413
+
1414
+ SWIGRUNTIME VALUE
1415
+ getExceptionClass(void) {
1416
+ static int init = 0;
1417
+ static VALUE rubyExceptionClass ;
1418
+ if (!init) {
1419
+ init = 1;
1420
+ rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception"));
1421
+ }
1422
+ return rubyExceptionClass;
1423
+ }
1424
+
1425
+ /* This code checks to see if the Ruby object being raised as part
1426
+ of an exception inherits from the Ruby class Exception. If so,
1427
+ the object is simply returned. If not, then a new Ruby exception
1428
+ object is created and that will be returned to Ruby.*/
1429
+ SWIGRUNTIME VALUE
1430
+ SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) {
1431
+ VALUE exceptionClass = getExceptionClass();
1432
+ if (rb_obj_is_kind_of(obj, exceptionClass)) {
1433
+ return obj;
1434
+ } else {
1435
+ return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj));
1436
+ }
1437
+ }
1438
+
1439
+ /* Initialize Ruby runtime support */
1440
+ SWIGRUNTIME void
1441
+ SWIG_Ruby_InitRuntime(void)
1442
+ {
1443
+ if (_mSWIG == Qnil) {
1444
+ _mSWIG = rb_define_module("SWIG");
1445
+ swig_call_id = rb_intern("call");
1446
+ swig_arity_id = rb_intern("arity");
1447
+ }
1448
+ }
1449
+
1450
+ /* Define Ruby class for C type */
1451
+ SWIGRUNTIME void
1452
+ SWIG_Ruby_define_class(swig_type_info *type)
1453
+ {
1454
+ VALUE klass;
1455
+ char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1456
+ sprintf(klass_name, "TYPE%s", type->name);
1457
+ if (NIL_P(_cSWIG_Pointer)) {
1458
+ _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
1459
+ rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
1460
+ }
1461
+ klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
1462
+ free((void *) klass_name);
1463
+ }
1464
+
1465
+ /* Create a new pointer object */
1466
+ SWIGRUNTIME VALUE
1467
+ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1468
+ {
1469
+ int own = flags & SWIG_POINTER_OWN;
1470
+ int track;
1471
+ char *klass_name;
1472
+ swig_class *sklass;
1473
+ VALUE klass;
1474
+ VALUE obj;
1475
+
1476
+ if (!ptr)
1477
+ return Qnil;
1478
+
1479
+ if (type->clientdata) {
1480
+ sklass = (swig_class *) type->clientdata;
1481
+
1482
+ /* Are we tracking this class and have we already returned this Ruby object? */
1483
+ track = sklass->trackObjects;
1484
+ if (track) {
1485
+ obj = SWIG_RubyInstanceFor(ptr);
1486
+
1487
+ /* Check the object's type and make sure it has the correct type.
1488
+ It might not in cases where methods do things like
1489
+ downcast methods. */
1490
+ if (obj != Qnil) {
1491
+ VALUE value = rb_iv_get(obj, "@__swigtype__");
1492
+ char* type_name = RSTRING_PTR(value);
1493
+
1494
+ if (strcmp(type->name, type_name) == 0) {
1495
+ return obj;
1496
+ }
1497
+ }
1498
+ }
1499
+
1500
+ /* Create a new Ruby object */
1501
+ obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark),
1502
+ ( own ? VOIDFUNC(sklass->destroy) :
1503
+ (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 )
1504
+ ), ptr);
1505
+
1506
+ /* If tracking is on for this class then track this object. */
1507
+ if (track) {
1508
+ SWIG_RubyAddTracking(ptr, obj);
1509
+ }
1510
+ } else {
1511
+ klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1512
+ sprintf(klass_name, "TYPE%s", type->name);
1513
+ klass = rb_const_get(_mSWIG, rb_intern(klass_name));
1514
+ free((void *) klass_name);
1515
+ obj = Data_Wrap_Struct(klass, 0, 0, ptr);
1516
+ }
1517
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1518
+
1519
+ return obj;
1520
+ }
1521
+
1522
+ /* Create a new class instance (always owned) */
1523
+ SWIGRUNTIME VALUE
1524
+ SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
1525
+ {
1526
+ VALUE obj;
1527
+ swig_class *sklass = (swig_class *) type->clientdata;
1528
+ obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0);
1529
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1530
+ return obj;
1531
+ }
1532
+
1533
+ /* Get type mangle from class name */
1534
+ SWIGRUNTIMEINLINE char *
1535
+ SWIG_Ruby_MangleStr(VALUE obj)
1536
+ {
1537
+ VALUE stype = rb_iv_get(obj, "@__swigtype__");
1538
+ return StringValuePtr(stype);
1539
+ }
1540
+
1541
+ /* Acquire a pointer value */
1542
+ typedef void (*ruby_owntype)(void*);
1543
+
1544
+ SWIGRUNTIME ruby_owntype
1545
+ SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) {
1546
+ if (obj) {
1547
+ ruby_owntype oldown = RDATA(obj)->dfree;
1548
+ RDATA(obj)->dfree = own;
1549
+ return oldown;
1550
+ } else {
1551
+ return 0;
1552
+ }
1553
+ }
1554
+
1555
+ /* Convert a pointer value */
1556
+ SWIGRUNTIME int
1557
+ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own)
1558
+ {
1559
+ char *c;
1560
+ swig_cast_info *tc;
1561
+ void *vptr = 0;
1562
+
1563
+ /* Grab the pointer */
1564
+ if (NIL_P(obj)) {
1565
+ *ptr = 0;
1566
+ return SWIG_OK;
1567
+ } else {
1568
+ if (TYPE(obj) != T_DATA) {
1569
+ return SWIG_ERROR;
1570
+ }
1571
+ Data_Get_Struct(obj, void, vptr);
1572
+ }
1573
+
1574
+ if (own) *own = RDATA(obj)->dfree;
1575
+
1576
+ /* Check to see if the input object is giving up ownership
1577
+ of the underlying C struct or C++ object. If so then we
1578
+ need to reset the destructor since the Ruby object no
1579
+ longer owns the underlying C++ object.*/
1580
+ if (flags & SWIG_POINTER_DISOWN) {
1581
+ /* Is tracking on for this class? */
1582
+ int track = 0;
1583
+ if (ty && ty->clientdata) {
1584
+ swig_class *sklass = (swig_class *) ty->clientdata;
1585
+ track = sklass->trackObjects;
1586
+ }
1587
+
1588
+ if (track) {
1589
+ /* We are tracking objects for this class. Thus we change the destructor
1590
+ * to SWIG_RubyRemoveTracking. This allows us to
1591
+ * remove the mapping from the C++ to Ruby object
1592
+ * when the Ruby object is garbage collected. If we don't
1593
+ * do this, then it is possible we will return a reference
1594
+ * to a Ruby object that no longer exists thereby crashing Ruby. */
1595
+ RDATA(obj)->dfree = SWIG_RubyRemoveTracking;
1596
+ } else {
1597
+ RDATA(obj)->dfree = 0;
1598
+ }
1599
+ }
1600
+
1601
+ /* Do type-checking if type info was provided */
1602
+ if (ty) {
1603
+ if (ty->clientdata) {
1604
+ if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
1605
+ if (vptr == 0) {
1606
+ /* The object has already been deleted */
1607
+ return SWIG_ObjectPreviouslyDeletedError;
1608
+ }
1609
+ *ptr = vptr;
1610
+ return SWIG_OK;
1611
+ }
1612
+ }
1613
+ if ((c = SWIG_MangleStr(obj)) == NULL) {
1614
+ return SWIG_ERROR;
1615
+ }
1616
+ tc = SWIG_TypeCheck(c, ty);
1617
+ if (!tc) {
1618
+ return SWIG_ERROR;
1619
+ } else {
1620
+ int newmemory = 0;
1621
+ *ptr = SWIG_TypeCast(tc, vptr, &newmemory);
1622
+ assert(!newmemory); /* newmemory handling not yet implemented */
1623
+ }
1624
+ } else {
1625
+ *ptr = vptr;
1626
+ }
1627
+
1628
+ return SWIG_OK;
1629
+ }
1630
+
1631
+ /* Check convert */
1632
+ SWIGRUNTIMEINLINE int
1633
+ SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty)
1634
+ {
1635
+ char *c = SWIG_MangleStr(obj);
1636
+ if (!c) return 0;
1637
+ return SWIG_TypeCheck(c,ty) != 0;
1638
+ }
1639
+
1640
+ SWIGRUNTIME VALUE
1641
+ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
1642
+ char result[1024];
1643
+ char *r = result;
1644
+ if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
1645
+ *(r++) = '_';
1646
+ r = SWIG_PackData(r, ptr, sz);
1647
+ strcpy(r, type->name);
1648
+ return rb_str_new2(result);
1649
+ }
1650
+
1651
+ /* Convert a packed value value */
1652
+ SWIGRUNTIME int
1653
+ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
1654
+ swig_cast_info *tc;
1655
+ const char *c;
1656
+
1657
+ if (TYPE(obj) != T_STRING) goto type_error;
1658
+ c = StringValuePtr(obj);
1659
+ /* Pointer values must start with leading underscore */
1660
+ if (*c != '_') goto type_error;
1661
+ c++;
1662
+ c = SWIG_UnpackData(c, ptr, sz);
1663
+ if (ty) {
1664
+ tc = SWIG_TypeCheck(c, ty);
1665
+ if (!tc) goto type_error;
1666
+ }
1667
+ return SWIG_OK;
1668
+
1669
+ type_error:
1670
+ return SWIG_ERROR;
1671
+ }
1672
+
1673
+ SWIGRUNTIME swig_module_info *
1674
+ SWIG_Ruby_GetModule(void)
1675
+ {
1676
+ VALUE pointer;
1677
+ swig_module_info *ret = 0;
1678
+ VALUE verbose = rb_gv_get("VERBOSE");
1679
+
1680
+ /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */
1681
+ rb_gv_set("VERBOSE", Qfalse);
1682
+
1683
+ /* first check if pointer already created */
1684
+ pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
1685
+ if (pointer != Qnil) {
1686
+ Data_Get_Struct(pointer, swig_module_info, ret);
1687
+ }
1688
+
1689
+ /* reinstate warnings */
1690
+ rb_gv_set("VERBOSE", verbose);
1691
+ return ret;
1692
+ }
1693
+
1694
+ SWIGRUNTIME void
1695
+ SWIG_Ruby_SetModule(swig_module_info *pointer)
1696
+ {
1697
+ /* register a new class */
1698
+ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
1699
+ /* create and store the structure pointer to a global variable */
1700
+ swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
1701
+ rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
1702
+ }
1703
+
1704
+ /* This function can be used to check whether a proc or method or similarly
1705
+ callable function has been passed. Usually used in a %typecheck, like:
1706
+
1707
+ %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) {
1708
+ $result = SWIG_Ruby_isCallable( $input );
1709
+ }
1710
+ */
1711
+ SWIGINTERN
1712
+ int SWIG_Ruby_isCallable( VALUE proc )
1713
+ {
1714
+ if ( rb_respond_to( proc, swig_call_id ) == Qtrue )
1715
+ return 1;
1716
+ return 0;
1717
+ }
1718
+
1719
+ /* This function can be used to check the arity (number of arguments)
1720
+ a proc or method can take. Usually used in a %typecheck.
1721
+ Valid arities will be that equal to minimal or those < 0
1722
+ which indicate a variable number of parameters at the end.
1723
+ */
1724
+ SWIGINTERN
1725
+ int SWIG_Ruby_arity( VALUE proc, int minimal )
1726
+ {
1727
+ if ( rb_respond_to( proc, swig_arity_id ) == Qtrue )
1728
+ {
1729
+ VALUE num = rb_funcall( proc, swig_arity_id, 0 );
1730
+ int arity = NUM2INT(num);
1731
+ if ( arity < 0 && (arity+1) < -minimal ) return 1;
1732
+ if ( arity == minimal ) return 1;
1733
+ return 1;
1734
+ }
1735
+ return 0;
1736
+ }
1737
+
1738
+
1739
+ #ifdef __cplusplus
1740
+ }
1741
+ #endif
1742
+
1743
+
1744
+
1745
+ #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
1746
+
1747
+ #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
1748
+
1749
+
1750
+
1751
+ #define SWIG_exception(code, msg) do { SWIG_Error(code, msg);; } while(0)
1752
+
1753
+
1754
+ /* -------- TYPES TABLE (BEGIN) -------- */
1755
+
1756
+ #define SWIGTYPE_p_char swig_types[0]
1757
+ #define SWIGTYPE_p_double swig_types[1]
1758
+ #define SWIGTYPE_p_float swig_types[2]
1759
+ #define SWIGTYPE_p_int swig_types[3]
1760
+ #define SWIGTYPE_p_p_void swig_types[4]
1761
+ #define SWIGTYPE_p_uvio swig_types[5]
1762
+ static swig_type_info *swig_types[7];
1763
+ static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0};
1764
+ #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
1765
+ #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
1766
+
1767
+ /* -------- TYPES TABLE (END) -------- */
1768
+
1769
+ #define SWIG_init Init_miriad
1770
+ #define SWIG_name "Miriad"
1771
+
1772
+ static VALUE mMiriad;
1773
+
1774
+ #define SWIG_RUBY_THREAD_BEGIN_BLOCK
1775
+ #define SWIG_RUBY_THREAD_END_BLOCK
1776
+
1777
+
1778
+ #define SWIGVERSION 0x010335
1779
+ #define SWIG_VERSION SWIGVERSION
1780
+
1781
+
1782
+ #define SWIG_as_voidptr(a) (void *)((const void *)(a))
1783
+ #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
1784
+
1785
+
1786
+ #include "miriad.h"
1787
+ #define MAX_STRLEN (255)
1788
+
1789
+ typedef struct {
1790
+ int fd;
1791
+ } uvio;
1792
+
1793
+
1794
+ VALUE mirlib_eMirlibError;
1795
+
1796
+
1797
+ #include "narray.h"
1798
+ extern const char * na_typestring[];
1799
+
1800
+ // Raises TypeError is v is not an NArray
1801
+ #define Check_NArray(v) \
1802
+ if(!NA_IsNArray(v)) { \
1803
+ rb_raise(rb_eTypeError,"requires NArray, got %s", \
1804
+ rb_class2name(CLASS_OF(v))); \
1805
+ }
1806
+
1807
+ #define Check_NArrayType(v,tc) \
1808
+ Check_NArray(v) \
1809
+ if(tc >= NA_NTYPES) { \
1810
+ rb_raise(rb_eArgError,"invalid type code check requested (%d)", tc); \
1811
+ } \
1812
+ if(NA_TYPE(v) >= NA_NTYPES) { \
1813
+ rb_raise(rb_eArgError,"invalid type code found in NArray object (%d)", NA_TYPE(v)); \
1814
+ } \
1815
+ if(NA_TYPE(v) != tc) { \
1816
+ rb_raise(rb_eTypeError,"requires type code %s (not %s)", \
1817
+ na_typestring[tc], \
1818
+ na_typestring[NA_TYPE(v)]); \
1819
+ }
1820
+
1821
+ #define Check_NArrayType2(v,tc1,tc2) \
1822
+ Check_NArray(v) \
1823
+ if(tc1 >= NA_NTYPES) { \
1824
+ rb_raise(rb_eArgError,"invalid type code check requested (%d)", tc1); \
1825
+ } \
1826
+ if(tc2 >= NA_NTYPES) { \
1827
+ rb_raise(rb_eArgError,"invalid type code check requested (%d)", tc2); \
1828
+ } \
1829
+ if(NA_TYPE(v) >= NA_NTYPES) { \
1830
+ rb_raise(rb_eArgError,"invalid type code found in NArray object (%d)", NA_TYPE(v)); \
1831
+ } \
1832
+ if(NA_TYPE(v) != tc1 && NA_TYPE(v) != tc2) { \
1833
+ rb_raise(rb_eTypeError,"requires type code %s or %s (not %s)", \
1834
+ na_typestring[tc1], \
1835
+ na_typestring[tc2], \
1836
+ na_typestring[NA_TYPE(v)]); \
1837
+ }
1838
+
1839
+
1840
+ SWIGINTERN swig_type_info*
1841
+ SWIG_pchar_descriptor(void)
1842
+ {
1843
+ static int init = 0;
1844
+ static swig_type_info* info = 0;
1845
+ if (!init) {
1846
+ info = SWIG_TypeQuery("_p_char");
1847
+ init = 1;
1848
+ }
1849
+ return info;
1850
+ }
1851
+
1852
+
1853
+ SWIGINTERN int
1854
+ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
1855
+ {
1856
+ if (TYPE(obj) == T_STRING) {
1857
+ #if defined(StringValuePtr)
1858
+ char *cstr = StringValuePtr(obj);
1859
+ #else
1860
+ char *cstr = STR2CSTR(obj);
1861
+ #endif
1862
+ size_t size = RSTRING_LEN(obj) + 1;
1863
+ if (cptr) {
1864
+ if (alloc) {
1865
+ if (*alloc == SWIG_NEWOBJ) {
1866
+ *cptr = (char *)memcpy((char *)malloc((size)*sizeof(char)), cstr, sizeof(char)*(size));
1867
+ } else {
1868
+ *cptr = cstr;
1869
+ *alloc = SWIG_OLDOBJ;
1870
+ }
1871
+ }
1872
+ }
1873
+ if (psize) *psize = size;
1874
+ return SWIG_OK;
1875
+ } else {
1876
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
1877
+ if (pchar_descriptor) {
1878
+ void* vptr = 0;
1879
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
1880
+ if (cptr) *cptr = (char *)vptr;
1881
+ if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0;
1882
+ if (alloc) *alloc = SWIG_OLDOBJ;
1883
+ return SWIG_OK;
1884
+ }
1885
+ }
1886
+ }
1887
+ return SWIG_TypeError;
1888
+ }
1889
+
1890
+
1891
+
1892
+
1893
+ SWIGINTERN uvio *new_uvio(char *name,char *status){
1894
+ char * his_status = "append";
1895
+ uvio * self;
1896
+ if(name == NULL) {
1897
+ SWIG_exception(SWIG_NullReferenceError,"invalid name");
1898
+ }
1899
+ if(status == NULL) {
1900
+ SWIG_exception(SWIG_NullReferenceError,"invalid status");
1901
+ }
1902
+ switch(status[0]) {
1903
+ case 'o':
1904
+ case 'r': status = "old";
1905
+ his_status = "read";
1906
+ break;
1907
+ case 'n':
1908
+ case 'w': status = "new";
1909
+ break;
1910
+ case 'a': status = "append";
1911
+ break;
1912
+ default: SWIG_exception(SWIG_ValueError,"invalid status");
1913
+ break;
1914
+ }
1915
+ self = malloc(sizeof(uvio));
1916
+ uvopen_c(&(self->fd), name, status);
1917
+ // TODO Error check
1918
+ hisopen_c(self->fd,his_status);
1919
+ uvset_c(self->fd, "preamble", "uvw/time/baseline", 0, 0.0, 0.0, 0.0);
1920
+ uvset_c(self->fd, "coord", "nanosec", 0, 0.0, 0.0, 0.0);
1921
+ if(status[0] == 'o') {
1922
+ // To read initial values of uv vars
1923
+ uvnext_c(self->fd);
1924
+ uvrewind_c(self->fd);
1925
+ }
1926
+ return self;
1927
+ }
1928
+ SWIGINTERN void uvio_close(uvio *self){
1929
+ hisclose_c(self->fd);
1930
+ uvflush_c(self->fd);
1931
+ uvclose_c(self->fd);
1932
+ self->fd = -1;
1933
+ }
1934
+ SWIGINTERN void uvio_flush(uvio *self){
1935
+ uvflush_c(self->fd);
1936
+ }
1937
+ SWIGINTERN void uvio_uvnext(uvio *self){
1938
+ uvnext_c(self->fd);
1939
+ }
1940
+ SWIGINTERN void uvio_rewind(uvio *self){
1941
+ uvrewind_c(self->fd);
1942
+ }
1943
+ SWIGINTERN void uvio_probvr(uvio *self,char *var,char *type,int *length,int *updated){
1944
+ uvprobvr_c(self->fd, var, type, length, updated);
1945
+ }
1946
+
1947
+ #include <limits.h>
1948
+ #if !defined(SWIG_NO_LLONG_MAX)
1949
+ # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
1950
+ # define LLONG_MAX __LONG_LONG_MAX__
1951
+ # define LLONG_MIN (-LLONG_MAX - 1LL)
1952
+ # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
1953
+ # endif
1954
+ #endif
1955
+
1956
+
1957
+ SWIGINTERN VALUE
1958
+ SWIG_ruby_failed(void)
1959
+ {
1960
+ return Qnil;
1961
+ }
1962
+
1963
+
1964
+ /*@SWIG:/Users/davidm/local/share/swig/1.3.35/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1965
+ SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
1966
+ {
1967
+ VALUE obj = args[0];
1968
+ VALUE type = TYPE(obj);
1969
+ long *res = (long *)(args[1]);
1970
+ *res = type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj);
1971
+ return obj;
1972
+ }
1973
+ /*@SWIG@*/
1974
+
1975
+ SWIGINTERN int
1976
+ SWIG_AsVal_long (VALUE obj, long* val)
1977
+ {
1978
+ VALUE type = TYPE(obj);
1979
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
1980
+ long v;
1981
+ VALUE a[2];
1982
+ a[0] = obj;
1983
+ a[1] = (VALUE)(&v);
1984
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
1985
+ if (val) *val = v;
1986
+ return SWIG_OK;
1987
+ }
1988
+ }
1989
+ return SWIG_TypeError;
1990
+ }
1991
+
1992
+
1993
+ SWIGINTERN int
1994
+ SWIG_AsVal_int (VALUE obj, int *val)
1995
+ {
1996
+ long v;
1997
+ int res = SWIG_AsVal_long (obj, &v);
1998
+ if (SWIG_IsOK(res)) {
1999
+ if ((v < INT_MIN || v > INT_MAX)) {
2000
+ return SWIG_OverflowError;
2001
+ } else {
2002
+ if (val) *val = (int)(v);
2003
+ }
2004
+ }
2005
+ return res;
2006
+ }
2007
+
2008
+ SWIGINTERN void uvio_putvr(uvio *self,char *var,char *data,int n,int type){
2009
+ uvputvr_c(self->fd, type, var, data, n);
2010
+ }
2011
+ SWIGINTERN void uvio_scan(uvio *self,char *var){
2012
+ uvscan_c(self->fd, var);
2013
+ }
2014
+ SWIGINTERN void uvio_write(uvio *self,double *preamble,float *data,int *flags,int n){
2015
+ uvwrite_c(self->fd, preamble, data, flags, n);
2016
+ }
2017
+ SWIGINTERN void uvio_wwrite(uvio *self,float *data,int *flags,int n){
2018
+ uvwwrite_c(self->fd, data, flags, n);
2019
+ }
2020
+
2021
+ /*@SWIG:/Users/davidm/local/share/swig/1.3.35/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
2022
+ SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
2023
+ {
2024
+ VALUE obj = args[0];
2025
+ VALUE type = TYPE(obj);
2026
+ double *res = (double *)(args[1]);
2027
+ *res = (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj)));
2028
+ return obj;
2029
+ }
2030
+ /*@SWIG@*/
2031
+
2032
+ SWIGINTERN int
2033
+ SWIG_AsVal_double (VALUE obj, double *val)
2034
+ {
2035
+ VALUE type = TYPE(obj);
2036
+ if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) {
2037
+ double v;
2038
+ VALUE a[2];
2039
+ a[0] = obj;
2040
+ a[1] = (VALUE)(&v);
2041
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
2042
+ if (val) *val = v;
2043
+ return SWIG_OK;
2044
+ }
2045
+ }
2046
+ return SWIG_TypeError;
2047
+ }
2048
+
2049
+ SWIGINTERN void uvio_set(uvio *self,char *object,char *type,int n,double p1,double p2,double p3){
2050
+ uvset_c(self->fd, object, type, n, p1, p2, p3);
2051
+ }
2052
+ SWIGINTERN void uvio_uvread(uvio *self,double *preamble,float *data,int *flags,int n,int *nread){
2053
+ uvread_c(self->fd, preamble, data, flags, n, nread);
2054
+ }
2055
+ SWIGINTERN void uvio_uvwread(uvio *self,float *data,int *flags,int n,int *nread){
2056
+ uvwread_c(self->fd, data, flags, n, nread);
2057
+ }
2058
+ SWIGINTERN void uvio_getvr(uvio *self,char *name,void **value,int *n,char *type){
2059
+ int updated = 0;
2060
+ *n = 0;
2061
+ *type = ' ';
2062
+ uvprobvr_c(self->fd,name,type,n,&updated);
2063
+ if(*n > 0) {
2064
+ switch(*type) {
2065
+ case 'a': *value = malloc(sizeof(char)*((*n)+1));
2066
+ uvgetvr_c(self->fd,H_BYTE,name,(char *)(*value),((*n)+1));
2067
+ break;
2068
+ case 'i': *value = malloc(sizeof(int)*(*n));
2069
+ uvgetvr_c(self->fd,H_INT,name,(char *)(*value),*n);
2070
+ break;
2071
+ case 'r': *value = malloc(sizeof(float)*(*n));
2072
+ uvgetvr_c(self->fd,H_REAL,name,(char *)(*value),*n);
2073
+ break;
2074
+ case 'd': *value = malloc(sizeof(double)*(*n));
2075
+ uvgetvr_c(self->fd,H_DBLE,name,(char *)(*value),*n);
2076
+ break;
2077
+ case ' ': // Variable not present
2078
+ case 'j': // Unsuported
2079
+ // Return NULL, but don't raise exception
2080
+ break;
2081
+ default: // TODO Raise exception
2082
+ break;
2083
+ }
2084
+ }
2085
+ }
2086
+ SWIGINTERN int uvio_updated(uvio *self){
2087
+ return uvupdate_c(self->fd);
2088
+ }
2089
+ SWIGINTERN void uvio_track(uvio *self,char *name,char *switches){
2090
+ uvtrack_c(self->fd, name, switches);
2091
+ }
2092
+ SWIGINTERN void uvio_sela(uvio *self,char *object,int datasel,char *string){
2093
+ uvsela_c(self->fd, object, string, datasel);
2094
+ }
2095
+ SWIGINTERN void uvio_select(uvio *self,char *object,int datasel,double p1,double p2){
2096
+ uvselect_c(self->fd, object, p1, p2, datasel);
2097
+ }
2098
+ SWIGINTERN void uvio_flagwr(uvio *self,int *flags){
2099
+ uvflgwr_c(self->fd, flags);
2100
+ }
2101
+ SWIGINTERN void uvio_wflagwr(uvio *self,int *flags){
2102
+ uvwflgwr_c(self->fd, flags);
2103
+ }
2104
+ SWIGINTERN int uvio_haccess(uvio *self,char *keyword,char *status){
2105
+ int ihandle;
2106
+ int iostat;
2107
+
2108
+ if(keyword == NULL) {
2109
+ SWIG_exception(SWIG_NullReferenceError,"invalid item name");
2110
+ }
2111
+ if(status == NULL) {
2112
+ SWIG_exception(SWIG_NullReferenceError,"invalid status");
2113
+ }
2114
+ switch(status[0]) {
2115
+ case 'r': status = "read";
2116
+ break;
2117
+ case 'w': status = "write";
2118
+ break;
2119
+ case 'a': status = "append";
2120
+ break;
2121
+ case 's': status = "scratch";
2122
+ break;
2123
+ default: SWIG_exception(SWIG_ValueError,"invalid status");
2124
+ break;
2125
+ }
2126
+
2127
+ haccess_c(self->fd,&ihandle,keyword,status,&iostat);
2128
+
2129
+ if(iostat != 0) {
2130
+ SWIG_exception(SWIG_IOError, "error opening item");
2131
+ }
2132
+ return ihandle;
2133
+ }
2134
+
2135
+ #define SWIG_From_long LONG2NUM
2136
+
2137
+
2138
+ SWIGINTERNINLINE VALUE
2139
+ SWIG_From_int (int value)
2140
+ {
2141
+ return SWIG_From_long (value);
2142
+ }
2143
+
2144
+ SWIGINTERN void uvio_hdaccess(uvio *self,int ihandle){
2145
+ int iostat;
2146
+ hdaccess_c(ihandle,&iostat);
2147
+ if(iostat != 0 && iostat != -1) {
2148
+ SWIG_exception(SWIG_IOError, "error closing item");
2149
+ }
2150
+ }
2151
+
2152
+ /*@SWIG:/Users/davidm/local/share/swig/1.3.35/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
2153
+ SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
2154
+ {
2155
+ VALUE obj = args[0];
2156
+ VALUE type = TYPE(obj);
2157
+ unsigned long *res = (unsigned long *)(args[1]);
2158
+ *res = type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj);
2159
+ return obj;
2160
+ }
2161
+ /*@SWIG@*/
2162
+
2163
+ SWIGINTERN int
2164
+ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val)
2165
+ {
2166
+ VALUE type = TYPE(obj);
2167
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
2168
+ unsigned long v;
2169
+ VALUE a[2];
2170
+ a[0] = obj;
2171
+ a[1] = (VALUE)(&v);
2172
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
2173
+ if (val) *val = v;
2174
+ return SWIG_OK;
2175
+ }
2176
+ }
2177
+ return SWIG_TypeError;
2178
+ }
2179
+
2180
+
2181
+ SWIGINTERNINLINE int
2182
+ SWIG_AsVal_size_t (VALUE obj, size_t *val)
2183
+ {
2184
+ unsigned long v;
2185
+ int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
2186
+ if (SWIG_IsOK(res) && val) *val = (size_t)(v);
2187
+ return res;
2188
+ }
2189
+
2190
+ SWIGINTERN void uvio_hreadln(uvio *self,int ihandle,char *linein,size_t length,int *iostat){
2191
+ if(linein == NULL) {
2192
+ SWIG_exception(
2193
+ SWIG_NullReferenceError, "no buffer to receive line from item");
2194
+ }
2195
+ if(length < 1) {
2196
+ SWIG_exception(
2197
+ SWIG_ValueError, "invalid buffer length to receive line from item");
2198
+ }
2199
+
2200
+ hreada_c(ihandle, linein, length, iostat);
2201
+ linein[length-1] = '\0';
2202
+
2203
+ if(*iostat != 0 && *iostat != -1) {
2204
+ SWIG_exception(SWIG_IOError, "error reading item");
2205
+ }
2206
+ }
2207
+ SWIGINTERN void uvio_hwriteln(uvio *self,int ihandle,char *lineout,size_t length){
2208
+ int iostat;
2209
+ if(lineout == NULL) {
2210
+ SWIG_exception(
2211
+ SWIG_NullReferenceError, "no line to write to item");
2212
+ }
2213
+ if(length < 1) {
2214
+ SWIG_exception(
2215
+ SWIG_ValueError, "invalid line length to write to item");
2216
+ }
2217
+
2218
+ hwritea_c(ihandle, lineout, length, &iostat);
2219
+
2220
+ if(iostat != 0 && iostat != -1) {
2221
+ SWIG_exception(SWIG_IOError, "error writing item");
2222
+ }
2223
+ }
2224
+ SWIGINTERN void uvio_hiswrite(uvio *self,char *text){
2225
+ hiswrite_c(self->fd, text);
2226
+ }
2227
+ SWIGINTERN void uvio_wrhda(uvio *self,char *keyword,char *value){
2228
+ wrhda_c (self->fd, keyword, value);
2229
+ }
2230
+ swig_class cUvio;
2231
+
2232
+ #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
2233
+ SWIGINTERN VALUE
2234
+ _wrap_Uvio_allocate(VALUE self) {
2235
+ #else
2236
+ SWIGINTERN VALUE
2237
+ _wrap_Uvio_allocate(int argc, VALUE *argv, VALUE self) {
2238
+ #endif
2239
+
2240
+
2241
+ VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_uvio);
2242
+ #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
2243
+ rb_obj_call_init(vresult, argc, argv);
2244
+ #endif
2245
+ return vresult;
2246
+ }
2247
+
2248
+
2249
+ SWIGINTERN VALUE
2250
+ _wrap_new_Uvio(int argc, VALUE *argv, VALUE self) {
2251
+ char *arg1 = (char *) 0 ;
2252
+ char *arg2 = (char *) 0 ;
2253
+ uvio *result = 0 ;
2254
+ int res2 ;
2255
+ char *buf2 = 0 ;
2256
+ int alloc2 = 0 ;
2257
+
2258
+ if ((argc < 2) || (argc > 2)) {
2259
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2260
+ }
2261
+ {
2262
+ arg1 = StringValuePtr(argv[0]);
2263
+ }
2264
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2265
+ if (!SWIG_IsOK(res2)) {
2266
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","uvio", 2, argv[1] ));
2267
+ }
2268
+ arg2 = (char *)(buf2);
2269
+ result = (uvio *)new_uvio(arg1,arg2);DATA_PTR(self) = result;
2270
+
2271
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2272
+ return self;
2273
+ fail:
2274
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2275
+ return Qnil;
2276
+ }
2277
+
2278
+
2279
+ SWIGINTERN void delete_uvio(uvio *self){
2280
+ if(self->fd != -1) {
2281
+ hisclose_c(self->fd);
2282
+ uvflush_c(self->fd);
2283
+ uvclose_c(self->fd);
2284
+ self->fd = -1;
2285
+ }
2286
+ free(self);
2287
+ }
2288
+ SWIGINTERN void
2289
+ free_uvio(uvio *arg1) {
2290
+ delete_uvio(arg1);
2291
+ }
2292
+
2293
+ SWIGINTERN VALUE
2294
+ _wrap_Uvio_close(int argc, VALUE *argv, VALUE self) {
2295
+ uvio *arg1 = (uvio *) 0 ;
2296
+ void *argp1 = 0 ;
2297
+ int res1 = 0 ;
2298
+
2299
+ if ((argc < 0) || (argc > 0)) {
2300
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2301
+ }
2302
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2303
+ if (!SWIG_IsOK(res1)) {
2304
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","close", 1, self ));
2305
+ }
2306
+ arg1 = (uvio *)(argp1);
2307
+ uvio_close(arg1);
2308
+ return Qnil;
2309
+ fail:
2310
+ return Qnil;
2311
+ }
2312
+
2313
+
2314
+ SWIGINTERN VALUE
2315
+ _wrap_Uvio_flush(int argc, VALUE *argv, VALUE self) {
2316
+ uvio *arg1 = (uvio *) 0 ;
2317
+ void *argp1 = 0 ;
2318
+ int res1 = 0 ;
2319
+
2320
+ if ((argc < 0) || (argc > 0)) {
2321
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2322
+ }
2323
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2324
+ if (!SWIG_IsOK(res1)) {
2325
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","flush", 1, self ));
2326
+ }
2327
+ arg1 = (uvio *)(argp1);
2328
+ uvio_flush(arg1);
2329
+ return Qnil;
2330
+ fail:
2331
+ return Qnil;
2332
+ }
2333
+
2334
+
2335
+ SWIGINTERN VALUE
2336
+ _wrap_Uvio_uvnext(int argc, VALUE *argv, VALUE self) {
2337
+ uvio *arg1 = (uvio *) 0 ;
2338
+ void *argp1 = 0 ;
2339
+ int res1 = 0 ;
2340
+
2341
+ if ((argc < 0) || (argc > 0)) {
2342
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2343
+ }
2344
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2345
+ if (!SWIG_IsOK(res1)) {
2346
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","uvnext", 1, self ));
2347
+ }
2348
+ arg1 = (uvio *)(argp1);
2349
+ uvio_uvnext(arg1);
2350
+ return Qnil;
2351
+ fail:
2352
+ return Qnil;
2353
+ }
2354
+
2355
+
2356
+ SWIGINTERN VALUE
2357
+ _wrap_Uvio_rewind(int argc, VALUE *argv, VALUE self) {
2358
+ uvio *arg1 = (uvio *) 0 ;
2359
+ void *argp1 = 0 ;
2360
+ int res1 = 0 ;
2361
+
2362
+ if ((argc < 0) || (argc > 0)) {
2363
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2364
+ }
2365
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2366
+ if (!SWIG_IsOK(res1)) {
2367
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","rewind", 1, self ));
2368
+ }
2369
+ arg1 = (uvio *)(argp1);
2370
+ uvio_rewind(arg1);
2371
+ return Qnil;
2372
+ fail:
2373
+ return Qnil;
2374
+ }
2375
+
2376
+
2377
+ SWIGINTERN VALUE
2378
+ _wrap_Uvio_probvr(int argc, VALUE *argv, VALUE self) {
2379
+ uvio *arg1 = (uvio *) 0 ;
2380
+ char *arg2 = (char *) 0 ;
2381
+ char *arg3 = (char *) 0 ;
2382
+ int *arg4 = (int *) 0 ;
2383
+ int *arg5 = (int *) 0 ;
2384
+ void *argp1 = 0 ;
2385
+ int res1 = 0 ;
2386
+ int res2 ;
2387
+ char *buf2 = 0 ;
2388
+ int alloc2 = 0 ;
2389
+ char type3 ;
2390
+ int length3 ;
2391
+ int updated3 ;
2392
+ VALUE vresult = Qnil;
2393
+
2394
+ {
2395
+ arg3 = &type3;
2396
+ arg4 = &length3;
2397
+ arg5 = &updated3;
2398
+ }
2399
+ if ((argc < 1) || (argc > 1)) {
2400
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2401
+ }
2402
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2403
+ if (!SWIG_IsOK(res1)) {
2404
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","probvr", 1, self ));
2405
+ }
2406
+ arg1 = (uvio *)(argp1);
2407
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
2408
+ if (!SWIG_IsOK(res2)) {
2409
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","probvr", 2, argv[0] ));
2410
+ }
2411
+ arg2 = (char *)(buf2);
2412
+ uvio_probvr(arg1,arg2,arg3,arg4,arg5);
2413
+ {
2414
+ if(arg3[0] == ' ') {
2415
+ vresult = Qnil;
2416
+ } else {
2417
+ vresult = SWIG_Ruby_AppendOutput(vresult, rb_str_new(arg3,1));
2418
+ vresult = SWIG_Ruby_AppendOutput(vresult, INT2NUM(*arg4));
2419
+ vresult = SWIG_Ruby_AppendOutput(vresult, *arg5 ? Qtrue : Qfalse);
2420
+ }
2421
+ }
2422
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2423
+ return vresult;
2424
+ fail:
2425
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2426
+ return Qnil;
2427
+ }
2428
+
2429
+
2430
+ SWIGINTERN VALUE
2431
+ _wrap_Uvio_putvr(int argc, VALUE *argv, VALUE self) {
2432
+ uvio *arg1 = (uvio *) 0 ;
2433
+ char *arg2 = (char *) 0 ;
2434
+ char *arg3 = (char *) 0 ;
2435
+ int arg4 ;
2436
+ int arg5 = (int) -1 ;
2437
+ void *argp1 = 0 ;
2438
+ int res1 = 0 ;
2439
+ int res2 ;
2440
+ char *buf2 = 0 ;
2441
+ int alloc2 = 0 ;
2442
+ VALUE vinput3 ;
2443
+ int datatype3 ;
2444
+
2445
+ if ((argc < 2) || (argc > 3)) {
2446
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2447
+ }
2448
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2449
+ if (!SWIG_IsOK(res1)) {
2450
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","putvr", 1, self ));
2451
+ }
2452
+ arg1 = (uvio *)(argp1);
2453
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
2454
+ if (!SWIG_IsOK(res2)) {
2455
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","putvr", 2, argv[0] ));
2456
+ }
2457
+ arg2 = (char *)(buf2);
2458
+ {
2459
+ // If NArray
2460
+ if(NA_IsNArray(argv[1])) {
2461
+ int type_code = NA_TYPE(argv[1]);
2462
+ switch(type_code) {
2463
+ case NA_SINT:
2464
+ case NA_LINT: datatype3 = H_INT; break;
2465
+ case NA_SFLOAT: datatype3 = H_REAL; break;
2466
+ case NA_DFLOAT: datatype3 = H_DBLE; break;
2467
+ default:
2468
+ rb_raise(rb_eTypeError, "unsupported type code '%s'",
2469
+ na_typestring[type_code]);
2470
+ }
2471
+ arg3 = NA_PTR_TYPE(argv[1],char *);
2472
+ arg4 = NA_TOTAL(argv[1]);
2473
+
2474
+ // Else, treat as Ruby type
2475
+ } else {
2476
+ VALUE elem0 = argv[1];
2477
+ if(TYPE(argv[1]) == T_ARRAY) {
2478
+ arg4 = RARRAY(argv[1])->len;
2479
+ elem0 = rb_ary_entry(argv[1],0);
2480
+ } else {
2481
+ // Convert into one element array
2482
+ arg4 = 1;
2483
+ argv[1] = rb_ary_new3(1,argv[1]);
2484
+ }
2485
+ // Autodetect Miriad type from Ruby type
2486
+ // (Convenient, but not always a good idea)
2487
+ switch(TYPE(elem0)) {
2488
+ case T_FIXNUM:
2489
+ case T_BIGNUM: datatype3 = H_INT; break;
2490
+ case T_FLOAT: datatype3 = H_DBLE; break;
2491
+ case T_STRING: datatype3 = H_BYTE; break;
2492
+ default:
2493
+ rb_raise(rb_eArgError,
2494
+ "invalid or unsupported type for uv variable (%d)", TYPE(elem0));
2495
+ }
2496
+ }
2497
+ vinput3 = argv[1];
2498
+ }
2499
+ if (argc > 2) {
2500
+ {
2501
+ arg5 = NUM2INT(argv[2]);
2502
+ switch(arg5) {
2503
+ case 'a': arg5 = H_BYTE; break;
2504
+ case 'i': arg5 = H_INT; break;
2505
+ case 'd': arg5 = H_DBLE; break;
2506
+ case 'r': arg5 = H_REAL; break;
2507
+ }
2508
+ }
2509
+ }
2510
+ {
2511
+ int i;
2512
+ if(arg5 == -1) {
2513
+ // Autodetect from Ruby type
2514
+ arg5 = datatype3;
2515
+ }
2516
+ // NArray input will have already set pointer
2517
+ if(TYPE(vinput3) == T_ARRAY) {
2518
+ switch(arg5) {
2519
+ case H_INT:
2520
+ arg3 = (char *)ALLOCA_N(int,arg4);
2521
+ for(i=0;i<arg4;i++) {
2522
+ ((int *)arg3)[i] = NUM2INT(rb_ary_entry(vinput3,i));
2523
+ }
2524
+ break;
2525
+ case H_REAL:
2526
+ arg3 = (char *)ALLOCA_N(double,arg4);
2527
+ for(i=0;i<arg4;i++) {
2528
+ ((float *)arg3)[i] = NUM2DBL(rb_ary_entry(vinput3,i));
2529
+ }
2530
+ break;
2531
+ case H_DBLE:
2532
+ arg3 = (char *)ALLOCA_N(double,arg4);
2533
+ for(i=0;i<arg4;i++) {
2534
+ ((double *)arg3)[i] = NUM2DBL(rb_ary_entry(vinput3,i));
2535
+ }
2536
+ break;
2537
+ case H_BYTE:
2538
+ arg3 = RSTRING(rb_ary_entry(vinput3,0))->ptr;
2539
+ arg4 = RSTRING(rb_ary_entry(vinput3,0))->len;
2540
+ break;
2541
+ default:
2542
+ rb_raise(rb_eArgError,
2543
+ "invalid or unsupported type for uv variable (%d)", arg5);
2544
+ }
2545
+ }
2546
+ }
2547
+ uvio_putvr(arg1,arg2,arg3,arg4,arg5);
2548
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2549
+ return Qnil;
2550
+ fail:
2551
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2552
+ return Qnil;
2553
+ }
2554
+
2555
+
2556
+ SWIGINTERN VALUE
2557
+ _wrap_Uvio_scan(int argc, VALUE *argv, VALUE self) {
2558
+ uvio *arg1 = (uvio *) 0 ;
2559
+ char *arg2 = (char *) 0 ;
2560
+ void *argp1 = 0 ;
2561
+ int res1 = 0 ;
2562
+ int res2 ;
2563
+ char *buf2 = 0 ;
2564
+ int alloc2 = 0 ;
2565
+
2566
+ if ((argc < 1) || (argc > 1)) {
2567
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2568
+ }
2569
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2570
+ if (!SWIG_IsOK(res1)) {
2571
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","scan", 1, self ));
2572
+ }
2573
+ arg1 = (uvio *)(argp1);
2574
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
2575
+ if (!SWIG_IsOK(res2)) {
2576
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","scan", 2, argv[0] ));
2577
+ }
2578
+ arg2 = (char *)(buf2);
2579
+ uvio_scan(arg1,arg2);
2580
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2581
+ return Qnil;
2582
+ fail:
2583
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2584
+ return Qnil;
2585
+ }
2586
+
2587
+
2588
+ SWIGINTERN VALUE
2589
+ _wrap_Uvio_write(int argc, VALUE *argv, VALUE self) {
2590
+ uvio *arg1 = (uvio *) 0 ;
2591
+ double *arg2 = (double *) 0 ;
2592
+ float *arg3 = (float *) 0 ;
2593
+ int *arg4 = (int *) 0 ;
2594
+ int arg5 ;
2595
+ void *argp1 = 0 ;
2596
+ int res1 = 0 ;
2597
+ int ndata3 ;
2598
+ int nflag4 ;
2599
+ VALUE vresult = Qnil;
2600
+
2601
+ if ((argc < 3) || (argc > 3)) {
2602
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
2603
+ }
2604
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2605
+ if (!SWIG_IsOK(res1)) {
2606
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","write", 1, self ));
2607
+ }
2608
+ arg1 = (uvio *)(argp1);
2609
+ {
2610
+ // If FIXNUM allocate NA_DFLOAT array that many
2611
+ // This only makes sense for reads (or writing zeros)
2612
+ if(TYPE(argv[0]) == T_FIXNUM) {
2613
+ int rank = 1;
2614
+ int shape = FIX2INT(argv[0]);
2615
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
2616
+ argv[0] = na_make_object(NA_DFLOAT,rank,&shape,naclass);
2617
+ }
2618
+ // If NArray
2619
+ if(NA_IsNArray(argv[0])) {
2620
+ Check_NArrayType(argv[0],NA_DFLOAT);
2621
+ arg2 = NA_PTR_TYPE(argv[0],double *);
2622
+ } else {
2623
+ int i;
2624
+ Check_Type(argv[0], T_ARRAY);
2625
+ // Get the length of the array
2626
+ // TODO Bounds checking somehow?
2627
+ int n = RARRAY(argv[0])->len;
2628
+ arg2 = ALLOCA_N(double, n);
2629
+ // Get the first element in array
2630
+ VALUE *ptr = RARRAY(argv[0])->ptr;
2631
+ for (i=0; i < n; i++) {
2632
+ // Convert Ruby Object to double
2633
+ arg2[i] = NUM2DBL(ptr[i]);
2634
+ }
2635
+ }
2636
+ }
2637
+ {
2638
+ int i;
2639
+ // If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
2640
+ // This only makes sense for reads (or writing zeros)
2641
+ if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
2642
+ ndata3 = NUM2INT(argv[1]);
2643
+ int rank = 1;
2644
+ int shape = ndata3;
2645
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
2646
+ argv[1] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
2647
+ }
2648
+ // If NArray
2649
+ if(NA_IsNArray(argv[1])) {
2650
+ Check_NArrayType2(argv[1],NA_SFLOAT,NA_SCOMPLEX);
2651
+ arg3 = NA_PTR_TYPE(argv[1],float *);
2652
+ ndata3 = NA_TOTAL(argv[1]);
2653
+ if(NA_TYPE(argv[1]) == NA_SFLOAT) {
2654
+ ndata3 /= 2;
2655
+ }
2656
+ } else {
2657
+ Check_Type(argv[1], T_ARRAY);
2658
+ // Allocate C array on stack
2659
+ ndata3 = RARRAY(argv[1])->len;
2660
+ arg3 = ALLOCA_N(float,ndata3);
2661
+ VALUE * ptr = RARRAY(argv[1])->ptr;
2662
+ // TODO Use write in #if to avoid copying on read?
2663
+ for(i=0; i < ndata3; i++) {
2664
+ arg3[i] = NUM2DBL(ptr[i]);
2665
+ }
2666
+ ndata3 /= 2;
2667
+ }
2668
+ }
2669
+ {
2670
+ int i;
2671
+ // If FIXNUM or BIGNUM, allocate NA_LINT array that many
2672
+ // This only makes sense for reads (or writing zeros)
2673
+ if(TYPE(argv[2]) == T_FIXNUM || TYPE(argv[2]) == T_BIGNUM) {
2674
+ nflag4 = NUM2INT(argv[2]);
2675
+ int rank = 1;
2676
+ int shape = nflag4;
2677
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
2678
+ argv[2] = na_make_object(NA_LINT,rank,&shape,naclass);
2679
+ }
2680
+ // If NArray
2681
+ if(NA_IsNArray(argv[2])) {
2682
+ Check_NArrayType(argv[2],NA_LINT);
2683
+ arg4 = NA_PTR_TYPE(argv[2],int *);
2684
+ nflag4 = NA_TOTAL(argv[2]);
2685
+ } else {
2686
+ Check_Type(argv[2], T_ARRAY);
2687
+ nflag4 = RARRAY(argv[2])->len;
2688
+ arg4 = ALLOCA_N(int,nflag4);
2689
+ VALUE * ptr = RARRAY(argv[2])->ptr;
2690
+ for(i=0; i < nflag4; i++) {
2691
+ arg4[i] = FIX2INT(ptr[i]);
2692
+ }
2693
+ }
2694
+
2695
+ arg5 = nflag4;
2696
+ }
2697
+ {
2698
+ if(ndata3 != nflag4) {
2699
+ rb_raise(rb_eArgError,
2700
+ "lengths of complex data (%d) and flags (%d) do not match", ndata3, nflag4);
2701
+ }
2702
+ }
2703
+ uvio_write(arg1,arg2,arg3,arg4,arg5);
2704
+ vresult = rb_ary_new();
2705
+ {
2706
+ // If NArray, data are already in place
2707
+ if(TYPE(argv[0]) == T_ARRAY) {
2708
+ int i;
2709
+ // Get the length of the array
2710
+ // TODO Bounds checking somehow?
2711
+ int n = RARRAY(argv[0])->len;
2712
+ // Get the first element in array
2713
+ VALUE *ptr = RARRAY(argv[0])->ptr;
2714
+ for (i=0; i < n; i++) {
2715
+ // Store or convert doubles to Ruby Objects
2716
+ if(TYPE(ptr[i]) == T_FLOAT) {
2717
+ // TODO Is this legit?
2718
+ RFLOAT(ptr[i])->value = arg2[i];
2719
+ } else {
2720
+ ptr[i] = rb_float_new(arg2[i]);
2721
+ }
2722
+ }
2723
+ }
2724
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[0]);
2725
+ }
2726
+ {
2727
+ int ndata;
2728
+ int i;
2729
+ // If NArray, data are already in place
2730
+ if(TYPE(argv[1]) == T_ARRAY) {
2731
+ ndata = RARRAY(argv[1])->len;
2732
+ VALUE * ptr = RARRAY(argv[1])->ptr;
2733
+ for(i=0; i < ndata; i++) {
2734
+ // Store or convert doubles to Ruby Objects
2735
+ if(TYPE(ptr[i]) == T_FLOAT) {
2736
+ // TODO Is this legit?
2737
+ RFLOAT(ptr[i])->value = arg3[i];
2738
+ } else {
2739
+ ptr[i] = rb_float_new(arg3[i]);
2740
+ }
2741
+ }
2742
+ }
2743
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[1]);
2744
+ }
2745
+ {
2746
+ int nflag;
2747
+ int i;
2748
+ // If NArray, data are already in place
2749
+ if(TYPE(argv[2]) == T_ARRAY) {
2750
+ nflag = RARRAY(argv[2])->len;
2751
+ VALUE * ptr = RARRAY(argv[2])->ptr;
2752
+ for(i=0; i < nflag; i++) {
2753
+ ptr[i] = INT2FIX(arg4[i]);
2754
+ }
2755
+ }
2756
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[2]);
2757
+ }
2758
+ return vresult;
2759
+ fail:
2760
+ return Qnil;
2761
+ }
2762
+
2763
+
2764
+ SWIGINTERN VALUE
2765
+ _wrap_Uvio_wwrite(int argc, VALUE *argv, VALUE self) {
2766
+ uvio *arg1 = (uvio *) 0 ;
2767
+ float *arg2 = (float *) 0 ;
2768
+ int *arg3 = (int *) 0 ;
2769
+ int arg4 ;
2770
+ void *argp1 = 0 ;
2771
+ int res1 = 0 ;
2772
+ int ndata2 ;
2773
+ int nflag3 ;
2774
+ VALUE vresult = Qnil;
2775
+
2776
+ if ((argc < 2) || (argc > 2)) {
2777
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2778
+ }
2779
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2780
+ if (!SWIG_IsOK(res1)) {
2781
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","wwrite", 1, self ));
2782
+ }
2783
+ arg1 = (uvio *)(argp1);
2784
+ {
2785
+ int i;
2786
+ // If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
2787
+ // This only makes sense for reads (or writing zeros)
2788
+ if(TYPE(argv[0]) == T_FIXNUM || TYPE(argv[0]) == T_BIGNUM) {
2789
+ ndata2 = NUM2INT(argv[0]);
2790
+ int rank = 1;
2791
+ int shape = ndata2;
2792
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
2793
+ argv[0] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
2794
+ }
2795
+ // If NArray
2796
+ if(NA_IsNArray(argv[0])) {
2797
+ Check_NArrayType2(argv[0],NA_SFLOAT,NA_SCOMPLEX);
2798
+ arg2 = NA_PTR_TYPE(argv[0],float *);
2799
+ ndata2 = NA_TOTAL(argv[0]);
2800
+ if(NA_TYPE(argv[0]) == NA_SFLOAT) {
2801
+ ndata2 /= 2;
2802
+ }
2803
+ } else {
2804
+ Check_Type(argv[0], T_ARRAY);
2805
+ // Allocate C array on stack
2806
+ ndata2 = RARRAY(argv[0])->len;
2807
+ arg2 = ALLOCA_N(float,ndata2);
2808
+ VALUE * ptr = RARRAY(argv[0])->ptr;
2809
+ // TODO Use wwrite in #if to avoid copying on read?
2810
+ for(i=0; i < ndata2; i++) {
2811
+ arg2[i] = NUM2DBL(ptr[i]);
2812
+ }
2813
+ ndata2 /= 2;
2814
+ }
2815
+ }
2816
+ {
2817
+ int i;
2818
+ // If FIXNUM or BIGNUM, allocate NA_LINT array that many
2819
+ // This only makes sense for reads (or writing zeros)
2820
+ if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
2821
+ nflag3 = NUM2INT(argv[1]);
2822
+ int rank = 1;
2823
+ int shape = nflag3;
2824
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
2825
+ argv[1] = na_make_object(NA_LINT,rank,&shape,naclass);
2826
+ }
2827
+ // If NArray
2828
+ if(NA_IsNArray(argv[1])) {
2829
+ Check_NArrayType(argv[1],NA_LINT);
2830
+ arg3 = NA_PTR_TYPE(argv[1],int *);
2831
+ nflag3 = NA_TOTAL(argv[1]);
2832
+ } else {
2833
+ Check_Type(argv[1], T_ARRAY);
2834
+ nflag3 = RARRAY(argv[1])->len;
2835
+ arg3 = ALLOCA_N(int,nflag3);
2836
+ VALUE * ptr = RARRAY(argv[1])->ptr;
2837
+ for(i=0; i < nflag3; i++) {
2838
+ arg3[i] = FIX2INT(ptr[i]);
2839
+ }
2840
+ }
2841
+
2842
+ arg4 = nflag3;
2843
+ }
2844
+ uvio_wwrite(arg1,arg2,arg3,arg4);
2845
+ vresult = rb_ary_new();
2846
+ {
2847
+ int ndata;
2848
+ int i;
2849
+ // If NArray, data are already in place
2850
+ if(TYPE(argv[0]) == T_ARRAY) {
2851
+ ndata = RARRAY(argv[0])->len;
2852
+ VALUE * ptr = RARRAY(argv[0])->ptr;
2853
+ for(i=0; i < ndata; i++) {
2854
+ // Store or convert doubles to Ruby Objects
2855
+ if(TYPE(ptr[i]) == T_FLOAT) {
2856
+ // TODO Is this legit?
2857
+ RFLOAT(ptr[i])->value = arg2[i];
2858
+ } else {
2859
+ ptr[i] = rb_float_new(arg2[i]);
2860
+ }
2861
+ }
2862
+ }
2863
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[0]);
2864
+ }
2865
+ {
2866
+ int nflag;
2867
+ int i;
2868
+ // If NArray, data are already in place
2869
+ if(TYPE(argv[1]) == T_ARRAY) {
2870
+ nflag = RARRAY(argv[1])->len;
2871
+ VALUE * ptr = RARRAY(argv[1])->ptr;
2872
+ for(i=0; i < nflag; i++) {
2873
+ ptr[i] = INT2FIX(arg3[i]);
2874
+ }
2875
+ }
2876
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[1]);
2877
+ }
2878
+ return vresult;
2879
+ fail:
2880
+ return Qnil;
2881
+ }
2882
+
2883
+
2884
+ SWIGINTERN VALUE
2885
+ _wrap_Uvio_set(int argc, VALUE *argv, VALUE self) {
2886
+ uvio *arg1 = (uvio *) 0 ;
2887
+ char *arg2 = (char *) 0 ;
2888
+ char *arg3 = (char *) 0 ;
2889
+ int arg4 = (int) 0 ;
2890
+ double arg5 = (double) 0.0 ;
2891
+ double arg6 = (double) 0.0 ;
2892
+ double arg7 = (double) 0.0 ;
2893
+ void *argp1 = 0 ;
2894
+ int res1 = 0 ;
2895
+ int res2 ;
2896
+ char *buf2 = 0 ;
2897
+ int alloc2 = 0 ;
2898
+ int res3 ;
2899
+ char *buf3 = 0 ;
2900
+ int alloc3 = 0 ;
2901
+ int val4 ;
2902
+ int ecode4 = 0 ;
2903
+ double val5 ;
2904
+ int ecode5 = 0 ;
2905
+ double val6 ;
2906
+ int ecode6 = 0 ;
2907
+ double val7 ;
2908
+ int ecode7 = 0 ;
2909
+
2910
+ if ((argc < 2) || (argc > 6)) {
2911
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2912
+ }
2913
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2914
+ if (!SWIG_IsOK(res1)) {
2915
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","set", 1, self ));
2916
+ }
2917
+ arg1 = (uvio *)(argp1);
2918
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
2919
+ if (!SWIG_IsOK(res2)) {
2920
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","set", 2, argv[0] ));
2921
+ }
2922
+ arg2 = (char *)(buf2);
2923
+ res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3);
2924
+ if (!SWIG_IsOK(res3)) {
2925
+ SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char *","set", 3, argv[1] ));
2926
+ }
2927
+ arg3 = (char *)(buf3);
2928
+ if (argc > 2) {
2929
+ ecode4 = SWIG_AsVal_int(argv[2], &val4);
2930
+ if (!SWIG_IsOK(ecode4)) {
2931
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "int","set", 4, argv[2] ));
2932
+ }
2933
+ arg4 = (int)(val4);
2934
+ }
2935
+ if (argc > 3) {
2936
+ ecode5 = SWIG_AsVal_double(argv[3], &val5);
2937
+ if (!SWIG_IsOK(ecode5)) {
2938
+ SWIG_exception_fail(SWIG_ArgError(ecode5), Ruby_Format_TypeError( "", "double","set", 5, argv[3] ));
2939
+ }
2940
+ arg5 = (double)(val5);
2941
+ }
2942
+ if (argc > 4) {
2943
+ ecode6 = SWIG_AsVal_double(argv[4], &val6);
2944
+ if (!SWIG_IsOK(ecode6)) {
2945
+ SWIG_exception_fail(SWIG_ArgError(ecode6), Ruby_Format_TypeError( "", "double","set", 6, argv[4] ));
2946
+ }
2947
+ arg6 = (double)(val6);
2948
+ }
2949
+ if (argc > 5) {
2950
+ ecode7 = SWIG_AsVal_double(argv[5], &val7);
2951
+ if (!SWIG_IsOK(ecode7)) {
2952
+ SWIG_exception_fail(SWIG_ArgError(ecode7), Ruby_Format_TypeError( "", "double","set", 7, argv[5] ));
2953
+ }
2954
+ arg7 = (double)(val7);
2955
+ }
2956
+ uvio_set(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
2957
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2958
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
2959
+ return Qnil;
2960
+ fail:
2961
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2962
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
2963
+ return Qnil;
2964
+ }
2965
+
2966
+
2967
+ SWIGINTERN VALUE
2968
+ _wrap_Uvio_uvread(int argc, VALUE *argv, VALUE self) {
2969
+ uvio *arg1 = (uvio *) 0 ;
2970
+ double *arg2 = (double *) 0 ;
2971
+ float *arg3 = (float *) 0 ;
2972
+ int *arg4 = (int *) 0 ;
2973
+ int arg5 ;
2974
+ int *arg6 = (int *) 0 ;
2975
+ void *argp1 = 0 ;
2976
+ int res1 = 0 ;
2977
+ int ndata3 ;
2978
+ int nflag4 ;
2979
+ int temp6 ;
2980
+ VALUE vresult = Qnil;
2981
+
2982
+ {
2983
+ arg6 = &temp6;
2984
+ }
2985
+ if ((argc < 3) || (argc > 3)) {
2986
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
2987
+ }
2988
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
2989
+ if (!SWIG_IsOK(res1)) {
2990
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","uvread", 1, self ));
2991
+ }
2992
+ arg1 = (uvio *)(argp1);
2993
+ {
2994
+ // If FIXNUM allocate NA_DFLOAT array that many
2995
+ // This only makes sense for reads (or writing zeros)
2996
+ if(TYPE(argv[0]) == T_FIXNUM) {
2997
+ int rank = 1;
2998
+ int shape = FIX2INT(argv[0]);
2999
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
3000
+ argv[0] = na_make_object(NA_DFLOAT,rank,&shape,naclass);
3001
+ }
3002
+ // If NArray
3003
+ if(NA_IsNArray(argv[0])) {
3004
+ Check_NArrayType(argv[0],NA_DFLOAT);
3005
+ arg2 = NA_PTR_TYPE(argv[0],double *);
3006
+ } else {
3007
+ int i;
3008
+ Check_Type(argv[0], T_ARRAY);
3009
+ // Get the length of the array
3010
+ // TODO Bounds checking somehow?
3011
+ int n = RARRAY(argv[0])->len;
3012
+ arg2 = ALLOCA_N(double, n);
3013
+ // Get the first element in array
3014
+ VALUE *ptr = RARRAY(argv[0])->ptr;
3015
+ for (i=0; i < n; i++) {
3016
+ // Convert Ruby Object to double
3017
+ arg2[i] = NUM2DBL(ptr[i]);
3018
+ }
3019
+ }
3020
+ }
3021
+ {
3022
+ int i;
3023
+ // If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
3024
+ // This only makes sense for reads (or writing zeros)
3025
+ if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
3026
+ ndata3 = NUM2INT(argv[1]);
3027
+ int rank = 1;
3028
+ int shape = ndata3;
3029
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
3030
+ argv[1] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
3031
+ }
3032
+ // If NArray
3033
+ if(NA_IsNArray(argv[1])) {
3034
+ Check_NArrayType2(argv[1],NA_SFLOAT,NA_SCOMPLEX);
3035
+ arg3 = NA_PTR_TYPE(argv[1],float *);
3036
+ ndata3 = NA_TOTAL(argv[1]);
3037
+ if(NA_TYPE(argv[1]) == NA_SFLOAT) {
3038
+ ndata3 /= 2;
3039
+ }
3040
+ } else {
3041
+ Check_Type(argv[1], T_ARRAY);
3042
+ // Allocate C array on stack
3043
+ ndata3 = RARRAY(argv[1])->len;
3044
+ arg3 = ALLOCA_N(float,ndata3);
3045
+ VALUE * ptr = RARRAY(argv[1])->ptr;
3046
+ // TODO Use uvread in #if to avoid copying on read?
3047
+ for(i=0; i < ndata3; i++) {
3048
+ arg3[i] = NUM2DBL(ptr[i]);
3049
+ }
3050
+ ndata3 /= 2;
3051
+ }
3052
+ }
3053
+ {
3054
+ int i;
3055
+ // If FIXNUM or BIGNUM, allocate NA_LINT array that many
3056
+ // This only makes sense for reads (or writing zeros)
3057
+ if(TYPE(argv[2]) == T_FIXNUM || TYPE(argv[2]) == T_BIGNUM) {
3058
+ nflag4 = NUM2INT(argv[2]);
3059
+ int rank = 1;
3060
+ int shape = nflag4;
3061
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
3062
+ argv[2] = na_make_object(NA_LINT,rank,&shape,naclass);
3063
+ }
3064
+ // If NArray
3065
+ if(NA_IsNArray(argv[2])) {
3066
+ Check_NArrayType(argv[2],NA_LINT);
3067
+ arg4 = NA_PTR_TYPE(argv[2],int *);
3068
+ nflag4 = NA_TOTAL(argv[2]);
3069
+ } else {
3070
+ Check_Type(argv[2], T_ARRAY);
3071
+ nflag4 = RARRAY(argv[2])->len;
3072
+ arg4 = ALLOCA_N(int,nflag4);
3073
+ VALUE * ptr = RARRAY(argv[2])->ptr;
3074
+ for(i=0; i < nflag4; i++) {
3075
+ arg4[i] = FIX2INT(ptr[i]);
3076
+ }
3077
+ }
3078
+
3079
+ arg5 = nflag4;
3080
+ }
3081
+ {
3082
+ if(ndata3 != nflag4) {
3083
+ rb_raise(rb_eArgError,
3084
+ "lengths of complex data (%d) and flags (%d) do not match", ndata3, nflag4);
3085
+ }
3086
+ }
3087
+ uvio_uvread(arg1,arg2,arg3,arg4,arg5,arg6);
3088
+ vresult = rb_ary_new();
3089
+ {
3090
+ // If NArray, data are already in place
3091
+ if(TYPE(argv[0]) == T_ARRAY) {
3092
+ int i;
3093
+ // Get the length of the array
3094
+ // TODO Bounds checking somehow?
3095
+ int n = RARRAY(argv[0])->len;
3096
+ // Get the first element in array
3097
+ VALUE *ptr = RARRAY(argv[0])->ptr;
3098
+ for (i=0; i < n; i++) {
3099
+ // Store or convert doubles to Ruby Objects
3100
+ if(TYPE(ptr[i]) == T_FLOAT) {
3101
+ // TODO Is this legit?
3102
+ RFLOAT(ptr[i])->value = arg2[i];
3103
+ } else {
3104
+ ptr[i] = rb_float_new(arg2[i]);
3105
+ }
3106
+ }
3107
+ }
3108
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[0]);
3109
+ }
3110
+ {
3111
+ int ndata;
3112
+ int i;
3113
+ // If NArray, data are already in place
3114
+ if(TYPE(argv[1]) == T_ARRAY) {
3115
+ ndata = RARRAY(argv[1])->len;
3116
+ VALUE * ptr = RARRAY(argv[1])->ptr;
3117
+ for(i=0; i < ndata; i++) {
3118
+ // Store or convert doubles to Ruby Objects
3119
+ if(TYPE(ptr[i]) == T_FLOAT) {
3120
+ // TODO Is this legit?
3121
+ RFLOAT(ptr[i])->value = arg3[i];
3122
+ } else {
3123
+ ptr[i] = rb_float_new(arg3[i]);
3124
+ }
3125
+ }
3126
+ }
3127
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[1]);
3128
+ }
3129
+ {
3130
+ int nflag;
3131
+ int i;
3132
+ // If NArray, data are already in place
3133
+ if(TYPE(argv[2]) == T_ARRAY) {
3134
+ nflag = RARRAY(argv[2])->len;
3135
+ VALUE * ptr = RARRAY(argv[2])->ptr;
3136
+ for(i=0; i < nflag; i++) {
3137
+ ptr[i] = INT2FIX(arg4[i]);
3138
+ }
3139
+ }
3140
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[2]);
3141
+ }
3142
+ {
3143
+ rb_ary_unshift(vresult,INT2NUM(*arg6));
3144
+ }
3145
+ return vresult;
3146
+ fail:
3147
+ return Qnil;
3148
+ }
3149
+
3150
+
3151
+ SWIGINTERN VALUE
3152
+ _wrap_Uvio_uvwread(int argc, VALUE *argv, VALUE self) {
3153
+ uvio *arg1 = (uvio *) 0 ;
3154
+ float *arg2 = (float *) 0 ;
3155
+ int *arg3 = (int *) 0 ;
3156
+ int arg4 ;
3157
+ int *arg5 = (int *) 0 ;
3158
+ void *argp1 = 0 ;
3159
+ int res1 = 0 ;
3160
+ int ndata2 ;
3161
+ int nflag3 ;
3162
+ int temp5 ;
3163
+ VALUE vresult = Qnil;
3164
+
3165
+ {
3166
+ arg5 = &temp5;
3167
+ }
3168
+ if ((argc < 2) || (argc > 2)) {
3169
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3170
+ }
3171
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3172
+ if (!SWIG_IsOK(res1)) {
3173
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","uvwread", 1, self ));
3174
+ }
3175
+ arg1 = (uvio *)(argp1);
3176
+ {
3177
+ int i;
3178
+ // If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
3179
+ // This only makes sense for reads (or writing zeros)
3180
+ if(TYPE(argv[0]) == T_FIXNUM || TYPE(argv[0]) == T_BIGNUM) {
3181
+ ndata2 = NUM2INT(argv[0]);
3182
+ int rank = 1;
3183
+ int shape = ndata2;
3184
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
3185
+ argv[0] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
3186
+ }
3187
+ // If NArray
3188
+ if(NA_IsNArray(argv[0])) {
3189
+ Check_NArrayType2(argv[0],NA_SFLOAT,NA_SCOMPLEX);
3190
+ arg2 = NA_PTR_TYPE(argv[0],float *);
3191
+ ndata2 = NA_TOTAL(argv[0]);
3192
+ if(NA_TYPE(argv[0]) == NA_SFLOAT) {
3193
+ ndata2 /= 2;
3194
+ }
3195
+ } else {
3196
+ Check_Type(argv[0], T_ARRAY);
3197
+ // Allocate C array on stack
3198
+ ndata2 = RARRAY(argv[0])->len;
3199
+ arg2 = ALLOCA_N(float,ndata2);
3200
+ VALUE * ptr = RARRAY(argv[0])->ptr;
3201
+ // TODO Use uvwread in #if to avoid copying on read?
3202
+ for(i=0; i < ndata2; i++) {
3203
+ arg2[i] = NUM2DBL(ptr[i]);
3204
+ }
3205
+ ndata2 /= 2;
3206
+ }
3207
+ }
3208
+ {
3209
+ int i;
3210
+ // If FIXNUM or BIGNUM, allocate NA_LINT array that many
3211
+ // This only makes sense for reads (or writing zeros)
3212
+ if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
3213
+ nflag3 = NUM2INT(argv[1]);
3214
+ int rank = 1;
3215
+ int shape = nflag3;
3216
+ VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
3217
+ argv[1] = na_make_object(NA_LINT,rank,&shape,naclass);
3218
+ }
3219
+ // If NArray
3220
+ if(NA_IsNArray(argv[1])) {
3221
+ Check_NArrayType(argv[1],NA_LINT);
3222
+ arg3 = NA_PTR_TYPE(argv[1],int *);
3223
+ nflag3 = NA_TOTAL(argv[1]);
3224
+ } else {
3225
+ Check_Type(argv[1], T_ARRAY);
3226
+ nflag3 = RARRAY(argv[1])->len;
3227
+ arg3 = ALLOCA_N(int,nflag3);
3228
+ VALUE * ptr = RARRAY(argv[1])->ptr;
3229
+ for(i=0; i < nflag3; i++) {
3230
+ arg3[i] = FIX2INT(ptr[i]);
3231
+ }
3232
+ }
3233
+
3234
+ arg4 = nflag3;
3235
+ }
3236
+ uvio_uvwread(arg1,arg2,arg3,arg4,arg5);
3237
+ vresult = rb_ary_new();
3238
+ {
3239
+ int ndata;
3240
+ int i;
3241
+ // If NArray, data are already in place
3242
+ if(TYPE(argv[0]) == T_ARRAY) {
3243
+ ndata = RARRAY(argv[0])->len;
3244
+ VALUE * ptr = RARRAY(argv[0])->ptr;
3245
+ for(i=0; i < ndata; i++) {
3246
+ // Store or convert doubles to Ruby Objects
3247
+ if(TYPE(ptr[i]) == T_FLOAT) {
3248
+ // TODO Is this legit?
3249
+ RFLOAT(ptr[i])->value = arg2[i];
3250
+ } else {
3251
+ ptr[i] = rb_float_new(arg2[i]);
3252
+ }
3253
+ }
3254
+ }
3255
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[0]);
3256
+ }
3257
+ {
3258
+ int nflag;
3259
+ int i;
3260
+ // If NArray, data are already in place
3261
+ if(TYPE(argv[1]) == T_ARRAY) {
3262
+ nflag = RARRAY(argv[1])->len;
3263
+ VALUE * ptr = RARRAY(argv[1])->ptr;
3264
+ for(i=0; i < nflag; i++) {
3265
+ ptr[i] = INT2FIX(arg3[i]);
3266
+ }
3267
+ }
3268
+ vresult = SWIG_Ruby_AppendOutput(vresult, argv[1]);
3269
+ }
3270
+ {
3271
+ rb_ary_unshift(vresult,INT2NUM(*arg5));
3272
+ }
3273
+ return vresult;
3274
+ fail:
3275
+ return Qnil;
3276
+ }
3277
+
3278
+
3279
+ SWIGINTERN VALUE
3280
+ _wrap_Uvio_getvr(int argc, VALUE *argv, VALUE self) {
3281
+ uvio *arg1 = (uvio *) 0 ;
3282
+ char *arg2 = (char *) 0 ;
3283
+ void **arg3 = (void **) 0 ;
3284
+ int *arg4 = (int *) 0 ;
3285
+ char *arg5 = (char *) 0 ;
3286
+ void *argp1 = 0 ;
3287
+ int res1 = 0 ;
3288
+ void *value3 ;
3289
+ int n3 ;
3290
+ char type3 ;
3291
+ VALUE vresult = Qnil;
3292
+
3293
+ {
3294
+ value3 = NULL;
3295
+ arg3 = &value3;
3296
+ arg4 = &n3;
3297
+ arg5 = &type3;
3298
+ }
3299
+ if ((argc < 1) || (argc > 1)) {
3300
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3301
+ }
3302
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3303
+ if (!SWIG_IsOK(res1)) {
3304
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","getvr", 1, self ));
3305
+ }
3306
+ arg1 = (uvio *)(argp1);
3307
+ {
3308
+ arg2 = StringValuePtr(argv[0]);
3309
+ }
3310
+ uvio_getvr(arg1,arg2,arg3,arg4,arg5);
3311
+ {
3312
+ int i;
3313
+ vresult = Qnil;
3314
+ if(n3 == 1 || type3 == 'a') {
3315
+ switch(type3) {
3316
+ case 'a': vresult = rb_tainted_str_new((char *)value3, n3);
3317
+ break;
3318
+ case 'i': vresult = INT2NUM(*(int *)value3);
3319
+ break;
3320
+ case 'r': vresult = rb_float_new((double)*(float *)value3);
3321
+ break;
3322
+ case 'd': vresult = rb_float_new(*(double *)value3);
3323
+ break;
3324
+ case ' ': // Variable not present
3325
+ case 'j': // Unsuported
3326
+ // Return NULL, but don't raise exception
3327
+ break;
3328
+ default: // TODO Raise exception
3329
+ break;
3330
+ }
3331
+ } else if(n3 > 1) {
3332
+ VALUE * elems = ALLOCA_N(VALUE,n3);
3333
+ switch(type3) {
3334
+ case 'i':
3335
+ for(i = 0; i < n3; i++) {
3336
+ elems[i] = INT2NUM(((int *)value3)[i]);
3337
+ }
3338
+ vresult = rb_ary_new4(n3,elems);
3339
+ break;
3340
+ case 'r':
3341
+ for(i = 0; i < n3; i++) {
3342
+ elems[i] = rb_float_new((double)(((float *)value3)[i]));
3343
+ }
3344
+ vresult = rb_ary_new4(n3,elems);
3345
+ break;
3346
+ case 'd':
3347
+ for(i = 0; i < n3; i++) {
3348
+ elems[i] = rb_float_new(((double *)value3)[i]);
3349
+ }
3350
+ vresult = rb_ary_new4(n3,elems);
3351
+ break;
3352
+ case ' ': // Variable not present
3353
+ case 'j': // Unsuported
3354
+ // Return NULL, but don't raise exception
3355
+ break;
3356
+ default: // TODO Raise exception
3357
+ break;
3358
+ }
3359
+ }
3360
+ // Free buffer allocated by getvr
3361
+ free(value3);
3362
+ }
3363
+ return vresult;
3364
+ fail:
3365
+ return Qnil;
3366
+ }
3367
+
3368
+
3369
+ SWIGINTERN VALUE
3370
+ _wrap_Uvio_updatedq___(int argc, VALUE *argv, VALUE self) {
3371
+ uvio *arg1 = (uvio *) 0 ;
3372
+ int result;
3373
+ void *argp1 = 0 ;
3374
+ int res1 = 0 ;
3375
+ VALUE vresult = Qnil;
3376
+
3377
+ if ((argc < 0) || (argc > 0)) {
3378
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3379
+ }
3380
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3381
+ if (!SWIG_IsOK(res1)) {
3382
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","updated", 1, self ));
3383
+ }
3384
+ arg1 = (uvio *)(argp1);
3385
+ result = (int)uvio_updated(arg1);
3386
+ vresult = (result ? Qtrue : Qfalse);
3387
+ return vresult;
3388
+ fail:
3389
+ return Qnil;
3390
+ }
3391
+
3392
+
3393
+ SWIGINTERN VALUE
3394
+ _wrap_Uvio_track(int argc, VALUE *argv, VALUE self) {
3395
+ uvio *arg1 = (uvio *) 0 ;
3396
+ char *arg2 = (char *) 0 ;
3397
+ char *arg3 = (char *) 0 ;
3398
+ void *argp1 = 0 ;
3399
+ int res1 = 0 ;
3400
+ int res3 ;
3401
+ char *buf3 = 0 ;
3402
+ int alloc3 = 0 ;
3403
+
3404
+ if ((argc < 2) || (argc > 2)) {
3405
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3406
+ }
3407
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3408
+ if (!SWIG_IsOK(res1)) {
3409
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","track", 1, self ));
3410
+ }
3411
+ arg1 = (uvio *)(argp1);
3412
+ {
3413
+ arg2 = StringValuePtr(argv[0]);
3414
+ }
3415
+ res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3);
3416
+ if (!SWIG_IsOK(res3)) {
3417
+ SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char *","track", 3, argv[1] ));
3418
+ }
3419
+ arg3 = (char *)(buf3);
3420
+ uvio_track(arg1,arg2,arg3);
3421
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3422
+ return Qnil;
3423
+ fail:
3424
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3425
+ return Qnil;
3426
+ }
3427
+
3428
+
3429
+ SWIGINTERN VALUE
3430
+ _wrap_Uvio_sela(int argc, VALUE *argv, VALUE self) {
3431
+ uvio *arg1 = (uvio *) 0 ;
3432
+ char *arg2 = (char *) 0 ;
3433
+ int arg3 ;
3434
+ char *arg4 = (char *) 0 ;
3435
+ void *argp1 = 0 ;
3436
+ int res1 = 0 ;
3437
+ int res2 ;
3438
+ char *buf2 = 0 ;
3439
+ int alloc2 = 0 ;
3440
+ int val3 ;
3441
+ int ecode3 = 0 ;
3442
+ int res4 ;
3443
+ char *buf4 = 0 ;
3444
+ int alloc4 = 0 ;
3445
+
3446
+ if ((argc < 3) || (argc > 3)) {
3447
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
3448
+ }
3449
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3450
+ if (!SWIG_IsOK(res1)) {
3451
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","sela", 1, self ));
3452
+ }
3453
+ arg1 = (uvio *)(argp1);
3454
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
3455
+ if (!SWIG_IsOK(res2)) {
3456
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","sela", 2, argv[0] ));
3457
+ }
3458
+ arg2 = (char *)(buf2);
3459
+ ecode3 = SWIG_AsVal_int(argv[1], &val3);
3460
+ if (!SWIG_IsOK(ecode3)) {
3461
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","sela", 3, argv[1] ));
3462
+ }
3463
+ arg3 = (int)(val3);
3464
+ res4 = SWIG_AsCharPtrAndSize(argv[2], &buf4, NULL, &alloc4);
3465
+ if (!SWIG_IsOK(res4)) {
3466
+ SWIG_exception_fail(SWIG_ArgError(res4), Ruby_Format_TypeError( "", "char *","sela", 4, argv[2] ));
3467
+ }
3468
+ arg4 = (char *)(buf4);
3469
+ uvio_sela(arg1,arg2,arg3,arg4);
3470
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3471
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
3472
+ return Qnil;
3473
+ fail:
3474
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3475
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
3476
+ return Qnil;
3477
+ }
3478
+
3479
+
3480
+
3481
+ /*
3482
+ Document-method: Miriad::Uvio.select
3483
+
3484
+ call-seq:
3485
+ select(object, datasel, p1=0.0, p2=0.0)
3486
+
3487
+ Iterate thru each element in the Uvio and select those that match a condition. A block must be provided.
3488
+ */
3489
+ SWIGINTERN VALUE
3490
+ _wrap_Uvio_select(int argc, VALUE *argv, VALUE self) {
3491
+ uvio *arg1 = (uvio *) 0 ;
3492
+ char *arg2 = (char *) 0 ;
3493
+ int arg3 ;
3494
+ double arg4 = (double) 0.0 ;
3495
+ double arg5 = (double) 0.0 ;
3496
+ void *argp1 = 0 ;
3497
+ int res1 = 0 ;
3498
+ int res2 ;
3499
+ char *buf2 = 0 ;
3500
+ int alloc2 = 0 ;
3501
+ int val3 ;
3502
+ int ecode3 = 0 ;
3503
+ double val4 ;
3504
+ int ecode4 = 0 ;
3505
+ double val5 ;
3506
+ int ecode5 = 0 ;
3507
+
3508
+ if ((argc < 2) || (argc > 4)) {
3509
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3510
+ }
3511
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3512
+ if (!SWIG_IsOK(res1)) {
3513
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","select", 1, self ));
3514
+ }
3515
+ arg1 = (uvio *)(argp1);
3516
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
3517
+ if (!SWIG_IsOK(res2)) {
3518
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","select", 2, argv[0] ));
3519
+ }
3520
+ arg2 = (char *)(buf2);
3521
+ ecode3 = SWIG_AsVal_int(argv[1], &val3);
3522
+ if (!SWIG_IsOK(ecode3)) {
3523
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","select", 3, argv[1] ));
3524
+ }
3525
+ arg3 = (int)(val3);
3526
+ if (argc > 2) {
3527
+ ecode4 = SWIG_AsVal_double(argv[2], &val4);
3528
+ if (!SWIG_IsOK(ecode4)) {
3529
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "double","select", 4, argv[2] ));
3530
+ }
3531
+ arg4 = (double)(val4);
3532
+ }
3533
+ if (argc > 3) {
3534
+ ecode5 = SWIG_AsVal_double(argv[3], &val5);
3535
+ if (!SWIG_IsOK(ecode5)) {
3536
+ SWIG_exception_fail(SWIG_ArgError(ecode5), Ruby_Format_TypeError( "", "double","select", 5, argv[3] ));
3537
+ }
3538
+ arg5 = (double)(val5);
3539
+ }
3540
+ uvio_select(arg1,arg2,arg3,arg4,arg5);
3541
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3542
+ return Qnil;
3543
+ fail:
3544
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3545
+ return Qnil;
3546
+ }
3547
+
3548
+
3549
+ SWIGINTERN VALUE
3550
+ _wrap_Uvio_flagwr(int argc, VALUE *argv, VALUE self) {
3551
+ uvio *arg1 = (uvio *) 0 ;
3552
+ int *arg2 = (int *) 0 ;
3553
+ void *argp1 = 0 ;
3554
+ int res1 = 0 ;
3555
+
3556
+ if ((argc < 1) || (argc > 1)) {
3557
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3558
+ }
3559
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3560
+ if (!SWIG_IsOK(res1)) {
3561
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","flagwr", 1, self ));
3562
+ }
3563
+ arg1 = (uvio *)(argp1);
3564
+ {
3565
+ // If NArray
3566
+ if(NA_IsNArray(argv[0])) {
3567
+ Check_NArrayType(argv[0],NA_LINT);
3568
+ arg2 = NA_PTR_TYPE(argv[0],int *);
3569
+ } else {
3570
+ int i;
3571
+ int nflag;
3572
+ Check_Type(argv[0], T_ARRAY);
3573
+ nflag = RARRAY(argv[0])->len;
3574
+ arg2 = ALLOCA_N(int,nflag);
3575
+ VALUE * ptr = RARRAY(argv[0])->ptr;
3576
+ for(i=0; i < nflag; i++) {
3577
+ arg2[i] = FIX2INT(ptr[i]);
3578
+ }
3579
+ }
3580
+ }
3581
+ uvio_flagwr(arg1,arg2);
3582
+ return Qnil;
3583
+ fail:
3584
+ return Qnil;
3585
+ }
3586
+
3587
+
3588
+ SWIGINTERN VALUE
3589
+ _wrap_Uvio_wflagwr(int argc, VALUE *argv, VALUE self) {
3590
+ uvio *arg1 = (uvio *) 0 ;
3591
+ int *arg2 = (int *) 0 ;
3592
+ void *argp1 = 0 ;
3593
+ int res1 = 0 ;
3594
+
3595
+ if ((argc < 1) || (argc > 1)) {
3596
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3597
+ }
3598
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3599
+ if (!SWIG_IsOK(res1)) {
3600
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","wflagwr", 1, self ));
3601
+ }
3602
+ arg1 = (uvio *)(argp1);
3603
+ {
3604
+ // If NArray
3605
+ if(NA_IsNArray(argv[0])) {
3606
+ Check_NArrayType(argv[0],NA_LINT);
3607
+ arg2 = NA_PTR_TYPE(argv[0],int *);
3608
+ } else {
3609
+ int i;
3610
+ int nflag;
3611
+ Check_Type(argv[0], T_ARRAY);
3612
+ nflag = RARRAY(argv[0])->len;
3613
+ arg2 = ALLOCA_N(int,nflag);
3614
+ VALUE * ptr = RARRAY(argv[0])->ptr;
3615
+ for(i=0; i < nflag; i++) {
3616
+ arg2[i] = FIX2INT(ptr[i]);
3617
+ }
3618
+ }
3619
+ }
3620
+ uvio_wflagwr(arg1,arg2);
3621
+ return Qnil;
3622
+ fail:
3623
+ return Qnil;
3624
+ }
3625
+
3626
+
3627
+ SWIGINTERN VALUE
3628
+ _wrap_Uvio_haccess(int argc, VALUE *argv, VALUE self) {
3629
+ uvio *arg1 = (uvio *) 0 ;
3630
+ char *arg2 = (char *) 0 ;
3631
+ char *arg3 = (char *) 0 ;
3632
+ int result;
3633
+ void *argp1 = 0 ;
3634
+ int res1 = 0 ;
3635
+ int res2 ;
3636
+ char *buf2 = 0 ;
3637
+ int alloc2 = 0 ;
3638
+ int res3 ;
3639
+ char *buf3 = 0 ;
3640
+ int alloc3 = 0 ;
3641
+ VALUE vresult = Qnil;
3642
+
3643
+ if ((argc < 2) || (argc > 2)) {
3644
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3645
+ }
3646
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3647
+ if (!SWIG_IsOK(res1)) {
3648
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","haccess", 1, self ));
3649
+ }
3650
+ arg1 = (uvio *)(argp1);
3651
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
3652
+ if (!SWIG_IsOK(res2)) {
3653
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","haccess", 2, argv[0] ));
3654
+ }
3655
+ arg2 = (char *)(buf2);
3656
+ res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3);
3657
+ if (!SWIG_IsOK(res3)) {
3658
+ SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char *","haccess", 3, argv[1] ));
3659
+ }
3660
+ arg3 = (char *)(buf3);
3661
+ result = (int)uvio_haccess(arg1,arg2,arg3);
3662
+ vresult = SWIG_From_int((int)(result));
3663
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3664
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3665
+ return vresult;
3666
+ fail:
3667
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3668
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3669
+ return Qnil;
3670
+ }
3671
+
3672
+
3673
+ SWIGINTERN VALUE
3674
+ _wrap_Uvio_hdaccess(int argc, VALUE *argv, VALUE self) {
3675
+ uvio *arg1 = (uvio *) 0 ;
3676
+ int arg2 ;
3677
+ void *argp1 = 0 ;
3678
+ int res1 = 0 ;
3679
+ int val2 ;
3680
+ int ecode2 = 0 ;
3681
+
3682
+ if ((argc < 1) || (argc > 1)) {
3683
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3684
+ }
3685
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3686
+ if (!SWIG_IsOK(res1)) {
3687
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","hdaccess", 1, self ));
3688
+ }
3689
+ arg1 = (uvio *)(argp1);
3690
+ ecode2 = SWIG_AsVal_int(argv[0], &val2);
3691
+ if (!SWIG_IsOK(ecode2)) {
3692
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","hdaccess", 2, argv[0] ));
3693
+ }
3694
+ arg2 = (int)(val2);
3695
+ uvio_hdaccess(arg1,arg2);
3696
+ return Qnil;
3697
+ fail:
3698
+ return Qnil;
3699
+ }
3700
+
3701
+
3702
+ SWIGINTERN VALUE
3703
+ _wrap_Uvio_hreadln(int argc, VALUE *argv, VALUE self) {
3704
+ uvio *arg1 = (uvio *) 0 ;
3705
+ int arg2 ;
3706
+ char *arg3 = (char *) 0 ;
3707
+ size_t arg4 ;
3708
+ int *arg5 = (int *) 0 ;
3709
+ void *argp1 = 0 ;
3710
+ int res1 = 0 ;
3711
+ int val2 ;
3712
+ int ecode2 = 0 ;
3713
+ int iostat3 ;
3714
+ VALUE vresult = Qnil;
3715
+
3716
+ {
3717
+ arg4 = 100;
3718
+ arg3 = ALLOCA_N(char,arg4);
3719
+ arg5 = &iostat3;
3720
+ }
3721
+ if ((argc < 1) || (argc > 1)) {
3722
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3723
+ }
3724
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3725
+ if (!SWIG_IsOK(res1)) {
3726
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","hreadln", 1, self ));
3727
+ }
3728
+ arg1 = (uvio *)(argp1);
3729
+ ecode2 = SWIG_AsVal_int(argv[0], &val2);
3730
+ if (!SWIG_IsOK(ecode2)) {
3731
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","hreadln", 2, argv[0] ));
3732
+ }
3733
+ arg2 = (int)(val2);
3734
+ uvio_hreadln(arg1,arg2,arg3,arg4,arg5);
3735
+ {
3736
+ if(*arg5 == 0) {
3737
+ vresult = rb_str_new2(arg3);
3738
+ } else if(*arg5 != -1) {
3739
+ SWIG_exception(SWIG_IOError, "error reading item");
3740
+ } else {
3741
+ // EOF
3742
+ vresult = Qnil;
3743
+ }
3744
+ }
3745
+ return vresult;
3746
+ fail:
3747
+ return Qnil;
3748
+ }
3749
+
3750
+
3751
+ SWIGINTERN VALUE
3752
+ _wrap_Uvio_hwriteln(int argc, VALUE *argv, VALUE self) {
3753
+ uvio *arg1 = (uvio *) 0 ;
3754
+ int arg2 ;
3755
+ char *arg3 = (char *) 0 ;
3756
+ size_t arg4 ;
3757
+ void *argp1 = 0 ;
3758
+ int res1 = 0 ;
3759
+ int val2 ;
3760
+ int ecode2 = 0 ;
3761
+ int res3 ;
3762
+ char *buf3 = 0 ;
3763
+ int alloc3 = 0 ;
3764
+ size_t val4 ;
3765
+ int ecode4 = 0 ;
3766
+
3767
+ if ((argc < 3) || (argc > 3)) {
3768
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
3769
+ }
3770
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3771
+ if (!SWIG_IsOK(res1)) {
3772
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","hwriteln", 1, self ));
3773
+ }
3774
+ arg1 = (uvio *)(argp1);
3775
+ ecode2 = SWIG_AsVal_int(argv[0], &val2);
3776
+ if (!SWIG_IsOK(ecode2)) {
3777
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","hwriteln", 2, argv[0] ));
3778
+ }
3779
+ arg2 = (int)(val2);
3780
+ res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3);
3781
+ if (!SWIG_IsOK(res3)) {
3782
+ SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char *","hwriteln", 3, argv[1] ));
3783
+ }
3784
+ arg3 = (char *)(buf3);
3785
+ ecode4 = SWIG_AsVal_size_t(argv[2], &val4);
3786
+ if (!SWIG_IsOK(ecode4)) {
3787
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "size_t","hwriteln", 4, argv[2] ));
3788
+ }
3789
+ arg4 = (size_t)(val4);
3790
+ uvio_hwriteln(arg1,arg2,arg3,arg4);
3791
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3792
+ return Qnil;
3793
+ fail:
3794
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3795
+ return Qnil;
3796
+ }
3797
+
3798
+
3799
+ SWIGINTERN VALUE
3800
+ _wrap_Uvio_hiswrite(int argc, VALUE *argv, VALUE self) {
3801
+ uvio *arg1 = (uvio *) 0 ;
3802
+ char *arg2 = (char *) 0 ;
3803
+ void *argp1 = 0 ;
3804
+ int res1 = 0 ;
3805
+ int res2 ;
3806
+ char *buf2 = 0 ;
3807
+ int alloc2 = 0 ;
3808
+
3809
+ if ((argc < 1) || (argc > 1)) {
3810
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3811
+ }
3812
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3813
+ if (!SWIG_IsOK(res1)) {
3814
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","hiswrite", 1, self ));
3815
+ }
3816
+ arg1 = (uvio *)(argp1);
3817
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
3818
+ if (!SWIG_IsOK(res2)) {
3819
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","hiswrite", 2, argv[0] ));
3820
+ }
3821
+ arg2 = (char *)(buf2);
3822
+ uvio_hiswrite(arg1,arg2);
3823
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3824
+ return Qnil;
3825
+ fail:
3826
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3827
+ return Qnil;
3828
+ }
3829
+
3830
+
3831
+ SWIGINTERN VALUE
3832
+ _wrap_Uvio_wrhda(int argc, VALUE *argv, VALUE self) {
3833
+ uvio *arg1 = (uvio *) 0 ;
3834
+ char *arg2 = (char *) 0 ;
3835
+ char *arg3 = (char *) 0 ;
3836
+ void *argp1 = 0 ;
3837
+ int res1 = 0 ;
3838
+ int res2 ;
3839
+ char *buf2 = 0 ;
3840
+ int alloc2 = 0 ;
3841
+ int res3 ;
3842
+ char *buf3 = 0 ;
3843
+ int alloc3 = 0 ;
3844
+
3845
+ if ((argc < 2) || (argc > 2)) {
3846
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3847
+ }
3848
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_uvio, 0 | 0 );
3849
+ if (!SWIG_IsOK(res1)) {
3850
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "uvio *","wrhda", 1, self ));
3851
+ }
3852
+ arg1 = (uvio *)(argp1);
3853
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
3854
+ if (!SWIG_IsOK(res2)) {
3855
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","wrhda", 2, argv[0] ));
3856
+ }
3857
+ arg2 = (char *)(buf2);
3858
+ res3 = SWIG_AsCharPtrAndSize(argv[1], &buf3, NULL, &alloc3);
3859
+ if (!SWIG_IsOK(res3)) {
3860
+ SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char *","wrhda", 3, argv[1] ));
3861
+ }
3862
+ arg3 = (char *)(buf3);
3863
+ uvio_wrhda(arg1,arg2,arg3);
3864
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3865
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3866
+ return Qnil;
3867
+ fail:
3868
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3869
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
3870
+ return Qnil;
3871
+ }
3872
+
3873
+
3874
+
3875
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
3876
+
3877
+ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
3878
+ static swig_type_info _swigt__p_double = {"_p_double", "double *", 0, 0, (void*)0, 0};
3879
+ static swig_type_info _swigt__p_float = {"_p_float", "float *", 0, 0, (void*)0, 0};
3880
+ static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0};
3881
+ static swig_type_info _swigt__p_p_void = {"_p_p_void", "void **", 0, 0, (void*)0, 0};
3882
+ static swig_type_info _swigt__p_uvio = {"_p_uvio", "uvio *", 0, 0, (void*)0, 0};
3883
+
3884
+ static swig_type_info *swig_type_initial[] = {
3885
+ &_swigt__p_char,
3886
+ &_swigt__p_double,
3887
+ &_swigt__p_float,
3888
+ &_swigt__p_int,
3889
+ &_swigt__p_p_void,
3890
+ &_swigt__p_uvio,
3891
+ };
3892
+
3893
+ static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
3894
+ static swig_cast_info _swigc__p_double[] = { {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
3895
+ static swig_cast_info _swigc__p_float[] = { {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}};
3896
+ static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
3897
+ static swig_cast_info _swigc__p_p_void[] = { {&_swigt__p_p_void, 0, 0, 0},{0, 0, 0, 0}};
3898
+ static swig_cast_info _swigc__p_uvio[] = { {&_swigt__p_uvio, 0, 0, 0},{0, 0, 0, 0}};
3899
+
3900
+ static swig_cast_info *swig_cast_initial[] = {
3901
+ _swigc__p_char,
3902
+ _swigc__p_double,
3903
+ _swigc__p_float,
3904
+ _swigc__p_int,
3905
+ _swigc__p_p_void,
3906
+ _swigc__p_uvio,
3907
+ };
3908
+
3909
+
3910
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
3911
+
3912
+ /* -----------------------------------------------------------------------------
3913
+ * Type initialization:
3914
+ * This problem is tough by the requirement that no dynamic
3915
+ * memory is used. Also, since swig_type_info structures store pointers to
3916
+ * swig_cast_info structures and swig_cast_info structures store pointers back
3917
+ * to swig_type_info structures, we need some lookup code at initialization.
3918
+ * The idea is that swig generates all the structures that are needed.
3919
+ * The runtime then collects these partially filled structures.
3920
+ * The SWIG_InitializeModule function takes these initial arrays out of
3921
+ * swig_module, and does all the lookup, filling in the swig_module.types
3922
+ * array with the correct data and linking the correct swig_cast_info
3923
+ * structures together.
3924
+ *
3925
+ * The generated swig_type_info structures are assigned staticly to an initial
3926
+ * array. We just loop through that array, and handle each type individually.
3927
+ * First we lookup if this type has been already loaded, and if so, use the
3928
+ * loaded structure instead of the generated one. Then we have to fill in the
3929
+ * cast linked list. The cast data is initially stored in something like a
3930
+ * two-dimensional array. Each row corresponds to a type (there are the same
3931
+ * number of rows as there are in the swig_type_initial array). Each entry in
3932
+ * a column is one of the swig_cast_info structures for that type.
3933
+ * The cast_initial array is actually an array of arrays, because each row has
3934
+ * a variable number of columns. So to actually build the cast linked list,
3935
+ * we find the array of casts associated with the type, and loop through it
3936
+ * adding the casts to the list. The one last trick we need to do is making
3937
+ * sure the type pointer in the swig_cast_info struct is correct.
3938
+ *
3939
+ * First off, we lookup the cast->type name to see if it is already loaded.
3940
+ * There are three cases to handle:
3941
+ * 1) If the cast->type has already been loaded AND the type we are adding
3942
+ * casting info to has not been loaded (it is in this module), THEN we
3943
+ * replace the cast->type pointer with the type pointer that has already
3944
+ * been loaded.
3945
+ * 2) If BOTH types (the one we are adding casting info to, and the
3946
+ * cast->type) are loaded, THEN the cast info has already been loaded by
3947
+ * the previous module so we just ignore it.
3948
+ * 3) Finally, if cast->type has not already been loaded, then we add that
3949
+ * swig_cast_info to the linked list (because the cast->type) pointer will
3950
+ * be correct.
3951
+ * ----------------------------------------------------------------------------- */
3952
+
3953
+ #ifdef __cplusplus
3954
+ extern "C" {
3955
+ #if 0
3956
+ } /* c-mode */
3957
+ #endif
3958
+ #endif
3959
+
3960
+ #if 0
3961
+ #define SWIGRUNTIME_DEBUG
3962
+ #endif
3963
+
3964
+
3965
+ SWIGRUNTIME void
3966
+ SWIG_InitializeModule(void *clientdata) {
3967
+ size_t i;
3968
+ swig_module_info *module_head, *iter;
3969
+ int found, init;
3970
+
3971
+ clientdata = clientdata;
3972
+
3973
+ /* check to see if the circular list has been setup, if not, set it up */
3974
+ if (swig_module.next==0) {
3975
+ /* Initialize the swig_module */
3976
+ swig_module.type_initial = swig_type_initial;
3977
+ swig_module.cast_initial = swig_cast_initial;
3978
+ swig_module.next = &swig_module;
3979
+ init = 1;
3980
+ } else {
3981
+ init = 0;
3982
+ }
3983
+
3984
+ /* Try and load any already created modules */
3985
+ module_head = SWIG_GetModule(clientdata);
3986
+ if (!module_head) {
3987
+ /* This is the first module loaded for this interpreter */
3988
+ /* so set the swig module into the interpreter */
3989
+ SWIG_SetModule(clientdata, &swig_module);
3990
+ module_head = &swig_module;
3991
+ } else {
3992
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
3993
+ found=0;
3994
+ iter=module_head;
3995
+ do {
3996
+ if (iter==&swig_module) {
3997
+ found=1;
3998
+ break;
3999
+ }
4000
+ iter=iter->next;
4001
+ } while (iter!= module_head);
4002
+
4003
+ /* if the is found in the list, then all is done and we may leave */
4004
+ if (found) return;
4005
+ /* otherwise we must add out module into the list */
4006
+ swig_module.next = module_head->next;
4007
+ module_head->next = &swig_module;
4008
+ }
4009
+
4010
+ /* When multiple interpeters are used, a module could have already been initialized in
4011
+ a different interpreter, but not yet have a pointer in this interpreter.
4012
+ In this case, we do not want to continue adding types... everything should be
4013
+ set up already */
4014
+ if (init == 0) return;
4015
+
4016
+ /* Now work on filling in swig_module.types */
4017
+ #ifdef SWIGRUNTIME_DEBUG
4018
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
4019
+ #endif
4020
+ for (i = 0; i < swig_module.size; ++i) {
4021
+ swig_type_info *type = 0;
4022
+ swig_type_info *ret;
4023
+ swig_cast_info *cast;
4024
+
4025
+ #ifdef SWIGRUNTIME_DEBUG
4026
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
4027
+ #endif
4028
+
4029
+ /* if there is another module already loaded */
4030
+ if (swig_module.next != &swig_module) {
4031
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
4032
+ }
4033
+ if (type) {
4034
+ /* Overwrite clientdata field */
4035
+ #ifdef SWIGRUNTIME_DEBUG
4036
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
4037
+ #endif
4038
+ if (swig_module.type_initial[i]->clientdata) {
4039
+ type->clientdata = swig_module.type_initial[i]->clientdata;
4040
+ #ifdef SWIGRUNTIME_DEBUG
4041
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
4042
+ #endif
4043
+ }
4044
+ } else {
4045
+ type = swig_module.type_initial[i];
4046
+ }
4047
+
4048
+ /* Insert casting types */
4049
+ cast = swig_module.cast_initial[i];
4050
+ while (cast->type) {
4051
+
4052
+ /* Don't need to add information already in the list */
4053
+ ret = 0;
4054
+ #ifdef SWIGRUNTIME_DEBUG
4055
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
4056
+ #endif
4057
+ if (swig_module.next != &swig_module) {
4058
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
4059
+ #ifdef SWIGRUNTIME_DEBUG
4060
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
4061
+ #endif
4062
+ }
4063
+ if (ret) {
4064
+ if (type == swig_module.type_initial[i]) {
4065
+ #ifdef SWIGRUNTIME_DEBUG
4066
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
4067
+ #endif
4068
+ cast->type = ret;
4069
+ ret = 0;
4070
+ } else {
4071
+ /* Check for casting already in the list */
4072
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
4073
+ #ifdef SWIGRUNTIME_DEBUG
4074
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
4075
+ #endif
4076
+ if (!ocast) ret = 0;
4077
+ }
4078
+ }
4079
+
4080
+ if (!ret) {
4081
+ #ifdef SWIGRUNTIME_DEBUG
4082
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
4083
+ #endif
4084
+ if (type->cast) {
4085
+ type->cast->prev = cast;
4086
+ cast->next = type->cast;
4087
+ }
4088
+ type->cast = cast;
4089
+ }
4090
+ cast++;
4091
+ }
4092
+ /* Set entry in modules->types array equal to the type */
4093
+ swig_module.types[i] = type;
4094
+ }
4095
+ swig_module.types[i] = 0;
4096
+
4097
+ #ifdef SWIGRUNTIME_DEBUG
4098
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
4099
+ for (i = 0; i < swig_module.size; ++i) {
4100
+ int j = 0;
4101
+ swig_cast_info *cast = swig_module.cast_initial[i];
4102
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
4103
+ while (cast->type) {
4104
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
4105
+ cast++;
4106
+ ++j;
4107
+ }
4108
+ printf("---- Total casts: %d\n",j);
4109
+ }
4110
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
4111
+ #endif
4112
+ }
4113
+
4114
+ /* This function will propagate the clientdata field of type to
4115
+ * any new swig_type_info structures that have been added into the list
4116
+ * of equivalent types. It is like calling
4117
+ * SWIG_TypeClientData(type, clientdata) a second time.
4118
+ */
4119
+ SWIGRUNTIME void
4120
+ SWIG_PropagateClientData(void) {
4121
+ size_t i;
4122
+ swig_cast_info *equiv;
4123
+ static int init_run = 0;
4124
+
4125
+ if (init_run) return;
4126
+ init_run = 1;
4127
+
4128
+ for (i = 0; i < swig_module.size; i++) {
4129
+ if (swig_module.types[i]->clientdata) {
4130
+ equiv = swig_module.types[i]->cast;
4131
+ while (equiv) {
4132
+ if (!equiv->converter) {
4133
+ if (equiv->type && !equiv->type->clientdata)
4134
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
4135
+ }
4136
+ equiv = equiv->next;
4137
+ }
4138
+ }
4139
+ }
4140
+ }
4141
+
4142
+ #ifdef __cplusplus
4143
+ #if 0
4144
+ { /* c-mode */
4145
+ #endif
4146
+ }
4147
+ #endif
4148
+
4149
+ /*
4150
+
4151
+ */
4152
+ #ifdef __cplusplus
4153
+ extern "C"
4154
+ #endif
4155
+ SWIGEXPORT void Init_miriad(void) {
4156
+ size_t i;
4157
+
4158
+ SWIG_InitRuntime();
4159
+ mMiriad = rb_define_module("Miriad");
4160
+
4161
+ SWIG_InitializeModule(0);
4162
+ for (i = 0; i < swig_module.size; i++) {
4163
+ SWIG_define_class(swig_module.types[i]);
4164
+ }
4165
+
4166
+ SWIG_RubyInitializeTrackings();
4167
+
4168
+ buglabel_c("mirlib");
4169
+
4170
+
4171
+ mirlib_eMirlibError = rb_define_class("MirlibError", rb_eStandardError);
4172
+
4173
+
4174
+ rb_require("narray");
4175
+
4176
+
4177
+ cUvio.klass = rb_define_class_under(mMiriad, "Uvio", rb_cObject);
4178
+ SWIG_TypeClientData(SWIGTYPE_p_uvio, (void *) &cUvio);
4179
+ rb_define_alloc_func(cUvio.klass, _wrap_Uvio_allocate);
4180
+ rb_define_method(cUvio.klass, "initialize", _wrap_new_Uvio, -1);
4181
+ rb_define_method(cUvio.klass, "close", _wrap_Uvio_close, -1);
4182
+ rb_define_method(cUvio.klass, "flush", _wrap_Uvio_flush, -1);
4183
+ rb_define_method(cUvio.klass, "uvnext", _wrap_Uvio_uvnext, -1);
4184
+ rb_define_method(cUvio.klass, "rewind", _wrap_Uvio_rewind, -1);
4185
+ rb_define_method(cUvio.klass, "probvr", _wrap_Uvio_probvr, -1);
4186
+ rb_define_method(cUvio.klass, "putvr", _wrap_Uvio_putvr, -1);
4187
+ rb_define_method(cUvio.klass, "scan", _wrap_Uvio_scan, -1);
4188
+ rb_define_method(cUvio.klass, "write", _wrap_Uvio_write, -1);
4189
+ rb_define_method(cUvio.klass, "wwrite", _wrap_Uvio_wwrite, -1);
4190
+ rb_define_method(cUvio.klass, "set", _wrap_Uvio_set, -1);
4191
+ rb_define_method(cUvio.klass, "uvread", _wrap_Uvio_uvread, -1);
4192
+ rb_define_method(cUvio.klass, "uvwread", _wrap_Uvio_uvwread, -1);
4193
+ rb_define_method(cUvio.klass, "getvr", _wrap_Uvio_getvr, -1);
4194
+ rb_define_method(cUvio.klass, "updated?", _wrap_Uvio_updatedq___, -1);
4195
+ rb_define_method(cUvio.klass, "track", _wrap_Uvio_track, -1);
4196
+ rb_define_method(cUvio.klass, "sela", _wrap_Uvio_sela, -1);
4197
+ rb_define_method(cUvio.klass, "select", _wrap_Uvio_select, -1);
4198
+ rb_define_method(cUvio.klass, "flagwr", _wrap_Uvio_flagwr, -1);
4199
+ rb_define_method(cUvio.klass, "wflagwr", _wrap_Uvio_wflagwr, -1);
4200
+ rb_define_method(cUvio.klass, "haccess", _wrap_Uvio_haccess, -1);
4201
+ rb_define_method(cUvio.klass, "hdaccess", _wrap_Uvio_hdaccess, -1);
4202
+ rb_define_method(cUvio.klass, "hreadln", _wrap_Uvio_hreadln, -1);
4203
+ rb_define_method(cUvio.klass, "hwriteln", _wrap_Uvio_hwriteln, -1);
4204
+ rb_define_method(cUvio.klass, "hiswrite", _wrap_Uvio_hiswrite, -1);
4205
+ rb_define_method(cUvio.klass, "wrhda", _wrap_Uvio_wrhda, -1);
4206
+ cUvio.mark = 0;
4207
+ cUvio.destroy = (void (*)(void *)) free_uvio;
4208
+ cUvio.trackObjects = 0;
4209
+ }
4210
+