tomz-liblinear-ruby-swig 0.1.0

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