diff options
author | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-27 15:29:28 +0000 |
---|---|---|
committer | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-27 15:29:28 +0000 |
commit | f5df3fcb1ec5bf86ec3660f34aa7381e66c7ce4e (patch) | |
tree | b5471beb94deb4c304f6e2e4be4c4b0908123a45 /ext/dl | |
parent | 9dcc08646f0a26b61ae162daffeb0ce5fbc60f0e (diff) |
merged from HEAD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl')
-rw-r--r-- | ext/dl/lib/dl/import.rb | 10 | ||||
-rw-r--r-- | ext/dl/lib/dl/types.rb | 9 |
2 files changed, 8 insertions, 11 deletions
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb index c0dfb5f705..1ab5145def 100644 --- a/ext/dl/lib/dl/import.rb +++ b/ext/dl/lib/dl/import.rb @@ -9,15 +9,11 @@ module DL module Internal def init_types() - if( !@types ) - @types = ::DL::Types.new - end + @types ||= ::DL::Types.new end def init_sym() - if( !@SYM ) - @SYM = {} - end + @SYM ||= {} end def [](name) @@ -85,7 +81,7 @@ module DL " args = enc.call(args) if enc", " r,rs = #{func}(*args)", " r = renc.call(r) if rdec", - " rs = dec.call(rs) if dec", + " rs = dec.call(rs) if (dec && rs)", " @retval = r", " @args = rs", " @retval", diff --git a/ext/dl/lib/dl/types.rb b/ext/dl/lib/dl/types.rb index b9a235f3b4..139426473a 100644 --- a/ext/dl/lib/dl/types.rb +++ b/ext/dl/lib/dl/types.rb @@ -53,7 +53,7 @@ module DL proc{|v| (v != 0) ? true : false}, proc{|v,len| v ? 1 : 0}, proc{|v,len| (v != 0) ? true : false}], - ["unsigned char", "I", + ["unsigned char", "C", proc{|v| [v].pack("C").unpack("c")[0]}, proc{|v| [v].pack("c").unpack("C")[0]}, proc{|v| [v].pack("C").unpack("c")[0]}, @@ -73,7 +73,7 @@ module DL proc{|v| [v].pack("l").unpack("L")[0]}, proc{|v| [v].pack("L").unpack("l")[0]}, proc{|v| [v].pack("l").unpack("L")[0]}], - ["unsigned char ref", "i", + ["unsigned char ref", "c", proc{|v| [v].pack("C").unpack("c")[0]}, proc{|v| [v].pack("c").unpack("C")[0]}, nil, nil], @@ -97,8 +97,9 @@ module DL ["long", "L", nil, nil, nil, nil], ["float", "F", nil, nil, nil, nil], ["double", "D", nil, nil, nil, nil], - [/^char\s*\*$/,"S",nil, nil, nil, nil], - [/^.+\*$/, "P", nil, nil, nil, nil], + [/^char\s*\*$/,"s",nil, nil, nil, nil], + [/^const char\s*\*$/,"S",nil, nil, nil, nil], + [/^.+\*$/, "p", nil, nil, nil, nil], [/^.+\[\]$/, "a", nil, nil, nil, nil], ["void", "0", nil, nil, nil, nil], ] |