From 38a8992822c638ded9db7e3b1ae5aa28dee38fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 14 Apr 2011 06:23:43 +0200 Subject: add ffi_helper --- lib/e17/ffi_helper.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/e17/ffi_helper.rb diff --git a/lib/e17/ffi_helper.rb b/lib/e17/ffi_helper.rb new file mode 100644 index 0000000..36c9c6b --- /dev/null +++ b/lib/e17/ffi_helper.rb @@ -0,0 +1,27 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'ffi' +# +module FFIHelper + def attach_fcts + @fcts.each do |func| + begin + attach_function *func + rescue Object => e + puts "Could not attach #{func} #{e.message}" + 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 + end + end +end +# +# EOF -- cgit v1.1-2-g2b99