summaryrefslogtreecommitdiff
path: root/ext/dl
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-14 13:24:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-14 13:24:12 +0000
commit67bf09903f9391181841f3a6194282dd43c05ff2 (patch)
tree16f42329c75b5fe935e1390e54ccf75c0df85e26 /ext/dl
parent45fd88877fe91f2d73c971e87e513fb445d502d9 (diff)
* ext/dl/callback/mkcallback.rb (gencallback): suppress unused
variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl')
-rw-r--r--ext/dl/callback/mkcallback.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/dl/callback/mkcallback.rb b/ext/dl/callback/mkcallback.rb
index c644099..e94a196 100644
--- a/ext/dl/callback/mkcallback.rb
+++ b/ext/dl/callback/mkcallback.rb
@@ -121,20 +121,24 @@ def foreach_proc_entry
end
def gencallback(ty, calltype, proc_entry, argc, n)
- <<-EOS
+ dltype = DLTYPE[ty]
+ ret = dltype[:conv]
+ src = <<-EOS
#{calltype == STDCALL ? "\n#ifdef FUNC_STDCALL" : ""}
-static #{DLTYPE[ty][:type]}
+static #{dltype[:type]}
FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|i| "DLSTACK_TYPE stack#{i}"}.join(", ")})
{
- VALUE ret, cb#{argc > 0 ? ", args[#{argc}]" : ""};
+ VALUE #{ret ? "ret, " : ""}cb#{argc > 0 ? ", args[#{argc}]" : ""};
#{
(0...argc).collect{|i|
"\n args[#{i}] = PTR2NUM(stack#{i});"
}.join("")
}
cb = rb_ary_entry(rb_ary_entry(#{proc_entry}, #{ty}), #{(n * DLSTACK_SIZE) + argc});
- ret = rb_funcall2(cb, rb_dl_cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});
- return #{DLTYPE[ty][:conv] ? DLTYPE[ty][:conv] % "ret" : ""};
+ #{ret ? "ret = " : ""}rb_funcall2(cb, rb_dl_cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});
+ EOS
+ src << " return #{ret % "ret"};\n" if ret
+ src << <<-EOS
}
#{calltype == STDCALL ? "#endif\n" : ""}
EOS