mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ext/dl/ptr.c: missing break in switch statements.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cc3b6901b2
commit
076a82105a
3 changed files with 36 additions and 14 deletions
|
@ -1,3 +1,7 @@
|
|||
Fri Apr 26 06:48:23 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp>
|
||||
|
||||
* ext/dl/ptr.c (cary2ary): missing break in switch statements.
|
||||
|
||||
Fri Apr 26 09:35:47 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* eval.c (rb_proc_new): make Proc from C function. [new]
|
||||
|
|
31
ext/dl/ptr.c
31
ext/dl/ptr.c
|
@ -621,33 +621,34 @@ cary2ary(void *ptr, char t, int len)
|
|||
|
||||
if( len == 1 ){
|
||||
switch( t ){
|
||||
case 'I': case 'i':
|
||||
case 'I':
|
||||
elem = INT2NUM(*((int*)ptr));
|
||||
ptr = (char *)ptr + sizeof(int);
|
||||
break;
|
||||
case 'L': case 'l':
|
||||
case 'L':
|
||||
elem = DLLONG2NUM(*((long*)ptr));
|
||||
ptr = (char *)ptr + sizeof(long);
|
||||
break;
|
||||
case 'P': case 'p':
|
||||
case 'P':
|
||||
elem = rb_dlptr_new(*((void**)ptr),0, 0);
|
||||
ptr = (char *)ptr + sizeof(void*);
|
||||
break;
|
||||
case 'F': case 'f':
|
||||
case 'F':
|
||||
elem = rb_float_new(*((float*)ptr));
|
||||
ptr = (char *)ptr + sizeof(float);
|
||||
break;
|
||||
case 'D': case 'd':
|
||||
case 'D':
|
||||
elem = rb_float_new(*((float*)ptr));
|
||||
ptr = (char *)ptr + sizeof(double);
|
||||
break;
|
||||
case 'C': case 'c':
|
||||
case 'C':
|
||||
elem = INT2NUM(*((char*)ptr));
|
||||
ptr = (char *)ptr + sizeof(char);
|
||||
break;
|
||||
case 'H': case 'h':
|
||||
case 'H':
|
||||
elem = INT2NUM(*((short*)ptr));
|
||||
ptr = (char *)ptr + sizeof(short);
|
||||
break;
|
||||
default:
|
||||
rb_raise(rb_eDLTypeError, "unsupported type '%c'", t);
|
||||
};
|
||||
|
@ -657,33 +658,34 @@ cary2ary(void *ptr, char t, int len)
|
|||
ary = rb_ary_new();
|
||||
for( i=0; i < len; i++ ){
|
||||
switch( t ){
|
||||
case 'I': case 'i':
|
||||
case 'I':
|
||||
elem = INT2NUM(*((int*)ptr));
|
||||
ptr = (char *)ptr + sizeof(int);
|
||||
break;
|
||||
case 'L': case 'l':
|
||||
case 'L':
|
||||
elem = DLLONG2NUM(*((long*)ptr));
|
||||
ptr = (char *)ptr + sizeof(long);
|
||||
break;
|
||||
case 'P': case 'p':
|
||||
case 'P':
|
||||
elem = rb_dlptr_new(*((void**)ptr), 0, 0);
|
||||
ptr = (char *)ptr + sizeof(void*);
|
||||
break;
|
||||
case 'F': case 'f':
|
||||
case 'F':
|
||||
elem = rb_float_new(*((float*)ptr));
|
||||
ptr = (char *)ptr + sizeof(float);
|
||||
break;
|
||||
case 'D': case 'd':
|
||||
case 'D':
|
||||
elem = rb_float_new(*((float*)ptr));
|
||||
ptr = (char *)ptr + sizeof(double);
|
||||
break;
|
||||
case 'C': case 'c':
|
||||
case 'C':
|
||||
elem = INT2NUM(*((char*)ptr));
|
||||
ptr = (char *)ptr + sizeof(char);
|
||||
break;
|
||||
case 'H': case 'h':
|
||||
case 'H':
|
||||
elem = INT2NUM(*((short*)ptr));
|
||||
ptr = (char *)ptr + sizeof(short);
|
||||
break;
|
||||
default:
|
||||
rb_raise(rb_eDLTypeError, "unsupported type '%c'", t);
|
||||
};
|
||||
|
@ -733,6 +735,7 @@ rb_dlptr_aref(int argc, VALUE argv[], VALUE self)
|
|||
break;
|
||||
case 'P':
|
||||
DLALIGN(data->ptr,offset,VOIDP_ALIGN);
|
||||
break;
|
||||
case 'F':
|
||||
DLALIGN(data->ptr,offset,FLOAT_ALIGN);
|
||||
break;
|
||||
|
|
|
@ -264,6 +264,7 @@ assert("data_aref", :must,
|
|||
ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name2")
|
||||
assert("data_aref", :must,
|
||||
ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name2") unless (Fixnum === :-)
|
||||
|
||||
ptr = ptr["next"]
|
||||
ptr.struct!("C1024P", :name, :next)
|
||||
assert("data_aref", :must,
|
||||
|
@ -272,3 +273,17 @@ assert("data_aref", :must,
|
|||
ptr["name"].collect{|c| c.chr}.join.split("\0")[0] == "name1") unless (Fixnum === :-)
|
||||
|
||||
GC.start
|
||||
|
||||
ptr = DL::malloc(1024)
|
||||
ptr.struct!("CHIL", "c", "h", "i", "l")
|
||||
ptr["c"] = 1
|
||||
ptr["h"] = 2
|
||||
ptr["i"] = 3
|
||||
ptr["l"] = 4
|
||||
assert("struct!", :must,
|
||||
ptr["c"] == 1 &&
|
||||
ptr["h"] == 2 &&
|
||||
ptr["i"] == 3 &&
|
||||
ptr["l"] == 4)
|
||||
|
||||
GC.start
|
||||
|
|
Loading…
Reference in a new issue