M
Michael Hale
I have a library that I wrapped with SWIG. One of the SWIG generated
functions looks like this:
static VALUE
_wrap_NSCalculateGap(int argc, VALUE *argv, VALUE self) {
int arg1 ;
int arg2 ;
unsigned long arg3 ;
double arg4 ;
unsigned long *arg5 = (unsigned long *) 0 ;
int arg6 ;
int arg7 ;
int arg8 ;
int result;
VALUE vresult = Qnil;
if ((argc < 8) || (argc > 8))
rb_raise(rb_eArgError, "wrong # of arguments(%d for 8)",argc);
arg1 = NUM2INT(argv[0]);
arg2 = NUM2INT(argv[1]);
arg3 = NUM2ULONG(argv[2]);
arg4 = (double) NUM2DBL(argv[3]);
SWIG_ConvertPtr(argv[4], (void **) &arg5, SWIGTYPE_p_unsigned_long,
1);
arg6 = NUM2INT(argv[5]);
arg7 = NUM2INT(argv[6]);
arg8 = NUM2INT(argv[7]);
result =
(int)NSCalculateGap(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
vresult = INT2NUM(result);
return vresult;
}
How should I call this function from ruby? I am having problems with
arg5. Here is my current attempt:
pulGap = 0
Smartlib::NSCalculateGap(iMode, iSpeed, ulPacketLength, dValue,
pulGap, hub, slot, port)
However this gives me the following error:
TypeError: wrong argument type Fixnum (expected Data)
Also here is an example from the library documetation:
int iMode = PERCENT_LOAD_TO_GAP_BITS
int iSpeed = SPEED_10GHZ
unsigned long ulPacketLength = 100
double dValue = 95.5
unsigned long ulGap = 0;
NSCalculateGap(iMode,iSpeed,dValue,&ulGap,iHub,iSlot,iPort);
Thanks, Michael
"OS X: because it was easier to make UNIX user-friendly than to fix
Windows"
functions looks like this:
static VALUE
_wrap_NSCalculateGap(int argc, VALUE *argv, VALUE self) {
int arg1 ;
int arg2 ;
unsigned long arg3 ;
double arg4 ;
unsigned long *arg5 = (unsigned long *) 0 ;
int arg6 ;
int arg7 ;
int arg8 ;
int result;
VALUE vresult = Qnil;
if ((argc < 8) || (argc > 8))
rb_raise(rb_eArgError, "wrong # of arguments(%d for 8)",argc);
arg1 = NUM2INT(argv[0]);
arg2 = NUM2INT(argv[1]);
arg3 = NUM2ULONG(argv[2]);
arg4 = (double) NUM2DBL(argv[3]);
SWIG_ConvertPtr(argv[4], (void **) &arg5, SWIGTYPE_p_unsigned_long,
1);
arg6 = NUM2INT(argv[5]);
arg7 = NUM2INT(argv[6]);
arg8 = NUM2INT(argv[7]);
result =
(int)NSCalculateGap(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);
vresult = INT2NUM(result);
return vresult;
}
How should I call this function from ruby? I am having problems with
arg5. Here is my current attempt:
pulGap = 0
Smartlib::NSCalculateGap(iMode, iSpeed, ulPacketLength, dValue,
pulGap, hub, slot, port)
However this gives me the following error:
TypeError: wrong argument type Fixnum (expected Data)
Also here is an example from the library documetation:
int iMode = PERCENT_LOAD_TO_GAP_BITS
int iSpeed = SPEED_10GHZ
unsigned long ulPacketLength = 100
double dValue = 95.5
unsigned long ulGap = 0;
NSCalculateGap(iMode,iSpeed,dValue,&ulGap,iHub,iSlot,iPort);
Thanks, Michael
"OS X: because it was easier to make UNIX user-friendly than to fix
Windows"