diff options
author | Jérémy Zurcher <jeremy.zurcher@heraeus.com> | 2011-04-19 16:29:46 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy.zurcher@heraeus.com> | 2011-04-19 16:29:46 +0200 |
commit | a8b448a7dd7851ebbf0bdd41c56d184142a91cb0 (patch) | |
tree | da68648d912f4f71d49fec5e2fa996f00e822a8f /lib | |
parent | 95acc146082d844e961452ef8c9c14cfed1b569c (diff) | |
download | ffi-efl-a8b448a7dd7851ebbf0bdd41c56d184142a91cb0.zip ffi-efl-a8b448a7dd7851ebbf0bdd41c56d184142a91cb0.tar.gz |
DESIGN FIX: attach functions, define types, ... into E17::API module, use method missing to delegate
Diffstat (limited to 'lib')
-rw-r--r-- | lib/e17/ffi.rb | 35 | ||||
-rw-r--r-- | lib/e17/ffi_helper.rb | 39 |
2 files changed, 35 insertions, 39 deletions
diff --git a/lib/e17/ffi.rb b/lib/e17/ffi.rb new file mode 100644 index 0000000..e8a644c --- /dev/null +++ b/lib/e17/ffi.rb @@ -0,0 +1,35 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'ffi' +# +module E17 + # + module API + # + extend FFI::Library + # + def attach_fcts fcts + fcts.each do |func| + begin + attach_function *func + rescue Object => e + puts "Could not attach #{func} #{e.message}" + end + end + end + module_function :attach_fcts + # + typedef :pointer, :int_p + typedef :pointer, :uint_p + typedef :pointer, :void_p + typedef :pointer, :uchar_p + typedef :pointer, :string_array + # + typedef :pointer, :eina_list_p + # + end + # +end +# +# EOF diff --git a/lib/e17/ffi_helper.rb b/lib/e17/ffi_helper.rb deleted file mode 100644 index 26efe57..0000000 --- a/lib/e17/ffi_helper.rb +++ /dev/null @@ -1,39 +0,0 @@ -#! /usr/bin/env ruby -# -*- coding: UTF-8 -*- -# -require 'ffi' -# -module FFIHelper - # - def attach_fcts 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 - module_eval <<-code - class << self - #{fcts.map{ |f,a,r| "alias #{f.to_s[l..-1]} #{f}" }.join "\n" } - end - code - end - # - def self.extended mod - mod.module_eval <<-EOF - typedef :pointer, :int_p - typedef :pointer, :uint_p - typedef :pointer, :void_p - typedef :pointer, :uchar_p - typedef :pointer, :string_array - # - typedef :pointer, :eina_list_p - EOF - end -end -# -# EOF |