⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tinysvm_wrap.cc

📁 机器学习工具:非常流行的一种分类器
💻 CC
📖 第 1 页 / 共 2 页
字号:
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.6u-20010826-1259 *  * This file is not intended to be easily readable and contains a number of  * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG  * interface file instead.  * ----------------------------------------------------------------------------- *//* Implementation : RUBY */#define SWIGRUBY/*********************************************************************** * common.swg * *     This file contains generic SWIG runtime support for pointer *     type checking as well as a few commonly used macros to control *     external linkage. * * Author : David Beazley (beazley@cs.uchicago.edu) * * Copyright (c) 1999-2000, The University of Chicago *  * This file may be freely redistributed without license or fee provided * this copyright message remains intact. ************************************************************************/#include <string.h>#if defined(_WIN32) || defined(__WIN32__)#       if defined(_MSC_VER)#               if defined(STATIC_LINKED)#                       define SWIGEXPORT(a) a#               else#                       define SWIGEXPORT(a) __declspec(dllexport) a#               endif#       else#               if defined(__BORLANDC__)#                       define SWIGEXPORT(a) a _export#               else#                       define SWIGEXPORT(a) a#       endif#endif#else#       define SWIGEXPORT(a) a#endif#ifdef SWIG_GLOBAL#define SWIGRUNTIME(a) SWIGEXPORT(a)#else#define SWIGRUNTIME(a) static a#endif#ifdef __cplusplusextern "C" {#endiftypedef struct swig_type_info {  const char  *name;                   void *(*converter)(void *);  const char  *str;  struct swig_type_info  *next;  struct swig_type_info  *prev;} swig_type_info;#ifdef SWIG_NOINCLUDESWIGEXPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);SWIGEXPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);SWIGEXPORT(void *) SWIG_TypeCast(swig_type_info *, void *);SWIGEXPORT(swig_type_info *) SWIG_TypeQuery(const char *);#elsestatic swig_type_info *swig_type_list = 0;/* Register a type mapping with the type-checking */SWIGRUNTIME(swig_type_info *)SWIG_TypeRegister(swig_type_info *ti){  swig_type_info *tc, *head, *ret, *next;  /* Check to see if this type has already been registered */  tc = swig_type_list;  while (tc) {    if (strcmp(tc->name, ti->name) == 0) {      /* Already exists in the table.  Just add additional types to the list */      head = tc;      next = tc->next;      goto l1;    }    tc = tc->prev;  }  head = ti;  next = 0;  /* Place in list */  ti->prev = swig_type_list;  swig_type_list = ti;  /* Build linked lists */ l1:  ret = head;  tc = ti + 1;  /* Patch up the rest of the links */  while (tc->name) {    head->next = tc;    tc->prev = head;    head = tc;    tc++;  }  head->next = next;  return ret;}/* Check the typename */SWIGRUNTIME(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *ty){  swig_type_info *s;  if (!ty) return 0;        /* Void pointer */  s = ty->next;             /* First element always just a name */  while (s) {    if (strcmp(s->name,c) == 0) {      if (s == ty->next) return s;      /* Move s to the top of the linked list */      s->prev->next = s->next;      if (s->next) {	s->next->prev = s->prev;      }      /* Insert s as second element in the list */      s->next = ty->next;      if (ty->next) ty->next->prev = s;      ty->next = s;      return s;    }    s = s->next;  }  return 0;}/* Cast a pointer (needed for C++ inheritance */SWIGRUNTIME(void *) SWIG_TypeCast(swig_type_info *ty, void *ptr) {  if ((!ty) || (!ty->converter)) return ptr;  return (*ty->converter)(ptr);}/* Search for a swig_type_info structure */SWIGRUNTIME(swig_type_info *)SWIG_TypeQuery(const char *name) {  swig_type_info *ty = swig_type_list;  while (ty) {    if (ty->str && (strcmp(name,ty->str) == 0)) return ty;    if (ty->name && (strcmp(name,ty->name) == 0)) return ty;    ty = ty->prev;  }  return 0;}#endif#ifdef __cplusplus}#endif/* ruby.swg */#include "ruby.h"#define NUM2USHRT(n) NUM2UINT(n)#define NUM2SHRT(n) (\    (SHRT_MIN <= NUM2INT(n) && NUM2INT(n) <= SHRT_MAX)\    ? (short)NUM2INT(n)\    : (rb_raise(rb_eArgError, "integer %d out of range of `short'",\               NUM2INT(n)), (short)0)\)#ifdef __cplusplus# define VALUEFUNC(f) ((VALUE (*)(...))f)# define VOIDFUNC(f) ((void (*)(...))f)#else# define VALUEFUNC(f) (f)# define VOIDFUNC(f) (f)#endif/* rubydef.swg */#ifdef __cplusplusextern "C" {#endifstatic VALUE _mSWIG = Qnil;static VALUE _cSWIG_Pointer = Qnil;/* Define ruby class for C type */SWIGRUNTIME(void)SWIG_define_class(swig_type_info *type){    VALUE klass;    char *klass_name = ALLOCA_N(char, 4 + strlen(type->name) + 1);    sprintf(klass_name, "TYPE%s", type->name);    if (NIL_P(_cSWIG_Pointer)) {	_cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);	rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");    }    klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);}/* Create a new pointer object */SWIGRUNTIME(VALUE)SWIG_NewPointerObj(void *ptr, swig_type_info *type){    char *klass_name;    VALUE klass;    if (!ptr)	return Qnil;    klass_name = ALLOCA_N(char, 4 + strlen(type->name) + 1);    sprintf(klass_name, "TYPE%s", type->name);    klass = rb_const_get(_mSWIG, rb_intern(klass_name));    return Data_Wrap_Struct(klass, 0, 0, ptr);}/* Get type mangle from class name */SWIGRUNTIME(char *)SWIG_MangleStr(VALUE obj){  char *c;  if (!rb_obj_is_kind_of(obj, _cSWIG_Pointer))    return 0;  c = rb_class2name(rb_class_of(obj));  c += strlen(c);  while (*(--c) != ':');  /* skip ":TYPE" */  c += 5;  return c;}/* Convert a pointer value */SWIGRUNTIME(void *)SWIG_ConvertPtr(VALUE obj, swig_type_info *ty){  char *c;  void *ptr;  swig_type_info *tc;  if ((c = SWIG_MangleStr(obj)) == NULL)    rb_raise(rb_eTypeError, "Expected %s", ty->str);	  Data_Get_Struct(obj, void, ptr);  if (ty) {    tc = SWIG_TypeCheck(c, ty);    if (!tc) rb_raise(rb_eTypeError, "Expected %s", ty->str);    ptr = SWIG_TypeCast(tc, ptr);  }  return ptr;}/* Check convert */SWIGRUNTIME(int)SWIG_CheckConvert(VALUE obj, swig_type_info *ty){  char *c = SWIG_MangleStr(obj);  if (!c)    return 0;  return SWIG_TypeCheck(c,ty) != 0;}#ifdef __cplusplus}#endif#define SWIG_init    Init_TinySVM#define SWIG_name    "TinySVM"static VALUE mTinySVM;#include <tinysvm.h>#include <ctype.h>#include <string.h>#define BaseExample TinySVM::BaseExample#define Example TinySVM::Example #define Model TinySVM::Model#undef VALUEFUNC#define VALUEFUNC(f) ((VALUE (*)())f)static VALUE cBaseExample;static void free_BaseExample(BaseExample *);#define Wrap_BaseExample(klass, ptr) (\    (ptr) ? Data_Wrap_Struct(klass, 0, VOIDFUNC(free_BaseExample), ptr) : Qnil )#define Get_BaseExample(val, ptr) {\    if (NIL_P(val)) ptr = NULL;\    else {\        if (!rb_obj_is_kind_of(val, cBaseExample))\            rb_raise(rb_eTypeError, "wrong argument type (expected BaseExample)");\        Data_Get_Struct(val, BaseExample, ptr);\        if (!ptr) rb_raise(rb_eRuntimeError, "This BaseExample already released");\    }\}static VALUE cModel;static void free_Model(Model *);#define Wrap_Model(klass, ptr) (\    (ptr) ? Data_Wrap_Struct(klass, 0, VOIDFUNC(free_Model), ptr) : Qnil )#define Get_Model(val, ptr) {\    if (NIL_P(val)) ptr = NULL;\    else {\        if (!rb_obj_is_kind_of(val, cModel))\            rb_raise(rb_eTypeError, "wrong argument type (expected Model)");\        Data_Get_Struct(val, Model, ptr);\        if (!ptr) rb_raise(rb_eRuntimeError, "This Model already released");\    }\}static VALUE cExample;static void free_Example(Example *);#define Wrap_Example(klass, ptr) (\    (ptr) ? Data_Wrap_Struct(klass, 0, VOIDFUNC(free_Example), ptr) : Qnil )#define Get_Example(val, ptr) {\    if (NIL_P(val)) ptr = NULL;\    else {\        if (!rb_obj_is_kind_of(val, cExample))\            rb_raise(rb_eTypeError, "wrong argument type (expected Example)");\        Data_Get_Struct(val, Example, ptr);\        if (!ptr) rb_raise(rb_eRuntimeError, "This Example already released");\    }\}/* -------- TYPES TABLE (BEGIN) -------- */static swig_type_info *swig_types[1];/* -------- TYPES TABLE (END) -------- */static VALUE_wrap_BaseExample_add(VALUE self, VALUE varg1) {    BaseExample *arg0 ;    char *arg1 ;    int result ;    VALUE vresult = Qnil;        Get_BaseExample(self, arg0);    arg1 = STR2CSTR(varg1);    result = (int )arg0->add((char const *)arg1);    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_set(VALUE self, VALUE varg1, VALUE varg2) {    BaseExample *arg0 ;    int arg1 ;    char *arg2 ;    int result ;    VALUE vresult = Qnil;        Get_BaseExample(self, arg0);    arg1 = NUM2INT(varg1);    arg2 = STR2CSTR(varg2);    result = (int )arg0->set(arg1,(char const *)arg2);    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_get(VALUE self, VALUE varg1) {    BaseExample *arg0 ;    int arg1 ;    char *result ;    VALUE vresult = Qnil;        Get_BaseExample(self, arg0);    arg1 = NUM2INT(varg1);    result = (char *)arg0->get(arg1);    vresult = rb_str_new2(result);    return vresult;}static VALUE_wrap_BaseExample_remove(VALUE self, VALUE varg1) {    BaseExample *arg0 ;    int arg1 ;    int result ;    VALUE vresult = Qnil;        Get_BaseExample(self, arg0);    arg1 = NUM2INT(varg1);    result = (int )arg0->remove(arg1);    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_clear(VALUE self) {    BaseExample *arg0 ;    int result ;    VALUE vresult = Qnil;        Get_BaseExample(self, arg0);    result = (int )arg0->clear();    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_size(VALUE self) {    BaseExample *arg0 ;    int result ;    VALUE vresult = Qnil;        Get_BaseExample(self, arg0);    result = (int )arg0->size();    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_read(int argc, VALUE *argv, VALUE self) {    VALUE varg1 ;    VALUE varg2 ;    VALUE varg3 ;    BaseExample *arg0 ;    char *arg1 ;    char *arg2 = "r" ;    int arg3 = 0 ;    int result ;    VALUE vresult = Qnil;        rb_scan_args(argc, argv, "12", &varg1, &varg2, &varg3);    Get_BaseExample(self, arg0);    arg1 = STR2CSTR(varg1);    if (argc > 1) {        arg2 = STR2CSTR(varg2);    }    if (argc > 2) {        arg3 = NUM2INT(varg3);    }    result = (int )arg0->read((char const *)arg1,(char const *)arg2,arg3);    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_write(int argc, VALUE *argv, VALUE self) {    VALUE varg1 ;    VALUE varg2 ;    VALUE varg3 ;    BaseExample *arg0 ;    char *arg1 ;    char *arg2 = "w" ;    int arg3 = 0 ;    int result ;    VALUE vresult = Qnil;        rb_scan_args(argc, argv, "12", &varg1, &varg2, &varg3);    Get_BaseExample(self, arg0);    arg1 = STR2CSTR(varg1);    if (argc > 1) {        arg2 = STR2CSTR(varg2);    }    if (argc > 2) {        arg3 = NUM2INT(varg3);    }    result = (int )arg0->write((char const *)arg1,(char const *)arg2,arg3);    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_readSVindex(int argc, VALUE *argv, VALUE self) {    VALUE varg1 ;    VALUE varg2 ;    VALUE varg3 ;    BaseExample *arg0 ;    char *arg1 ;    char *arg2 = "r" ;    int arg3 = 0 ;    int result ;    VALUE vresult = Qnil;        rb_scan_args(argc, argv, "12", &varg1, &varg2, &varg3);    Get_BaseExample(self, arg0);    arg1 = STR2CSTR(varg1);    if (argc > 1) {        arg2 = STR2CSTR(varg2);    }    if (argc > 2) {        arg3 = NUM2INT(varg3);    }    result = (int )arg0->readSVindex((char const *)arg1,(char const *)arg2,arg3);    vresult = INT2NUM(result);    return vresult;}static VALUE_wrap_BaseExample_writeSVindex(int argc, VALUE *argv, VALUE self) {    VALUE varg1 ;    VALUE varg2 ;    VALUE varg3 ;    BaseExample *arg0 ;    char *arg1 ;    char *arg2 = "w" ;    int arg3 = 0 ;    int result ;    VALUE vresult = Qnil;        rb_scan_args(argc, argv, "12", &varg1, &varg2, &varg3);    Get_BaseExample(self, arg0);    arg1 = STR2CSTR(varg1);    if (argc > 1) {        arg2 = STR2CSTR(varg2);    }    if (argc > 2) {        arg3 = NUM2INT(varg3);    }    result = (int )arg0->writeSVindex((char const *)arg1,(char const *)arg2,arg3);    vresult = INT2NUM(result);    return vresult;}static voidfree_BaseExample(BaseExample *arg0) {    delete arg0;}int  BaseExample_append(BaseExample *self,char *f) {    {        return self->write(f,"a");     }}static VALUE_wrap_BaseExample_append(VALUE self, VALUE varg1) {    BaseExample *arg0 ;    char *arg1 ;    int result ;    VALUE vresult = Qnil;        Get_BaseExample(self, arg0);    arg1 = STR2CSTR(varg1);    result = (int )BaseExample_append(arg0,arg1);    vresult = INT2NUM(result);    return vresult;}int  BaseExample_appendSVindex(BaseExample *self,char *f) {    {        return self->writeSVindex(f,"a");     }}static VALUE_wrap_BaseExample_appendSVindex(VALUE self, VALUE varg1) {    BaseExample *arg0 ;    char *arg1 ;    int result ;    VALUE vresult = Qnil;    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -