diff options
author | Jérémy Zurcher <jeremy.zurcher@heraeus.com> | 2011-04-12 14:14:31 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy.zurcher@heraeus.com> | 2011-04-12 14:14:31 +0200 |
commit | b95723834ba5bdcb85e90760bba8fc26574e7ff3 (patch) | |
tree | 8b829d99a2e18ec7d0f557aaaebb60348912b480 | |
parent | 0c3cbdb988566ea3e2dcd52396b834cbab02d3fa (diff) | |
download | ffi-efl-b95723834ba5bdcb85e90760bba8fc26574e7ff3.zip ffi-efl-b95723834ba5bdcb85e90760bba8fc26574e7ff3.tar.gz |
update ecore + spec with ecore_pipe, ...
-rw-r--r-- | lib/efl/ecore.rb | 23 | ||||
-rw-r--r-- | spec/ecore_spec.rb | 23 |
2 files changed, 40 insertions, 6 deletions
diff --git a/lib/efl/ecore.rb b/lib/efl/ecore.rb index 5583a5a..c1599aa 100644 --- a/lib/efl/ecore.rb +++ b/lib/efl/ecore.rb @@ -8,17 +8,26 @@ module EFL # extend FFI::Library # - callback:ecore_select_function, [ :int, :pointer, :pointer, :pointer, :pointer], :int + callback :ecore_pipe_cb, [:pointer, :pointer, :int], :void + callback :ecore_select_function, [:int, :pointer, :pointer, :pointer, :pointer], :int # ffi_lib 'ecore' - functions = [ - [ :ecore_init, [ ], :int ], - [ :ecore_shutdown, [], :int ], + [ + # http://docs.enlightenment.org/auto/ecore/group__Ecore__Group.html + [ :ecore_init, [ ], :int], + [ :ecore_shutdown, [], :int], + [ :ecore_pipe_add, [:ecore_pipe_cb, :pointer], :pointer], + [ :ecore_pipe_del, [:pointer], :pointer], + [ :ecore_pipe_read_close, [:pointer], :void], + [ :ecore_pipe_write_close, [:pointer], :void], + [ :ecore_pipe_write, [:pointer, :pointer, :int], :bool], + # http://docs.enlightenment.org/auto/ecore/group__Ecore__Main__Loop__Group.html [ :ecore_main_loop_iterate, [], :void], [ :ecore_main_loop_begin, [], :void], [ :ecore_main_loop_quit, [], :void], [ :ecore_main_loop_select_func_set, [], :void], # TODO spec [ :ecore_main_loop_select_func_get, [], :void], # TODO spec +# EAPI void ecore_main_fd_handler_prepare_callback_set (Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data) # TODO ].each do |func| begin attach_function *func @@ -30,6 +39,12 @@ module EFL class << self alias init ecore_init alias shutdown ecore_shutdown + alias pipe_add ecore_pipe_add + alias pipe_del ecore_pipe_del + alias pipe_read_close ecore_pipe_read_close + alias pipe_write_close ecore_pipe_write_close + alias pipe_write ecore_pipe_write + # alias main_loop_iterate ecore_main_loop_iterate alias main_loop_begin ecore_main_loop_begin alias main_loop_quit ecore_main_loop_quit diff --git a/spec/ecore_spec.rb b/spec/ecore_spec.rb index e1260fc..8d7f4bf 100644 --- a/spec/ecore_spec.rb +++ b/spec/ecore_spec.rb @@ -20,8 +20,27 @@ describe EFL::ECORE do end # it "should run a single iteration of the mainloop" do - ECORE.init.should eql 1 + ECORE.init ECORE.main_loop_iterate - ECORE.shutdown.should eql 0 + ECORE.shutdown + end + # + it 'should write and read data from pipe' do + ECORE.init + cb = Proc.new do |data,buffer,bytes| + data.read_string.should eql 'none' + buffer.read_string.should eql 'hello world' + bytes.should eql 12 + end + data = FFI::MemoryPointer.from_string("none") + pipe = ECORE.pipe_add cb, data + buffer = FFI::MemoryPointer.new(:string,128) + buffer.write_string 'hello world' + ECORE.pipe_write pipe, buffer, 12 + ECORE.main_loop_iterate + ECORE.pipe_read_close pipe + ECORE.pipe_write_close pipe + ECORE.pipe_del pipe + ECORE.shutdown end end |