Kouhei Sutou
kou****@cozmi*****
2008年 5月 9日 (金) 17:28:21 JST
須藤です。
Rubyバインディングの.iでは自前で複数の戻り値に対応していますが、
これを%append_outputを使うようにしてはいかがでしょうか?
全部やろうかと思ったのですが、多かったので試しに一つだけやって
みました。
Index: bindings/ruby/senna_api.i
===================================================================
--- bindings/ruby/senna_api.i (revision 804)
+++ bindings/ruby/senna_api.i (working copy)
@@ -174,20 +174,12 @@
$2 = size;
}
%typemap(argout) (void *keybuf, int bufsize) {
- VALUE ary;
- if (TYPE($result) == T_ARRAY) {
- ary = $result;
- } else {
- ary = rb_ary_new2(2);
- rb_ary_push(ary, $result);
- }
if ($1) {
- rb_ary_push(ary, rb_str_new2($1));
+ %append_output(rb_str_new2($1));
free($1);
} else {
- rb_ary_push(ary, Qnil);
+ %append_output(Qnil);
}
- $result = ary;
}
%typemap(in) (char *pathbuf, int bufsize) {