summaryrefslogtreecommitdiff
path: root/ext/dl/lib
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-25 08:39:31 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-25 08:39:31 +0000
commitf7884c6beb479950cb8863a556df38ec29806b9f (patch)
tree16884e428d2573913c0576819ad40960d29d5300 /ext/dl/lib
parentf7a5ee56d72e4badc825d60af0d8efc36d3d95d1 (diff)
bugfix for [ruby-talk:121309].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/lib')
-rw-r--r--ext/dl/lib/dl/import.rb9
-rw-r--r--ext/dl/lib/dl/struct.rb3
-rw-r--r--ext/dl/lib/dl/types.rb22
3 files changed, 21 insertions, 13 deletions
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb
index f145c0fedf..99978c6a14 100644
--- a/ext/dl/lib/dl/import.rb
+++ b/ext/dl/lib/dl/import.rb
@@ -71,6 +71,9 @@ module DL
init_sym()
rty,renc,rdec,_,_,_ = @types.encode_type(ret)
+ if( !rty )
+ raise(TypeError, "unsupported type: #{ret}")
+ end
ty,enc,dec = encode_types(args)
symty = rty + ty
@@ -132,6 +135,9 @@ module DL
init_sym()
rty,_,rdec,_,_,_ = @types.encode_type(rettype)
+ if( !rty )
+ raise(TypeError, "unsupported type: #{rettype}")
+ end
ty,enc,dec = encode_types(argtypes)
symty = rty + ty
@@ -185,6 +191,9 @@ module DL
dec = nil
tys.each_with_index{|ty,idx|
ty,c1,c2,_,_,_ = @types.encode_type(ty)
+ if( !ty )
+ raise(TypeError, "unsupported type: #{ty}")
+ end
encty.push(ty)
if( enc )
if( c1 )
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 638b095312..d3107fcf50 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -129,6 +129,9 @@ module DL
raise(RuntimeError, "invalid element: #{elem}")
end
_,_,_,ty,enc,dec = @types.encode_type(ty)
+ if( !ty )
+ raise(TypeError, "unsupported type: #{ty}")
+ end
return [name,ty,num,enc,dec]
end
end # class Struct
diff --git a/ext/dl/lib/dl/types.rb b/ext/dl/lib/dl/types.rb
index a929df6ccd..cc73893049 100644
--- a/ext/dl/lib/dl/types.rb
+++ b/ext/dl/lib/dl/types.rb
@@ -179,17 +179,12 @@ module DL
dec = nil
senc = nil
sdec = nil
- ty1 = nil
- ty2 = nil
+ ty1 = ty
+ ty2 = ty
@TYDEFS.each{|t1,t2,c1,c2,t3,c3,c4|
-# if( t1.is_a?(String) )
-# t1 = Regexp.new("^" + t1 + "$")
-# end
- if( (t1.is_a?(Regexp) && (t1 =~ ty)) || (t1 == ty) )
- ty1 = ty.gsub(t1,t2) if t2
- ty2 = ty.gsub(t1,t3) if t3
+ if( (t1.is_a?(Regexp) && (t1 =~ ty1)) || (t1 == ty1) )
+ ty1 = ty1.gsub(t1,t2) if t2
ty1.strip! if ty1
- ty2.strip! if ty2
if( enc )
if( c1 )
conv1 = enc
@@ -210,6 +205,10 @@ module DL
dec = c2
end
end
+ end
+ if( (t1.is_a?(Regexp) && (t1 =~ ty2)) || (t1 == ty2) )
+ ty2 = ty2.gsub(t1,t3) if t3
+ ty2.strip! if ty2
if( senc )
if( c3 )
conv3 = senc
@@ -230,11 +229,8 @@ module DL
sdec = c4
end
end
- end
+ end
}
- if( ty1.length != 1 && ty2.length != 1 )
- raise(TypeError, "unknown type: #{orig_ty}.")
- end
return [ty1,enc,dec,ty2,senc,sdec]
end
end # end of Types