From c73ec67bdca66b39b1bcea63434c560f21af2d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 14 Apr 2011 07:30:04 +0200 Subject: update ffi_helper API --- lib/e17/ffi_helper.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/e17/ffi_helper.rb b/lib/e17/ffi_helper.rb index 36c9c6b..5aaf7a4 100644 --- a/lib/e17/ffi_helper.rb +++ b/lib/e17/ffi_helper.rb @@ -4,8 +4,8 @@ require 'ffi' # module FFIHelper - def attach_fcts - @fcts.each do |func| + def attach_fcts fcts + fcts.each do |func| begin attach_function *func rescue Object => e @@ -13,14 +13,12 @@ module FFIHelper end end end - def create_aliases l - @fcts.each do |f,a,r| - module_eval <<-code - class << self - alias #{f.to_s[l..-1]} #{f} - end - code + def create_aliases l, fcts + module_eval <<-code + class << self + #{fcts.map{ |f,a,r| "alias #{f.to_s[l..-1]} #{f}" }.join "\n" } end + code end end # -- cgit v1.1-2-g2b99