Skip to content

Commit f698a36

Browse files
author
support
committed
upgraded to LIBSVM 2.9
1 parent 2851070 commit f698a36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+28369
-177
lines changed

README.rdoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
This is the Ruby port of the LIBSVM Python SWIG (Simplified Wrapper and
1010
Interface Generator) interface.
1111

12-
A slightly modified version of LIBSVM 2.89 is included, it allows turrning on/off
12+
A slightly modified version of LIBSVM 2.9 is included, it allows turrning on/off
1313
the debug log. You don't need your own copy of SWIG to use this library - all
1414
needed files are generated using SWIG already.
1515

1616
Look for the README file in the ruby subdirectory for instructions.
17-
The binaries included were built under Ubuntu Linux 2.6.24-23-generic,
18-
you should run make under the libsvm-2.89 and libsvm-2.89/ruby
17+
The binaries included were built under Ubuntu Linux 2.6.28-18-generic x86_64,
18+
you should run make under the libsvm-2.9 and libsvm-2.9/ruby
1919
directories to regenerate the executables for your environment.
2020

2121
LIBSVM is in use at http://tweetsentiments.com - A Twitter / Tweet sentiment
2222
analysis application
2323

2424
== INSTALL:
25-
Currently the gem is available on linux only(tested on Ubuntu 8 and Fedora 9/10,
25+
Currently the gem is available on linux only(tested on Ubuntu 8-9 and Fedora 9-12,
2626
and on OS X by danielsdeleo), and you will need g++ installed to compile the
2727
native code.
2828

Rakefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ task :default => ["sync_files","make_gem"]
66

77
EXT = "ext/svm?.#{Hoe::DLEXT}"
88

9-
Hoe.new('libsvm-ruby-swig', '0.3.3') do |p|
9+
Hoe.new('libsvm-ruby-swig', '0.4.0') do |p|
1010
p.author = 'Tom Zeng'
1111
p.email = '[email protected]'
1212
p.url = 'http://www.tomzconsulting.com'
@@ -27,10 +27,10 @@ file EXT => ["ext/extconf.rb", "ext/libsvm_wrap.cxx", "ext/svm.cpp", "ext/svm.h"
2727
end
2828

2929
task :sync_files do
30-
cp "libsvm-2.89/svm.h","ext/"
31-
cp "libsvm-2.89/svm.cpp","ext/"
32-
cp "libsvm-2.89/ruby/libsvm_wrap.cxx","ext/"
33-
cp "libsvm-2.89/ruby/svm.rb","lib/"
30+
cp "libsvm-2.9/svm.h","ext/"
31+
cp "libsvm-2.9/svm.cpp","ext/"
32+
cp "libsvm-2.9/ruby/libsvm_wrap.cxx","ext/"
33+
cp "libsvm-2.9/ruby/svm.rb","lib/"
3434
end
3535

3636
task :test do

ext/libsvm_wrap.cxx

Lines changed: 57 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* ----------------------------------------------------------------------------
22
* This file was automatically generated by SWIG (http://www.swig.org).
3-
* Version 1.3.38
3+
* Version 1.3.36
44
*
55
* This file is not intended to be easily readable and contains a number of
66
* coding conventions designed to improve portability and efficiency. Do not make
@@ -10,23 +10,19 @@
1010

1111
#define SWIGRUBY
1212

13-
1413
#ifdef __cplusplus
15-
/* SwigValueWrapper is described in swig.swg */
1614
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);
15+
T *tt;
2516
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; }
17+
SwigValueWrapper() : tt(0) { }
18+
SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
19+
SwigValueWrapper(const T& t) : tt(new T(t)) { }
20+
~SwigValueWrapper() { delete tt; }
21+
SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
22+
operator T&() const { return *tt; }
23+
T *operator&() { return tt; }
24+
private:
25+
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
3026
};
3127

3228
template <typename T> T SwigValueInit() {
@@ -255,7 +251,7 @@ template <typename T> T SwigValueInit() {
255251
/* -----------------------------------------------------------------------------
256252
* swigrun.swg
257253
*
258-
* This file contains generic C API SWIG runtime support for pointer
254+
* This file contains generic CAPI SWIG runtime support for pointer
259255
* type checking.
260256
* ----------------------------------------------------------------------------- */
261257

@@ -274,11 +270,11 @@ template <typename T> T SwigValueInit() {
274270

275271
/*
276272
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'.
273+
creating a static or dynamic library from the swig runtime code.
274+
In 99.9% of the cases, swig just needs to declare them as 'static'.
279275
280-
But only do this if strictly necessary, ie, if you have problems
281-
with your compiler or suchlike.
276+
But only do this if is strictly necessary, ie, if you have problems
277+
with your compiler or so.
282278
*/
283279

284280
#ifndef SWIGRUNTIME
@@ -305,22 +301,22 @@ template <typename T> T SwigValueInit() {
305301
/*
306302
Flags/methods for returning states.
307303
308-
The SWIG conversion methods, as ConvertPtr, return and integer
304+
The swig conversion methods, as ConvertPtr, return and integer
309305
that tells if the conversion was successful or not. And if not,
310306
an error code can be returned (see swigerrors.swg for the codes).
311307
312308
Use the following macros/flags to set or process the returning
313309
states.
314310
315-
In old versions of SWIG, code such as the following was usually written:
311+
In old swig versions, you usually write code as:
316312
317313
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
318314
// success code
319315
} else {
320316
//fail code
321317
}
322318
323-
Now you can be more explicit:
319+
Now you can be more explicit as:
324320
325321
int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
326322
if (SWIG_IsOK(res)) {
@@ -329,7 +325,7 @@ template <typename T> T SwigValueInit() {
329325
// fail code
330326
}
331327
332-
which is the same really, but now you can also do
328+
that seems to be the same, but now you can also do
333329
334330
Type *ptr;
335331
int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
@@ -347,7 +343,7 @@ template <typename T> T SwigValueInit() {
347343
348344
I.e., now SWIG_ConvertPtr can return new objects and you can
349345
identify the case and take care of the deallocation. Of course that
350-
also requires SWIG_ConvertPtr to return new result values, such as
346+
requires also to SWIG_ConvertPtr to return new result values, as
351347
352348
int SWIG_ConvertPtr(obj, ptr,...) {
353349
if (<obj is ok>) {
@@ -365,7 +361,7 @@ template <typename T> T SwigValueInit() {
365361
366362
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
367363
more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
368-
SWIG errors code.
364+
swig errors code.
369365
370366
Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
371367
allows to return the 'cast rank', for example, if you have this
@@ -379,8 +375,9 @@ template <typename T> T SwigValueInit() {
379375
fooi(1) // cast rank '0'
380376
381377
just use the SWIG_AddCast()/SWIG_CheckState()
382-
*/
383378
379+
380+
*/
384381
#define SWIG_OK (0)
385382
#define SWIG_ERROR (-1)
386383
#define SWIG_IsOK(r) (r >= 0)
@@ -405,6 +402,7 @@ template <typename T> T SwigValueInit() {
405402
#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
406403
#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
407404

405+
408406
/* Cast-Rank Mode */
409407
#if defined(SWIG_CASTRANK_MODE)
410408
# ifndef SWIG_TypeRank
@@ -427,6 +425,8 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
427425
#endif
428426

429427

428+
429+
430430
#include <string.h>
431431

432432
#ifdef __cplusplus
@@ -523,58 +523,40 @@ SWIG_TypeCompare(const char *nb, const char *tb) {
523523
}
524524

525525

526+
/* think of this as a c++ template<> or a scheme macro */
527+
#define SWIG_TypeCheck_Template(comparison, ty) \
528+
if (ty) { \
529+
swig_cast_info *iter = ty->cast; \
530+
while (iter) { \
531+
if (comparison) { \
532+
if (iter == ty->cast) return iter; \
533+
/* Move iter to the top of the linked list */ \
534+
iter->prev->next = iter->next; \
535+
if (iter->next) \
536+
iter->next->prev = iter->prev; \
537+
iter->next = ty->cast; \
538+
iter->prev = 0; \
539+
if (ty->cast) ty->cast->prev = iter; \
540+
ty->cast = iter; \
541+
return iter; \
542+
} \
543+
iter = iter->next; \
544+
} \
545+
} \
546+
return 0
547+
526548
/*
527549
Check the typename
528550
*/
529551
SWIGRUNTIME swig_cast_info *
530552
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;
553+
SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
551554
}
552555

553-
/*
554-
Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
555-
*/
556+
/* Same as previous function, except strcmp is replaced with a pointer comparison */
556557
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;
558+
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
559+
SWIG_TypeCheck_Template(iter->type == from, into);
578560
}
579561

580562
/*
@@ -1825,7 +1807,7 @@ static VALUE mLibsvm;
18251807
#define SWIG_RUBY_THREAD_END_BLOCK
18261808

18271809

1828-
#define SWIGVERSION 0x010338
1810+
#define SWIGVERSION 0x010336
18291811
#define SWIG_VERSION SWIGVERSION
18301812

18311813

@@ -1866,7 +1848,7 @@ SWIG_ruby_failed(void)
18661848
}
18671849

18681850

1869-
/*@SWIG:/usr/local/share/swig/1.3.38/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1851+
/*@SWIG:/usr/share/swig1.3/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
18701852
SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
18711853
{
18721854
VALUE obj = args[0];
@@ -1911,7 +1893,7 @@ SWIG_AsVal_int (VALUE obj, int *val)
19111893
}
19121894

19131895

1914-
/*@SWIG:/usr/local/share/swig/1.3.38/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
1896+
/*@SWIG:/usr/share/swig1.3/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
19151897
SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args)
19161898
{
19171899
VALUE obj = args[0];
@@ -2037,7 +2019,7 @@ SWIG_FromCharPtr(const char *cptr)
20372019
}
20382020

20392021

2040-
/*@SWIG:/usr/local/share/swig/1.3.38/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
2022+
/*@SWIG:/usr/share/swig1.3/ruby/rubyprimtypes.swg,23,%ruby_aux_method@*/
20412023
SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
20422024
{
20432025
VALUE obj = args[0];

0 commit comments

Comments
 (0)