зеркало из https://github.com/github/ruby.git
* ext/dl/mkcallback.rb (foreach_proc_entry): extracted.
(gencallback): ditto. (gen_push_proc_ary): ditto. (gen_push_addr_ary): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a2a32f9f02
Коммит
f69c1c5eda
|
@ -1,3 +1,10 @@
|
|||
Sun Aug 31 01:27:46 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/dl/mkcallback.rb (foreach_proc_entry): extracted.
|
||||
(gencallback): ditto.
|
||||
(gen_push_proc_ary): ditto.
|
||||
(gen_push_addr_ary): ditto.
|
||||
|
||||
Sat Aug 30 23:51:01 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
|
||||
|
||||
* test/rinda/test_tuplebag.rb (test_has_expires_eh): fix failures
|
||||
|
|
|
@ -97,19 +97,22 @@ VALUE rb_DLStdcallCallbackAddrs, rb_DLStdcallCallbackProcs;
|
|||
static ID cb_call;
|
||||
EOS
|
||||
|
||||
for calltype in CALLTYPES
|
||||
case calltype
|
||||
when CDECL
|
||||
proc_entry = "rb_DLCdeclCallbackProcs"
|
||||
when STDCALL
|
||||
proc_entry = "rb_DLStdcallCallbackProcs"
|
||||
else
|
||||
raise "unknown calltype: #{calltype}"
|
||||
def foreach_proc_entry
|
||||
for calltype in CALLTYPES
|
||||
case calltype
|
||||
when CDECL
|
||||
proc_entry = "rb_DLCdeclCallbackProcs"
|
||||
when STDCALL
|
||||
proc_entry = "rb_DLStdcallCallbackProcs"
|
||||
else
|
||||
raise "unknown calltype: #{calltype}"
|
||||
end
|
||||
yield calltype, proc_entry
|
||||
end
|
||||
for ty in 0..(MAX_DLTYPE-1)
|
||||
for argc in 0..(DLSTACK_SIZE-1)
|
||||
for n in 0..(MAX_CALLBACK-1)
|
||||
$out << (<<-EOS)
|
||||
end
|
||||
|
||||
def gencallback(ty, calltype, proc_entry, argc, n)
|
||||
<<-EOS
|
||||
|
||||
static #{DLTYPE[ty][:type]}
|
||||
FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|i| "DLSTACK_TYPE stack" + i.to_s}.join(", ")})
|
||||
|
@ -125,7 +128,32 @@ FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|
|
|||
return #{DLTYPE[ty][:conv] ? DLTYPE[ty][:conv] % "ret" : ""};
|
||||
}
|
||||
|
||||
EOS
|
||||
EOS
|
||||
end
|
||||
|
||||
def gen_push_proc_ary(ty, aryname)
|
||||
sprintf(" rb_ary_push(#{aryname}, rb_ary_new3(%d,%s));",
|
||||
MAX_CALLBACK * DLSTACK_SIZE,
|
||||
(0...MAX_CALLBACK).collect{
|
||||
(0...DLSTACK_SIZE).collect{ "Qnil" }.join(",")
|
||||
}.join(","))
|
||||
end
|
||||
|
||||
def gen_push_addr_ary(ty, aryname, calltype)
|
||||
sprintf(" rb_ary_push(#{aryname}, rb_ary_new3(%d,%s));",
|
||||
MAX_CALLBACK * DLSTACK_SIZE,
|
||||
(0...MAX_CALLBACK).collect{|i|
|
||||
(0...DLSTACK_SIZE).collect{|argc|
|
||||
"PTR2NUM(%s)" % func_name(ty,argc,i,calltype)
|
||||
}.join(",")
|
||||
}.join(","))
|
||||
end
|
||||
|
||||
foreach_proc_entry do |calltype, proc_entry|
|
||||
for ty in 0..(MAX_DLTYPE-1)
|
||||
for argc in 0..(DLSTACK_SIZE-1)
|
||||
for n in 0..(MAX_CALLBACK-1)
|
||||
$out << gencallback(ty, calltype, proc_entry, argc, n)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -152,42 +180,22 @@ rb_dl_init_callbacks()
|
|||
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
sprintf(" rb_ary_push(rb_DLCdeclCallbackProcs, rb_ary_new3(%d,%s));",
|
||||
MAX_CALLBACK * DLSTACK_SIZE,
|
||||
(0...MAX_CALLBACK).collect{
|
||||
(0...DLSTACK_SIZE).collect{ "Qnil" }.join(",")
|
||||
}.join(","))
|
||||
gen_push_proc_ary(ty, "rb_DLCdeclCallbackProcs")
|
||||
}.join("\n")
|
||||
}
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
sprintf(" rb_ary_push(rb_DLCdeclCallbackAddrs, rb_ary_new3(%d,%s));",
|
||||
MAX_CALLBACK * DLSTACK_SIZE,
|
||||
(0...MAX_CALLBACK).collect{|i|
|
||||
(0...DLSTACK_SIZE).collect{|argc|
|
||||
"PTR2NUM(%s)" % func_name(ty,argc,i,CDECL)
|
||||
}.join(",")
|
||||
}.join(","))
|
||||
gen_push_addr_ary(ty, "rb_DLCdeclCallbackAddrs", CDECL)
|
||||
}.join("\n")
|
||||
}
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
sprintf(" rb_ary_push(rb_DLStdcallCallbackProcs, rb_ary_new3(%d,%s));",
|
||||
MAX_CALLBACK * DLSTACK_SIZE,
|
||||
(0...MAX_CALLBACK).collect{
|
||||
(0...DLSTACK_SIZE).collect{ "Qnil" }.join(",")
|
||||
}.join(","))
|
||||
gen_push_proc_ary(ty, "rb_DLStdcallCallbackProcs")
|
||||
}.join("\n")
|
||||
}
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
sprintf(" rb_ary_push(rb_DLStdcallCallbackAddrs, rb_ary_new3(%d,%s));",
|
||||
MAX_CALLBACK * DLSTACK_SIZE,
|
||||
(0...MAX_CALLBACK).collect{|i|
|
||||
(0...DLSTACK_SIZE).collect{|argc|
|
||||
"PTR2NUM(%s)" % func_name(ty,argc,i,STDCALL)
|
||||
}.join(",")
|
||||
}.join(","))
|
||||
gen_push_addr_ary(ty, "rb_DLStdcallCallbackAddrs", STDCALL)
|
||||
}.join("\n")
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче