summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/dl/lib/dl/import.rb10
-rw-r--r--ext/dl/lib/dl/types.rb9
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],
]