wiringpi 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ /*
2
+ * wiringPi:
3
+ * Arduino compatable (ish) Wiring library for the Raspberry Pi
4
+ * Copyright (c) 2012 Gordon Henderson
5
+ ***********************************************************************
6
+ * This file is part of wiringPi:
7
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
8
+ *
9
+ * wiringPi is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * wiringPi is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
21
+ ***********************************************************************
22
+ */
23
+
24
+ // Handy defines
25
+
26
+ #define NUM_PINS 17
27
+
28
+ #define WPI_MODE_PINS 0
29
+ #define WPI_MODE_GPIO 1
30
+
31
+ #define INPUT 0
32
+ #define OUTPUT 1
33
+ #define PWM_OUTPUT 2
34
+
35
+ #define LOW 0
36
+ #define HIGH 1
37
+
38
+ #define PUD_OFF 0
39
+ #define PUD_DOWN 1
40
+ #define PUD_UP 2
41
+
42
+ // Function prototypes
43
+ // c++ wrappers thanks to a commend by Nick Lott
44
+ // (and others on the Raspberry Pi forums)
45
+
46
+ #ifdef __cplusplus
47
+ extern "C" {
48
+ #endif
49
+
50
+ extern int wiringPiSetup (void) ;
51
+ extern void wiringPiGpioMode (int mode) ;
52
+ extern void pullUpDnControl (int pin, int pud) ;
53
+ extern void pinMode (int pin, int mode) ;
54
+ extern void digitalWrite (int pin, int value) ;
55
+ extern void pwmWrite (int pin, int value) ;
56
+ extern int digitalRead (int pin) ;
57
+
58
+ extern void delay (unsigned int howLong) ;
59
+ extern void delayMicroseconds (unsigned int howLong) ;
60
+ extern unsigned int millis (void) ;
61
+
62
+ #ifdef __cplusplus
63
+ }
64
+ #endif
@@ -0,0 +1,84 @@
1
+ /*
2
+ * wiringShift.c:
3
+ * Emulate some of the Arduino wiring functionality.
4
+ *
5
+ * Copyright (c) 2009-2012 Gordon Henderson.
6
+ ***********************************************************************
7
+ * This file is part of wiringPi:
8
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
9
+ *
10
+ * wiringPi is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * wiringPi is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #include <stdint.h>
26
+
27
+ #include "wiringPi.h"
28
+ #include "wiringShift.h"
29
+
30
+ /*
31
+ * shiftIn:
32
+ * Shift data in from a clocked source
33
+ *********************************************************************************
34
+ */
35
+
36
+ uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order)
37
+ {
38
+ uint8_t value = 0 ;
39
+ int8_t i ;
40
+
41
+ if (order == MSBFIRST)
42
+ for (i = 7 ; i >= 0 ; --i)
43
+ {
44
+ digitalWrite (cPin, HIGH) ;
45
+ value |= digitalRead (dPin) << i ;
46
+ digitalWrite (cPin, LOW) ;
47
+ }
48
+ else
49
+ for (i = 0 ; i < 8 ; ++i)
50
+ {
51
+ digitalWrite (cPin, HIGH) ;
52
+ value |= digitalRead (dPin) << i ;
53
+ digitalWrite (cPin, LOW) ;
54
+ }
55
+
56
+ return value;
57
+ }
58
+
59
+
60
+ /*
61
+ * shiftOut:
62
+ * Shift data out to a clocked source
63
+ *********************************************************************************
64
+ */
65
+
66
+ void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val)
67
+ {
68
+ int8_t i;
69
+
70
+ if (order == MSBFIRST)
71
+ for (i = 7 ; i >= 0 ; --i)
72
+ {
73
+ digitalWrite (dPin, val & (1 << i)) ;
74
+ digitalWrite (cPin, HIGH) ;
75
+ digitalWrite (cPin, LOW) ;
76
+ }
77
+ else
78
+ for (i = 0 ; i < 8 ; ++i)
79
+ {
80
+ digitalWrite (dPin, val & (1 << i)) ;
81
+ digitalWrite (cPin, HIGH) ;
82
+ digitalWrite (cPin, LOW) ;
83
+ }
84
+ }
@@ -0,0 +1,41 @@
1
+ /*
2
+ * wiringShift.h:
3
+ * Emulate some of the Arduino wiring functionality.
4
+ *
5
+ * Copyright (c) 2009-2012 Gordon Henderson.
6
+ ***********************************************************************
7
+ * This file is part of wiringPi:
8
+ * https://projects.drogon.net/raspberry-pi/wiringpi/
9
+ *
10
+ * wiringPi is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * wiringPi is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
22
+ ***********************************************************************
23
+ */
24
+
25
+ #define LSBFIRST 0
26
+ #define MSBFIRST 1
27
+
28
+ #ifndef _STDINT_H
29
+ # include <stdint.h>
30
+ #endif
31
+
32
+ #ifdef __cplusplus
33
+ extern "C" {
34
+ #endif
35
+
36
+ extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ;
37
+ extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ;
38
+
39
+ #ifdef __cplusplus
40
+ }
41
+ #endif
@@ -0,0 +1,2753 @@
1
+ /* ----------------------------------------------------------------------------
2
+ * This file was automatically generated by SWIG (http://www.swig.org).
3
+ * Version 1.3.40
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
+ /* -----------------------------------------------------------------------------
14
+ * This section contains generic SWIG labels for method/variable
15
+ * declarations/attributes, and other compiler dependent labels.
16
+ * ----------------------------------------------------------------------------- */
17
+
18
+ /* template workaround for compilers that cannot correctly implement the C++ standard */
19
+ #ifndef SWIGTEMPLATEDISAMBIGUATOR
20
+ # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
21
+ # define SWIGTEMPLATEDISAMBIGUATOR template
22
+ # elif defined(__HP_aCC)
23
+ /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
24
+ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
25
+ # define SWIGTEMPLATEDISAMBIGUATOR template
26
+ # else
27
+ # define SWIGTEMPLATEDISAMBIGUATOR
28
+ # endif
29
+ #endif
30
+
31
+ /* inline attribute */
32
+ #ifndef SWIGINLINE
33
+ # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
34
+ # define SWIGINLINE inline
35
+ # else
36
+ # define SWIGINLINE
37
+ # endif
38
+ #endif
39
+
40
+ /* attribute recognised by some compilers to avoid 'unused' warnings */
41
+ #ifndef SWIGUNUSED
42
+ # if defined(__GNUC__)
43
+ # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
44
+ # define SWIGUNUSED __attribute__ ((__unused__))
45
+ # else
46
+ # define SWIGUNUSED
47
+ # endif
48
+ # elif defined(__ICC)
49
+ # define SWIGUNUSED __attribute__ ((__unused__))
50
+ # else
51
+ # define SWIGUNUSED
52
+ # endif
53
+ #endif
54
+
55
+ #ifndef SWIG_MSC_UNSUPPRESS_4505
56
+ # if defined(_MSC_VER)
57
+ # pragma warning(disable : 4505) /* unreferenced local function has been removed */
58
+ # endif
59
+ #endif
60
+
61
+ #ifndef SWIGUNUSEDPARM
62
+ # ifdef __cplusplus
63
+ # define SWIGUNUSEDPARM(p)
64
+ # else
65
+ # define SWIGUNUSEDPARM(p) p SWIGUNUSED
66
+ # endif
67
+ #endif
68
+
69
+ /* internal SWIG method */
70
+ #ifndef SWIGINTERN
71
+ # define SWIGINTERN static SWIGUNUSED
72
+ #endif
73
+
74
+ /* internal inline SWIG method */
75
+ #ifndef SWIGINTERNINLINE
76
+ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
77
+ #endif
78
+
79
+ /* exporting methods */
80
+ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
81
+ # ifndef GCC_HASCLASSVISIBILITY
82
+ # define GCC_HASCLASSVISIBILITY
83
+ # endif
84
+ #endif
85
+
86
+ #ifndef SWIGEXPORT
87
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
88
+ # if defined(STATIC_LINKED)
89
+ # define SWIGEXPORT
90
+ # else
91
+ # define SWIGEXPORT __declspec(dllexport)
92
+ # endif
93
+ # else
94
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
95
+ # define SWIGEXPORT __attribute__ ((visibility("default")))
96
+ # else
97
+ # define SWIGEXPORT
98
+ # endif
99
+ # endif
100
+ #endif
101
+
102
+ /* calling conventions for Windows */
103
+ #ifndef SWIGSTDCALL
104
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
105
+ # define SWIGSTDCALL __stdcall
106
+ # else
107
+ # define SWIGSTDCALL
108
+ # endif
109
+ #endif
110
+
111
+ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
112
+ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
113
+ # define _CRT_SECURE_NO_DEPRECATE
114
+ #endif
115
+
116
+ /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
117
+ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
118
+ # define _SCL_SECURE_NO_DEPRECATE
119
+ #endif
120
+
121
+
122
+ /* -----------------------------------------------------------------------------
123
+ * This section contains generic SWIG labels for method/variable
124
+ * declarations/attributes, and other compiler dependent labels.
125
+ * ----------------------------------------------------------------------------- */
126
+
127
+ /* template workaround for compilers that cannot correctly implement the C++ standard */
128
+ #ifndef SWIGTEMPLATEDISAMBIGUATOR
129
+ # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
130
+ # define SWIGTEMPLATEDISAMBIGUATOR template
131
+ # elif defined(__HP_aCC)
132
+ /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
133
+ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
134
+ # define SWIGTEMPLATEDISAMBIGUATOR template
135
+ # else
136
+ # define SWIGTEMPLATEDISAMBIGUATOR
137
+ # endif
138
+ #endif
139
+
140
+ /* inline attribute */
141
+ #ifndef SWIGINLINE
142
+ # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
143
+ # define SWIGINLINE inline
144
+ # else
145
+ # define SWIGINLINE
146
+ # endif
147
+ #endif
148
+
149
+ /* attribute recognised by some compilers to avoid 'unused' warnings */
150
+ #ifndef SWIGUNUSED
151
+ # if defined(__GNUC__)
152
+ # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
153
+ # define SWIGUNUSED __attribute__ ((__unused__))
154
+ # else
155
+ # define SWIGUNUSED
156
+ # endif
157
+ # elif defined(__ICC)
158
+ # define SWIGUNUSED __attribute__ ((__unused__))
159
+ # else
160
+ # define SWIGUNUSED
161
+ # endif
162
+ #endif
163
+
164
+ #ifndef SWIG_MSC_UNSUPPRESS_4505
165
+ # if defined(_MSC_VER)
166
+ # pragma warning(disable : 4505) /* unreferenced local function has been removed */
167
+ # endif
168
+ #endif
169
+
170
+ #ifndef SWIGUNUSEDPARM
171
+ # ifdef __cplusplus
172
+ # define SWIGUNUSEDPARM(p)
173
+ # else
174
+ # define SWIGUNUSEDPARM(p) p SWIGUNUSED
175
+ # endif
176
+ #endif
177
+
178
+ /* internal SWIG method */
179
+ #ifndef SWIGINTERN
180
+ # define SWIGINTERN static SWIGUNUSED
181
+ #endif
182
+
183
+ /* internal inline SWIG method */
184
+ #ifndef SWIGINTERNINLINE
185
+ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
186
+ #endif
187
+
188
+ /* exporting methods */
189
+ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
190
+ # ifndef GCC_HASCLASSVISIBILITY
191
+ # define GCC_HASCLASSVISIBILITY
192
+ # endif
193
+ #endif
194
+
195
+ #ifndef SWIGEXPORT
196
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
197
+ # if defined(STATIC_LINKED)
198
+ # define SWIGEXPORT
199
+ # else
200
+ # define SWIGEXPORT __declspec(dllexport)
201
+ # endif
202
+ # else
203
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
204
+ # define SWIGEXPORT __attribute__ ((visibility("default")))
205
+ # else
206
+ # define SWIGEXPORT
207
+ # endif
208
+ # endif
209
+ #endif
210
+
211
+ /* calling conventions for Windows */
212
+ #ifndef SWIGSTDCALL
213
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
214
+ # define SWIGSTDCALL __stdcall
215
+ # else
216
+ # define SWIGSTDCALL
217
+ # endif
218
+ #endif
219
+
220
+ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
221
+ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
222
+ # define _CRT_SECURE_NO_DEPRECATE
223
+ #endif
224
+
225
+ /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
226
+ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
227
+ # define _SCL_SECURE_NO_DEPRECATE
228
+ #endif
229
+
230
+
231
+ /* -----------------------------------------------------------------------------
232
+ * swigrun.swg
233
+ *
234
+ * This file contains generic C API SWIG runtime support for pointer
235
+ * type checking.
236
+ * ----------------------------------------------------------------------------- */
237
+
238
+ /* This should only be incremented when either the layout of swig_type_info changes,
239
+ or for whatever reason, the runtime changes incompatibly */
240
+ #define SWIG_RUNTIME_VERSION "4"
241
+
242
+ /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
243
+ #ifdef SWIG_TYPE_TABLE
244
+ # define SWIG_QUOTE_STRING(x) #x
245
+ # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
246
+ # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
247
+ #else
248
+ # define SWIG_TYPE_TABLE_NAME
249
+ #endif
250
+
251
+ /*
252
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
253
+ creating a static or dynamic library from the SWIG runtime code.
254
+ In 99.9% of the cases, SWIG just needs to declare them as 'static'.
255
+
256
+ But only do this if strictly necessary, ie, if you have problems
257
+ with your compiler or suchlike.
258
+ */
259
+
260
+ #ifndef SWIGRUNTIME
261
+ # define SWIGRUNTIME SWIGINTERN
262
+ #endif
263
+
264
+ #ifndef SWIGRUNTIMEINLINE
265
+ # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
266
+ #endif
267
+
268
+ /* Generic buffer size */
269
+ #ifndef SWIG_BUFFER_SIZE
270
+ # define SWIG_BUFFER_SIZE 1024
271
+ #endif
272
+
273
+ /* Flags for pointer conversions */
274
+ #define SWIG_POINTER_DISOWN 0x1
275
+ #define SWIG_CAST_NEW_MEMORY 0x2
276
+
277
+ /* Flags for new pointer objects */
278
+ #define SWIG_POINTER_OWN 0x1
279
+
280
+
281
+ /*
282
+ Flags/methods for returning states.
283
+
284
+ The SWIG conversion methods, as ConvertPtr, return and integer
285
+ that tells if the conversion was successful or not. And if not,
286
+ an error code can be returned (see swigerrors.swg for the codes).
287
+
288
+ Use the following macros/flags to set or process the returning
289
+ states.
290
+
291
+ In old versions of SWIG, code such as the following was usually written:
292
+
293
+ if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
294
+ // success code
295
+ } else {
296
+ //fail code
297
+ }
298
+
299
+ Now you can be more explicit:
300
+
301
+ int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
302
+ if (SWIG_IsOK(res)) {
303
+ // success code
304
+ } else {
305
+ // fail code
306
+ }
307
+
308
+ which is the same really, but now you can also do
309
+
310
+ Type *ptr;
311
+ int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
312
+ if (SWIG_IsOK(res)) {
313
+ // success code
314
+ if (SWIG_IsNewObj(res) {
315
+ ...
316
+ delete *ptr;
317
+ } else {
318
+ ...
319
+ }
320
+ } else {
321
+ // fail code
322
+ }
323
+
324
+ I.e., now SWIG_ConvertPtr can return new objects and you can
325
+ identify the case and take care of the deallocation. Of course that
326
+ also requires SWIG_ConvertPtr to return new result values, such as
327
+
328
+ int SWIG_ConvertPtr(obj, ptr,...) {
329
+ if (<obj is ok>) {
330
+ if (<need new object>) {
331
+ *ptr = <ptr to new allocated object>;
332
+ return SWIG_NEWOBJ;
333
+ } else {
334
+ *ptr = <ptr to old object>;
335
+ return SWIG_OLDOBJ;
336
+ }
337
+ } else {
338
+ return SWIG_BADOBJ;
339
+ }
340
+ }
341
+
342
+ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
343
+ more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
344
+ SWIG errors code.
345
+
346
+ Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
347
+ allows to return the 'cast rank', for example, if you have this
348
+
349
+ int food(double)
350
+ int fooi(int);
351
+
352
+ and you call
353
+
354
+ food(1) // cast rank '1' (1 -> 1.0)
355
+ fooi(1) // cast rank '0'
356
+
357
+ just use the SWIG_AddCast()/SWIG_CheckState()
358
+ */
359
+
360
+ #define SWIG_OK (0)
361
+ #define SWIG_ERROR (-1)
362
+ #define SWIG_IsOK(r) (r >= 0)
363
+ #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
364
+
365
+ /* The CastRankLimit says how many bits are used for the cast rank */
366
+ #define SWIG_CASTRANKLIMIT (1 << 8)
367
+ /* The NewMask denotes the object was created (using new/malloc) */
368
+ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
369
+ /* The TmpMask is for in/out typemaps that use temporal objects */
370
+ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
371
+ /* Simple returning values */
372
+ #define SWIG_BADOBJ (SWIG_ERROR)
373
+ #define SWIG_OLDOBJ (SWIG_OK)
374
+ #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
375
+ #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
376
+ /* Check, add and del mask methods */
377
+ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
378
+ #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
379
+ #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
380
+ #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
381
+ #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
382
+ #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
383
+
384
+ /* Cast-Rank Mode */
385
+ #if defined(SWIG_CASTRANK_MODE)
386
+ # ifndef SWIG_TypeRank
387
+ # define SWIG_TypeRank unsigned long
388
+ # endif
389
+ # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
390
+ # define SWIG_MAXCASTRANK (2)
391
+ # endif
392
+ # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
393
+ # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
394
+ SWIGINTERNINLINE int SWIG_AddCast(int r) {
395
+ return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
396
+ }
397
+ SWIGINTERNINLINE int SWIG_CheckState(int r) {
398
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
399
+ }
400
+ #else /* no cast-rank mode */
401
+ # define SWIG_AddCast
402
+ # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
403
+ #endif
404
+
405
+
406
+ #include <string.h>
407
+
408
+ #ifdef __cplusplus
409
+ extern "C" {
410
+ #endif
411
+
412
+ typedef void *(*swig_converter_func)(void *, int *);
413
+ typedef struct swig_type_info *(*swig_dycast_func)(void **);
414
+
415
+ /* Structure to store information on one type */
416
+ typedef struct swig_type_info {
417
+ const char *name; /* mangled name of this type */
418
+ const char *str; /* human readable name of this type */
419
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
420
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
421
+ void *clientdata; /* language specific type data */
422
+ int owndata; /* flag if the structure owns the clientdata */
423
+ } swig_type_info;
424
+
425
+ /* Structure to store a type and conversion function used for casting */
426
+ typedef struct swig_cast_info {
427
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
428
+ swig_converter_func converter; /* function to cast the void pointers */
429
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
430
+ struct swig_cast_info *prev; /* pointer to the previous cast */
431
+ } swig_cast_info;
432
+
433
+ /* Structure used to store module information
434
+ * Each module generates one structure like this, and the runtime collects
435
+ * all of these structures and stores them in a circularly linked list.*/
436
+ typedef struct swig_module_info {
437
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
438
+ size_t size; /* Number of types in this module */
439
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
440
+ swig_type_info **type_initial; /* Array of initially generated type structures */
441
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
442
+ void *clientdata; /* Language specific module data */
443
+ } swig_module_info;
444
+
445
+ /*
446
+ Compare two type names skipping the space characters, therefore
447
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
448
+
449
+ Return 0 when the two name types are equivalent, as in
450
+ strncmp, but skipping ' '.
451
+ */
452
+ SWIGRUNTIME int
453
+ SWIG_TypeNameComp(const char *f1, const char *l1,
454
+ const char *f2, const char *l2) {
455
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
456
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
457
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
458
+ if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
459
+ }
460
+ return (int)((l1 - f1) - (l2 - f2));
461
+ }
462
+
463
+ /*
464
+ Check type equivalence in a name list like <name1>|<name2>|...
465
+ Return 0 if not equal, 1 if equal
466
+ */
467
+ SWIGRUNTIME int
468
+ SWIG_TypeEquiv(const char *nb, const char *tb) {
469
+ int equiv = 0;
470
+ const char* te = tb + strlen(tb);
471
+ const char* ne = nb;
472
+ while (!equiv && *ne) {
473
+ for (nb = ne; *ne; ++ne) {
474
+ if (*ne == '|') break;
475
+ }
476
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
477
+ if (*ne) ++ne;
478
+ }
479
+ return equiv;
480
+ }
481
+
482
+ /*
483
+ Check type equivalence in a name list like <name1>|<name2>|...
484
+ Return 0 if equal, -1 if nb < tb, 1 if nb > tb
485
+ */
486
+ SWIGRUNTIME int
487
+ SWIG_TypeCompare(const char *nb, const char *tb) {
488
+ int equiv = 0;
489
+ const char* te = tb + strlen(tb);
490
+ const char* ne = nb;
491
+ while (!equiv && *ne) {
492
+ for (nb = ne; *ne; ++ne) {
493
+ if (*ne == '|') break;
494
+ }
495
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
496
+ if (*ne) ++ne;
497
+ }
498
+ return equiv;
499
+ }
500
+
501
+
502
+ /*
503
+ Check the typename
504
+ */
505
+ SWIGRUNTIME swig_cast_info *
506
+ SWIG_TypeCheck(const char *c, swig_type_info *ty) {
507
+ if (ty) {
508
+ swig_cast_info *iter = ty->cast;
509
+ while (iter) {
510
+ if (strcmp(iter->type->name, c) == 0) {
511
+ if (iter == ty->cast)
512
+ return iter;
513
+ /* Move iter to the top of the linked list */
514
+ iter->prev->next = iter->next;
515
+ if (iter->next)
516
+ iter->next->prev = iter->prev;
517
+ iter->next = ty->cast;
518
+ iter->prev = 0;
519
+ if (ty->cast) ty->cast->prev = iter;
520
+ ty->cast = iter;
521
+ return iter;
522
+ }
523
+ iter = iter->next;
524
+ }
525
+ }
526
+ return 0;
527
+ }
528
+
529
+ /*
530
+ Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
531
+ */
532
+ SWIGRUNTIME swig_cast_info *
533
+ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
534
+ if (ty) {
535
+ swig_cast_info *iter = ty->cast;
536
+ while (iter) {
537
+ if (iter->type == from) {
538
+ if (iter == ty->cast)
539
+ return iter;
540
+ /* Move iter to the top of the linked list */
541
+ iter->prev->next = iter->next;
542
+ if (iter->next)
543
+ iter->next->prev = iter->prev;
544
+ iter->next = ty->cast;
545
+ iter->prev = 0;
546
+ if (ty->cast) ty->cast->prev = iter;
547
+ ty->cast = iter;
548
+ return iter;
549
+ }
550
+ iter = iter->next;
551
+ }
552
+ }
553
+ return 0;
554
+ }
555
+
556
+ /*
557
+ Cast a pointer up an inheritance hierarchy
558
+ */
559
+ SWIGRUNTIMEINLINE void *
560
+ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
561
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
562
+ }
563
+
564
+ /*
565
+ Dynamic pointer casting. Down an inheritance hierarchy
566
+ */
567
+ SWIGRUNTIME swig_type_info *
568
+ SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
569
+ swig_type_info *lastty = ty;
570
+ if (!ty || !ty->dcast) return ty;
571
+ while (ty && (ty->dcast)) {
572
+ ty = (*ty->dcast)(ptr);
573
+ if (ty) lastty = ty;
574
+ }
575
+ return lastty;
576
+ }
577
+
578
+ /*
579
+ Return the name associated with this type
580
+ */
581
+ SWIGRUNTIMEINLINE const char *
582
+ SWIG_TypeName(const swig_type_info *ty) {
583
+ return ty->name;
584
+ }
585
+
586
+ /*
587
+ Return the pretty name associated with this type,
588
+ that is an unmangled type name in a form presentable to the user.
589
+ */
590
+ SWIGRUNTIME const char *
591
+ SWIG_TypePrettyName(const swig_type_info *type) {
592
+ /* The "str" field contains the equivalent pretty names of the
593
+ type, separated by vertical-bar characters. We choose
594
+ to print the last name, as it is often (?) the most
595
+ specific. */
596
+ if (!type) return NULL;
597
+ if (type->str != NULL) {
598
+ const char *last_name = type->str;
599
+ const char *s;
600
+ for (s = type->str; *s; s++)
601
+ if (*s == '|') last_name = s+1;
602
+ return last_name;
603
+ }
604
+ else
605
+ return type->name;
606
+ }
607
+
608
+ /*
609
+ Set the clientdata field for a type
610
+ */
611
+ SWIGRUNTIME void
612
+ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
613
+ swig_cast_info *cast = ti->cast;
614
+ /* if (ti->clientdata == clientdata) return; */
615
+ ti->clientdata = clientdata;
616
+
617
+ while (cast) {
618
+ if (!cast->converter) {
619
+ swig_type_info *tc = cast->type;
620
+ if (!tc->clientdata) {
621
+ SWIG_TypeClientData(tc, clientdata);
622
+ }
623
+ }
624
+ cast = cast->next;
625
+ }
626
+ }
627
+ SWIGRUNTIME void
628
+ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
629
+ SWIG_TypeClientData(ti, clientdata);
630
+ ti->owndata = 1;
631
+ }
632
+
633
+ /*
634
+ Search for a swig_type_info structure only by mangled name
635
+ Search is a O(log #types)
636
+
637
+ We start searching at module start, and finish searching when start == end.
638
+ Note: if start == end at the beginning of the function, we go all the way around
639
+ the circular list.
640
+ */
641
+ SWIGRUNTIME swig_type_info *
642
+ SWIG_MangledTypeQueryModule(swig_module_info *start,
643
+ swig_module_info *end,
644
+ const char *name) {
645
+ swig_module_info *iter = start;
646
+ do {
647
+ if (iter->size) {
648
+ register size_t l = 0;
649
+ register size_t r = iter->size - 1;
650
+ do {
651
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
652
+ register size_t i = (l + r) >> 1;
653
+ const char *iname = iter->types[i]->name;
654
+ if (iname) {
655
+ register int compare = strcmp(name, iname);
656
+ if (compare == 0) {
657
+ return iter->types[i];
658
+ } else if (compare < 0) {
659
+ if (i) {
660
+ r = i - 1;
661
+ } else {
662
+ break;
663
+ }
664
+ } else if (compare > 0) {
665
+ l = i + 1;
666
+ }
667
+ } else {
668
+ break; /* should never happen */
669
+ }
670
+ } while (l <= r);
671
+ }
672
+ iter = iter->next;
673
+ } while (iter != end);
674
+ return 0;
675
+ }
676
+
677
+ /*
678
+ Search for a swig_type_info structure for either a mangled name or a human readable name.
679
+ It first searches the mangled names of the types, which is a O(log #types)
680
+ If a type is not found it then searches the human readable names, which is O(#types).
681
+
682
+ We start searching at module start, and finish searching when start == end.
683
+ Note: if start == end at the beginning of the function, we go all the way around
684
+ the circular list.
685
+ */
686
+ SWIGRUNTIME swig_type_info *
687
+ SWIG_TypeQueryModule(swig_module_info *start,
688
+ swig_module_info *end,
689
+ const char *name) {
690
+ /* STEP 1: Search the name field using binary search */
691
+ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
692
+ if (ret) {
693
+ return ret;
694
+ } else {
695
+ /* STEP 2: If the type hasn't been found, do a complete search
696
+ of the str field (the human readable name) */
697
+ swig_module_info *iter = start;
698
+ do {
699
+ register size_t i = 0;
700
+ for (; i < iter->size; ++i) {
701
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
702
+ return iter->types[i];
703
+ }
704
+ iter = iter->next;
705
+ } while (iter != end);
706
+ }
707
+
708
+ /* neither found a match */
709
+ return 0;
710
+ }
711
+
712
+ /*
713
+ Pack binary data into a string
714
+ */
715
+ SWIGRUNTIME char *
716
+ SWIG_PackData(char *c, void *ptr, size_t sz) {
717
+ static const char hex[17] = "0123456789abcdef";
718
+ register const unsigned char *u = (unsigned char *) ptr;
719
+ register const unsigned char *eu = u + sz;
720
+ for (; u != eu; ++u) {
721
+ register unsigned char uu = *u;
722
+ *(c++) = hex[(uu & 0xf0) >> 4];
723
+ *(c++) = hex[uu & 0xf];
724
+ }
725
+ return c;
726
+ }
727
+
728
+ /*
729
+ Unpack binary data from a string
730
+ */
731
+ SWIGRUNTIME const char *
732
+ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
733
+ register unsigned char *u = (unsigned char *) ptr;
734
+ register const unsigned char *eu = u + sz;
735
+ for (; u != eu; ++u) {
736
+ register char d = *(c++);
737
+ register unsigned char uu;
738
+ if ((d >= '0') && (d <= '9'))
739
+ uu = ((d - '0') << 4);
740
+ else if ((d >= 'a') && (d <= 'f'))
741
+ uu = ((d - ('a'-10)) << 4);
742
+ else
743
+ return (char *) 0;
744
+ d = *(c++);
745
+ if ((d >= '0') && (d <= '9'))
746
+ uu |= (d - '0');
747
+ else if ((d >= 'a') && (d <= 'f'))
748
+ uu |= (d - ('a'-10));
749
+ else
750
+ return (char *) 0;
751
+ *u = uu;
752
+ }
753
+ return c;
754
+ }
755
+
756
+ /*
757
+ Pack 'void *' into a string buffer.
758
+ */
759
+ SWIGRUNTIME char *
760
+ SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
761
+ char *r = buff;
762
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
763
+ *(r++) = '_';
764
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
765
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
766
+ strcpy(r,name);
767
+ return buff;
768
+ }
769
+
770
+ SWIGRUNTIME const char *
771
+ SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
772
+ if (*c != '_') {
773
+ if (strcmp(c,"NULL") == 0) {
774
+ *ptr = (void *) 0;
775
+ return name;
776
+ } else {
777
+ return 0;
778
+ }
779
+ }
780
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
781
+ }
782
+
783
+ SWIGRUNTIME char *
784
+ SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
785
+ char *r = buff;
786
+ size_t lname = (name ? strlen(name) : 0);
787
+ if ((2*sz + 2 + lname) > bsz) return 0;
788
+ *(r++) = '_';
789
+ r = SWIG_PackData(r,ptr,sz);
790
+ if (lname) {
791
+ strncpy(r,name,lname+1);
792
+ } else {
793
+ *r = 0;
794
+ }
795
+ return buff;
796
+ }
797
+
798
+ SWIGRUNTIME const char *
799
+ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
800
+ if (*c != '_') {
801
+ if (strcmp(c,"NULL") == 0) {
802
+ memset(ptr,0,sz);
803
+ return name;
804
+ } else {
805
+ return 0;
806
+ }
807
+ }
808
+ return SWIG_UnpackData(++c,ptr,sz);
809
+ }
810
+
811
+ #ifdef __cplusplus
812
+ }
813
+ #endif
814
+
815
+ /* Errors in SWIG */
816
+ #define SWIG_UnknownError -1
817
+ #define SWIG_IOError -2
818
+ #define SWIG_RuntimeError -3
819
+ #define SWIG_IndexError -4
820
+ #define SWIG_TypeError -5
821
+ #define SWIG_DivisionByZero -6
822
+ #define SWIG_OverflowError -7
823
+ #define SWIG_SyntaxError -8
824
+ #define SWIG_ValueError -9
825
+ #define SWIG_SystemError -10
826
+ #define SWIG_AttributeError -11
827
+ #define SWIG_MemoryError -12
828
+ #define SWIG_NullReferenceError -13
829
+
830
+
831
+
832
+ #include <ruby.h>
833
+
834
+ /* Remove global macros defined in Ruby's win32.h */
835
+ #ifdef write
836
+ # undef write
837
+ #endif
838
+ #ifdef read
839
+ # undef read
840
+ #endif
841
+ #ifdef bind
842
+ # undef bind
843
+ #endif
844
+ #ifdef close
845
+ # undef close
846
+ #endif
847
+ #ifdef connect
848
+ # undef connect
849
+ #endif
850
+
851
+
852
+ /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
853
+ #ifndef NUM2LL
854
+ #define NUM2LL(x) NUM2LONG((x))
855
+ #endif
856
+ #ifndef LL2NUM
857
+ #define LL2NUM(x) INT2NUM((long) (x))
858
+ #endif
859
+ #ifndef ULL2NUM
860
+ #define ULL2NUM(x) UINT2NUM((unsigned long) (x))
861
+ #endif
862
+
863
+ /* Ruby 1.7 doesn't (yet) define NUM2ULL() */
864
+ #ifndef NUM2ULL
865
+ #ifdef HAVE_LONG_LONG
866
+ #define NUM2ULL(x) rb_num2ull((x))
867
+ #else
868
+ #define NUM2ULL(x) NUM2ULONG(x)
869
+ #endif
870
+ #endif
871
+
872
+ /* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */
873
+ /* Define these for older versions so we can just write code the new way */
874
+ #ifndef RSTRING_LEN
875
+ # define RSTRING_LEN(x) RSTRING(x)->len
876
+ #endif
877
+ #ifndef RSTRING_PTR
878
+ # define RSTRING_PTR(x) RSTRING(x)->ptr
879
+ #endif
880
+ #ifndef RSTRING_END
881
+ # define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x))
882
+ #endif
883
+ #ifndef RARRAY_LEN
884
+ # define RARRAY_LEN(x) RARRAY(x)->len
885
+ #endif
886
+ #ifndef RARRAY_PTR
887
+ # define RARRAY_PTR(x) RARRAY(x)->ptr
888
+ #endif
889
+ #ifndef RFLOAT_VALUE
890
+ # define RFLOAT_VALUE(x) RFLOAT(x)->value
891
+ #endif
892
+ #ifndef DOUBLE2NUM
893
+ # define DOUBLE2NUM(x) rb_float_new(x)
894
+ #endif
895
+ #ifndef RHASH_TBL
896
+ # define RHASH_TBL(x) (RHASH(x)->tbl)
897
+ #endif
898
+ #ifndef RHASH_ITER_LEV
899
+ # define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev)
900
+ #endif
901
+ #ifndef RHASH_IFNONE
902
+ # define RHASH_IFNONE(x) (RHASH(x)->ifnone)
903
+ #endif
904
+ #ifndef RHASH_SIZE
905
+ # define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries)
906
+ #endif
907
+ #ifndef RHASH_EMPTY_P
908
+ # define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0)
909
+ #endif
910
+ #ifndef RSTRUCT_LEN
911
+ # define RSTRUCT_LEN(x) RSTRUCT(x)->len
912
+ #endif
913
+ #ifndef RSTRUCT_PTR
914
+ # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
915
+ #endif
916
+
917
+
918
+
919
+ /*
920
+ * Need to be very careful about how these macros are defined, especially
921
+ * when compiling C++ code or C code with an ANSI C compiler.
922
+ *
923
+ * VALUEFUNC(f) is a macro used to typecast a C function that implements
924
+ * a Ruby method so that it can be passed as an argument to API functions
925
+ * like rb_define_method() and rb_define_singleton_method().
926
+ *
927
+ * VOIDFUNC(f) is a macro used to typecast a C function that implements
928
+ * either the "mark" or "free" stuff for a Ruby Data object, so that it
929
+ * can be passed as an argument to API functions like Data_Wrap_Struct()
930
+ * and Data_Make_Struct().
931
+ */
932
+
933
+ #ifdef __cplusplus
934
+ # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
935
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
936
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
937
+ # define VOIDFUNC(f) ((void (*)()) f)
938
+ # else
939
+ # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
940
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
941
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
942
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
943
+ # else /* These definitions should work for Ruby 1.7+ */
944
+ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
945
+ # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
946
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
947
+ # endif
948
+ # endif
949
+ #else
950
+ # define VALUEFUNC(f) (f)
951
+ # define VOIDFUNC(f) (f)
952
+ #endif
953
+
954
+ /* Don't use for expressions have side effect */
955
+ #ifndef RB_STRING_VALUE
956
+ #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
957
+ #endif
958
+ #ifndef StringValue
959
+ #define StringValue(s) RB_STRING_VALUE(s)
960
+ #endif
961
+ #ifndef StringValuePtr
962
+ #define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s))
963
+ #endif
964
+ #ifndef StringValueLen
965
+ #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
966
+ #endif
967
+ #ifndef SafeStringValue
968
+ #define SafeStringValue(v) do {\
969
+ StringValue(v);\
970
+ rb_check_safe_str(v);\
971
+ } while (0)
972
+ #endif
973
+
974
+ #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
975
+ #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1)
976
+ #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new")
977
+ #endif
978
+
979
+ static VALUE _mSWIG = Qnil;
980
+
981
+ /* -----------------------------------------------------------------------------
982
+ * error manipulation
983
+ * ----------------------------------------------------------------------------- */
984
+
985
+
986
+ /* Define some additional error types */
987
+ #define SWIG_ObjectPreviouslyDeletedError -100
988
+
989
+
990
+ /* Define custom exceptions for errors that do not map to existing Ruby
991
+ exceptions. Note this only works for C++ since a global cannot be
992
+ initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/
993
+
994
+ SWIGINTERN VALUE
995
+ getNullReferenceError(void) {
996
+ static int init = 0;
997
+ static VALUE rb_eNullReferenceError ;
998
+ if (!init) {
999
+ init = 1;
1000
+ rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError);
1001
+ }
1002
+ return rb_eNullReferenceError;
1003
+ }
1004
+
1005
+ SWIGINTERN VALUE
1006
+ getObjectPreviouslyDeletedError(void) {
1007
+ static int init = 0;
1008
+ static VALUE rb_eObjectPreviouslyDeleted ;
1009
+ if (!init) {
1010
+ init = 1;
1011
+ rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError);
1012
+ }
1013
+ return rb_eObjectPreviouslyDeleted;
1014
+ }
1015
+
1016
+
1017
+ SWIGINTERN VALUE
1018
+ SWIG_Ruby_ErrorType(int SWIG_code) {
1019
+ VALUE type;
1020
+ switch (SWIG_code) {
1021
+ case SWIG_MemoryError:
1022
+ type = rb_eNoMemError;
1023
+ break;
1024
+ case SWIG_IOError:
1025
+ type = rb_eIOError;
1026
+ break;
1027
+ case SWIG_RuntimeError:
1028
+ type = rb_eRuntimeError;
1029
+ break;
1030
+ case SWIG_IndexError:
1031
+ type = rb_eIndexError;
1032
+ break;
1033
+ case SWIG_TypeError:
1034
+ type = rb_eTypeError;
1035
+ break;
1036
+ case SWIG_DivisionByZero:
1037
+ type = rb_eZeroDivError;
1038
+ break;
1039
+ case SWIG_OverflowError:
1040
+ type = rb_eRangeError;
1041
+ break;
1042
+ case SWIG_SyntaxError:
1043
+ type = rb_eSyntaxError;
1044
+ break;
1045
+ case SWIG_ValueError:
1046
+ type = rb_eArgError;
1047
+ break;
1048
+ case SWIG_SystemError:
1049
+ type = rb_eFatal;
1050
+ break;
1051
+ case SWIG_AttributeError:
1052
+ type = rb_eRuntimeError;
1053
+ break;
1054
+ case SWIG_NullReferenceError:
1055
+ type = getNullReferenceError();
1056
+ break;
1057
+ case SWIG_ObjectPreviouslyDeletedError:
1058
+ type = getObjectPreviouslyDeletedError();
1059
+ break;
1060
+ case SWIG_UnknownError:
1061
+ type = rb_eRuntimeError;
1062
+ break;
1063
+ default:
1064
+ type = rb_eRuntimeError;
1065
+ }
1066
+ return type;
1067
+ }
1068
+
1069
+
1070
+ /* This function is called when a user inputs a wrong argument to
1071
+ a method.
1072
+ */
1073
+ SWIGINTERN
1074
+ const char* Ruby_Format_TypeError( const char* msg,
1075
+ const char* type,
1076
+ const char* name,
1077
+ const int argn,
1078
+ VALUE input )
1079
+ {
1080
+ char buf[128];
1081
+ VALUE str;
1082
+ VALUE asStr;
1083
+ if ( msg && *msg )
1084
+ {
1085
+ str = rb_str_new2(msg);
1086
+ }
1087
+ else
1088
+ {
1089
+ str = rb_str_new(NULL, 0);
1090
+ }
1091
+
1092
+ str = rb_str_cat2( str, "Expected argument " );
1093
+ sprintf( buf, "%d of type ", argn-1 );
1094
+ str = rb_str_cat2( str, buf );
1095
+ str = rb_str_cat2( str, type );
1096
+ str = rb_str_cat2( str, ", but got " );
1097
+ str = rb_str_cat2( str, rb_obj_classname(input) );
1098
+ str = rb_str_cat2( str, " " );
1099
+ asStr = rb_inspect(input);
1100
+ if ( RSTRING_LEN(asStr) > 30 )
1101
+ {
1102
+ str = rb_str_cat( str, StringValuePtr(asStr), 30 );
1103
+ str = rb_str_cat2( str, "..." );
1104
+ }
1105
+ else
1106
+ {
1107
+ str = rb_str_append( str, asStr );
1108
+ }
1109
+
1110
+ if ( name )
1111
+ {
1112
+ str = rb_str_cat2( str, "\n\tin SWIG method '" );
1113
+ str = rb_str_cat2( str, name );
1114
+ str = rb_str_cat2( str, "'" );
1115
+ }
1116
+
1117
+ return StringValuePtr( str );
1118
+ }
1119
+
1120
+ /* This function is called when an overloaded method fails */
1121
+ SWIGINTERN
1122
+ void Ruby_Format_OverloadedError(
1123
+ const int argc,
1124
+ const int maxargs,
1125
+ const char* method,
1126
+ const char* prototypes
1127
+ )
1128
+ {
1129
+ const char* msg = "Wrong # of arguments";
1130
+ if ( argc <= maxargs ) msg = "Wrong arguments";
1131
+ rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n"
1132
+ "Possible C/C++ prototypes are:\n%s",
1133
+ msg, method, prototypes);
1134
+ }
1135
+
1136
+ /* -----------------------------------------------------------------------------
1137
+ * See the LICENSE file for information on copyright, usage and redistribution
1138
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
1139
+ *
1140
+ * rubytracking.swg
1141
+ *
1142
+ * This file contains support for tracking mappings from
1143
+ * Ruby objects to C++ objects. This functionality is needed
1144
+ * to implement mark functions for Ruby's mark and sweep
1145
+ * garbage collector.
1146
+ * ----------------------------------------------------------------------------- */
1147
+
1148
+ #ifdef __cplusplus
1149
+ extern "C" {
1150
+ #endif
1151
+
1152
+ /* Ruby 1.8 actually assumes the first case. */
1153
+ #if SIZEOF_VOIDP == SIZEOF_LONG
1154
+ # define SWIG2NUM(v) LONG2NUM((unsigned long)v)
1155
+ # define NUM2SWIG(x) (unsigned long)NUM2LONG(x)
1156
+ #elif SIZEOF_VOIDP == SIZEOF_LONG_LONG
1157
+ # define SWIG2NUM(v) LL2NUM((unsigned long long)v)
1158
+ # define NUM2SWIG(x) (unsigned long long)NUM2LL(x)
1159
+ #else
1160
+ # error sizeof(void*) is not the same as long or long long
1161
+ #endif
1162
+
1163
+
1164
+ /* Global Ruby hash table to store Trackings from C/C++
1165
+ structs to Ruby Objects.
1166
+ */
1167
+ static VALUE swig_ruby_trackings = Qnil;
1168
+
1169
+ /* Global variable that stores a reference to the ruby
1170
+ hash table delete function. */
1171
+ static ID swig_ruby_hash_delete;
1172
+
1173
+ /* Setup a Ruby hash table to store Trackings */
1174
+ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1175
+ /* Create a ruby hash table to store Trackings from C++
1176
+ objects to Ruby objects. */
1177
+
1178
+ /* Try to see if some other .so has already created a
1179
+ tracking hash table, which we keep hidden in an instance var
1180
+ in the SWIG module.
1181
+ This is done to allow multiple DSOs to share the same
1182
+ tracking table.
1183
+ */
1184
+ ID trackings_id = rb_intern( "@__trackings__" );
1185
+ VALUE verbose = rb_gv_get("VERBOSE");
1186
+ rb_gv_set("VERBOSE", Qfalse);
1187
+ swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
1188
+ rb_gv_set("VERBOSE", verbose);
1189
+
1190
+ /* No, it hasn't. Create one ourselves */
1191
+ if ( swig_ruby_trackings == Qnil )
1192
+ {
1193
+ swig_ruby_trackings = rb_hash_new();
1194
+ rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
1195
+ }
1196
+
1197
+ /* Now store a reference to the hash table delete function
1198
+ so that we only have to look it up once.*/
1199
+ swig_ruby_hash_delete = rb_intern("delete");
1200
+ }
1201
+
1202
+ /* Get a Ruby number to reference a pointer */
1203
+ SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
1204
+ /* We cast the pointer to an unsigned long
1205
+ and then store a reference to it using
1206
+ a Ruby number object. */
1207
+
1208
+ /* Convert the pointer to a Ruby number */
1209
+ return SWIG2NUM(ptr);
1210
+ }
1211
+
1212
+ /* Get a Ruby number to reference an object */
1213
+ SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
1214
+ /* We cast the object to an unsigned long
1215
+ and then store a reference to it using
1216
+ a Ruby number object. */
1217
+
1218
+ /* Convert the Object to a Ruby number */
1219
+ return SWIG2NUM(object);
1220
+ }
1221
+
1222
+ /* Get a Ruby object from a previously stored reference */
1223
+ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
1224
+ /* The provided Ruby number object is a reference
1225
+ to the Ruby object we want.*/
1226
+
1227
+ /* Convert the Ruby number to a Ruby object */
1228
+ return NUM2SWIG(reference);
1229
+ }
1230
+
1231
+ /* Add a Tracking from a C/C++ struct to a Ruby object */
1232
+ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1233
+ /* In a Ruby hash table we store the pointer and
1234
+ the associated Ruby object. The trick here is
1235
+ that we cannot store the Ruby object directly - if
1236
+ we do then it cannot be garbage collected. So
1237
+ instead we typecast it as a unsigned long and
1238
+ convert it to a Ruby number object.*/
1239
+
1240
+ /* Get a reference to the pointer as a Ruby number */
1241
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1242
+
1243
+ /* Get a reference to the Ruby object as a Ruby number */
1244
+ VALUE value = SWIG_RubyObjectToReference(object);
1245
+
1246
+ /* Store the mapping to the global hash table. */
1247
+ rb_hash_aset(swig_ruby_trackings, key, value);
1248
+ }
1249
+
1250
+ /* Get the Ruby object that owns the specified C/C++ struct */
1251
+ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1252
+ /* Get a reference to the pointer as a Ruby number */
1253
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1254
+
1255
+ /* Now lookup the value stored in the global hash table */
1256
+ VALUE value = rb_hash_aref(swig_ruby_trackings, key);
1257
+
1258
+ if (value == Qnil) {
1259
+ /* No object exists - return nil. */
1260
+ return Qnil;
1261
+ }
1262
+ else {
1263
+ /* Convert this value to Ruby object */
1264
+ return SWIG_RubyReferenceToObject(value);
1265
+ }
1266
+ }
1267
+
1268
+ /* Remove a Tracking from a C/C++ struct to a Ruby object. It
1269
+ is very important to remove objects once they are destroyed
1270
+ since the same memory address may be reused later to create
1271
+ a new object. */
1272
+ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1273
+ /* Get a reference to the pointer as a Ruby number */
1274
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1275
+
1276
+ /* Delete the object from the hash table by calling Ruby's
1277
+ do this we need to call the Hash.delete method.*/
1278
+ rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
1279
+ }
1280
+
1281
+ /* This is a helper method that unlinks a Ruby object from its
1282
+ underlying C++ object. This is needed if the lifetime of the
1283
+ Ruby object is longer than the C++ object */
1284
+ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1285
+ VALUE object = SWIG_RubyInstanceFor(ptr);
1286
+
1287
+ if (object != Qnil) {
1288
+ DATA_PTR(object) = 0;
1289
+ }
1290
+ }
1291
+
1292
+
1293
+ #ifdef __cplusplus
1294
+ }
1295
+ #endif
1296
+
1297
+ /* -----------------------------------------------------------------------------
1298
+ * Ruby API portion that goes into the runtime
1299
+ * ----------------------------------------------------------------------------- */
1300
+
1301
+ #ifdef __cplusplus
1302
+ extern "C" {
1303
+ #endif
1304
+
1305
+ SWIGINTERN VALUE
1306
+ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1307
+ if (NIL_P(target)) {
1308
+ target = o;
1309
+ } else {
1310
+ if (TYPE(target) != T_ARRAY) {
1311
+ VALUE o2 = target;
1312
+ target = rb_ary_new();
1313
+ rb_ary_push(target, o2);
1314
+ }
1315
+ rb_ary_push(target, o);
1316
+ }
1317
+ return target;
1318
+ }
1319
+
1320
+ /* For ruby1.8.4 and earlier. */
1321
+ #ifndef RUBY_INIT_STACK
1322
+ RUBY_EXTERN void Init_stack(VALUE* addr);
1323
+ # define RUBY_INIT_STACK \
1324
+ VALUE variable_in_this_stack_frame; \
1325
+ Init_stack(&variable_in_this_stack_frame);
1326
+ #endif
1327
+
1328
+
1329
+ #ifdef __cplusplus
1330
+ }
1331
+ #endif
1332
+
1333
+
1334
+ /* -----------------------------------------------------------------------------
1335
+ * See the LICENSE file for information on copyright, usage and redistribution
1336
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
1337
+ *
1338
+ * rubyrun.swg
1339
+ *
1340
+ * This file contains the runtime support for Ruby modules
1341
+ * and includes code for managing global variables and pointer
1342
+ * type checking.
1343
+ * ----------------------------------------------------------------------------- */
1344
+
1345
+ /* For backward compatibility only */
1346
+ #define SWIG_POINTER_EXCEPTION 0
1347
+
1348
+ /* for raw pointers */
1349
+ #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
1350
+ #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own)
1351
+ #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags)
1352
+ #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own)
1353
+ #define swig_owntype ruby_owntype
1354
+
1355
+ /* for raw packed data */
1356
+ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
1357
+ #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
1358
+
1359
+ /* for class or struct pointers */
1360
+ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
1361
+ #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
1362
+
1363
+ /* for C or C++ function pointers */
1364
+ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0)
1365
+ #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0)
1366
+
1367
+ /* for C++ member pointers, ie, member methods */
1368
+ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty)
1369
+ #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
1370
+
1371
+
1372
+ /* Runtime API */
1373
+
1374
+ #define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
1375
+ #define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
1376
+
1377
+
1378
+ /* Error manipulation */
1379
+
1380
+ #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
1381
+ #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg)
1382
+ #define SWIG_fail goto fail
1383
+
1384
+
1385
+ /* Ruby-specific SWIG API */
1386
+
1387
+ #define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
1388
+ #define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
1389
+ #define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
1390
+ #define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
1391
+ #define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
1392
+
1393
+ #include "assert.h"
1394
+
1395
+ /* -----------------------------------------------------------------------------
1396
+ * pointers/data manipulation
1397
+ * ----------------------------------------------------------------------------- */
1398
+
1399
+ #ifdef __cplusplus
1400
+ extern "C" {
1401
+ #endif
1402
+
1403
+ typedef struct {
1404
+ VALUE klass;
1405
+ VALUE mImpl;
1406
+ void (*mark)(void *);
1407
+ void (*destroy)(void *);
1408
+ int trackObjects;
1409
+ } swig_class;
1410
+
1411
+
1412
+ /* Global pointer used to keep some internal SWIG stuff */
1413
+ static VALUE _cSWIG_Pointer = Qnil;
1414
+ static VALUE swig_runtime_data_type_pointer = Qnil;
1415
+
1416
+ /* Global IDs used to keep some internal SWIG stuff */
1417
+ static ID swig_arity_id = 0;
1418
+ static ID swig_call_id = 0;
1419
+
1420
+ /*
1421
+ If your swig extension is to be run within an embedded ruby and has
1422
+ director callbacks, you should set -DRUBY_EMBEDDED during compilation.
1423
+ This will reset ruby's stack frame on each entry point from the main
1424
+ program the first time a virtual director function is invoked (in a
1425
+ non-recursive way).
1426
+ If this is not done, you run the risk of Ruby trashing the stack.
1427
+ */
1428
+
1429
+ #ifdef RUBY_EMBEDDED
1430
+
1431
+ # define SWIG_INIT_STACK \
1432
+ if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \
1433
+ ++swig_virtual_calls;
1434
+ # define SWIG_RELEASE_STACK --swig_virtual_calls;
1435
+ # define Ruby_DirectorTypeMismatchException(x) \
1436
+ rb_raise( rb_eTypeError, x ); return c_result;
1437
+
1438
+ static unsigned int swig_virtual_calls = 0;
1439
+
1440
+ #else /* normal non-embedded extension */
1441
+
1442
+ # define SWIG_INIT_STACK
1443
+ # define SWIG_RELEASE_STACK
1444
+ # define Ruby_DirectorTypeMismatchException(x) \
1445
+ throw Swig::DirectorTypeMismatchException( x );
1446
+
1447
+ #endif /* RUBY_EMBEDDED */
1448
+
1449
+
1450
+ SWIGRUNTIME VALUE
1451
+ getExceptionClass(void) {
1452
+ static int init = 0;
1453
+ static VALUE rubyExceptionClass ;
1454
+ if (!init) {
1455
+ init = 1;
1456
+ rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception"));
1457
+ }
1458
+ return rubyExceptionClass;
1459
+ }
1460
+
1461
+ /* This code checks to see if the Ruby object being raised as part
1462
+ of an exception inherits from the Ruby class Exception. If so,
1463
+ the object is simply returned. If not, then a new Ruby exception
1464
+ object is created and that will be returned to Ruby.*/
1465
+ SWIGRUNTIME VALUE
1466
+ SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) {
1467
+ VALUE exceptionClass = getExceptionClass();
1468
+ if (rb_obj_is_kind_of(obj, exceptionClass)) {
1469
+ return obj;
1470
+ } else {
1471
+ return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj));
1472
+ }
1473
+ }
1474
+
1475
+ /* Initialize Ruby runtime support */
1476
+ SWIGRUNTIME void
1477
+ SWIG_Ruby_InitRuntime(void)
1478
+ {
1479
+ if (_mSWIG == Qnil) {
1480
+ _mSWIG = rb_define_module("SWIG");
1481
+ swig_call_id = rb_intern("call");
1482
+ swig_arity_id = rb_intern("arity");
1483
+ }
1484
+ }
1485
+
1486
+ /* Define Ruby class for C type */
1487
+ SWIGRUNTIME void
1488
+ SWIG_Ruby_define_class(swig_type_info *type)
1489
+ {
1490
+ VALUE klass;
1491
+ char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1492
+ sprintf(klass_name, "TYPE%s", type->name);
1493
+ if (NIL_P(_cSWIG_Pointer)) {
1494
+ _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
1495
+ rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
1496
+ }
1497
+ klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
1498
+ free((void *) klass_name);
1499
+ }
1500
+
1501
+ /* Create a new pointer object */
1502
+ SWIGRUNTIME VALUE
1503
+ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1504
+ {
1505
+ int own = flags & SWIG_POINTER_OWN;
1506
+ int track;
1507
+ char *klass_name;
1508
+ swig_class *sklass;
1509
+ VALUE klass;
1510
+ VALUE obj;
1511
+
1512
+ if (!ptr)
1513
+ return Qnil;
1514
+
1515
+ if (type->clientdata) {
1516
+ sklass = (swig_class *) type->clientdata;
1517
+
1518
+ /* Are we tracking this class and have we already returned this Ruby object? */
1519
+ track = sklass->trackObjects;
1520
+ if (track) {
1521
+ obj = SWIG_RubyInstanceFor(ptr);
1522
+
1523
+ /* Check the object's type and make sure it has the correct type.
1524
+ It might not in cases where methods do things like
1525
+ downcast methods. */
1526
+ if (obj != Qnil) {
1527
+ VALUE value = rb_iv_get(obj, "@__swigtype__");
1528
+ char* type_name = RSTRING_PTR(value);
1529
+
1530
+ if (strcmp(type->name, type_name) == 0) {
1531
+ return obj;
1532
+ }
1533
+ }
1534
+ }
1535
+
1536
+ /* Create a new Ruby object */
1537
+ obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark),
1538
+ ( own ? VOIDFUNC(sklass->destroy) :
1539
+ (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 )
1540
+ ), ptr);
1541
+
1542
+ /* If tracking is on for this class then track this object. */
1543
+ if (track) {
1544
+ SWIG_RubyAddTracking(ptr, obj);
1545
+ }
1546
+ } else {
1547
+ klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1548
+ sprintf(klass_name, "TYPE%s", type->name);
1549
+ klass = rb_const_get(_mSWIG, rb_intern(klass_name));
1550
+ free((void *) klass_name);
1551
+ obj = Data_Wrap_Struct(klass, 0, 0, ptr);
1552
+ }
1553
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1554
+
1555
+ return obj;
1556
+ }
1557
+
1558
+ /* Create a new class instance (always owned) */
1559
+ SWIGRUNTIME VALUE
1560
+ SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
1561
+ {
1562
+ VALUE obj;
1563
+ swig_class *sklass = (swig_class *) type->clientdata;
1564
+ obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0);
1565
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1566
+ return obj;
1567
+ }
1568
+
1569
+ /* Get type mangle from class name */
1570
+ SWIGRUNTIMEINLINE char *
1571
+ SWIG_Ruby_MangleStr(VALUE obj)
1572
+ {
1573
+ VALUE stype = rb_iv_get(obj, "@__swigtype__");
1574
+ return StringValuePtr(stype);
1575
+ }
1576
+
1577
+ /* Acquire a pointer value */
1578
+ typedef void (*ruby_owntype)(void*);
1579
+
1580
+ SWIGRUNTIME ruby_owntype
1581
+ SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) {
1582
+ if (obj) {
1583
+ ruby_owntype oldown = RDATA(obj)->dfree;
1584
+ RDATA(obj)->dfree = own;
1585
+ return oldown;
1586
+ } else {
1587
+ return 0;
1588
+ }
1589
+ }
1590
+
1591
+ /* Convert a pointer value */
1592
+ SWIGRUNTIME int
1593
+ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own)
1594
+ {
1595
+ char *c;
1596
+ swig_cast_info *tc;
1597
+ void *vptr = 0;
1598
+
1599
+ /* Grab the pointer */
1600
+ if (NIL_P(obj)) {
1601
+ *ptr = 0;
1602
+ return SWIG_OK;
1603
+ } else {
1604
+ if (TYPE(obj) != T_DATA) {
1605
+ return SWIG_ERROR;
1606
+ }
1607
+ Data_Get_Struct(obj, void, vptr);
1608
+ }
1609
+
1610
+ if (own) *own = RDATA(obj)->dfree;
1611
+
1612
+ /* Check to see if the input object is giving up ownership
1613
+ of the underlying C struct or C++ object. If so then we
1614
+ need to reset the destructor since the Ruby object no
1615
+ longer owns the underlying C++ object.*/
1616
+ if (flags & SWIG_POINTER_DISOWN) {
1617
+ /* Is tracking on for this class? */
1618
+ int track = 0;
1619
+ if (ty && ty->clientdata) {
1620
+ swig_class *sklass = (swig_class *) ty->clientdata;
1621
+ track = sklass->trackObjects;
1622
+ }
1623
+
1624
+ if (track) {
1625
+ /* We are tracking objects for this class. Thus we change the destructor
1626
+ * to SWIG_RubyRemoveTracking. This allows us to
1627
+ * remove the mapping from the C++ to Ruby object
1628
+ * when the Ruby object is garbage collected. If we don't
1629
+ * do this, then it is possible we will return a reference
1630
+ * to a Ruby object that no longer exists thereby crashing Ruby. */
1631
+ RDATA(obj)->dfree = SWIG_RubyRemoveTracking;
1632
+ } else {
1633
+ RDATA(obj)->dfree = 0;
1634
+ }
1635
+ }
1636
+
1637
+ /* Do type-checking if type info was provided */
1638
+ if (ty) {
1639
+ if (ty->clientdata) {
1640
+ if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
1641
+ if (vptr == 0) {
1642
+ /* The object has already been deleted */
1643
+ return SWIG_ObjectPreviouslyDeletedError;
1644
+ }
1645
+ *ptr = vptr;
1646
+ return SWIG_OK;
1647
+ }
1648
+ }
1649
+ if ((c = SWIG_MangleStr(obj)) == NULL) {
1650
+ return SWIG_ERROR;
1651
+ }
1652
+ tc = SWIG_TypeCheck(c, ty);
1653
+ if (!tc) {
1654
+ return SWIG_ERROR;
1655
+ } else {
1656
+ int newmemory = 0;
1657
+ *ptr = SWIG_TypeCast(tc, vptr, &newmemory);
1658
+ assert(!newmemory); /* newmemory handling not yet implemented */
1659
+ }
1660
+ } else {
1661
+ *ptr = vptr;
1662
+ }
1663
+
1664
+ return SWIG_OK;
1665
+ }
1666
+
1667
+ /* Check convert */
1668
+ SWIGRUNTIMEINLINE int
1669
+ SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty)
1670
+ {
1671
+ char *c = SWIG_MangleStr(obj);
1672
+ if (!c) return 0;
1673
+ return SWIG_TypeCheck(c,ty) != 0;
1674
+ }
1675
+
1676
+ SWIGRUNTIME VALUE
1677
+ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
1678
+ char result[1024];
1679
+ char *r = result;
1680
+ if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
1681
+ *(r++) = '_';
1682
+ r = SWIG_PackData(r, ptr, sz);
1683
+ strcpy(r, type->name);
1684
+ return rb_str_new2(result);
1685
+ }
1686
+
1687
+ /* Convert a packed value value */
1688
+ SWIGRUNTIME int
1689
+ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
1690
+ swig_cast_info *tc;
1691
+ const char *c;
1692
+
1693
+ if (TYPE(obj) != T_STRING) goto type_error;
1694
+ c = StringValuePtr(obj);
1695
+ /* Pointer values must start with leading underscore */
1696
+ if (*c != '_') goto type_error;
1697
+ c++;
1698
+ c = SWIG_UnpackData(c, ptr, sz);
1699
+ if (ty) {
1700
+ tc = SWIG_TypeCheck(c, ty);
1701
+ if (!tc) goto type_error;
1702
+ }
1703
+ return SWIG_OK;
1704
+
1705
+ type_error:
1706
+ return SWIG_ERROR;
1707
+ }
1708
+
1709
+ SWIGRUNTIME swig_module_info *
1710
+ SWIG_Ruby_GetModule(void)
1711
+ {
1712
+ VALUE pointer;
1713
+ swig_module_info *ret = 0;
1714
+ VALUE verbose = rb_gv_get("VERBOSE");
1715
+
1716
+ /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */
1717
+ rb_gv_set("VERBOSE", Qfalse);
1718
+
1719
+ /* first check if pointer already created */
1720
+ pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
1721
+ if (pointer != Qnil) {
1722
+ Data_Get_Struct(pointer, swig_module_info, ret);
1723
+ }
1724
+
1725
+ /* reinstate warnings */
1726
+ rb_gv_set("VERBOSE", verbose);
1727
+ return ret;
1728
+ }
1729
+
1730
+ SWIGRUNTIME void
1731
+ SWIG_Ruby_SetModule(swig_module_info *pointer)
1732
+ {
1733
+ /* register a new class */
1734
+ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
1735
+ /* create and store the structure pointer to a global variable */
1736
+ swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
1737
+ rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
1738
+ }
1739
+
1740
+ /* This function can be used to check whether a proc or method or similarly
1741
+ callable function has been passed. Usually used in a %typecheck, like:
1742
+
1743
+ %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) {
1744
+ $result = SWIG_Ruby_isCallable( $input );
1745
+ }
1746
+ */
1747
+ SWIGINTERN
1748
+ int SWIG_Ruby_isCallable( VALUE proc )
1749
+ {
1750
+ if ( rb_respond_to( proc, swig_call_id ) == Qtrue )
1751
+ return 1;
1752
+ return 0;
1753
+ }
1754
+
1755
+ /* This function can be used to check the arity (number of arguments)
1756
+ a proc or method can take. Usually used in a %typecheck.
1757
+ Valid arities will be that equal to minimal or those < 0
1758
+ which indicate a variable number of parameters at the end.
1759
+ */
1760
+ SWIGINTERN
1761
+ int SWIG_Ruby_arity( VALUE proc, int minimal )
1762
+ {
1763
+ if ( rb_respond_to( proc, swig_arity_id ) == Qtrue )
1764
+ {
1765
+ VALUE num = rb_funcall( proc, swig_arity_id, 0 );
1766
+ int arity = NUM2INT(num);
1767
+ if ( arity < 0 && (arity+1) < -minimal ) return 1;
1768
+ if ( arity == minimal ) return 1;
1769
+ return 1;
1770
+ }
1771
+ return 0;
1772
+ }
1773
+
1774
+
1775
+ #ifdef __cplusplus
1776
+ }
1777
+ #endif
1778
+
1779
+
1780
+
1781
+ #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
1782
+
1783
+ #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
1784
+
1785
+
1786
+
1787
+ /* -------- TYPES TABLE (BEGIN) -------- */
1788
+
1789
+ #define SWIGTYPE_p_char swig_types[0]
1790
+ static swig_type_info *swig_types[2];
1791
+ static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0};
1792
+ #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
1793
+ #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
1794
+
1795
+ /* -------- TYPES TABLE (END) -------- */
1796
+
1797
+ #define SWIG_init Init_wiringpi
1798
+ #define SWIG_name "Wiringpi"
1799
+
1800
+ static VALUE mWiringpi;
1801
+
1802
+ #define SWIG_RUBY_THREAD_BEGIN_BLOCK
1803
+ #define SWIG_RUBY_THREAD_END_BLOCK
1804
+
1805
+
1806
+ #define SWIGVERSION 0x010340
1807
+ #define SWIG_VERSION SWIGVERSION
1808
+
1809
+
1810
+ #define SWIG_as_voidptr(a) (void *)((const void *)(a))
1811
+ #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
1812
+
1813
+
1814
+ #include <limits.h>
1815
+ #if !defined(SWIG_NO_LLONG_MAX)
1816
+ # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
1817
+ # define LLONG_MAX __LONG_LONG_MAX__
1818
+ # define LLONG_MIN (-LLONG_MAX - 1LL)
1819
+ # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
1820
+ # endif
1821
+ #endif
1822
+
1823
+
1824
+ #define SWIG_From_long LONG2NUM
1825
+
1826
+
1827
+ SWIGINTERNINLINE VALUE
1828
+ SWIG_From_int (int value)
1829
+ {
1830
+ return SWIG_From_long (value);
1831
+ }
1832
+
1833
+
1834
+ SWIGINTERN VALUE
1835
+ SWIG_ruby_failed(void)
1836
+ {
1837
+ return Qnil;
1838
+ }
1839
+
1840
+
1841
+ /*@SWIG:/usr/share/swig1.3/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1842
+ SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
1843
+ {
1844
+ VALUE obj = args[0];
1845
+ VALUE type = TYPE(obj);
1846
+ long *res = (long *)(args[1]);
1847
+ *res = type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj);
1848
+ return obj;
1849
+ }
1850
+ /*@SWIG@*/
1851
+
1852
+ SWIGINTERN int
1853
+ SWIG_AsVal_long (VALUE obj, long* val)
1854
+ {
1855
+ VALUE type = TYPE(obj);
1856
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
1857
+ long v;
1858
+ VALUE a[2];
1859
+ a[0] = obj;
1860
+ a[1] = (VALUE)(&v);
1861
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
1862
+ if (val) *val = v;
1863
+ return SWIG_OK;
1864
+ }
1865
+ }
1866
+ return SWIG_TypeError;
1867
+ }
1868
+
1869
+
1870
+ SWIGINTERN int
1871
+ SWIG_AsVal_int (VALUE obj, int *val)
1872
+ {
1873
+ long v;
1874
+ int res = SWIG_AsVal_long (obj, &v);
1875
+ if (SWIG_IsOK(res)) {
1876
+ if ((v < INT_MIN || v > INT_MAX)) {
1877
+ return SWIG_OverflowError;
1878
+ } else {
1879
+ if (val) *val = (int)(v);
1880
+ }
1881
+ }
1882
+ return res;
1883
+ }
1884
+
1885
+
1886
+ /*@SWIG:/usr/share/swig1.3/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1887
+ SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
1888
+ {
1889
+ VALUE obj = args[0];
1890
+ VALUE type = TYPE(obj);
1891
+ unsigned long *res = (unsigned long *)(args[1]);
1892
+ *res = type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj);
1893
+ return obj;
1894
+ }
1895
+ /*@SWIG@*/
1896
+
1897
+ SWIGINTERN int
1898
+ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val)
1899
+ {
1900
+ VALUE type = TYPE(obj);
1901
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
1902
+ unsigned long v;
1903
+ VALUE a[2];
1904
+ a[0] = obj;
1905
+ a[1] = (VALUE)(&v);
1906
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
1907
+ if (val) *val = v;
1908
+ return SWIG_OK;
1909
+ }
1910
+ }
1911
+ return SWIG_TypeError;
1912
+ }
1913
+
1914
+
1915
+ SWIGINTERN int
1916
+ SWIG_AsVal_unsigned_SS_char (VALUE obj, unsigned char *val)
1917
+ {
1918
+ unsigned long v;
1919
+ int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
1920
+ if (SWIG_IsOK(res)) {
1921
+ if ((v > UCHAR_MAX)) {
1922
+ return SWIG_OverflowError;
1923
+ } else {
1924
+ if (val) *val = (unsigned char)(v);
1925
+ }
1926
+ }
1927
+ return res;
1928
+ }
1929
+
1930
+
1931
+ SWIGINTERNINLINE VALUE
1932
+ SWIG_From_unsigned_SS_long (unsigned long value)
1933
+ {
1934
+ return ULONG2NUM(value);
1935
+ }
1936
+
1937
+
1938
+ SWIGINTERNINLINE VALUE
1939
+ SWIG_From_unsigned_SS_char (unsigned char value)
1940
+ {
1941
+ return SWIG_From_unsigned_SS_long (value);
1942
+ }
1943
+
1944
+
1945
+ SWIGINTERN swig_type_info*
1946
+ SWIG_pchar_descriptor(void)
1947
+ {
1948
+ static int init = 0;
1949
+ static swig_type_info* info = 0;
1950
+ if (!init) {
1951
+ info = SWIG_TypeQuery("_p_char");
1952
+ init = 1;
1953
+ }
1954
+ return info;
1955
+ }
1956
+
1957
+
1958
+ SWIGINTERN int
1959
+ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
1960
+ {
1961
+ if (TYPE(obj) == T_STRING) {
1962
+ #if defined(StringValuePtr)
1963
+ char *cstr = StringValuePtr(obj);
1964
+ #else
1965
+ char *cstr = STR2CSTR(obj);
1966
+ #endif
1967
+ size_t size = RSTRING_LEN(obj) + 1;
1968
+ if (cptr) {
1969
+ if (alloc) {
1970
+ if (*alloc == SWIG_NEWOBJ) {
1971
+ *cptr = (char *)memcpy((char *)malloc((size)*sizeof(char)), cstr, sizeof(char)*(size));
1972
+ } else {
1973
+ *cptr = cstr;
1974
+ *alloc = SWIG_OLDOBJ;
1975
+ }
1976
+ }
1977
+ }
1978
+ if (psize) *psize = size;
1979
+ return SWIG_OK;
1980
+ } else {
1981
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
1982
+ if (pchar_descriptor) {
1983
+ void* vptr = 0;
1984
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
1985
+ if (cptr) *cptr = (char *)vptr;
1986
+ if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0;
1987
+ if (alloc) *alloc = SWIG_OLDOBJ;
1988
+ return SWIG_OK;
1989
+ }
1990
+ }
1991
+ }
1992
+ return SWIG_TypeError;
1993
+ }
1994
+
1995
+
1996
+
1997
+
1998
+
1999
+ #include "wiringPi.h";
2000
+ #include "wiringShift.h";
2001
+ #include "serial.h";
2002
+
2003
+ SWIGINTERN VALUE
2004
+ _wrap_wiringPiSetup(int argc, VALUE *argv, VALUE self) {
2005
+ int result;
2006
+ VALUE vresult = Qnil;
2007
+
2008
+ if ((argc < 0) || (argc > 0)) {
2009
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2010
+ }
2011
+ result = (int)wiringPiSetup();
2012
+ vresult = SWIG_From_int((int)(result));
2013
+ return vresult;
2014
+ fail:
2015
+ return Qnil;
2016
+ }
2017
+
2018
+
2019
+ SWIGINTERN VALUE
2020
+ _wrap_wiringPiGpioMode(int argc, VALUE *argv, VALUE self) {
2021
+ int arg1 ;
2022
+ int val1 ;
2023
+ int ecode1 = 0 ;
2024
+
2025
+ if ((argc < 1) || (argc > 1)) {
2026
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2027
+ }
2028
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2029
+ if (!SWIG_IsOK(ecode1)) {
2030
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","wiringPiGpioMode", 1, argv[0] ));
2031
+ }
2032
+ arg1 = (int)(val1);
2033
+ wiringPiGpioMode(arg1);
2034
+ return Qnil;
2035
+ fail:
2036
+ return Qnil;
2037
+ }
2038
+
2039
+
2040
+ SWIGINTERN VALUE
2041
+ _wrap_pullUpDnControl(int argc, VALUE *argv, VALUE self) {
2042
+ int arg1 ;
2043
+ int arg2 ;
2044
+ int val1 ;
2045
+ int ecode1 = 0 ;
2046
+ int val2 ;
2047
+ int ecode2 = 0 ;
2048
+
2049
+ if ((argc < 2) || (argc > 2)) {
2050
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2051
+ }
2052
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2053
+ if (!SWIG_IsOK(ecode1)) {
2054
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","pullUpDnControl", 1, argv[0] ));
2055
+ }
2056
+ arg1 = (int)(val1);
2057
+ ecode2 = SWIG_AsVal_int(argv[1], &val2);
2058
+ if (!SWIG_IsOK(ecode2)) {
2059
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","pullUpDnControl", 2, argv[1] ));
2060
+ }
2061
+ arg2 = (int)(val2);
2062
+ pullUpDnControl(arg1,arg2);
2063
+ return Qnil;
2064
+ fail:
2065
+ return Qnil;
2066
+ }
2067
+
2068
+
2069
+ SWIGINTERN VALUE
2070
+ _wrap_pinMode(int argc, VALUE *argv, VALUE self) {
2071
+ int arg1 ;
2072
+ int arg2 ;
2073
+ int val1 ;
2074
+ int ecode1 = 0 ;
2075
+ int val2 ;
2076
+ int ecode2 = 0 ;
2077
+
2078
+ if ((argc < 2) || (argc > 2)) {
2079
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2080
+ }
2081
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2082
+ if (!SWIG_IsOK(ecode1)) {
2083
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","pinMode", 1, argv[0] ));
2084
+ }
2085
+ arg1 = (int)(val1);
2086
+ ecode2 = SWIG_AsVal_int(argv[1], &val2);
2087
+ if (!SWIG_IsOK(ecode2)) {
2088
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","pinMode", 2, argv[1] ));
2089
+ }
2090
+ arg2 = (int)(val2);
2091
+ pinMode(arg1,arg2);
2092
+ return Qnil;
2093
+ fail:
2094
+ return Qnil;
2095
+ }
2096
+
2097
+
2098
+ SWIGINTERN VALUE
2099
+ _wrap_digitalWrite(int argc, VALUE *argv, VALUE self) {
2100
+ int arg1 ;
2101
+ int arg2 ;
2102
+ int val1 ;
2103
+ int ecode1 = 0 ;
2104
+ int val2 ;
2105
+ int ecode2 = 0 ;
2106
+
2107
+ if ((argc < 2) || (argc > 2)) {
2108
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2109
+ }
2110
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2111
+ if (!SWIG_IsOK(ecode1)) {
2112
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","digitalWrite", 1, argv[0] ));
2113
+ }
2114
+ arg1 = (int)(val1);
2115
+ ecode2 = SWIG_AsVal_int(argv[1], &val2);
2116
+ if (!SWIG_IsOK(ecode2)) {
2117
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","digitalWrite", 2, argv[1] ));
2118
+ }
2119
+ arg2 = (int)(val2);
2120
+ digitalWrite(arg1,arg2);
2121
+ return Qnil;
2122
+ fail:
2123
+ return Qnil;
2124
+ }
2125
+
2126
+
2127
+ SWIGINTERN VALUE
2128
+ _wrap_pwmWrite(int argc, VALUE *argv, VALUE self) {
2129
+ int arg1 ;
2130
+ int arg2 ;
2131
+ int val1 ;
2132
+ int ecode1 = 0 ;
2133
+ int val2 ;
2134
+ int ecode2 = 0 ;
2135
+
2136
+ if ((argc < 2) || (argc > 2)) {
2137
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2138
+ }
2139
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2140
+ if (!SWIG_IsOK(ecode1)) {
2141
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","pwmWrite", 1, argv[0] ));
2142
+ }
2143
+ arg1 = (int)(val1);
2144
+ ecode2 = SWIG_AsVal_int(argv[1], &val2);
2145
+ if (!SWIG_IsOK(ecode2)) {
2146
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","pwmWrite", 2, argv[1] ));
2147
+ }
2148
+ arg2 = (int)(val2);
2149
+ pwmWrite(arg1,arg2);
2150
+ return Qnil;
2151
+ fail:
2152
+ return Qnil;
2153
+ }
2154
+
2155
+
2156
+ SWIGINTERN VALUE
2157
+ _wrap_digitalRead(int argc, VALUE *argv, VALUE self) {
2158
+ int arg1 ;
2159
+ int val1 ;
2160
+ int ecode1 = 0 ;
2161
+ int result;
2162
+ VALUE vresult = Qnil;
2163
+
2164
+ if ((argc < 1) || (argc > 1)) {
2165
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2166
+ }
2167
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2168
+ if (!SWIG_IsOK(ecode1)) {
2169
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","digitalRead", 1, argv[0] ));
2170
+ }
2171
+ arg1 = (int)(val1);
2172
+ result = (int)digitalRead(arg1);
2173
+ vresult = SWIG_From_int((int)(result));
2174
+ return vresult;
2175
+ fail:
2176
+ return Qnil;
2177
+ }
2178
+
2179
+
2180
+ SWIGINTERN VALUE
2181
+ _wrap_shiftOut(int argc, VALUE *argv, VALUE self) {
2182
+ uint8_t arg1 ;
2183
+ uint8_t arg2 ;
2184
+ uint8_t arg3 ;
2185
+ uint8_t arg4 ;
2186
+ unsigned char val1 ;
2187
+ int ecode1 = 0 ;
2188
+ unsigned char val2 ;
2189
+ int ecode2 = 0 ;
2190
+ unsigned char val3 ;
2191
+ int ecode3 = 0 ;
2192
+ unsigned char val4 ;
2193
+ int ecode4 = 0 ;
2194
+
2195
+ if ((argc < 4) || (argc > 4)) {
2196
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail;
2197
+ }
2198
+ ecode1 = SWIG_AsVal_unsigned_SS_char(argv[0], &val1);
2199
+ if (!SWIG_IsOK(ecode1)) {
2200
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "uint8_t","shiftOut", 1, argv[0] ));
2201
+ }
2202
+ arg1 = (uint8_t)(val1);
2203
+ ecode2 = SWIG_AsVal_unsigned_SS_char(argv[1], &val2);
2204
+ if (!SWIG_IsOK(ecode2)) {
2205
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "uint8_t","shiftOut", 2, argv[1] ));
2206
+ }
2207
+ arg2 = (uint8_t)(val2);
2208
+ ecode3 = SWIG_AsVal_unsigned_SS_char(argv[2], &val3);
2209
+ if (!SWIG_IsOK(ecode3)) {
2210
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "uint8_t","shiftOut", 3, argv[2] ));
2211
+ }
2212
+ arg3 = (uint8_t)(val3);
2213
+ ecode4 = SWIG_AsVal_unsigned_SS_char(argv[3], &val4);
2214
+ if (!SWIG_IsOK(ecode4)) {
2215
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "uint8_t","shiftOut", 4, argv[3] ));
2216
+ }
2217
+ arg4 = (uint8_t)(val4);
2218
+ shiftOut(arg1,arg2,arg3,arg4);
2219
+ return Qnil;
2220
+ fail:
2221
+ return Qnil;
2222
+ }
2223
+
2224
+
2225
+ SWIGINTERN VALUE
2226
+ _wrap_shiftIn(int argc, VALUE *argv, VALUE self) {
2227
+ uint8_t arg1 ;
2228
+ uint8_t arg2 ;
2229
+ uint8_t arg3 ;
2230
+ unsigned char val1 ;
2231
+ int ecode1 = 0 ;
2232
+ unsigned char val2 ;
2233
+ int ecode2 = 0 ;
2234
+ unsigned char val3 ;
2235
+ int ecode3 = 0 ;
2236
+ uint8_t result;
2237
+ VALUE vresult = Qnil;
2238
+
2239
+ if ((argc < 3) || (argc > 3)) {
2240
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
2241
+ }
2242
+ ecode1 = SWIG_AsVal_unsigned_SS_char(argv[0], &val1);
2243
+ if (!SWIG_IsOK(ecode1)) {
2244
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "uint8_t","shiftIn", 1, argv[0] ));
2245
+ }
2246
+ arg1 = (uint8_t)(val1);
2247
+ ecode2 = SWIG_AsVal_unsigned_SS_char(argv[1], &val2);
2248
+ if (!SWIG_IsOK(ecode2)) {
2249
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "uint8_t","shiftIn", 2, argv[1] ));
2250
+ }
2251
+ arg2 = (uint8_t)(val2);
2252
+ ecode3 = SWIG_AsVal_unsigned_SS_char(argv[2], &val3);
2253
+ if (!SWIG_IsOK(ecode3)) {
2254
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "uint8_t","shiftIn", 3, argv[2] ));
2255
+ }
2256
+ arg3 = (uint8_t)(val3);
2257
+ result = shiftIn(arg1,arg2,arg3);
2258
+ vresult = SWIG_From_unsigned_SS_char((unsigned char)(result));
2259
+ return vresult;
2260
+ fail:
2261
+ return Qnil;
2262
+ }
2263
+
2264
+
2265
+ SWIGINTERN VALUE
2266
+ _wrap_serialOpen(int argc, VALUE *argv, VALUE self) {
2267
+ char *arg1 = (char *) 0 ;
2268
+ int arg2 ;
2269
+ int res1 ;
2270
+ char *buf1 = 0 ;
2271
+ int alloc1 = 0 ;
2272
+ int val2 ;
2273
+ int ecode2 = 0 ;
2274
+ int result;
2275
+ VALUE vresult = Qnil;
2276
+
2277
+ if ((argc < 2) || (argc > 2)) {
2278
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2279
+ }
2280
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2281
+ if (!SWIG_IsOK(res1)) {
2282
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char *","serialOpen", 1, argv[0] ));
2283
+ }
2284
+ arg1 = (char *)(buf1);
2285
+ ecode2 = SWIG_AsVal_int(argv[1], &val2);
2286
+ if (!SWIG_IsOK(ecode2)) {
2287
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","serialOpen", 2, argv[1] ));
2288
+ }
2289
+ arg2 = (int)(val2);
2290
+ result = (int)serialOpen(arg1,arg2);
2291
+ vresult = SWIG_From_int((int)(result));
2292
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2293
+ return vresult;
2294
+ fail:
2295
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2296
+ return Qnil;
2297
+ }
2298
+
2299
+
2300
+ SWIGINTERN VALUE
2301
+ _wrap_serialClose(int argc, VALUE *argv, VALUE self) {
2302
+ int arg1 ;
2303
+ int val1 ;
2304
+ int ecode1 = 0 ;
2305
+
2306
+ if ((argc < 1) || (argc > 1)) {
2307
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2308
+ }
2309
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2310
+ if (!SWIG_IsOK(ecode1)) {
2311
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","serialClose", 1, argv[0] ));
2312
+ }
2313
+ arg1 = (int)(val1);
2314
+ serialClose(arg1);
2315
+ return Qnil;
2316
+ fail:
2317
+ return Qnil;
2318
+ }
2319
+
2320
+
2321
+ SWIGINTERN VALUE
2322
+ _wrap_serialPutchar(int argc, VALUE *argv, VALUE self) {
2323
+ int arg1 ;
2324
+ uint8_t arg2 ;
2325
+ int val1 ;
2326
+ int ecode1 = 0 ;
2327
+ unsigned char val2 ;
2328
+ int ecode2 = 0 ;
2329
+
2330
+ if ((argc < 2) || (argc > 2)) {
2331
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2332
+ }
2333
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2334
+ if (!SWIG_IsOK(ecode1)) {
2335
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","serialPutchar", 1, argv[0] ));
2336
+ }
2337
+ arg1 = (int)(val1);
2338
+ ecode2 = SWIG_AsVal_unsigned_SS_char(argv[1], &val2);
2339
+ if (!SWIG_IsOK(ecode2)) {
2340
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "uint8_t","serialPutchar", 2, argv[1] ));
2341
+ }
2342
+ arg2 = (uint8_t)(val2);
2343
+ serialPutchar(arg1,arg2);
2344
+ return Qnil;
2345
+ fail:
2346
+ return Qnil;
2347
+ }
2348
+
2349
+
2350
+ SWIGINTERN VALUE
2351
+ _wrap_serialPuts(int argc, VALUE *argv, VALUE self) {
2352
+ int arg1 ;
2353
+ char *arg2 = (char *) 0 ;
2354
+ int val1 ;
2355
+ int ecode1 = 0 ;
2356
+ int res2 ;
2357
+ char *buf2 = 0 ;
2358
+ int alloc2 = 0 ;
2359
+
2360
+ if ((argc < 2) || (argc > 2)) {
2361
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2362
+ }
2363
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2364
+ if (!SWIG_IsOK(ecode1)) {
2365
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","serialPuts", 1, argv[0] ));
2366
+ }
2367
+ arg1 = (int)(val1);
2368
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2369
+ if (!SWIG_IsOK(res2)) {
2370
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","serialPuts", 2, argv[1] ));
2371
+ }
2372
+ arg2 = (char *)(buf2);
2373
+ serialPuts(arg1,arg2);
2374
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2375
+ return Qnil;
2376
+ fail:
2377
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2378
+ return Qnil;
2379
+ }
2380
+
2381
+
2382
+ SWIGINTERN VALUE
2383
+ _wrap_serialDataAvail(int argc, VALUE *argv, VALUE self) {
2384
+ int arg1 ;
2385
+ int val1 ;
2386
+ int ecode1 = 0 ;
2387
+ int result;
2388
+ VALUE vresult = Qnil;
2389
+
2390
+ if ((argc < 1) || (argc > 1)) {
2391
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2392
+ }
2393
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2394
+ if (!SWIG_IsOK(ecode1)) {
2395
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","serialDataAvail", 1, argv[0] ));
2396
+ }
2397
+ arg1 = (int)(val1);
2398
+ result = (int)serialDataAvail(arg1);
2399
+ vresult = SWIG_From_int((int)(result));
2400
+ return vresult;
2401
+ fail:
2402
+ return Qnil;
2403
+ }
2404
+
2405
+
2406
+ SWIGINTERN VALUE
2407
+ _wrap_serialGetchar(int argc, VALUE *argv, VALUE self) {
2408
+ int arg1 ;
2409
+ int val1 ;
2410
+ int ecode1 = 0 ;
2411
+ int result;
2412
+ VALUE vresult = Qnil;
2413
+
2414
+ if ((argc < 1) || (argc > 1)) {
2415
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2416
+ }
2417
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2418
+ if (!SWIG_IsOK(ecode1)) {
2419
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","serialGetchar", 1, argv[0] ));
2420
+ }
2421
+ arg1 = (int)(val1);
2422
+ result = (int)serialGetchar(arg1);
2423
+ vresult = SWIG_From_int((int)(result));
2424
+ return vresult;
2425
+ fail:
2426
+ return Qnil;
2427
+ }
2428
+
2429
+
2430
+ SWIGINTERN VALUE
2431
+ _wrap_serialPrintf(int argc, VALUE *argv, VALUE self) {
2432
+ int arg1 ;
2433
+ char *arg2 = (char *) 0 ;
2434
+ void *arg3 = 0 ;
2435
+ int val1 ;
2436
+ int ecode1 = 0 ;
2437
+ int res2 ;
2438
+ char *buf2 = 0 ;
2439
+ int alloc2 = 0 ;
2440
+
2441
+ if (argc < 2) {
2442
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2443
+ }
2444
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2445
+ if (!SWIG_IsOK(ecode1)) {
2446
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","serialPrintf", 1, argv[0] ));
2447
+ }
2448
+ arg1 = (int)(val1);
2449
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2450
+ if (!SWIG_IsOK(res2)) {
2451
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char *","serialPrintf", 2, argv[1] ));
2452
+ }
2453
+ arg2 = (char *)(buf2);
2454
+ serialPrintf(arg1,arg2,arg3);
2455
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2456
+ return Qnil;
2457
+ fail:
2458
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2459
+ return Qnil;
2460
+ }
2461
+
2462
+
2463
+
2464
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
2465
+
2466
+ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
2467
+
2468
+ static swig_type_info *swig_type_initial[] = {
2469
+ &_swigt__p_char,
2470
+ };
2471
+
2472
+ static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
2473
+
2474
+ static swig_cast_info *swig_cast_initial[] = {
2475
+ _swigc__p_char,
2476
+ };
2477
+
2478
+
2479
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
2480
+
2481
+ /* -----------------------------------------------------------------------------
2482
+ * Type initialization:
2483
+ * This problem is tough by the requirement that no dynamic
2484
+ * memory is used. Also, since swig_type_info structures store pointers to
2485
+ * swig_cast_info structures and swig_cast_info structures store pointers back
2486
+ * to swig_type_info structures, we need some lookup code at initialization.
2487
+ * The idea is that swig generates all the structures that are needed.
2488
+ * The runtime then collects these partially filled structures.
2489
+ * The SWIG_InitializeModule function takes these initial arrays out of
2490
+ * swig_module, and does all the lookup, filling in the swig_module.types
2491
+ * array with the correct data and linking the correct swig_cast_info
2492
+ * structures together.
2493
+ *
2494
+ * The generated swig_type_info structures are assigned staticly to an initial
2495
+ * array. We just loop through that array, and handle each type individually.
2496
+ * First we lookup if this type has been already loaded, and if so, use the
2497
+ * loaded structure instead of the generated one. Then we have to fill in the
2498
+ * cast linked list. The cast data is initially stored in something like a
2499
+ * two-dimensional array. Each row corresponds to a type (there are the same
2500
+ * number of rows as there are in the swig_type_initial array). Each entry in
2501
+ * a column is one of the swig_cast_info structures for that type.
2502
+ * The cast_initial array is actually an array of arrays, because each row has
2503
+ * a variable number of columns. So to actually build the cast linked list,
2504
+ * we find the array of casts associated with the type, and loop through it
2505
+ * adding the casts to the list. The one last trick we need to do is making
2506
+ * sure the type pointer in the swig_cast_info struct is correct.
2507
+ *
2508
+ * First off, we lookup the cast->type name to see if it is already loaded.
2509
+ * There are three cases to handle:
2510
+ * 1) If the cast->type has already been loaded AND the type we are adding
2511
+ * casting info to has not been loaded (it is in this module), THEN we
2512
+ * replace the cast->type pointer with the type pointer that has already
2513
+ * been loaded.
2514
+ * 2) If BOTH types (the one we are adding casting info to, and the
2515
+ * cast->type) are loaded, THEN the cast info has already been loaded by
2516
+ * the previous module so we just ignore it.
2517
+ * 3) Finally, if cast->type has not already been loaded, then we add that
2518
+ * swig_cast_info to the linked list (because the cast->type) pointer will
2519
+ * be correct.
2520
+ * ----------------------------------------------------------------------------- */
2521
+
2522
+ #ifdef __cplusplus
2523
+ extern "C" {
2524
+ #if 0
2525
+ } /* c-mode */
2526
+ #endif
2527
+ #endif
2528
+
2529
+ #if 0
2530
+ #define SWIGRUNTIME_DEBUG
2531
+ #endif
2532
+
2533
+
2534
+ SWIGRUNTIME void
2535
+ SWIG_InitializeModule(void *clientdata) {
2536
+ size_t i;
2537
+ swig_module_info *module_head, *iter;
2538
+ int found, init;
2539
+
2540
+ clientdata = clientdata;
2541
+
2542
+ /* check to see if the circular list has been setup, if not, set it up */
2543
+ if (swig_module.next==0) {
2544
+ /* Initialize the swig_module */
2545
+ swig_module.type_initial = swig_type_initial;
2546
+ swig_module.cast_initial = swig_cast_initial;
2547
+ swig_module.next = &swig_module;
2548
+ init = 1;
2549
+ } else {
2550
+ init = 0;
2551
+ }
2552
+
2553
+ /* Try and load any already created modules */
2554
+ module_head = SWIG_GetModule(clientdata);
2555
+ if (!module_head) {
2556
+ /* This is the first module loaded for this interpreter */
2557
+ /* so set the swig module into the interpreter */
2558
+ SWIG_SetModule(clientdata, &swig_module);
2559
+ module_head = &swig_module;
2560
+ } else {
2561
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
2562
+ found=0;
2563
+ iter=module_head;
2564
+ do {
2565
+ if (iter==&swig_module) {
2566
+ found=1;
2567
+ break;
2568
+ }
2569
+ iter=iter->next;
2570
+ } while (iter!= module_head);
2571
+
2572
+ /* if the is found in the list, then all is done and we may leave */
2573
+ if (found) return;
2574
+ /* otherwise we must add out module into the list */
2575
+ swig_module.next = module_head->next;
2576
+ module_head->next = &swig_module;
2577
+ }
2578
+
2579
+ /* When multiple interpeters are used, a module could have already been initialized in
2580
+ a different interpreter, but not yet have a pointer in this interpreter.
2581
+ In this case, we do not want to continue adding types... everything should be
2582
+ set up already */
2583
+ if (init == 0) return;
2584
+
2585
+ /* Now work on filling in swig_module.types */
2586
+ #ifdef SWIGRUNTIME_DEBUG
2587
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
2588
+ #endif
2589
+ for (i = 0; i < swig_module.size; ++i) {
2590
+ swig_type_info *type = 0;
2591
+ swig_type_info *ret;
2592
+ swig_cast_info *cast;
2593
+
2594
+ #ifdef SWIGRUNTIME_DEBUG
2595
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2596
+ #endif
2597
+
2598
+ /* if there is another module already loaded */
2599
+ if (swig_module.next != &swig_module) {
2600
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
2601
+ }
2602
+ if (type) {
2603
+ /* Overwrite clientdata field */
2604
+ #ifdef SWIGRUNTIME_DEBUG
2605
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
2606
+ #endif
2607
+ if (swig_module.type_initial[i]->clientdata) {
2608
+ type->clientdata = swig_module.type_initial[i]->clientdata;
2609
+ #ifdef SWIGRUNTIME_DEBUG
2610
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
2611
+ #endif
2612
+ }
2613
+ } else {
2614
+ type = swig_module.type_initial[i];
2615
+ }
2616
+
2617
+ /* Insert casting types */
2618
+ cast = swig_module.cast_initial[i];
2619
+ while (cast->type) {
2620
+
2621
+ /* Don't need to add information already in the list */
2622
+ ret = 0;
2623
+ #ifdef SWIGRUNTIME_DEBUG
2624
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
2625
+ #endif
2626
+ if (swig_module.next != &swig_module) {
2627
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
2628
+ #ifdef SWIGRUNTIME_DEBUG
2629
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
2630
+ #endif
2631
+ }
2632
+ if (ret) {
2633
+ if (type == swig_module.type_initial[i]) {
2634
+ #ifdef SWIGRUNTIME_DEBUG
2635
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
2636
+ #endif
2637
+ cast->type = ret;
2638
+ ret = 0;
2639
+ } else {
2640
+ /* Check for casting already in the list */
2641
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
2642
+ #ifdef SWIGRUNTIME_DEBUG
2643
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
2644
+ #endif
2645
+ if (!ocast) ret = 0;
2646
+ }
2647
+ }
2648
+
2649
+ if (!ret) {
2650
+ #ifdef SWIGRUNTIME_DEBUG
2651
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
2652
+ #endif
2653
+ if (type->cast) {
2654
+ type->cast->prev = cast;
2655
+ cast->next = type->cast;
2656
+ }
2657
+ type->cast = cast;
2658
+ }
2659
+ cast++;
2660
+ }
2661
+ /* Set entry in modules->types array equal to the type */
2662
+ swig_module.types[i] = type;
2663
+ }
2664
+ swig_module.types[i] = 0;
2665
+
2666
+ #ifdef SWIGRUNTIME_DEBUG
2667
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
2668
+ for (i = 0; i < swig_module.size; ++i) {
2669
+ int j = 0;
2670
+ swig_cast_info *cast = swig_module.cast_initial[i];
2671
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2672
+ while (cast->type) {
2673
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
2674
+ cast++;
2675
+ ++j;
2676
+ }
2677
+ printf("---- Total casts: %d\n",j);
2678
+ }
2679
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
2680
+ #endif
2681
+ }
2682
+
2683
+ /* This function will propagate the clientdata field of type to
2684
+ * any new swig_type_info structures that have been added into the list
2685
+ * of equivalent types. It is like calling
2686
+ * SWIG_TypeClientData(type, clientdata) a second time.
2687
+ */
2688
+ SWIGRUNTIME void
2689
+ SWIG_PropagateClientData(void) {
2690
+ size_t i;
2691
+ swig_cast_info *equiv;
2692
+ static int init_run = 0;
2693
+
2694
+ if (init_run) return;
2695
+ init_run = 1;
2696
+
2697
+ for (i = 0; i < swig_module.size; i++) {
2698
+ if (swig_module.types[i]->clientdata) {
2699
+ equiv = swig_module.types[i]->cast;
2700
+ while (equiv) {
2701
+ if (!equiv->converter) {
2702
+ if (equiv->type && !equiv->type->clientdata)
2703
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
2704
+ }
2705
+ equiv = equiv->next;
2706
+ }
2707
+ }
2708
+ }
2709
+ }
2710
+
2711
+ #ifdef __cplusplus
2712
+ #if 0
2713
+ { /* c-mode */
2714
+ #endif
2715
+ }
2716
+ #endif
2717
+
2718
+ /*
2719
+
2720
+ */
2721
+ #ifdef __cplusplus
2722
+ extern "C"
2723
+ #endif
2724
+ SWIGEXPORT void Init_wiringpi(void) {
2725
+ size_t i;
2726
+
2727
+ SWIG_InitRuntime();
2728
+ mWiringpi = rb_define_module("Wiringpi");
2729
+
2730
+ SWIG_InitializeModule(0);
2731
+ for (i = 0; i < swig_module.size; i++) {
2732
+ SWIG_define_class(swig_module.types[i]);
2733
+ }
2734
+
2735
+ SWIG_RubyInitializeTrackings();
2736
+ rb_define_module_function(mWiringpi, "wiringPiSetup", _wrap_wiringPiSetup, -1);
2737
+ rb_define_module_function(mWiringpi, "wiringPiGpioMode", _wrap_wiringPiGpioMode, -1);
2738
+ rb_define_module_function(mWiringpi, "pullUpDnControl", _wrap_pullUpDnControl, -1);
2739
+ rb_define_module_function(mWiringpi, "pinMode", _wrap_pinMode, -1);
2740
+ rb_define_module_function(mWiringpi, "digitalWrite", _wrap_digitalWrite, -1);
2741
+ rb_define_module_function(mWiringpi, "pwmWrite", _wrap_pwmWrite, -1);
2742
+ rb_define_module_function(mWiringpi, "digitalRead", _wrap_digitalRead, -1);
2743
+ rb_define_module_function(mWiringpi, "shiftOut", _wrap_shiftOut, -1);
2744
+ rb_define_module_function(mWiringpi, "shiftIn", _wrap_shiftIn, -1);
2745
+ rb_define_module_function(mWiringpi, "serialOpen", _wrap_serialOpen, -1);
2746
+ rb_define_module_function(mWiringpi, "serialClose", _wrap_serialClose, -1);
2747
+ rb_define_module_function(mWiringpi, "serialPutchar", _wrap_serialPutchar, -1);
2748
+ rb_define_module_function(mWiringpi, "serialPuts", _wrap_serialPuts, -1);
2749
+ rb_define_module_function(mWiringpi, "serialDataAvail", _wrap_serialDataAvail, -1);
2750
+ rb_define_module_function(mWiringpi, "serialGetchar", _wrap_serialGetchar, -1);
2751
+ rb_define_module_function(mWiringpi, "serialPrintf", _wrap_serialPrintf, -1);
2752
+ }
2753
+