5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/ffi_ez.rb', line 5
def attach_ez *args
raise unless args.length <= 2
method_name = ruby_name = parametersAndReturn = nil
if args.length == 1 args[0].each{|key, setting|
if key.is_a? Array
parametersAndReturn = {key => setting}
else
method_name = key
ruby_name = setting
_dbg unless method_name.is_a? String and ruby_name.is_a? Symbol
raise unless method_name.is_a? String and ruby_name.is_a? Symbol
end
}
else
ruby_name = method_name = args.shift
parametersAndReturn = args.shift
end
raise unless parametersAndReturn.is_a? Hash raise unless parametersAndReturn.size == 1
attach_function ruby_name, method_name, parametersAndReturn.keys[0], parametersAndReturn.values[0]
end
|