diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-01 08:22:00 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-01 08:22:00 +0200 |
commit | 51a6645abd257b37f3248ccf26b1007a7ac88208 (patch) | |
tree | 9e90ced4ab2b83af091ca5078d44cabbb7a43050 /lib/efl | |
parent | 314715fd3a8421571ffe77d1a497978011b976fb (diff) | |
download | ffi-efl-51a6645abd257b37f3248ccf26b1007a7ac88208.zip ffi-efl-51a6645abd257b37f3248ccf26b1007a7ac88208.tar.gz |
cleanup method_missing and [module,prefix] proxies usage and definition
Diffstat (limited to 'lib/efl')
-rw-r--r-- | lib/efl/ecore_evas.rb | 2 | ||||
-rw-r--r-- | lib/efl/edje.rb | 44 | ||||
-rw-r--r-- | lib/efl/eet.rb | 2 | ||||
-rw-r--r-- | lib/efl/eina_hash.rb | 2 | ||||
-rw-r--r-- | lib/efl/eina_list.rb | 2 | ||||
-rw-r--r-- | lib/efl/elementary.rb | 4 | ||||
-rw-r--r-- | lib/efl/evas.rb | 4 | ||||
-rw-r--r-- | lib/efl/ffi.rb | 32 |
8 files changed, 71 insertions, 21 deletions
diff --git a/lib/efl/ecore_evas.rb b/lib/efl/ecore_evas.rb index f92222c..6a592dc 100644 --- a/lib/efl/ecore_evas.rb +++ b/lib/efl/ecore_evas.rb @@ -9,7 +9,7 @@ module Efl # class REcoreEvas include Efl::ClassHelper - @search_paths = [ [Efl::EcoreEvas,'ecore_evas_'].freeze ] + proxy_list [Efl::EcoreEvas,'ecore_evas_'].freeze def initialize o=nil, &block @ptr = ( case o diff --git a/lib/efl/edje.rb b/lib/efl/edje.rb index cd062ff..4a2c4d9 100644 --- a/lib/efl/edje.rb +++ b/lib/efl/edje.rb @@ -1,14 +1,58 @@ #! /usr/bin/env ruby # -*- coding: UTF-8 -*- # +require 'efl/evas' require 'efl/ffi/edje' # module Efl # module Edje # + class REdje < Efl::Evas::REvasObject + # + proxy_list [Efl::Edje,'edje_object_'].freeze + def part_object_get part + # EAPI const Evas_Object *edje_object_part_object_get (const Evas_Object *obj, const char *part); + Efl::Evas::RevasObject.new Efl::Edje.edje_object_part_object_get @ptr, part + end + def part_swallow_get part + # EAPI Evas_Object *edje_object_part_swallow_get (const Evas_Object *obj, const char *part); + Efl::Evas::RevasObject.new Efl::Edje.edje_object_part_swallow_get @ptr, part + end + def external_object_get part + # EAPI Evas_Object *edje_object_part_external_object_get (const Evas_Object *obj, const char *part); + Efl::Evas::RevasObject.new Efl::Edje.edje_object_part_external_object_get @ptr, part + end + def external_content_get part, content + # EAPI Evas_Object *edje_object_part_external_content_get (const Evas_Object *obj, const char *part, const char *content); + Efl::Evas::RevasObject.new Efl::Edje.edje_object_part_external_content_get @ptr, part, content + end + def part_box_remove part, child + # EAPI Evas_Object *edje_object_part_box_remove (Evas_Object *obj, const char *part, Evas_Object *child); + Efl::Evas::RevasObject.new Efl::Edje.edje_object_part_box_remove @ptr, part, child + end + def part_box_remove_at part, pos + # EAPI Evas_Object *edje_object_part_box_remove_at (Evas_Object *obj, const char *part, unsigned int pos); + Efl::Evas::RevasObject.new Efl::Edje.edje_object_part_box_remove_at @ptr, part, pos + end + def part_child_get part, col, row + # EAPI Evas_Object *edje_object_part_table_child_get (Evas_Object *obj, const char *part, unsigned int col, unsigned int row); + Efl::Evas::RevasObject.new Efl::Edje.edje_object_part_child_get @ptr, part, col, row + end + end + # end # + module Evas + # + class REvas + def edje_object_add + # EAPI Evas_Object *edje_object_add (Evas *evas); + Efl::Edje::REdje.new Efl::Edje.edje_object_add @ptr + end + end + # + end end # # EOF diff --git a/lib/efl/eet.rb b/lib/efl/eet.rb index 9073a73..f66ede7 100644 --- a/lib/efl/eet.rb +++ b/lib/efl/eet.rb @@ -10,7 +10,7 @@ module Efl class REetFile # include Efl::ClassHelper - @search_paths = [ [Efl::Eet,'eet_'].freeze ] + proxy_list [Efl::Eet,'eet_'].freeze # def initialize ptr @ptr=ptr diff --git a/lib/efl/eina_hash.rb b/lib/efl/eina_hash.rb index f9435c7..4f4f44d 100644 --- a/lib/efl/eina_hash.rb +++ b/lib/efl/eina_hash.rb @@ -20,7 +20,7 @@ module Efl class REinaHash include Enumerable include Efl::ClassHelper - @search_paths = [ [Efl::EinaHash,'eina_hash_'].freeze ] + proxy_list [Efl::EinaHash,'eina_hash_'].freeze def initialize o=nil, &block cstr = ( block_given? ? block : Proc.new { Efl::EinaHash.eina_hash_string_djb2_new FFI::Pointer::NULL } ) @ptr = ( diff --git a/lib/efl/eina_list.rb b/lib/efl/eina_list.rb index e0e0d36..42395b2 100644 --- a/lib/efl/eina_list.rb +++ b/lib/efl/eina_list.rb @@ -28,7 +28,7 @@ module Efl class REinaList include Enumerable include Efl::ClassHelper - @search_paths = [ [Efl::EinaList,'eina_list_'].freeze ] + proxy_list [Efl::EinaList,'eina_list_'].freeze def initialize o=nil @ptr = ( case o diff --git a/lib/efl/elementary.rb b/lib/efl/elementary.rb index 96a3d2d..0844587 100644 --- a/lib/efl/elementary.rb +++ b/lib/efl/elementary.rb @@ -15,7 +15,7 @@ end # require 'efl/ffi/elementary' # -Efl::Evas::REvasObject.search_paths << [Efl::Elm,'elm_'].freeze +Efl::Evas::REvasObject.proxy_list << [Efl::Elm,'elm_'].freeze # append not prepend ! # module Efl module Elm @@ -34,7 +34,7 @@ module Efl # class ElmWin include Efl::ClassHelper - @search_paths = [ [Efl::Elm,'elm_win_'].freeze, [Efl::Elm,'elm_'].freeze ] + proxy_list [Efl::Elm,'elm_win_'].freeze, [Efl::Elm,'elm_'].freeze def initialize parent, title, type=:elm_win_basic @evas_object = Efl::Evas::REvasObject.new Efl::Elm.elm_win_add parent, title, type @ptr = @evas_object.to_ptr diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb index e54b07f..d6f476b 100644 --- a/lib/efl/evas.rb +++ b/lib/efl/evas.rb @@ -44,7 +44,7 @@ module Efl class REvas # include Efl::ClassHelper - @search_paths = [ [Efl::Evas,'evas_'].freeze ] + proxy_list [Efl::Evas,'evas_'].freeze # def initialize o=nil @ptr = ( @@ -101,7 +101,7 @@ module Efl class REvasObject # include Efl::ClassHelper - @search_paths = [ [Efl::Evas,'evas_object_'].freeze, [Efl::Evas,'evas_'].freeze ] + proxy_list [Efl::Evas,'evas_object_'].freeze, [Efl::Evas,'evas_'].freeze # def initialize o=nil @ptr = ( diff --git a/lib/efl/ffi.rb b/lib/efl/ffi.rb index bf68e22..0b7416e 100644 --- a/lib/efl/ffi.rb +++ b/lib/efl/ffi.rb @@ -68,18 +68,21 @@ module Efl end # module ClassHelper + def to_ptr; @ptr; end + def === o; @ptr === o.to_ptr; end + def address; @ptr.address; end def self.included kls - kls.class_eval "def self.search_paths; @search_paths; end" - kls.class_eval "def self.inherited sub; sub.class_eval 'def self.search_paths; superclass.search_paths; end'; end" - end - def to_ptr - @ptr - end - def === o - @ptr === o.to_ptr - end - def address - @ptr.address + # create class instance @proxy_list + kls.class_eval "@proxy_list ||=[]" + # access and prepend *args to @proxy_list + kls.class_eval "def self.proxy_list *args; @proxy_list.unshift *args unless args.empty?; @proxy_list; end" + # on inheritance, copy ancestor's @proxy_list + kls.class_eval <<-EOF + def self.inherited sub + sub.class_eval '@proxy_list = []' + sub.proxy_list *self.proxy_list + end + EOF end def method_missing m, *args, &block if m =~/^(.*)=$/ @@ -92,14 +95,17 @@ module Efl m_s = m.to_s args_s = '*args' end - self.class.search_paths.each do |mod,p| + self.class.proxy_list.each do |mod,p| sym = p+m_s if mod.respond_to? sym self.class.class_eval "def #{m} *args, █ r=#{mod.name}.#{sym}(@ptr,#{args_s}); yield r if block_given?; r; end" return self.send m, *args, &block + elsif mod.respond_to? m + self.class.class_eval "def #{m} *args, █ r=#{mod.name}.#{m}(@ptr,#{args_s}); yield r if block_given?; r; end" + return self.send m, *args, &block end end - raise NameError.new "#{self.class} is unable to resolve #{m} into #{self.class.search_paths.inspect}" + raise NameError.new "#{self.class} is unable to resolve #{m} within #{self.class.proxy_list.inspect}" end end end |