diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-04-29 15:10:39 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-04-29 15:10:39 +0200 |
commit | c3a35d205ef74abc0294b549f3f9a3c74a5df0d6 (patch) | |
tree | c5c2cac2293ed591174a78db16986814519822e9 | |
parent | 59c01ca8e688289af8a87c18a751c2557594ef65 (diff) | |
download | ffi-efl-c3a35d205ef74abc0294b549f3f9a3c74a5df0d6.zip ffi-efl-c3a35d205ef74abc0294b549f3f9a3c74a5df0d6.tar.gz |
update efl/evas* and specs
-rw-r--r-- | lib/efl/evas.rb | 124 | ||||
-rw-r--r-- | spec/evas_spec.rb | 95 |
2 files changed, 111 insertions, 108 deletions
diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb index c4dcbb7..22db560 100644 --- a/lib/efl/evas.rb +++ b/lib/efl/evas.rb @@ -4,7 +4,8 @@ require 'efl/ffi/evas' # module Efl - module FFI + # + module Evas # EVAS_ENGINE_BUFFER_DEPTH_ARGB32 = 0 EVAS_ENGINE_BUFFER_DEPTH_BGRA32 = 1 @@ -12,16 +13,17 @@ module Efl EVAS_ENGINE_BUFFER_DEPTH_BGR24 = 3 EVAS_ENGINE_BUFFER_DEPTH_RGB32 = 4 # - class EvasEngineInfo < ::FFI::Struct - layout :magic, :int - end callback :new_update_region_cb, [:int, :int, :int, :int, :int_p], :pointer callback :free_update_region_cb, [:int, :int, :int, :int, :pointer], :void - class EvasEngineInfoBufferFunc < ::FFI::Struct + # + class EngineInfoStruct < FFI::Struct + layout :magic, :int + end + class EngineInfoBufferFuncStruct < FFI::Struct layout :new_update_region, :new_update_region_cb, :free_update_region, :free_update_region_cb end - class EvasEngineInfoBufferInfo < ::FFI::Struct + class EngineInfoBufferInfoStruct < FFI::Struct layout :depth_type, :int, :dest_buffer, :pointer, :dest_buffer_row_bytes, :int, @@ -30,112 +32,112 @@ module Efl :color_key_r, :int, :color_key_g, :int, :color_key_b, :int, - :func, EvasEngineInfoBufferFunc, + :func, EngineInfoBufferFuncStruct, end - class EvasEngineInfoBuffer < ::FFI::Struct - layout :magic, EvasEngineInfo, - :info, EvasEngineInfoBufferInfo, -# :func, EvasEngineInfoBufferFunc, - :mode, :evas_engine_render_mode, + class EngineInfoBufferStruct < FFI::Struct + layout :magic, EngineInfoStruct, + :info, EngineInfoBufferInfoStruct, +# :func, EvasEngineInfoBufferFunc, + :mode, :evas_engine_render_mode, end # - end - # - module Evas - # - class Evas - include Efl::Helper - @func_prefixes = [ 'evas_' ].freeze + class REvas + # + include Efl::ClassHelper + @search_paths = [ [Efl::Evas,'evas_'] ].freeze + # def initialize o=nil @ptr = ( case o when NilClass - ::FFI::AutoPointer.new Efl::FFI.evas_new, method(:free) + FFI::AutoPointer.new Efl::Evas.evas_new, method(:free) when self.class - o.ptr - when ::FFI::AutoPointer + o.to_ptr + when FFI::AutoPointer o - when ::FFI::Pointer - ::FFI::AutoPointer.new o, method(:free) + when FFI::Pointer + FFI::AutoPointer.new o, method(:free) else - raise ArgumentError.new "#{ptr.class} valid argument" + raise ArgumentError.new "#{o.class} valid argument" end ) yield self if block_given? end def free - Efl::FFI.evas_free @ptr + Efl::Evas.evas_free @ptr @ptr=nil end def object_add t - Efl::Evas::EvasObject.new Efl::FFI.send "evas_object_#{t}_add", @ptr + Efl::Evas::REvasObject.new Efl::Evas.send "evas_object_#{t}_add", @ptr end def output_size_get - x = ::FFI::MemoryPointer.new :int - y = ::FFI::MemoryPointer.new :int - Efl::FFI.evas_output_size_get @ptr, x, y + x = FFI::MemoryPointer.new :int + y = FFI::MemoryPointer.new :int + Efl::Evas.evas_output_size_get @ptr, x, y [ x.read_int, y.read_int ] end def output_viewport_get - x = ::FFI::MemoryPointer.new :int - y = ::FFI::MemoryPointer.new :int - w = ::FFI::MemoryPointer.new :int - h = ::FFI::MemoryPointer.new :int - Efl::FFI.evas_output_viewport_get @ptr, x, y, w, h + x = FFI::MemoryPointer.new :int + y = FFI::MemoryPointer.new :int + w = FFI::MemoryPointer.new :int + h = FFI::MemoryPointer.new :int + Efl::Evas.evas_output_viewport_get @ptr, x, y, w, h [ x.read_int, y.read_int, w.read_int, h.read_int ] end def pointer_output_xy_get - x = ::FFI::MemoryPointer.new :int - y = ::FFI::MemoryPointer.new :int - Efl::FFI.evas_pointer_output_xy_get @ptr, x, y + x = FFI::MemoryPointer.new :int + y = FFI::MemoryPointer.new :int + Efl::Evas.evas_pointer_output_xy_get @ptr, x, y [ x.read_int, y.read_int ] end def pointer_canvas_xy_get - x = ::FFI::MemoryPointer.new :int - y = ::FFI::MemoryPointer.new :int - Efl::FFI.evas_pointer_canvas_xy_get @ptr, x, y + x = FFI::MemoryPointer.new :int + y = FFI::MemoryPointer.new :int + Efl::Evas.evas_pointer_canvas_xy_get @ptr, x, y [ x.read_int, y.read_int ] end end # - class EvasObject - include Efl::Helper - @func_prefixes = [ 'evas_object_', 'evas_' ].freeze + class REvasObject + # + include Efl::ClassHelper + @search_paths = [ [Efl::Evas,'evas_object_'],[Efl::Evas,'evas_'] ].freeze + # def initialize o=nil @ptr = ( case o when NilClass - ::FFI::AutoPointer.new Efl::FFI.evas_new, method(:free) + FFI::AutoPointer.new Efl::Evas.evas_new, method(:free) when self.class - o.ptr - when ::FFI::AutoPointer + o.to_ptr + when FFI::AutoPointer o - when ::FFI::Pointer - ::FFI::AutoPointer.new o, method(:free) + when FFI::Pointer + FFI::AutoPointer.new o, method(:free) else - raise ArgumentError.new "#{ptr.class} valid argument" + raise ArgumentError.new "#{o.class} valid argument" end ) yield self if block_given? end def free - Efl::FFI.evas_object_del @ptr + Efl::Evas.evas_object_del @ptr @ptr=nil end def geometry_get - x = ::FFI::MemoryPointer.new :int - y = ::FFI::MemoryPointer.new :int - w = ::FFI::MemoryPointer.new :int - h = ::FFI::MemoryPointer.new :int - Efl::FFI.evas_object_geometry_get @evas, x, y, w, h + x = FFI::MemoryPointer.new :int + y = FFI::MemoryPointer.new :int + w = FFI::MemoryPointer.new :int + h = FFI::MemoryPointer.new :int + Efl::Evas.evas_object_geometry_get @evas, x, y, w, h [ x.read_int, y.read_int, w.read_int, h.read_int ] end def color_get - r = ::FFI::MemoryPointer.new :int - g = ::FFI::MemoryPointer.new :int - b = ::FFI::MemoryPointer.new :int - a = ::FFI::MemoryPointer.new :int - Efl::FFI.evas_object_color_get @evas, r, g, b, a + r = FFI::MemoryPointer.new :int + g = FFI::MemoryPointer.new :int + b = FFI::MemoryPointer.new :int + a = FFI::MemoryPointer.new :int + Efl::Evas.evas_object_color_get @evas, r, g, b, a [ r.read_int, g.read_int, b.read_int, a.read_int ] end end diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb index 9e1c57a..90678fc 100644 --- a/spec/evas_spec.rb +++ b/spec/evas_spec.rb @@ -20,15 +20,15 @@ describe Efl::Evas do end # it "evas alloc error enum is ok" do - Efl::FFI.enum_value(:evas_alloc_error_none).should eql 0 - Efl::FFI.enum_value(:evas_alloc_error_fatal).should eql 1 - Efl::FFI.enum_value(:evas_alloc_error_recovered).should eql 2 - Efl::FFI.enum_type(:evas_alloc_error)[0].should eql :evas_alloc_error_none - Efl::FFI.enum_type(:evas_alloc_error)[1].should eql :evas_alloc_error_fatal - Efl::FFI.enum_type(:evas_alloc_error)[2].should eql :evas_alloc_error_recovered - Efl::FFI.enum_type(:evas_alloc_error)[:evas_alloc_error_none].should eql 0 - Efl::FFI.enum_type(:evas_alloc_error)[:evas_alloc_error_fatal].should eql 1 - Efl::FFI.enum_type(:evas_alloc_error)[:evas_alloc_error_recovered].should eql 2 + Efl::Evas.enum_value(:evas_alloc_error_none).should eql 0 + Efl::Evas.enum_value(:evas_alloc_error_fatal).should eql 1 + Efl::Evas.enum_value(:evas_alloc_error_recovered).should eql 2 + Efl::Evas.enum_type(:evas_alloc_error)[0].should eql :evas_alloc_error_none + Efl::Evas.enum_type(:evas_alloc_error)[1].should eql :evas_alloc_error_fatal + Efl::Evas.enum_type(:evas_alloc_error)[2].should eql :evas_alloc_error_recovered + Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_none].should eql 0 + Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_fatal].should eql 1 + Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_recovered].should eql 2 end # it "should have no memory allocation error occured" do @@ -52,18 +52,18 @@ describe Efl::Evas do Evas.shutdown end # - describe Efl::Evas::Evas do + describe Efl::Evas::REvas do before(:all) do Evas.init @width = 800 @height = 600 @pixels = FFI::MemoryPointer.new :int, @width*@height - @e = Evas::Evas.new + @e = Evas::REvas.new @e.output_method_set Evas::render_method_lookup("buffer") @e.output_viewport_set 0, 0, @width, @height @e.output_size_set @width, @height - einfo = Efl::FFI::EvasEngineInfoBuffer.new @e.engine_info_get - einfo[:info][:depth_type] = Efl::FFI::EVAS_ENGINE_BUFFER_DEPTH_ARGB32 + einfo = Efl::Evas::EngineInfoBufferStruct.new @e.engine_info_get + einfo[:info][:depth_type] = Efl::Evas::EVAS_ENGINE_BUFFER_DEPTH_ARGB32 einfo[:info][:dest_buffer] = @pixels einfo[:info][:dest_buffer_row_bytes] = @width * FFI::type_size(:int); einfo[:info][:use_color_key] = 0; @@ -78,11 +78,11 @@ describe Efl::Evas do Evas.shutdown end it "should be able to create and destroy evas" do - e1 = Evas::Evas.new + e1 = Evas::REvas.new e1.address.should_not eql 0 - e2 = Evas::Evas.new e1 + e2 = Evas::REvas.new e1 e1.address.should eql e2.address - e3 = Evas::Evas.new e1.ptr + e3 = Evas::REvas.new e1.to_ptr e1.address.should eql e3.address e2.address.should eql e3.address (e1==e2).should be_false @@ -92,26 +92,26 @@ describe Efl::Evas do (e2===e3).should be_true (e1===e3).should be_true e1.free - e1.ptr.should be_nil - e4 = Evas::Evas.new Efl::FFI.evas_new + e1.to_ptr.should be_nil + e4 = Evas::REvas.new Evas.evas_new e4.address.should_not eql 0 e5 = e4.dup e4.address.should eql e5.address e6 = e4.clone e4.address.should eql e6.address e4.free - e4.ptr.should be_nil + e4.to_ptr.should be_nil end # it "focus should work" do - Efl::FFI.evas_focus_in @e.ptr - Efl::FFI.evas_focus_state_get(@e.ptr).should be_true - Efl::FFI.evas_focus_out @e.ptr - Efl::FFI.evas_focus_state_get(@e.ptr).should be_false - Efl::Evas.focus_in @e.ptr - Efl::Evas.focus_state_get(@e.ptr).should be_true - Efl::Evas.focus_out @e.ptr - Efl::Evas.focus_state_get(@e.ptr).should be_false + Efl::Evas.evas_focus_in @e.to_ptr + Efl::Evas.evas_focus_state_get(@e.to_ptr).should be_true + Efl::Evas.evas_focus_out @e.to_ptr + Efl::Evas.evas_focus_state_get(@e.to_ptr).should be_false + Efl::Evas.focus_in @e.to_ptr + Efl::Evas.focus_state_get(@e.to_ptr).should be_true + Efl::Evas.focus_out @e.to_ptr + Efl::Evas.focus_state_get(@e.to_ptr).should be_false @e.focus_in { |r| r.should be_nil } @e.focus_state_get.should be_true @e.focus_state_get { |r| r.should be_true } @@ -226,7 +226,7 @@ describe Efl::Evas do true end kd_d = FFI::MemoryPointer.from_string "mouse_in" - @bg = Evas::EvasObject.new @e.object_rectangle_add + @bg = Evas::REvasObject.new @e.object_rectangle_add @bg.move 0, 0 @bg.resize 20, 20 @bg.show @@ -244,35 +244,35 @@ describe Efl::Evas do end # it "font functions should work" do - @e.evas_font_hinting_set :evas_font_hinting_bytecode - @e.evas_font_hinting_get.should eql :evas_font_hinting_bytecode - @e.evas_font_hinting_can_hint(:evas_font_hinting_none).should be_true - @e.evas_font_cache_flush - @e.evas_font_cache_set 666 - @e.evas_font_cache_get.should eql 666 - l = @e.evas_font_available_list - @e.evas_font_available_list_free l - @e.evas_font_path_clear + @e.font_hinting_set :evas_font_hinting_bytecode + @e.font_hinting_get.should eql :evas_font_hinting_bytecode + @e.font_hinting_can_hint(:evas_font_hinting_none).should be_true + @e.font_cache_flush + @e.font_cache_set 666 + @e.font_cache_get.should eql 666 + l = @e.font_available_list + @e.font_available_list_free l + @e.font_path_clear a = ['/tmp1','/tmp2'] - @e.evas_font_path_append a[1] - @e.evas_font_path_prepend a[0] - require 'efl/eina/eina_list' - Efl::Eina::EinaList.new(@e.evas_font_path_list).each_with_index do |p,i| + @e.font_path_append a[1] + @e.font_path_prepend a[0] + require 'efl/eina_list' + Efl::EinaList::REinaList.new(@e.font_path_list).each_with_index do |p,i| p.read_string.should eql a[i] end end end - describe Efl::Evas::EvasObject do + describe Efl::Evas::REvasObject do # before(:all) do Evas.init @pixels = FFI::MemoryPointer.new :int, 100*100 - @e = Evas::Evas.new + @e = Evas::REvas.new @e.output_method_set Evas::render_method_lookup("buffer") @e.output_viewport_set 0, 0, 100, 100 @e.output_size_set 100, 100 - einfo = Efl::FFI::EvasEngineInfoBuffer.new @e.engine_info_get - einfo[:info][:depth_type] = Efl::FFI::EVAS_ENGINE_BUFFER_DEPTH_ARGB32 + einfo = Efl::Evas::EngineInfoBufferStruct.new @e.engine_info_get + einfo[:info][:depth_type] = Efl::Evas::EVAS_ENGINE_BUFFER_DEPTH_ARGB32 einfo[:info][:dest_buffer] = @pixels einfo[:info][:dest_buffer_row_bytes] = 100 * FFI::type_size(:int); einfo[:info][:use_color_key] = 0; @@ -298,10 +298,11 @@ describe Efl::Evas do clipper.color = 255,255,255,255 clipper.move 25, 25 clipper.resize 50, 50 - @o.clip = clipper.ptr + @o.clip = clipper.to_ptr clipper.show @o.clip_get.address.should eql clipper.address - Efl::Eina::EinaList.new(clipper.clipees_get).to_ary[0].address.should eql @o.address + require 'efl/eina_list' + Efl::EinaList::REinaList.new(clipper.clipees_get).to_ary[0].address.should eql @o.address @o.clip_unset @o.clip_get.address.should eql 0 |