diff options
-rw-r--r-- | lib/efl/evas.rb | 21 | ||||
-rw-r--r-- | spec/evas_spec.rb | 20 |
2 files changed, 38 insertions, 3 deletions
diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb index ccb4af3..7f386b9 100644 --- a/lib/efl/evas.rb +++ b/lib/efl/evas.rb @@ -8,10 +8,17 @@ module EFL # extend FFI::Library # + callback :evas_async_events_put_cb, [:pointer, :int, :pointer], :void + # ffi_lib 'evas' - functions = [ - [ :evas_init, [ ], :int ], - [ :evas_shutdown, [], :int ], + [ + # http://docs.enlightenment.org/auto/evas/group__Evas__Group.html + [ :evas_init, [], :int], + [ :evas_shutdown, [], :int], + [ :evas_alloc_error, [], :int], + [ :evas_async_events_fd_get, [], :int], + [ :evas_async_events_process, [], :int], + [ :evas_async_events_put, [:pointer, :int, :pointer, :evas_async_events_put_cb], :bool], ].each do |func| begin attach_function *func @@ -20,9 +27,17 @@ module EFL end end # + ALLOC_ERROR_NONE = 0 + ALLOC_ERROR_FATAL = 1 + ALLOC_ERROR_RECOVERED = 2 + # class << self alias init evas_init alias shutdown evas_shutdown + alias alloc_error evas_alloc_error + alias async_events_fd_get evas_async_events_fd_get + alias async_events_process evas_async_events_process + alias async_events_put evas_async_events_put end # end diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb index 815c4a1..c04cd9f 100644 --- a/spec/evas_spec.rb +++ b/spec/evas_spec.rb @@ -19,4 +19,24 @@ describe EFL::EVAS do EVAS.shutdown.should eql 0 end # + it "should have no memory allocation error occured" do + EVAS.init + EVAS.alloc_error.should eql EVAS::ALLOC_ERROR_NONE + EVAS.shutdown + end + # + it "should process async events" do + cb = Proc.new do |target,type,evt| + target.read_string.should eql "target" + type.should eql 0 + evt.read_string.should eql "work" + end + EVAS.init + target = FFI::MemoryPointer.from_string("target") + work = FFI::MemoryPointer.from_string("work") + EVAS.async_events_put target, 0, work, cb + EVAS.async_events_process.should eql 1 + EVAS.async_events_process.should eql 0 + EVAS.shutdown + end end |