crfpp 0.0.1.pre1

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,11 @@
1
+ require 'autotest/restart'
2
+
3
+ Autotest.add_hook :initialize do |at|
4
+ at.add_mapping(/.*\.c(pp)?/) do |f,_|
5
+ at.files_matching(/test_.*rb$/)
6
+ end
7
+ end
8
+
9
+ Autotest.add_hook :run_command do |at|
10
+ system 'bundle exec rake clean compile'
11
+ end
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ tmp
2
+ Gemfile.lock
3
+ *.bundle
4
+
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright 2011 Sylvester Keil. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice,
7
+ this list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
14
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16
+ EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
22
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ The views and conclusions contained in the software and documentation are
25
+ those of the authors and should not be interpreted as representing official
26
+ policies, either expressed or implied, of the copyright holder.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ CRFPP
2
+ =====
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('../lib/', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require 'rake/clean'
5
+ require 'rake/testtask'
6
+ require 'rake/extensiontask'
7
+
8
+ require 'crfpp/version'
9
+
10
+ task :default => [:test]
11
+
12
+ Rake::ExtensionTask.new do |ext|
13
+ ext.name = 'native'
14
+
15
+ ext.ext_dir = 'ext/crfpp'
16
+ ext.lib_dir = 'lib/crfpp'
17
+
18
+ CLEAN.include("#{ext.lib_dir}/native.*")
19
+ CLEAN.include("#{ext.tmp_dir}")
20
+
21
+ end
22
+
23
+ Rake::TestTask.new :test => [:compile] do |test|
24
+ test.libs << 'test'
25
+ test.test_files = Dir['test/**/test_*.rb']
26
+ test.verbose = true
27
+ end
28
+
data/crfpp.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'crfpp/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'crfpp'
9
+ s.version = CRFPP::VERSION.dup
10
+ s.platform = Gem::Platform::RUBY
11
+ s.authors = ['Sylvester Keil']
12
+ s.email = ['http://sylvester.keil.or.at']
13
+ s.homepage = 'http://inukshuk.github.com/crfpp'
14
+ s.summary = 'Conditional Random Fields for Ruby.'
15
+ s.description = 'A Ruby extension to interface with CRF++, the Conditional Random Fields library written in C++. You need to install libcrfpp to use this gem.'
16
+ s.license = 'FreeBSD'
17
+
18
+ s.add_development_dependency('rake', '~>0.9')
19
+ s.add_development_dependency('rake-compiler', '~>0.7')
20
+ s.add_development_dependency('ZenTest', '~>4.6')
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.executables = []
25
+ s.require_path = 'lib'
26
+
27
+ s.extensions << 'ext/crfpp/extconf.rb'
28
+
29
+ s.rdoc_options = %w{--line-numbers --inline-source --title "CRFPP" --main README.md --webcvs=http://github.com/inukshuk/crfpp/tree/master/}
30
+ s.extra_rdoc_files = %w{README.md}
31
+
32
+ end
33
+
34
+ # vim: syntax=ruby
@@ -0,0 +1,24 @@
1
+ ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
2
+
3
+ require 'mkmf'
4
+
5
+ HEADER_DIRS = %W{
6
+ /usr/local/include #{Config::CONFIG['includedir']} /usr/include
7
+ }
8
+
9
+ LIB_DIRS = %W{
10
+ /usr/local/lib #{Config::CONFIG['libdir']} /usr/lib
11
+ }
12
+
13
+ dir_config('crfpp', HEADER_DIRS, LIB_DIRS)
14
+
15
+ crfpp_config = with_config('crfpp-config', 'crfpp-config')
16
+ use_crfpp_config = enable_config('crfpp-config')
17
+
18
+ find_header('crfpp.h') || abort('crfpp.h not found')
19
+
20
+ have_library('crfpp') || abort('library crfpp not found')
21
+ have_library('pthread')
22
+
23
+
24
+ create_makefile('crfpp/native')
@@ -0,0 +1,14 @@
1
+ #include <native.hpp>
2
+
3
+ static VALUE learn(VALUE klass) {
4
+ return rb_str_new2("learn");
5
+ }
6
+
7
+ extern "C" void Init_native() {
8
+ VALUE crfpp = rb_const_get(rb_mKernel, rb_intern("CRFPP"));
9
+ VALUE native = rb_define_module_under(crfpp, "Native");
10
+
11
+ rb_define_singleton_method(native, "learn", VFUNC(learn), 0);
12
+
13
+ Init_tagger(crfpp);
14
+ }
@@ -0,0 +1,11 @@
1
+ #ifndef RUBY_CRFPP
2
+ #define RUBY_CRFPP
3
+
4
+ #include <ruby.h>
5
+ #include <crfpp.h>
6
+
7
+ #include <tagger.hpp>
8
+
9
+ #define VFUNC(f) ((VALUE (*)(ANYARGS)) f)
10
+
11
+ #endif
@@ -0,0 +1,3947 @@
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
+ #define SWIG_exception(code, msg) do { SWIG_Error(code, msg);; } while(0)
1803
+
1804
+
1805
+ /* -------- TYPES TABLE (BEGIN) -------- */
1806
+
1807
+ #define SWIGTYPE_p_CRFPP__Tagger swig_types[0]
1808
+ #define SWIGTYPE_p_char swig_types[1]
1809
+ static swig_type_info *swig_types[3];
1810
+ static swig_module_info swig_module = {swig_types, 2, 0, 0, 0, 0};
1811
+ #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
1812
+ #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
1813
+
1814
+ /* -------- TYPES TABLE (END) -------- */
1815
+
1816
+ #define SWIG_init Init_tagger
1817
+ #define SWIG_name "crfpp"
1818
+
1819
+ static VALUE mCRFPP;
1820
+
1821
+ #define SWIG_RUBY_THREAD_BEGIN_BLOCK
1822
+ #define SWIG_RUBY_THREAD_END_BLOCK
1823
+
1824
+
1825
+ #define SWIGVERSION 0x010338
1826
+ #define SWIG_VERSION SWIGVERSION
1827
+
1828
+
1829
+ #define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a))
1830
+ #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),reinterpret_cast< void** >(a))
1831
+
1832
+
1833
+ #include <stdexcept>
1834
+
1835
+
1836
+ #include "crfpp.h"
1837
+
1838
+
1839
+
1840
+ void delete_CRFPP_Tagger (CRFPP::Tagger *t) {
1841
+ delete t;
1842
+ t = 0;
1843
+ }
1844
+
1845
+ CRFPP::Tagger* new_CRFPP_Tagger (const char *arg) {
1846
+ CRFPP::Tagger *tagger = CRFPP::createTagger(arg);
1847
+ if (! tagger) throw CRFPP::getTaggerError();
1848
+ return tagger;
1849
+ }
1850
+
1851
+
1852
+
1853
+ #include <limits.h>
1854
+ #if !defined(SWIG_NO_LLONG_MAX)
1855
+ # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
1856
+ # define LLONG_MAX __LONG_LONG_MAX__
1857
+ # define LLONG_MIN (-LLONG_MAX - 1LL)
1858
+ # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
1859
+ # endif
1860
+ #endif
1861
+
1862
+
1863
+ SWIGINTERN VALUE
1864
+ SWIG_ruby_failed(void)
1865
+ {
1866
+ return Qnil;
1867
+ }
1868
+
1869
+
1870
+ /*@SWIG:/usr/local/share/swig/1.3.38/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1871
+ SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
1872
+ {
1873
+ VALUE obj = args[0];
1874
+ VALUE type = TYPE(obj);
1875
+ unsigned long *res = (unsigned long *)(args[1]);
1876
+ *res = type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj);
1877
+ return obj;
1878
+ }
1879
+ /*@SWIG@*/
1880
+
1881
+ SWIGINTERN int
1882
+ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val)
1883
+ {
1884
+ VALUE type = TYPE(obj);
1885
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
1886
+ unsigned long v;
1887
+ VALUE a[2];
1888
+ a[0] = obj;
1889
+ a[1] = (VALUE)(&v);
1890
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
1891
+ if (val) *val = v;
1892
+ return SWIG_OK;
1893
+ }
1894
+ }
1895
+ return SWIG_TypeError;
1896
+ }
1897
+
1898
+
1899
+ SWIGINTERN int
1900
+ SWIG_AsVal_unsigned_SS_int (VALUE obj, unsigned int *val)
1901
+ {
1902
+ unsigned long v;
1903
+ int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
1904
+ if (SWIG_IsOK(res)) {
1905
+ if ((v > UINT_MAX)) {
1906
+ return SWIG_OverflowError;
1907
+ } else {
1908
+ if (val) *val = static_cast< unsigned int >(v);
1909
+ }
1910
+ }
1911
+ return res;
1912
+ }
1913
+
1914
+
1915
+ #define SWIG_From_long LONG2NUM
1916
+
1917
+
1918
+ SWIGINTERNINLINE VALUE
1919
+ SWIG_From_unsigned_SS_long (unsigned long value)
1920
+ {
1921
+ return ULONG2NUM(value);
1922
+ }
1923
+
1924
+
1925
+ SWIGINTERNINLINE VALUE
1926
+ SWIG_From_unsigned_SS_int (unsigned int value)
1927
+ {
1928
+ return SWIG_From_unsigned_SS_long (value);
1929
+ }
1930
+
1931
+
1932
+ #include <float.h>
1933
+
1934
+
1935
+ /*@SWIG:/usr/local/share/swig/1.3.38/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1936
+ SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
1937
+ {
1938
+ VALUE obj = args[0];
1939
+ VALUE type = TYPE(obj);
1940
+ double *res = (double *)(args[1]);
1941
+ *res = (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj)));
1942
+ return obj;
1943
+ }
1944
+ /*@SWIG@*/
1945
+
1946
+ SWIGINTERN int
1947
+ SWIG_AsVal_double (VALUE obj, double *val)
1948
+ {
1949
+ VALUE type = TYPE(obj);
1950
+ if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) {
1951
+ double v;
1952
+ VALUE a[2];
1953
+ a[0] = obj;
1954
+ a[1] = (VALUE)(&v);
1955
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
1956
+ if (val) *val = v;
1957
+ return SWIG_OK;
1958
+ }
1959
+ }
1960
+ return SWIG_TypeError;
1961
+ }
1962
+
1963
+
1964
+ SWIGINTERN int
1965
+ SWIG_AsVal_float (VALUE obj, float *val)
1966
+ {
1967
+ double v;
1968
+ int res = SWIG_AsVal_double (obj, &v);
1969
+ if (SWIG_IsOK(res)) {
1970
+ if ((v < -FLT_MAX || v > FLT_MAX)) {
1971
+ return SWIG_OverflowError;
1972
+ } else {
1973
+ if (val) *val = static_cast< float >(v);
1974
+ }
1975
+ }
1976
+ return res;
1977
+ }
1978
+
1979
+
1980
+ #define SWIG_From_double rb_float_new
1981
+
1982
+
1983
+ SWIGINTERNINLINE VALUE
1984
+ SWIG_From_float (float value)
1985
+ {
1986
+ return SWIG_From_double (value);
1987
+ }
1988
+
1989
+
1990
+ SWIGINTERNINLINE int
1991
+ SWIG_AsVal_size_t (VALUE obj, size_t *val)
1992
+ {
1993
+ unsigned long v;
1994
+ int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0);
1995
+ if (SWIG_IsOK(res) && val) *val = static_cast< size_t >(v);
1996
+ return res;
1997
+ }
1998
+
1999
+
2000
+ SWIGINTERNINLINE VALUE
2001
+ SWIG_From_size_t (size_t value)
2002
+ {
2003
+ return SWIG_From_unsigned_SS_long (static_cast< unsigned long >(value));
2004
+ }
2005
+
2006
+
2007
+ SWIGINTERN swig_type_info*
2008
+ SWIG_pchar_descriptor(void)
2009
+ {
2010
+ static int init = 0;
2011
+ static swig_type_info* info = 0;
2012
+ if (!init) {
2013
+ info = SWIG_TypeQuery("_p_char");
2014
+ init = 1;
2015
+ }
2016
+ return info;
2017
+ }
2018
+
2019
+
2020
+ SWIGINTERN int
2021
+ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
2022
+ {
2023
+ if (TYPE(obj) == T_STRING) {
2024
+ #if defined(StringValuePtr)
2025
+ char *cstr = StringValuePtr(obj);
2026
+ #else
2027
+ char *cstr = STR2CSTR(obj);
2028
+ #endif
2029
+ size_t size = RSTRING_LEN(obj) + 1;
2030
+ if (cptr) {
2031
+ if (alloc) {
2032
+ if (*alloc == SWIG_NEWOBJ) {
2033
+ *cptr = reinterpret_cast< char* >(memcpy((new char[size]), cstr, sizeof(char)*(size)));
2034
+ } else {
2035
+ *cptr = cstr;
2036
+ *alloc = SWIG_OLDOBJ;
2037
+ }
2038
+ }
2039
+ }
2040
+ if (psize) *psize = size;
2041
+ return SWIG_OK;
2042
+ } else {
2043
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
2044
+ if (pchar_descriptor) {
2045
+ void* vptr = 0;
2046
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
2047
+ if (cptr) *cptr = (char *)vptr;
2048
+ if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0;
2049
+ if (alloc) *alloc = SWIG_OLDOBJ;
2050
+ return SWIG_OK;
2051
+ }
2052
+ }
2053
+ }
2054
+ return SWIG_TypeError;
2055
+ }
2056
+
2057
+
2058
+
2059
+
2060
+
2061
+ SWIGINTERNINLINE VALUE
2062
+ SWIG_From_bool (bool value)
2063
+ {
2064
+ return value ? Qtrue : Qfalse;
2065
+ }
2066
+
2067
+
2068
+ SWIGINTERNINLINE VALUE
2069
+ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
2070
+ {
2071
+ if (carray) {
2072
+ if (size > LONG_MAX) {
2073
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
2074
+ return pchar_descriptor ?
2075
+ SWIG_NewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : Qnil;
2076
+ } else {
2077
+ return rb_str_new(carray, static_cast< long >(size));
2078
+ }
2079
+ } else {
2080
+ return Qnil;
2081
+ }
2082
+ }
2083
+
2084
+
2085
+ SWIGINTERNINLINE VALUE
2086
+ SWIG_FromCharPtr(const char *cptr)
2087
+ {
2088
+ return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
2089
+ }
2090
+
2091
+ swig_class cTagger;
2092
+
2093
+ SWIGINTERN VALUE
2094
+ _wrap_Tagger_set_vlevel(int argc, VALUE *argv, VALUE self) {
2095
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2096
+ unsigned int arg2 ;
2097
+ void *argp1 = 0 ;
2098
+ int res1 = 0 ;
2099
+ unsigned int val2 ;
2100
+ int ecode2 = 0 ;
2101
+
2102
+ if ((argc < 1) || (argc > 1)) {
2103
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2104
+ }
2105
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2106
+ if (!SWIG_IsOK(res1)) {
2107
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","set_vlevel", 1, self ));
2108
+ }
2109
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2110
+ ecode2 = SWIG_AsVal_unsigned_SS_int(argv[0], &val2);
2111
+ if (!SWIG_IsOK(ecode2)) {
2112
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "unsigned int","set_vlevel", 2, argv[0] ));
2113
+ }
2114
+ arg2 = static_cast< unsigned int >(val2);
2115
+ {
2116
+ try {
2117
+ (arg1)->set_vlevel(arg2);
2118
+ }
2119
+ catch (char *e) {
2120
+ SWIG_exception (SWIG_RuntimeError, e);
2121
+ }
2122
+ catch (const char *e) {
2123
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2124
+ }
2125
+ }
2126
+ return Qnil;
2127
+ fail:
2128
+ return Qnil;
2129
+ }
2130
+
2131
+
2132
+ SWIGINTERN VALUE
2133
+ _wrap_Tagger_vlevel(int argc, VALUE *argv, VALUE self) {
2134
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2135
+ void *argp1 = 0 ;
2136
+ int res1 = 0 ;
2137
+ unsigned int result;
2138
+ VALUE vresult = Qnil;
2139
+
2140
+ if ((argc < 0) || (argc > 0)) {
2141
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2142
+ }
2143
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2144
+ if (!SWIG_IsOK(res1)) {
2145
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","vlevel", 1, self ));
2146
+ }
2147
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2148
+ {
2149
+ try {
2150
+ result = (unsigned int)((CRFPP::Tagger const *)arg1)->vlevel();
2151
+ }
2152
+ catch (char *e) {
2153
+ SWIG_exception (SWIG_RuntimeError, e);
2154
+ }
2155
+ catch (const char *e) {
2156
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2157
+ }
2158
+ }
2159
+ vresult = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
2160
+ return vresult;
2161
+ fail:
2162
+ return Qnil;
2163
+ }
2164
+
2165
+
2166
+ SWIGINTERN VALUE
2167
+ _wrap_Tagger_set_cost_factor(int argc, VALUE *argv, VALUE self) {
2168
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2169
+ float arg2 ;
2170
+ void *argp1 = 0 ;
2171
+ int res1 = 0 ;
2172
+ float val2 ;
2173
+ int ecode2 = 0 ;
2174
+
2175
+ if ((argc < 1) || (argc > 1)) {
2176
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2177
+ }
2178
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2179
+ if (!SWIG_IsOK(res1)) {
2180
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","set_cost_factor", 1, self ));
2181
+ }
2182
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2183
+ ecode2 = SWIG_AsVal_float(argv[0], &val2);
2184
+ if (!SWIG_IsOK(ecode2)) {
2185
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "float","set_cost_factor", 2, argv[0] ));
2186
+ }
2187
+ arg2 = static_cast< float >(val2);
2188
+ {
2189
+ try {
2190
+ (arg1)->set_cost_factor(arg2);
2191
+ }
2192
+ catch (char *e) {
2193
+ SWIG_exception (SWIG_RuntimeError, e);
2194
+ }
2195
+ catch (const char *e) {
2196
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2197
+ }
2198
+ }
2199
+ return Qnil;
2200
+ fail:
2201
+ return Qnil;
2202
+ }
2203
+
2204
+
2205
+ SWIGINTERN VALUE
2206
+ _wrap_Tagger_cost_factor(int argc, VALUE *argv, VALUE self) {
2207
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2208
+ void *argp1 = 0 ;
2209
+ int res1 = 0 ;
2210
+ float result;
2211
+ VALUE vresult = Qnil;
2212
+
2213
+ if ((argc < 0) || (argc > 0)) {
2214
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2215
+ }
2216
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2217
+ if (!SWIG_IsOK(res1)) {
2218
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","cost_factor", 1, self ));
2219
+ }
2220
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2221
+ {
2222
+ try {
2223
+ result = (float)((CRFPP::Tagger const *)arg1)->cost_factor();
2224
+ }
2225
+ catch (char *e) {
2226
+ SWIG_exception (SWIG_RuntimeError, e);
2227
+ }
2228
+ catch (const char *e) {
2229
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2230
+ }
2231
+ }
2232
+ vresult = SWIG_From_float(static_cast< float >(result));
2233
+ return vresult;
2234
+ fail:
2235
+ return Qnil;
2236
+ }
2237
+
2238
+
2239
+ SWIGINTERN VALUE
2240
+ _wrap_Tagger_set_nbest(int argc, VALUE *argv, VALUE self) {
2241
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2242
+ size_t arg2 ;
2243
+ void *argp1 = 0 ;
2244
+ int res1 = 0 ;
2245
+ size_t val2 ;
2246
+ int ecode2 = 0 ;
2247
+
2248
+ if ((argc < 1) || (argc > 1)) {
2249
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2250
+ }
2251
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2252
+ if (!SWIG_IsOK(res1)) {
2253
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","set_nbest", 1, self ));
2254
+ }
2255
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2256
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2257
+ if (!SWIG_IsOK(ecode2)) {
2258
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","set_nbest", 2, argv[0] ));
2259
+ }
2260
+ arg2 = static_cast< size_t >(val2);
2261
+ {
2262
+ try {
2263
+ (arg1)->set_nbest(arg2);
2264
+ }
2265
+ catch (char *e) {
2266
+ SWIG_exception (SWIG_RuntimeError, e);
2267
+ }
2268
+ catch (const char *e) {
2269
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2270
+ }
2271
+ }
2272
+ return Qnil;
2273
+ fail:
2274
+ return Qnil;
2275
+ }
2276
+
2277
+
2278
+ SWIGINTERN VALUE
2279
+ _wrap_Tagger_nbest(int argc, VALUE *argv, VALUE self) {
2280
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2281
+ void *argp1 = 0 ;
2282
+ int res1 = 0 ;
2283
+ size_t result;
2284
+ VALUE vresult = Qnil;
2285
+
2286
+ if ((argc < 0) || (argc > 0)) {
2287
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2288
+ }
2289
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2290
+ if (!SWIG_IsOK(res1)) {
2291
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","nbest", 1, self ));
2292
+ }
2293
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2294
+ {
2295
+ try {
2296
+ result = ((CRFPP::Tagger const *)arg1)->nbest();
2297
+ }
2298
+ catch (char *e) {
2299
+ SWIG_exception (SWIG_RuntimeError, e);
2300
+ }
2301
+ catch (const char *e) {
2302
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2303
+ }
2304
+ }
2305
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2306
+ return vresult;
2307
+ fail:
2308
+ return Qnil;
2309
+ }
2310
+
2311
+
2312
+ SWIGINTERN VALUE
2313
+ _wrap_Tagger_add(int argc, VALUE *argv, VALUE self) {
2314
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2315
+ char *arg2 = (char *) 0 ;
2316
+ void *argp1 = 0 ;
2317
+ int res1 = 0 ;
2318
+ int res2 ;
2319
+ char *buf2 = 0 ;
2320
+ int alloc2 = 0 ;
2321
+ bool result;
2322
+ VALUE vresult = Qnil;
2323
+
2324
+ if ((argc < 1) || (argc > 1)) {
2325
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2326
+ }
2327
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2328
+ if (!SWIG_IsOK(res1)) {
2329
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","add", 1, self ));
2330
+ }
2331
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2332
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
2333
+ if (!SWIG_IsOK(res2)) {
2334
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","add", 2, argv[0] ));
2335
+ }
2336
+ arg2 = reinterpret_cast< char * >(buf2);
2337
+ {
2338
+ try {
2339
+ result = (bool)(arg1)->add((char const *)arg2);
2340
+ }
2341
+ catch (char *e) {
2342
+ SWIG_exception (SWIG_RuntimeError, e);
2343
+ }
2344
+ catch (const char *e) {
2345
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2346
+ }
2347
+ }
2348
+ vresult = SWIG_From_bool(static_cast< bool >(result));
2349
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
2350
+ return vresult;
2351
+ fail:
2352
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
2353
+ return Qnil;
2354
+ }
2355
+
2356
+
2357
+
2358
+ /*
2359
+ Document-method: CRFPP::Tagger.size
2360
+
2361
+ call-seq:
2362
+ size -> size_t
2363
+
2364
+ Size or Length of the Tagger.
2365
+ */
2366
+ SWIGINTERN VALUE
2367
+ _wrap_Tagger_size(int argc, VALUE *argv, VALUE self) {
2368
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2369
+ void *argp1 = 0 ;
2370
+ int res1 = 0 ;
2371
+ size_t result;
2372
+ VALUE vresult = Qnil;
2373
+
2374
+ if ((argc < 0) || (argc > 0)) {
2375
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2376
+ }
2377
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2378
+ if (!SWIG_IsOK(res1)) {
2379
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","size", 1, self ));
2380
+ }
2381
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2382
+ {
2383
+ try {
2384
+ result = ((CRFPP::Tagger const *)arg1)->size();
2385
+ }
2386
+ catch (char *e) {
2387
+ SWIG_exception (SWIG_RuntimeError, e);
2388
+ }
2389
+ catch (const char *e) {
2390
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2391
+ }
2392
+ }
2393
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2394
+ return vresult;
2395
+ fail:
2396
+ return Qnil;
2397
+ }
2398
+
2399
+
2400
+ SWIGINTERN VALUE
2401
+ _wrap_Tagger_xsize(int argc, VALUE *argv, VALUE self) {
2402
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2403
+ void *argp1 = 0 ;
2404
+ int res1 = 0 ;
2405
+ size_t result;
2406
+ VALUE vresult = Qnil;
2407
+
2408
+ if ((argc < 0) || (argc > 0)) {
2409
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2410
+ }
2411
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2412
+ if (!SWIG_IsOK(res1)) {
2413
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","xsize", 1, self ));
2414
+ }
2415
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2416
+ {
2417
+ try {
2418
+ result = ((CRFPP::Tagger const *)arg1)->xsize();
2419
+ }
2420
+ catch (char *e) {
2421
+ SWIG_exception (SWIG_RuntimeError, e);
2422
+ }
2423
+ catch (const char *e) {
2424
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2425
+ }
2426
+ }
2427
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2428
+ return vresult;
2429
+ fail:
2430
+ return Qnil;
2431
+ }
2432
+
2433
+
2434
+ SWIGINTERN VALUE
2435
+ _wrap_Tagger_dsize(int argc, VALUE *argv, VALUE self) {
2436
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2437
+ void *argp1 = 0 ;
2438
+ int res1 = 0 ;
2439
+ size_t result;
2440
+ VALUE vresult = Qnil;
2441
+
2442
+ if ((argc < 0) || (argc > 0)) {
2443
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2444
+ }
2445
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2446
+ if (!SWIG_IsOK(res1)) {
2447
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","dsize", 1, self ));
2448
+ }
2449
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2450
+ {
2451
+ try {
2452
+ result = ((CRFPP::Tagger const *)arg1)->dsize();
2453
+ }
2454
+ catch (char *e) {
2455
+ SWIG_exception (SWIG_RuntimeError, e);
2456
+ }
2457
+ catch (const char *e) {
2458
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2459
+ }
2460
+ }
2461
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2462
+ return vresult;
2463
+ fail:
2464
+ return Qnil;
2465
+ }
2466
+
2467
+
2468
+ SWIGINTERN VALUE
2469
+ _wrap_Tagger_result(int argc, VALUE *argv, VALUE self) {
2470
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2471
+ size_t arg2 ;
2472
+ void *argp1 = 0 ;
2473
+ int res1 = 0 ;
2474
+ size_t val2 ;
2475
+ int ecode2 = 0 ;
2476
+ size_t result;
2477
+ VALUE vresult = Qnil;
2478
+
2479
+ if ((argc < 1) || (argc > 1)) {
2480
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2481
+ }
2482
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2483
+ if (!SWIG_IsOK(res1)) {
2484
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","result", 1, self ));
2485
+ }
2486
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2487
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2488
+ if (!SWIG_IsOK(ecode2)) {
2489
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","result", 2, argv[0] ));
2490
+ }
2491
+ arg2 = static_cast< size_t >(val2);
2492
+ {
2493
+ try {
2494
+ result = ((CRFPP::Tagger const *)arg1)->result(arg2);
2495
+ }
2496
+ catch (char *e) {
2497
+ SWIG_exception (SWIG_RuntimeError, e);
2498
+ }
2499
+ catch (const char *e) {
2500
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2501
+ }
2502
+ }
2503
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2504
+ return vresult;
2505
+ fail:
2506
+ return Qnil;
2507
+ }
2508
+
2509
+
2510
+ SWIGINTERN VALUE
2511
+ _wrap_Tagger_answer(int argc, VALUE *argv, VALUE self) {
2512
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2513
+ size_t arg2 ;
2514
+ void *argp1 = 0 ;
2515
+ int res1 = 0 ;
2516
+ size_t val2 ;
2517
+ int ecode2 = 0 ;
2518
+ size_t result;
2519
+ VALUE vresult = Qnil;
2520
+
2521
+ if ((argc < 1) || (argc > 1)) {
2522
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2523
+ }
2524
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2525
+ if (!SWIG_IsOK(res1)) {
2526
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","answer", 1, self ));
2527
+ }
2528
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2529
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2530
+ if (!SWIG_IsOK(ecode2)) {
2531
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","answer", 2, argv[0] ));
2532
+ }
2533
+ arg2 = static_cast< size_t >(val2);
2534
+ {
2535
+ try {
2536
+ result = ((CRFPP::Tagger const *)arg1)->answer(arg2);
2537
+ }
2538
+ catch (char *e) {
2539
+ SWIG_exception (SWIG_RuntimeError, e);
2540
+ }
2541
+ catch (const char *e) {
2542
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2543
+ }
2544
+ }
2545
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2546
+ return vresult;
2547
+ fail:
2548
+ return Qnil;
2549
+ }
2550
+
2551
+
2552
+ SWIGINTERN VALUE
2553
+ _wrap_Tagger_y(int argc, VALUE *argv, VALUE self) {
2554
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2555
+ size_t arg2 ;
2556
+ void *argp1 = 0 ;
2557
+ int res1 = 0 ;
2558
+ size_t val2 ;
2559
+ int ecode2 = 0 ;
2560
+ size_t result;
2561
+ VALUE vresult = Qnil;
2562
+
2563
+ if ((argc < 1) || (argc > 1)) {
2564
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2565
+ }
2566
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2567
+ if (!SWIG_IsOK(res1)) {
2568
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","y", 1, self ));
2569
+ }
2570
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2571
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2572
+ if (!SWIG_IsOK(ecode2)) {
2573
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","y", 2, argv[0] ));
2574
+ }
2575
+ arg2 = static_cast< size_t >(val2);
2576
+ {
2577
+ try {
2578
+ result = ((CRFPP::Tagger const *)arg1)->y(arg2);
2579
+ }
2580
+ catch (char *e) {
2581
+ SWIG_exception (SWIG_RuntimeError, e);
2582
+ }
2583
+ catch (const char *e) {
2584
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2585
+ }
2586
+ }
2587
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2588
+ return vresult;
2589
+ fail:
2590
+ return Qnil;
2591
+ }
2592
+
2593
+
2594
+ SWIGINTERN VALUE
2595
+ _wrap_Tagger_y2(int argc, VALUE *argv, VALUE self) {
2596
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2597
+ size_t arg2 ;
2598
+ void *argp1 = 0 ;
2599
+ int res1 = 0 ;
2600
+ size_t val2 ;
2601
+ int ecode2 = 0 ;
2602
+ char *result = 0 ;
2603
+ VALUE vresult = Qnil;
2604
+
2605
+ if ((argc < 1) || (argc > 1)) {
2606
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2607
+ }
2608
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2609
+ if (!SWIG_IsOK(res1)) {
2610
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","y2", 1, self ));
2611
+ }
2612
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2613
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2614
+ if (!SWIG_IsOK(ecode2)) {
2615
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","y2", 2, argv[0] ));
2616
+ }
2617
+ arg2 = static_cast< size_t >(val2);
2618
+ {
2619
+ try {
2620
+ result = (char *)((CRFPP::Tagger const *)arg1)->y2(arg2);
2621
+ }
2622
+ catch (char *e) {
2623
+ SWIG_exception (SWIG_RuntimeError, e);
2624
+ }
2625
+ catch (const char *e) {
2626
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2627
+ }
2628
+ }
2629
+ vresult = SWIG_FromCharPtr((const char *)result);
2630
+ return vresult;
2631
+ fail:
2632
+ return Qnil;
2633
+ }
2634
+
2635
+
2636
+ SWIGINTERN VALUE
2637
+ _wrap_Tagger_yname(int argc, VALUE *argv, VALUE self) {
2638
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2639
+ size_t arg2 ;
2640
+ void *argp1 = 0 ;
2641
+ int res1 = 0 ;
2642
+ size_t val2 ;
2643
+ int ecode2 = 0 ;
2644
+ char *result = 0 ;
2645
+ VALUE vresult = Qnil;
2646
+
2647
+ if ((argc < 1) || (argc > 1)) {
2648
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2649
+ }
2650
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2651
+ if (!SWIG_IsOK(res1)) {
2652
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","yname", 1, self ));
2653
+ }
2654
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2655
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2656
+ if (!SWIG_IsOK(ecode2)) {
2657
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","yname", 2, argv[0] ));
2658
+ }
2659
+ arg2 = static_cast< size_t >(val2);
2660
+ {
2661
+ try {
2662
+ result = (char *)((CRFPP::Tagger const *)arg1)->yname(arg2);
2663
+ }
2664
+ catch (char *e) {
2665
+ SWIG_exception (SWIG_RuntimeError, e);
2666
+ }
2667
+ catch (const char *e) {
2668
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2669
+ }
2670
+ }
2671
+ vresult = SWIG_FromCharPtr((const char *)result);
2672
+ return vresult;
2673
+ fail:
2674
+ return Qnil;
2675
+ }
2676
+
2677
+
2678
+ SWIGINTERN VALUE
2679
+ _wrap_Tagger_x(int argc, VALUE *argv, VALUE self) {
2680
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2681
+ size_t arg2 ;
2682
+ size_t arg3 ;
2683
+ void *argp1 = 0 ;
2684
+ int res1 = 0 ;
2685
+ size_t val2 ;
2686
+ int ecode2 = 0 ;
2687
+ size_t val3 ;
2688
+ int ecode3 = 0 ;
2689
+ char *result = 0 ;
2690
+ VALUE vresult = Qnil;
2691
+
2692
+ if ((argc < 2) || (argc > 2)) {
2693
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2694
+ }
2695
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2696
+ if (!SWIG_IsOK(res1)) {
2697
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","x", 1, self ));
2698
+ }
2699
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2700
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2701
+ if (!SWIG_IsOK(ecode2)) {
2702
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","x", 2, argv[0] ));
2703
+ }
2704
+ arg2 = static_cast< size_t >(val2);
2705
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
2706
+ if (!SWIG_IsOK(ecode3)) {
2707
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","x", 3, argv[1] ));
2708
+ }
2709
+ arg3 = static_cast< size_t >(val3);
2710
+ {
2711
+ try {
2712
+ result = (char *)((CRFPP::Tagger const *)arg1)->x(arg2,arg3);
2713
+ }
2714
+ catch (char *e) {
2715
+ SWIG_exception (SWIG_RuntimeError, e);
2716
+ }
2717
+ catch (const char *e) {
2718
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2719
+ }
2720
+ }
2721
+ vresult = SWIG_FromCharPtr((const char *)result);
2722
+ return vresult;
2723
+ fail:
2724
+ return Qnil;
2725
+ }
2726
+
2727
+
2728
+ SWIGINTERN VALUE
2729
+ _wrap_Tagger_ysize(int argc, VALUE *argv, VALUE self) {
2730
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2731
+ void *argp1 = 0 ;
2732
+ int res1 = 0 ;
2733
+ size_t result;
2734
+ VALUE vresult = Qnil;
2735
+
2736
+ if ((argc < 0) || (argc > 0)) {
2737
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2738
+ }
2739
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2740
+ if (!SWIG_IsOK(res1)) {
2741
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","ysize", 1, self ));
2742
+ }
2743
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2744
+ {
2745
+ try {
2746
+ result = ((CRFPP::Tagger const *)arg1)->ysize();
2747
+ }
2748
+ catch (char *e) {
2749
+ SWIG_exception (SWIG_RuntimeError, e);
2750
+ }
2751
+ catch (const char *e) {
2752
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2753
+ }
2754
+ }
2755
+ vresult = SWIG_From_size_t(static_cast< size_t >(result));
2756
+ return vresult;
2757
+ fail:
2758
+ return Qnil;
2759
+ }
2760
+
2761
+
2762
+ SWIGINTERN VALUE
2763
+ _wrap_Tagger_prob__SWIG_0(int argc, VALUE *argv, VALUE self) {
2764
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2765
+ size_t arg2 ;
2766
+ size_t arg3 ;
2767
+ void *argp1 = 0 ;
2768
+ int res1 = 0 ;
2769
+ size_t val2 ;
2770
+ int ecode2 = 0 ;
2771
+ size_t val3 ;
2772
+ int ecode3 = 0 ;
2773
+ double result;
2774
+ VALUE vresult = Qnil;
2775
+
2776
+ if ((argc < 2) || (argc > 2)) {
2777
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2778
+ }
2779
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2780
+ if (!SWIG_IsOK(res1)) {
2781
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","prob", 1, self ));
2782
+ }
2783
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2784
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2785
+ if (!SWIG_IsOK(ecode2)) {
2786
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","prob", 2, argv[0] ));
2787
+ }
2788
+ arg2 = static_cast< size_t >(val2);
2789
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
2790
+ if (!SWIG_IsOK(ecode3)) {
2791
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","prob", 3, argv[1] ));
2792
+ }
2793
+ arg3 = static_cast< size_t >(val3);
2794
+ {
2795
+ try {
2796
+ result = (double)((CRFPP::Tagger const *)arg1)->prob(arg2,arg3);
2797
+ }
2798
+ catch (char *e) {
2799
+ SWIG_exception (SWIG_RuntimeError, e);
2800
+ }
2801
+ catch (const char *e) {
2802
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2803
+ }
2804
+ }
2805
+ vresult = SWIG_From_double(static_cast< double >(result));
2806
+ return vresult;
2807
+ fail:
2808
+ return Qnil;
2809
+ }
2810
+
2811
+
2812
+ SWIGINTERN VALUE
2813
+ _wrap_Tagger_prob__SWIG_1(int argc, VALUE *argv, VALUE self) {
2814
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2815
+ size_t arg2 ;
2816
+ void *argp1 = 0 ;
2817
+ int res1 = 0 ;
2818
+ size_t val2 ;
2819
+ int ecode2 = 0 ;
2820
+ double result;
2821
+ VALUE vresult = Qnil;
2822
+
2823
+ if ((argc < 1) || (argc > 1)) {
2824
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2825
+ }
2826
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2827
+ if (!SWIG_IsOK(res1)) {
2828
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","prob", 1, self ));
2829
+ }
2830
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2831
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2832
+ if (!SWIG_IsOK(ecode2)) {
2833
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","prob", 2, argv[0] ));
2834
+ }
2835
+ arg2 = static_cast< size_t >(val2);
2836
+ {
2837
+ try {
2838
+ result = (double)((CRFPP::Tagger const *)arg1)->prob(arg2);
2839
+ }
2840
+ catch (char *e) {
2841
+ SWIG_exception (SWIG_RuntimeError, e);
2842
+ }
2843
+ catch (const char *e) {
2844
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2845
+ }
2846
+ }
2847
+ vresult = SWIG_From_double(static_cast< double >(result));
2848
+ return vresult;
2849
+ fail:
2850
+ return Qnil;
2851
+ }
2852
+
2853
+
2854
+ SWIGINTERN VALUE
2855
+ _wrap_Tagger_prob__SWIG_2(int argc, VALUE *argv, VALUE self) {
2856
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2857
+ void *argp1 = 0 ;
2858
+ int res1 = 0 ;
2859
+ double result;
2860
+ VALUE vresult = Qnil;
2861
+
2862
+ if ((argc < 0) || (argc > 0)) {
2863
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2864
+ }
2865
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2866
+ if (!SWIG_IsOK(res1)) {
2867
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","prob", 1, self ));
2868
+ }
2869
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2870
+ {
2871
+ try {
2872
+ result = (double)((CRFPP::Tagger const *)arg1)->prob();
2873
+ }
2874
+ catch (char *e) {
2875
+ SWIG_exception (SWIG_RuntimeError, e);
2876
+ }
2877
+ catch (const char *e) {
2878
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2879
+ }
2880
+ }
2881
+ vresult = SWIG_From_double(static_cast< double >(result));
2882
+ return vresult;
2883
+ fail:
2884
+ return Qnil;
2885
+ }
2886
+
2887
+
2888
+ SWIGINTERN VALUE _wrap_Tagger_prob(int nargs, VALUE *args, VALUE self) {
2889
+ int argc;
2890
+ VALUE argv[4];
2891
+ int ii;
2892
+
2893
+ argc = nargs + 1;
2894
+ argv[0] = self;
2895
+ if (argc > 4) SWIG_fail;
2896
+ for (ii = 1; (ii < argc); ++ii) {
2897
+ argv[ii] = args[ii-1];
2898
+ }
2899
+ if (argc == 1) {
2900
+ int _v;
2901
+ void *vptr = 0;
2902
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CRFPP__Tagger, 0);
2903
+ _v = SWIG_CheckState(res);
2904
+ if (_v) {
2905
+ return _wrap_Tagger_prob__SWIG_2(nargs, args, self);
2906
+ }
2907
+ }
2908
+ if (argc == 2) {
2909
+ int _v;
2910
+ void *vptr = 0;
2911
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CRFPP__Tagger, 0);
2912
+ _v = SWIG_CheckState(res);
2913
+ if (_v) {
2914
+ {
2915
+ int res = SWIG_AsVal_size_t(argv[1], NULL);
2916
+ _v = SWIG_CheckState(res);
2917
+ }
2918
+ if (_v) {
2919
+ return _wrap_Tagger_prob__SWIG_1(nargs, args, self);
2920
+ }
2921
+ }
2922
+ }
2923
+ if (argc == 3) {
2924
+ int _v;
2925
+ void *vptr = 0;
2926
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CRFPP__Tagger, 0);
2927
+ _v = SWIG_CheckState(res);
2928
+ if (_v) {
2929
+ {
2930
+ int res = SWIG_AsVal_size_t(argv[1], NULL);
2931
+ _v = SWIG_CheckState(res);
2932
+ }
2933
+ if (_v) {
2934
+ {
2935
+ int res = SWIG_AsVal_size_t(argv[2], NULL);
2936
+ _v = SWIG_CheckState(res);
2937
+ }
2938
+ if (_v) {
2939
+ return _wrap_Tagger_prob__SWIG_0(nargs, args, self);
2940
+ }
2941
+ }
2942
+ }
2943
+ }
2944
+
2945
+ fail:
2946
+ Ruby_Format_OverloadedError( argc, 4, "Tagger.prob",
2947
+ " double Tagger.prob(size_t i, size_t j)\n"
2948
+ " double Tagger.prob(size_t i)\n"
2949
+ " double Tagger.prob()\n");
2950
+
2951
+ return Qnil;
2952
+ }
2953
+
2954
+
2955
+ SWIGINTERN VALUE
2956
+ _wrap_Tagger_alpha(int argc, VALUE *argv, VALUE self) {
2957
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
2958
+ size_t arg2 ;
2959
+ size_t arg3 ;
2960
+ void *argp1 = 0 ;
2961
+ int res1 = 0 ;
2962
+ size_t val2 ;
2963
+ int ecode2 = 0 ;
2964
+ size_t val3 ;
2965
+ int ecode3 = 0 ;
2966
+ double result;
2967
+ VALUE vresult = Qnil;
2968
+
2969
+ if ((argc < 2) || (argc > 2)) {
2970
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2971
+ }
2972
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
2973
+ if (!SWIG_IsOK(res1)) {
2974
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","alpha", 1, self ));
2975
+ }
2976
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
2977
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
2978
+ if (!SWIG_IsOK(ecode2)) {
2979
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","alpha", 2, argv[0] ));
2980
+ }
2981
+ arg2 = static_cast< size_t >(val2);
2982
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
2983
+ if (!SWIG_IsOK(ecode3)) {
2984
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","alpha", 3, argv[1] ));
2985
+ }
2986
+ arg3 = static_cast< size_t >(val3);
2987
+ {
2988
+ try {
2989
+ result = (double)((CRFPP::Tagger const *)arg1)->alpha(arg2,arg3);
2990
+ }
2991
+ catch (char *e) {
2992
+ SWIG_exception (SWIG_RuntimeError, e);
2993
+ }
2994
+ catch (const char *e) {
2995
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
2996
+ }
2997
+ }
2998
+ vresult = SWIG_From_double(static_cast< double >(result));
2999
+ return vresult;
3000
+ fail:
3001
+ return Qnil;
3002
+ }
3003
+
3004
+
3005
+ SWIGINTERN VALUE
3006
+ _wrap_Tagger_beta(int argc, VALUE *argv, VALUE self) {
3007
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3008
+ size_t arg2 ;
3009
+ size_t arg3 ;
3010
+ void *argp1 = 0 ;
3011
+ int res1 = 0 ;
3012
+ size_t val2 ;
3013
+ int ecode2 = 0 ;
3014
+ size_t val3 ;
3015
+ int ecode3 = 0 ;
3016
+ double result;
3017
+ VALUE vresult = Qnil;
3018
+
3019
+ if ((argc < 2) || (argc > 2)) {
3020
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3021
+ }
3022
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3023
+ if (!SWIG_IsOK(res1)) {
3024
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","beta", 1, self ));
3025
+ }
3026
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3027
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
3028
+ if (!SWIG_IsOK(ecode2)) {
3029
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","beta", 2, argv[0] ));
3030
+ }
3031
+ arg2 = static_cast< size_t >(val2);
3032
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
3033
+ if (!SWIG_IsOK(ecode3)) {
3034
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","beta", 3, argv[1] ));
3035
+ }
3036
+ arg3 = static_cast< size_t >(val3);
3037
+ {
3038
+ try {
3039
+ result = (double)((CRFPP::Tagger const *)arg1)->beta(arg2,arg3);
3040
+ }
3041
+ catch (char *e) {
3042
+ SWIG_exception (SWIG_RuntimeError, e);
3043
+ }
3044
+ catch (const char *e) {
3045
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3046
+ }
3047
+ }
3048
+ vresult = SWIG_From_double(static_cast< double >(result));
3049
+ return vresult;
3050
+ fail:
3051
+ return Qnil;
3052
+ }
3053
+
3054
+
3055
+ SWIGINTERN VALUE
3056
+ _wrap_Tagger_emission_cost(int argc, VALUE *argv, VALUE self) {
3057
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3058
+ size_t arg2 ;
3059
+ size_t arg3 ;
3060
+ void *argp1 = 0 ;
3061
+ int res1 = 0 ;
3062
+ size_t val2 ;
3063
+ int ecode2 = 0 ;
3064
+ size_t val3 ;
3065
+ int ecode3 = 0 ;
3066
+ double result;
3067
+ VALUE vresult = Qnil;
3068
+
3069
+ if ((argc < 2) || (argc > 2)) {
3070
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3071
+ }
3072
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3073
+ if (!SWIG_IsOK(res1)) {
3074
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","emission_cost", 1, self ));
3075
+ }
3076
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3077
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
3078
+ if (!SWIG_IsOK(ecode2)) {
3079
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","emission_cost", 2, argv[0] ));
3080
+ }
3081
+ arg2 = static_cast< size_t >(val2);
3082
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
3083
+ if (!SWIG_IsOK(ecode3)) {
3084
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","emission_cost", 3, argv[1] ));
3085
+ }
3086
+ arg3 = static_cast< size_t >(val3);
3087
+ {
3088
+ try {
3089
+ result = (double)((CRFPP::Tagger const *)arg1)->emission_cost(arg2,arg3);
3090
+ }
3091
+ catch (char *e) {
3092
+ SWIG_exception (SWIG_RuntimeError, e);
3093
+ }
3094
+ catch (const char *e) {
3095
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3096
+ }
3097
+ }
3098
+ vresult = SWIG_From_double(static_cast< double >(result));
3099
+ return vresult;
3100
+ fail:
3101
+ return Qnil;
3102
+ }
3103
+
3104
+
3105
+ SWIGINTERN VALUE
3106
+ _wrap_Tagger_next_transition_cost(int argc, VALUE *argv, VALUE self) {
3107
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3108
+ size_t arg2 ;
3109
+ size_t arg3 ;
3110
+ size_t arg4 ;
3111
+ void *argp1 = 0 ;
3112
+ int res1 = 0 ;
3113
+ size_t val2 ;
3114
+ int ecode2 = 0 ;
3115
+ size_t val3 ;
3116
+ int ecode3 = 0 ;
3117
+ size_t val4 ;
3118
+ int ecode4 = 0 ;
3119
+ double result;
3120
+ VALUE vresult = Qnil;
3121
+
3122
+ if ((argc < 3) || (argc > 3)) {
3123
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
3124
+ }
3125
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3126
+ if (!SWIG_IsOK(res1)) {
3127
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","next_transition_cost", 1, self ));
3128
+ }
3129
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3130
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
3131
+ if (!SWIG_IsOK(ecode2)) {
3132
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","next_transition_cost", 2, argv[0] ));
3133
+ }
3134
+ arg2 = static_cast< size_t >(val2);
3135
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
3136
+ if (!SWIG_IsOK(ecode3)) {
3137
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","next_transition_cost", 3, argv[1] ));
3138
+ }
3139
+ arg3 = static_cast< size_t >(val3);
3140
+ ecode4 = SWIG_AsVal_size_t(argv[2], &val4);
3141
+ if (!SWIG_IsOK(ecode4)) {
3142
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "size_t","next_transition_cost", 4, argv[2] ));
3143
+ }
3144
+ arg4 = static_cast< size_t >(val4);
3145
+ {
3146
+ try {
3147
+ result = (double)((CRFPP::Tagger const *)arg1)->next_transition_cost(arg2,arg3,arg4);
3148
+ }
3149
+ catch (char *e) {
3150
+ SWIG_exception (SWIG_RuntimeError, e);
3151
+ }
3152
+ catch (const char *e) {
3153
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3154
+ }
3155
+ }
3156
+ vresult = SWIG_From_double(static_cast< double >(result));
3157
+ return vresult;
3158
+ fail:
3159
+ return Qnil;
3160
+ }
3161
+
3162
+
3163
+ SWIGINTERN VALUE
3164
+ _wrap_Tagger_prev_transition_cost(int argc, VALUE *argv, VALUE self) {
3165
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3166
+ size_t arg2 ;
3167
+ size_t arg3 ;
3168
+ size_t arg4 ;
3169
+ void *argp1 = 0 ;
3170
+ int res1 = 0 ;
3171
+ size_t val2 ;
3172
+ int ecode2 = 0 ;
3173
+ size_t val3 ;
3174
+ int ecode3 = 0 ;
3175
+ size_t val4 ;
3176
+ int ecode4 = 0 ;
3177
+ double result;
3178
+ VALUE vresult = Qnil;
3179
+
3180
+ if ((argc < 3) || (argc > 3)) {
3181
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail;
3182
+ }
3183
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3184
+ if (!SWIG_IsOK(res1)) {
3185
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","prev_transition_cost", 1, self ));
3186
+ }
3187
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3188
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
3189
+ if (!SWIG_IsOK(ecode2)) {
3190
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","prev_transition_cost", 2, argv[0] ));
3191
+ }
3192
+ arg2 = static_cast< size_t >(val2);
3193
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
3194
+ if (!SWIG_IsOK(ecode3)) {
3195
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","prev_transition_cost", 3, argv[1] ));
3196
+ }
3197
+ arg3 = static_cast< size_t >(val3);
3198
+ ecode4 = SWIG_AsVal_size_t(argv[2], &val4);
3199
+ if (!SWIG_IsOK(ecode4)) {
3200
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "size_t","prev_transition_cost", 4, argv[2] ));
3201
+ }
3202
+ arg4 = static_cast< size_t >(val4);
3203
+ {
3204
+ try {
3205
+ result = (double)((CRFPP::Tagger const *)arg1)->prev_transition_cost(arg2,arg3,arg4);
3206
+ }
3207
+ catch (char *e) {
3208
+ SWIG_exception (SWIG_RuntimeError, e);
3209
+ }
3210
+ catch (const char *e) {
3211
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3212
+ }
3213
+ }
3214
+ vresult = SWIG_From_double(static_cast< double >(result));
3215
+ return vresult;
3216
+ fail:
3217
+ return Qnil;
3218
+ }
3219
+
3220
+
3221
+ SWIGINTERN VALUE
3222
+ _wrap_Tagger_best_cost(int argc, VALUE *argv, VALUE self) {
3223
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3224
+ size_t arg2 ;
3225
+ size_t arg3 ;
3226
+ void *argp1 = 0 ;
3227
+ int res1 = 0 ;
3228
+ size_t val2 ;
3229
+ int ecode2 = 0 ;
3230
+ size_t val3 ;
3231
+ int ecode3 = 0 ;
3232
+ double result;
3233
+ VALUE vresult = Qnil;
3234
+
3235
+ if ((argc < 2) || (argc > 2)) {
3236
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
3237
+ }
3238
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3239
+ if (!SWIG_IsOK(res1)) {
3240
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","best_cost", 1, self ));
3241
+ }
3242
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3243
+ ecode2 = SWIG_AsVal_size_t(argv[0], &val2);
3244
+ if (!SWIG_IsOK(ecode2)) {
3245
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "size_t","best_cost", 2, argv[0] ));
3246
+ }
3247
+ arg2 = static_cast< size_t >(val2);
3248
+ ecode3 = SWIG_AsVal_size_t(argv[1], &val3);
3249
+ if (!SWIG_IsOK(ecode3)) {
3250
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "size_t","best_cost", 3, argv[1] ));
3251
+ }
3252
+ arg3 = static_cast< size_t >(val3);
3253
+ {
3254
+ try {
3255
+ result = (double)((CRFPP::Tagger const *)arg1)->best_cost(arg2,arg3);
3256
+ }
3257
+ catch (char *e) {
3258
+ SWIG_exception (SWIG_RuntimeError, e);
3259
+ }
3260
+ catch (const char *e) {
3261
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3262
+ }
3263
+ }
3264
+ vresult = SWIG_From_double(static_cast< double >(result));
3265
+ return vresult;
3266
+ fail:
3267
+ return Qnil;
3268
+ }
3269
+
3270
+
3271
+ SWIGINTERN VALUE
3272
+ _wrap_Tagger_Z(int argc, VALUE *argv, VALUE self) {
3273
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3274
+ void *argp1 = 0 ;
3275
+ int res1 = 0 ;
3276
+ double result;
3277
+ VALUE vresult = Qnil;
3278
+
3279
+ if ((argc < 0) || (argc > 0)) {
3280
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3281
+ }
3282
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3283
+ if (!SWIG_IsOK(res1)) {
3284
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","Z", 1, self ));
3285
+ }
3286
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3287
+ {
3288
+ try {
3289
+ result = (double)((CRFPP::Tagger const *)arg1)->Z();
3290
+ }
3291
+ catch (char *e) {
3292
+ SWIG_exception (SWIG_RuntimeError, e);
3293
+ }
3294
+ catch (const char *e) {
3295
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3296
+ }
3297
+ }
3298
+ vresult = SWIG_From_double(static_cast< double >(result));
3299
+ return vresult;
3300
+ fail:
3301
+ return Qnil;
3302
+ }
3303
+
3304
+
3305
+ SWIGINTERN VALUE
3306
+ _wrap_Tagger_parse__SWIG_0(int argc, VALUE *argv, VALUE self) {
3307
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3308
+ void *argp1 = 0 ;
3309
+ int res1 = 0 ;
3310
+ bool result;
3311
+ VALUE vresult = Qnil;
3312
+
3313
+ if ((argc < 0) || (argc > 0)) {
3314
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3315
+ }
3316
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3317
+ if (!SWIG_IsOK(res1)) {
3318
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","parse", 1, self ));
3319
+ }
3320
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3321
+ {
3322
+ try {
3323
+ result = (bool)(arg1)->parse();
3324
+ }
3325
+ catch (char *e) {
3326
+ SWIG_exception (SWIG_RuntimeError, e);
3327
+ }
3328
+ catch (const char *e) {
3329
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3330
+ }
3331
+ }
3332
+ vresult = SWIG_From_bool(static_cast< bool >(result));
3333
+ return vresult;
3334
+ fail:
3335
+ return Qnil;
3336
+ }
3337
+
3338
+
3339
+
3340
+ /*
3341
+ Document-method: CRFPP::Tagger.empty
3342
+
3343
+ call-seq:
3344
+ empty -> bool
3345
+
3346
+ Check if Tagger is empty.
3347
+ */
3348
+ SWIGINTERN VALUE
3349
+ _wrap_Tagger_empty(int argc, VALUE *argv, VALUE self) {
3350
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3351
+ void *argp1 = 0 ;
3352
+ int res1 = 0 ;
3353
+ bool result;
3354
+ VALUE vresult = Qnil;
3355
+
3356
+ if ((argc < 0) || (argc > 0)) {
3357
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3358
+ }
3359
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3360
+ if (!SWIG_IsOK(res1)) {
3361
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger const *","empty", 1, self ));
3362
+ }
3363
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3364
+ {
3365
+ try {
3366
+ result = (bool)((CRFPP::Tagger const *)arg1)->empty();
3367
+ }
3368
+ catch (char *e) {
3369
+ SWIG_exception (SWIG_RuntimeError, e);
3370
+ }
3371
+ catch (const char *e) {
3372
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3373
+ }
3374
+ }
3375
+ vresult = SWIG_From_bool(static_cast< bool >(result));
3376
+ return vresult;
3377
+ fail:
3378
+ return Qnil;
3379
+ }
3380
+
3381
+
3382
+ SWIGINTERN VALUE
3383
+ _wrap_Tagger_clear(int argc, VALUE *argv, VALUE self) {
3384
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3385
+ void *argp1 = 0 ;
3386
+ int res1 = 0 ;
3387
+ bool result;
3388
+ VALUE vresult = Qnil;
3389
+
3390
+ if ((argc < 0) || (argc > 0)) {
3391
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3392
+ }
3393
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3394
+ if (!SWIG_IsOK(res1)) {
3395
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","clear", 1, self ));
3396
+ }
3397
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3398
+ {
3399
+ try {
3400
+ result = (bool)(arg1)->clear();
3401
+ }
3402
+ catch (char *e) {
3403
+ SWIG_exception (SWIG_RuntimeError, e);
3404
+ }
3405
+ catch (const char *e) {
3406
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3407
+ }
3408
+ }
3409
+ vresult = SWIG_From_bool(static_cast< bool >(result));
3410
+ return vresult;
3411
+ fail:
3412
+ return Qnil;
3413
+ }
3414
+
3415
+
3416
+ SWIGINTERN VALUE
3417
+ _wrap_Tagger_next(int argc, VALUE *argv, VALUE self) {
3418
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3419
+ void *argp1 = 0 ;
3420
+ int res1 = 0 ;
3421
+ bool result;
3422
+ VALUE vresult = Qnil;
3423
+
3424
+ if ((argc < 0) || (argc > 0)) {
3425
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3426
+ }
3427
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3428
+ if (!SWIG_IsOK(res1)) {
3429
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","next", 1, self ));
3430
+ }
3431
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3432
+ {
3433
+ try {
3434
+ result = (bool)(arg1)->next();
3435
+ }
3436
+ catch (char *e) {
3437
+ SWIG_exception (SWIG_RuntimeError, e);
3438
+ }
3439
+ catch (const char *e) {
3440
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3441
+ }
3442
+ }
3443
+ vresult = SWIG_From_bool(static_cast< bool >(result));
3444
+ return vresult;
3445
+ fail:
3446
+ return Qnil;
3447
+ }
3448
+
3449
+
3450
+ SWIGINTERN VALUE
3451
+ _wrap_Tagger_parse__SWIG_1(int argc, VALUE *argv, VALUE self) {
3452
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3453
+ char *arg2 = (char *) 0 ;
3454
+ void *argp1 = 0 ;
3455
+ int res1 = 0 ;
3456
+ int res2 ;
3457
+ char *buf2 = 0 ;
3458
+ int alloc2 = 0 ;
3459
+ char *result = 0 ;
3460
+ VALUE vresult = Qnil;
3461
+
3462
+ if ((argc < 1) || (argc > 1)) {
3463
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3464
+ }
3465
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3466
+ if (!SWIG_IsOK(res1)) {
3467
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","parse", 1, self ));
3468
+ }
3469
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3470
+ res2 = SWIG_AsCharPtrAndSize(argv[0], &buf2, NULL, &alloc2);
3471
+ if (!SWIG_IsOK(res2)) {
3472
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","parse", 2, argv[0] ));
3473
+ }
3474
+ arg2 = reinterpret_cast< char * >(buf2);
3475
+ {
3476
+ try {
3477
+ result = (char *)(arg1)->parse((char const *)arg2);
3478
+ }
3479
+ catch (char *e) {
3480
+ SWIG_exception (SWIG_RuntimeError, e);
3481
+ }
3482
+ catch (const char *e) {
3483
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3484
+ }
3485
+ }
3486
+ vresult = SWIG_FromCharPtr((const char *)result);
3487
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
3488
+ return vresult;
3489
+ fail:
3490
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
3491
+ return Qnil;
3492
+ }
3493
+
3494
+
3495
+ SWIGINTERN VALUE _wrap_Tagger_parse(int nargs, VALUE *args, VALUE self) {
3496
+ int argc;
3497
+ VALUE argv[3];
3498
+ int ii;
3499
+
3500
+ argc = nargs + 1;
3501
+ argv[0] = self;
3502
+ if (argc > 3) SWIG_fail;
3503
+ for (ii = 1; (ii < argc); ++ii) {
3504
+ argv[ii] = args[ii-1];
3505
+ }
3506
+ if (argc == 1) {
3507
+ int _v;
3508
+ void *vptr = 0;
3509
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CRFPP__Tagger, 0);
3510
+ _v = SWIG_CheckState(res);
3511
+ if (_v) {
3512
+ return _wrap_Tagger_parse__SWIG_0(nargs, args, self);
3513
+ }
3514
+ }
3515
+ if (argc == 2) {
3516
+ int _v;
3517
+ void *vptr = 0;
3518
+ int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_CRFPP__Tagger, 0);
3519
+ _v = SWIG_CheckState(res);
3520
+ if (_v) {
3521
+ int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
3522
+ _v = SWIG_CheckState(res);
3523
+ if (_v) {
3524
+ return _wrap_Tagger_parse__SWIG_1(nargs, args, self);
3525
+ }
3526
+ }
3527
+ }
3528
+
3529
+ fail:
3530
+ Ruby_Format_OverloadedError( argc, 3, "Tagger.parse",
3531
+ " char const * Tagger.parse()\n"
3532
+ " char const * Tagger.parse(char const *str)\n");
3533
+
3534
+ return Qnil;
3535
+ }
3536
+
3537
+
3538
+ SWIGINTERN VALUE
3539
+ _wrap_Tagger_what(int argc, VALUE *argv, VALUE self) {
3540
+ CRFPP::Tagger *arg1 = (CRFPP::Tagger *) 0 ;
3541
+ void *argp1 = 0 ;
3542
+ int res1 = 0 ;
3543
+ char *result = 0 ;
3544
+ VALUE vresult = Qnil;
3545
+
3546
+ if ((argc < 0) || (argc > 0)) {
3547
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
3548
+ }
3549
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CRFPP__Tagger, 0 | 0 );
3550
+ if (!SWIG_IsOK(res1)) {
3551
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "CRFPP::Tagger *","what", 1, self ));
3552
+ }
3553
+ arg1 = reinterpret_cast< CRFPP::Tagger * >(argp1);
3554
+ {
3555
+ try {
3556
+ result = (char *)(arg1)->what();
3557
+ }
3558
+ catch (char *e) {
3559
+ SWIG_exception (SWIG_RuntimeError, e);
3560
+ }
3561
+ catch (const char *e) {
3562
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3563
+ }
3564
+ }
3565
+ vresult = SWIG_FromCharPtr((const char *)result);
3566
+ return vresult;
3567
+ fail:
3568
+ return Qnil;
3569
+ }
3570
+
3571
+
3572
+ SWIGINTERN void
3573
+ free_CRFPP_Tagger(CRFPP::Tagger *arg1) {
3574
+ delete arg1;
3575
+ }
3576
+
3577
+ #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
3578
+ SWIGINTERN VALUE
3579
+ _wrap_Tagger_allocate(VALUE self) {
3580
+ #else
3581
+ SWIGINTERN VALUE
3582
+ _wrap_Tagger_allocate(int argc, VALUE *argv, VALUE self) {
3583
+ #endif
3584
+
3585
+
3586
+ VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_CRFPP__Tagger);
3587
+ #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
3588
+ rb_obj_call_init(vresult, argc, argv);
3589
+ #endif
3590
+ return vresult;
3591
+ }
3592
+
3593
+
3594
+ SWIGINTERN VALUE
3595
+ _wrap_new_Tagger(int argc, VALUE *argv, VALUE self) {
3596
+ char *arg1 = (char *) 0 ;
3597
+ int res1 ;
3598
+ char *buf1 = 0 ;
3599
+ int alloc1 = 0 ;
3600
+ CRFPP::Tagger *result = 0 ;
3601
+
3602
+ if ((argc < 1) || (argc > 1)) {
3603
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
3604
+ }
3605
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
3606
+ if (!SWIG_IsOK(res1)) {
3607
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","CRFPP::Tagger", 1, argv[0] ));
3608
+ }
3609
+ arg1 = reinterpret_cast< char * >(buf1);
3610
+ {
3611
+ try {
3612
+ result = (CRFPP::Tagger *)new_CRFPP_Tagger((char const *)arg1);
3613
+ DATA_PTR(self) = result;
3614
+ }
3615
+ catch (char *e) {
3616
+ SWIG_exception (SWIG_RuntimeError, e);
3617
+ }
3618
+ catch (const char *e) {
3619
+ SWIG_exception (SWIG_RuntimeError, (char*)e);
3620
+ }
3621
+ }
3622
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
3623
+ return self;
3624
+ fail:
3625
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
3626
+ return Qnil;
3627
+ }
3628
+
3629
+
3630
+
3631
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
3632
+
3633
+ static swig_type_info _swigt__p_CRFPP__Tagger = {"_p_CRFPP__Tagger", "CRFPP::Tagger *", 0, 0, (void*)0, 0};
3634
+ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
3635
+
3636
+ static swig_type_info *swig_type_initial[] = {
3637
+ &_swigt__p_CRFPP__Tagger,
3638
+ &_swigt__p_char,
3639
+ };
3640
+
3641
+ static swig_cast_info _swigc__p_CRFPP__Tagger[] = { {&_swigt__p_CRFPP__Tagger, 0, 0, 0},{0, 0, 0, 0}};
3642
+ static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
3643
+
3644
+ static swig_cast_info *swig_cast_initial[] = {
3645
+ _swigc__p_CRFPP__Tagger,
3646
+ _swigc__p_char,
3647
+ };
3648
+
3649
+
3650
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
3651
+
3652
+ /* -----------------------------------------------------------------------------
3653
+ * Type initialization:
3654
+ * This problem is tough by the requirement that no dynamic
3655
+ * memory is used. Also, since swig_type_info structures store pointers to
3656
+ * swig_cast_info structures and swig_cast_info structures store pointers back
3657
+ * to swig_type_info structures, we need some lookup code at initialization.
3658
+ * The idea is that swig generates all the structures that are needed.
3659
+ * The runtime then collects these partially filled structures.
3660
+ * The SWIG_InitializeModule function takes these initial arrays out of
3661
+ * swig_module, and does all the lookup, filling in the swig_module.types
3662
+ * array with the correct data and linking the correct swig_cast_info
3663
+ * structures together.
3664
+ *
3665
+ * The generated swig_type_info structures are assigned staticly to an initial
3666
+ * array. We just loop through that array, and handle each type individually.
3667
+ * First we lookup if this type has been already loaded, and if so, use the
3668
+ * loaded structure instead of the generated one. Then we have to fill in the
3669
+ * cast linked list. The cast data is initially stored in something like a
3670
+ * two-dimensional array. Each row corresponds to a type (there are the same
3671
+ * number of rows as there are in the swig_type_initial array). Each entry in
3672
+ * a column is one of the swig_cast_info structures for that type.
3673
+ * The cast_initial array is actually an array of arrays, because each row has
3674
+ * a variable number of columns. So to actually build the cast linked list,
3675
+ * we find the array of casts associated with the type, and loop through it
3676
+ * adding the casts to the list. The one last trick we need to do is making
3677
+ * sure the type pointer in the swig_cast_info struct is correct.
3678
+ *
3679
+ * First off, we lookup the cast->type name to see if it is already loaded.
3680
+ * There are three cases to handle:
3681
+ * 1) If the cast->type has already been loaded AND the type we are adding
3682
+ * casting info to has not been loaded (it is in this module), THEN we
3683
+ * replace the cast->type pointer with the type pointer that has already
3684
+ * been loaded.
3685
+ * 2) If BOTH types (the one we are adding casting info to, and the
3686
+ * cast->type) are loaded, THEN the cast info has already been loaded by
3687
+ * the previous module so we just ignore it.
3688
+ * 3) Finally, if cast->type has not already been loaded, then we add that
3689
+ * swig_cast_info to the linked list (because the cast->type) pointer will
3690
+ * be correct.
3691
+ * ----------------------------------------------------------------------------- */
3692
+
3693
+ #ifdef __cplusplus
3694
+ extern "C" {
3695
+ #if 0
3696
+ } /* c-mode */
3697
+ #endif
3698
+ #endif
3699
+
3700
+ #if 0
3701
+ #define SWIGRUNTIME_DEBUG
3702
+ #endif
3703
+
3704
+
3705
+ SWIGRUNTIME void
3706
+ SWIG_InitializeModule(void *clientdata) {
3707
+ size_t i;
3708
+ swig_module_info *module_head, *iter;
3709
+ int found, init;
3710
+
3711
+ clientdata = clientdata;
3712
+
3713
+ /* check to see if the circular list has been setup, if not, set it up */
3714
+ if (swig_module.next==0) {
3715
+ /* Initialize the swig_module */
3716
+ swig_module.type_initial = swig_type_initial;
3717
+ swig_module.cast_initial = swig_cast_initial;
3718
+ swig_module.next = &swig_module;
3719
+ init = 1;
3720
+ } else {
3721
+ init = 0;
3722
+ }
3723
+
3724
+ /* Try and load any already created modules */
3725
+ module_head = SWIG_GetModule(clientdata);
3726
+ if (!module_head) {
3727
+ /* This is the first module loaded for this interpreter */
3728
+ /* so set the swig module into the interpreter */
3729
+ SWIG_SetModule(clientdata, &swig_module);
3730
+ module_head = &swig_module;
3731
+ } else {
3732
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
3733
+ found=0;
3734
+ iter=module_head;
3735
+ do {
3736
+ if (iter==&swig_module) {
3737
+ found=1;
3738
+ break;
3739
+ }
3740
+ iter=iter->next;
3741
+ } while (iter!= module_head);
3742
+
3743
+ /* if the is found in the list, then all is done and we may leave */
3744
+ if (found) return;
3745
+ /* otherwise we must add out module into the list */
3746
+ swig_module.next = module_head->next;
3747
+ module_head->next = &swig_module;
3748
+ }
3749
+
3750
+ /* When multiple interpeters are used, a module could have already been initialized in
3751
+ a different interpreter, but not yet have a pointer in this interpreter.
3752
+ In this case, we do not want to continue adding types... everything should be
3753
+ set up already */
3754
+ if (init == 0) return;
3755
+
3756
+ /* Now work on filling in swig_module.types */
3757
+ #ifdef SWIGRUNTIME_DEBUG
3758
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
3759
+ #endif
3760
+ for (i = 0; i < swig_module.size; ++i) {
3761
+ swig_type_info *type = 0;
3762
+ swig_type_info *ret;
3763
+ swig_cast_info *cast;
3764
+
3765
+ #ifdef SWIGRUNTIME_DEBUG
3766
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
3767
+ #endif
3768
+
3769
+ /* if there is another module already loaded */
3770
+ if (swig_module.next != &swig_module) {
3771
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
3772
+ }
3773
+ if (type) {
3774
+ /* Overwrite clientdata field */
3775
+ #ifdef SWIGRUNTIME_DEBUG
3776
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
3777
+ #endif
3778
+ if (swig_module.type_initial[i]->clientdata) {
3779
+ type->clientdata = swig_module.type_initial[i]->clientdata;
3780
+ #ifdef SWIGRUNTIME_DEBUG
3781
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
3782
+ #endif
3783
+ }
3784
+ } else {
3785
+ type = swig_module.type_initial[i];
3786
+ }
3787
+
3788
+ /* Insert casting types */
3789
+ cast = swig_module.cast_initial[i];
3790
+ while (cast->type) {
3791
+
3792
+ /* Don't need to add information already in the list */
3793
+ ret = 0;
3794
+ #ifdef SWIGRUNTIME_DEBUG
3795
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
3796
+ #endif
3797
+ if (swig_module.next != &swig_module) {
3798
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
3799
+ #ifdef SWIGRUNTIME_DEBUG
3800
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
3801
+ #endif
3802
+ }
3803
+ if (ret) {
3804
+ if (type == swig_module.type_initial[i]) {
3805
+ #ifdef SWIGRUNTIME_DEBUG
3806
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
3807
+ #endif
3808
+ cast->type = ret;
3809
+ ret = 0;
3810
+ } else {
3811
+ /* Check for casting already in the list */
3812
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
3813
+ #ifdef SWIGRUNTIME_DEBUG
3814
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
3815
+ #endif
3816
+ if (!ocast) ret = 0;
3817
+ }
3818
+ }
3819
+
3820
+ if (!ret) {
3821
+ #ifdef SWIGRUNTIME_DEBUG
3822
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
3823
+ #endif
3824
+ if (type->cast) {
3825
+ type->cast->prev = cast;
3826
+ cast->next = type->cast;
3827
+ }
3828
+ type->cast = cast;
3829
+ }
3830
+ cast++;
3831
+ }
3832
+ /* Set entry in modules->types array equal to the type */
3833
+ swig_module.types[i] = type;
3834
+ }
3835
+ swig_module.types[i] = 0;
3836
+
3837
+ #ifdef SWIGRUNTIME_DEBUG
3838
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
3839
+ for (i = 0; i < swig_module.size; ++i) {
3840
+ int j = 0;
3841
+ swig_cast_info *cast = swig_module.cast_initial[i];
3842
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
3843
+ while (cast->type) {
3844
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
3845
+ cast++;
3846
+ ++j;
3847
+ }
3848
+ printf("---- Total casts: %d\n",j);
3849
+ }
3850
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
3851
+ #endif
3852
+ }
3853
+
3854
+ /* This function will propagate the clientdata field of type to
3855
+ * any new swig_type_info structures that have been added into the list
3856
+ * of equivalent types. It is like calling
3857
+ * SWIG_TypeClientData(type, clientdata) a second time.
3858
+ */
3859
+ SWIGRUNTIME void
3860
+ SWIG_PropagateClientData(void) {
3861
+ size_t i;
3862
+ swig_cast_info *equiv;
3863
+ static int init_run = 0;
3864
+
3865
+ if (init_run) return;
3866
+ init_run = 1;
3867
+
3868
+ for (i = 0; i < swig_module.size; i++) {
3869
+ if (swig_module.types[i]->clientdata) {
3870
+ equiv = swig_module.types[i]->cast;
3871
+ while (equiv) {
3872
+ if (!equiv->converter) {
3873
+ if (equiv->type && !equiv->type->clientdata)
3874
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
3875
+ }
3876
+ equiv = equiv->next;
3877
+ }
3878
+ }
3879
+ }
3880
+ }
3881
+
3882
+ #ifdef __cplusplus
3883
+ #if 0
3884
+ { /* c-mode */
3885
+ #endif
3886
+ }
3887
+ #endif
3888
+
3889
+ /*
3890
+
3891
+ */
3892
+ #ifdef __cplusplus
3893
+ extern "C"
3894
+ #endif
3895
+ SWIGEXPORT void Init_tagger(VALUE crfpp) {
3896
+ size_t i;
3897
+
3898
+ SWIG_InitRuntime();
3899
+ mCRFPP = crfpp;
3900
+
3901
+ SWIG_InitializeModule(0);
3902
+ for (i = 0; i < swig_module.size; i++) {
3903
+ SWIG_define_class(swig_module.types[i]);
3904
+ }
3905
+
3906
+ SWIG_RubyInitializeTrackings();
3907
+
3908
+ cTagger.klass = rb_define_class_under(mCRFPP, "Tagger", rb_cObject);
3909
+ SWIG_TypeClientData(SWIGTYPE_p_CRFPP__Tagger, (void *) &cTagger);
3910
+ rb_define_alloc_func(cTagger.klass, _wrap_Tagger_allocate);
3911
+ rb_define_method(cTagger.klass, "initialize", VALUEFUNC(_wrap_new_Tagger), -1);
3912
+ rb_define_method(cTagger.klass, "set_vlevel", VALUEFUNC(_wrap_Tagger_set_vlevel), -1);
3913
+ rb_define_method(cTagger.klass, "vlevel", VALUEFUNC(_wrap_Tagger_vlevel), -1);
3914
+ rb_define_method(cTagger.klass, "set_cost_factor", VALUEFUNC(_wrap_Tagger_set_cost_factor), -1);
3915
+ rb_define_method(cTagger.klass, "cost_factor", VALUEFUNC(_wrap_Tagger_cost_factor), -1);
3916
+ rb_define_method(cTagger.klass, "set_nbest", VALUEFUNC(_wrap_Tagger_set_nbest), -1);
3917
+ rb_define_method(cTagger.klass, "nbest", VALUEFUNC(_wrap_Tagger_nbest), -1);
3918
+ rb_define_method(cTagger.klass, "add", VALUEFUNC(_wrap_Tagger_add), -1);
3919
+ rb_define_method(cTagger.klass, "size", VALUEFUNC(_wrap_Tagger_size), -1);
3920
+ rb_define_method(cTagger.klass, "xsize", VALUEFUNC(_wrap_Tagger_xsize), -1);
3921
+ rb_define_method(cTagger.klass, "dsize", VALUEFUNC(_wrap_Tagger_dsize), -1);
3922
+ rb_define_method(cTagger.klass, "result", VALUEFUNC(_wrap_Tagger_result), -1);
3923
+ rb_define_method(cTagger.klass, "answer", VALUEFUNC(_wrap_Tagger_answer), -1);
3924
+ rb_define_method(cTagger.klass, "y", VALUEFUNC(_wrap_Tagger_y), -1);
3925
+ rb_define_method(cTagger.klass, "y2", VALUEFUNC(_wrap_Tagger_y2), -1);
3926
+ rb_define_method(cTagger.klass, "yname", VALUEFUNC(_wrap_Tagger_yname), -1);
3927
+ rb_define_method(cTagger.klass, "x", VALUEFUNC(_wrap_Tagger_x), -1);
3928
+ rb_define_method(cTagger.klass, "ysize", VALUEFUNC(_wrap_Tagger_ysize), -1);
3929
+ rb_define_method(cTagger.klass, "prob", VALUEFUNC(_wrap_Tagger_prob), -1);
3930
+ rb_define_method(cTagger.klass, "alpha", VALUEFUNC(_wrap_Tagger_alpha), -1);
3931
+ rb_define_method(cTagger.klass, "beta", VALUEFUNC(_wrap_Tagger_beta), -1);
3932
+ rb_define_method(cTagger.klass, "emission_cost", VALUEFUNC(_wrap_Tagger_emission_cost), -1);
3933
+ rb_define_method(cTagger.klass, "next_transition_cost", VALUEFUNC(_wrap_Tagger_next_transition_cost), -1);
3934
+ rb_define_method(cTagger.klass, "prev_transition_cost", VALUEFUNC(_wrap_Tagger_prev_transition_cost), -1);
3935
+ rb_define_method(cTagger.klass, "best_cost", VALUEFUNC(_wrap_Tagger_best_cost), -1);
3936
+ rb_define_method(cTagger.klass, "Z", VALUEFUNC(_wrap_Tagger_Z), -1);
3937
+ rb_define_method(cTagger.klass, "empty", VALUEFUNC(_wrap_Tagger_empty), -1);
3938
+ rb_define_method(cTagger.klass, "clear", VALUEFUNC(_wrap_Tagger_clear), -1);
3939
+ rb_define_method(cTagger.klass, "next", VALUEFUNC(_wrap_Tagger_next), -1);
3940
+ rb_define_method(cTagger.klass, "parse", VALUEFUNC(_wrap_Tagger_parse), -1);
3941
+ rb_define_method(cTagger.klass, "what", VALUEFUNC(_wrap_Tagger_what), -1);
3942
+ cTagger.mark = 0;
3943
+ cTagger.destroy = (void (*)(void *)) free_CRFPP_Tagger;
3944
+ cTagger.trackObjects = 0;
3945
+ rb_define_const(mCRFPP, "VERSION", SWIG_FromCharPtr("0.52"));
3946
+ }
3947
+