summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-05-03 10:22:41 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2013-05-03 10:22:41 +0200
commitbd1c6ade69608ef3d659dd397d0543a66026a443 (patch)
tree42d6cefbbd0bdef8fa8791146d84e194cb1d6a15
parent5008bdf84e2abe072a6995886c2f8f5b3e4aa905 (diff)
downloadffi-efl-bd1c6ade69608ef3d659dd397d0543a66026a443.zip
ffi-efl-bd1c6ade69608ef3d659dd397d0543a66026a443.tar.gz
move Efl::MethodResolver from efl.rb into native.rb
-rw-r--r--lib/efl.rb30
-rw-r--r--lib/efl/native.rb30
2 files changed, 30 insertions, 30 deletions
diff --git a/lib/efl.rb b/lib/efl.rb
index 9604e73..115ca6b 100644
--- a/lib/efl.rb
+++ b/lib/efl.rb
@@ -5,36 +5,6 @@ module Efl
#
VERSION = '0.1.0'
#
- module MethodResolver
- def self.resolve mod, meth, prefix
- meth_s = meth.to_s
- if meth_s =~/^(.*)=$/
- meth_s = $1+'_set'
- args_s = '*args[0]'
- elsif meth_s =~/^(.*)\?$/
- meth_s = $1+'_get'
- args_s = '*args'
- else
- args_s = '*args'
- end
- sym = (
- if Efl::Native.respond_to? prefix+meth_s
- prefix+meth_s
- elsif Efl::Native.respond_to? meth_s
- meth_s
- elsif Efl::Native.respond_to? prefix+meth_s+'_get'
- prefix+meth_s+'_get'
- elsif Efl::Native.respond_to? meth_s+'_get'
- meth_s+'_get'
- else
- raise NameError.new "#{mod.name}.#{meth_s} (#{meth})"
- end
- )
- mod.module_eval "def self.#{meth} *args, &block; r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end"
- sym
- end
- end
- #
module ClassHelper
def to_a; [self] end
def to_ary; [self] end
diff --git a/lib/efl/native.rb b/lib/efl/native.rb
index 24b336c..490ac9b 100644
--- a/lib/efl/native.rb
+++ b/lib/efl/native.rb
@@ -5,6 +5,36 @@ require 'ffi'
#
module Efl
#
+ module MethodResolver
+ def self.resolve mod, meth, prefix
+ meth_s = meth.to_s
+ if meth_s =~/^(.*)=$/
+ meth_s = $1+'_set'
+ args_s = '*args[0]'
+ elsif meth_s =~/^(.*)\?$/
+ meth_s = $1+'_get'
+ args_s = '*args'
+ else
+ args_s = '*args'
+ end
+ sym = (
+ if Efl::Native.respond_to? prefix+meth_s
+ prefix+meth_s
+ elsif Efl::Native.respond_to? meth_s
+ meth_s
+ elsif Efl::Native.respond_to? prefix+meth_s+'_get'
+ prefix+meth_s+'_get'
+ elsif Efl::Native.respond_to? meth_s+'_get'
+ meth_s+'_get'
+ else
+ raise NameError.new "#{mod.name}.#{meth_s} (#{meth})"
+ end
+ )
+ mod.module_eval "def self.#{meth} *args, &block; r=Efl::Native.#{sym}(#{args_s}); yield r if block_given?; r; end"
+ sym
+ end
+ end
+ #
module Native
#
extend FFI::Library