summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-04-14 06:23:43 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-04-14 06:23:43 +0200
commit38a8992822c638ded9db7e3b1ae5aa28dee38fab (patch)
tree360bf81dd920b0f4320013ee1948e85e3ac841e2
parent11725c389157c789edac1572a86c5542909900c4 (diff)
downloadffi-efl-38a8992822c638ded9db7e3b1ae5aa28dee38fab.zip
ffi-efl-38a8992822c638ded9db7e3b1ae5aa28dee38fab.tar.gz
add ffi_helper
-rw-r--r--lib/e17/ffi_helper.rb27
1 files changed, 27 insertions, 0 deletions
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