57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/kyotocabinet.rb', line 57
def self.included(mod)
super(mod)
mod.instance_eval do
def with_java_method(mname, args)
mh = self.java_method(mname, args)
yield mh
end
def convert_args(mname, args)
indices = []
args.each_with_index do |a, i|
if a == BYTE_ARRAY
indices << i
end
end
mh = self.java_method(mname, args)
self.send(:define_method, mname) do |*argv|
indices.each { |i| argv[i] = argv[i].to_java_bytes }
mh.bind(self).call(*argv)
end
end
def convert_args_ret(mname, args)
indices = []
args.each_with_index do |a, i|
if a == BYTE_ARRAY
indices << i
end
end
mh = self.java_method(mname, args)
self.send(:define_method, mname) do |*argv|
indices.each { |i| argv[i] = argv[i].to_java_bytes }
rv = mh.bind(self).call(*argv)
if rv
String.from_java_bytes(rv)
end
end
end
end
end
|