Many bug fixes to Ruby module
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@855 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fec0d06fa7
commit
feb39b0fd2
5 changed files with 214 additions and 103 deletions
|
|
@ -88,13 +88,13 @@ static VALUE ptrvalue(VALUE _PTRVALUE, int index, char *type) {
|
|||
}
|
||||
/* Now we have a datatype. Try to figure out what to do about it */
|
||||
if (strcmp(type,"int") == 0) {
|
||||
obj = LONG2NUM((long) *(((int *) ptr) + index));
|
||||
obj = INT2NUM((long) *(((int *) ptr) + index));
|
||||
} else if (strcmp(type,"double") == 0) {
|
||||
obj = rb_float_new((double) *(((double *) ptr)+index));
|
||||
} else if (strcmp(type,"short") == 0) {
|
||||
obj = LONG2NUM((long) *(((short *) ptr)+index));
|
||||
obj = INT2NUM((long) *(((short *) ptr)+index));
|
||||
} else if (strcmp(type,"long") == 0) {
|
||||
obj = LONG2NUM((long) *(((long *) ptr)+index));
|
||||
obj = INT2NUM((long) *(((long *) ptr)+index));
|
||||
} else if (strcmp(type,"float") == 0) {
|
||||
obj = rb_float_new((double) *(((float *) ptr)+index));
|
||||
} else if (strcmp(type,"char") == 0) {
|
||||
|
|
|
|||
5
SWIG/Lib/ruby/ruby.i
Normal file
5
SWIG/Lib/ruby/ruby.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
%typemap(ruby,varin) char * "
|
||||
Check_Type($source, T_STRING);
|
||||
if ($target) free($target);
|
||||
$target = xmalloc(RSTRING($source)->len + 1);
|
||||
strncpy($target, STR2CSTR($source), RSTRING($source)->len + 1);";
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
/* ruby.swg */
|
||||
#include "ruby.h"
|
||||
|
||||
#define UINT2NUM(v) rb_uint2inum(v)
|
||||
#define NUM2USHRT(n) NUM2UINT(n)
|
||||
#define NUM2SHRT(n) (\
|
||||
(SHRT_MIN <= NUM2INT(n) && NUM2INT(n) <= SHRT_MAX)\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue