summaryrefslogtreecommitdiffstats
path: root/lib/e17/ecore/event.rb
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy.zurcher@heraeus.com>2011-04-14 10:28:58 +0200
committerJérémy Zurcher <jeremy.zurcher@heraeus.com>2011-04-14 10:28:58 +0200
commitcc0f3f9e31ad216224b44f3a7897108cd96e17bb (patch)
tree91fdc2b4a7de82c9110516cb808d2cf4c9c4fa94 /lib/e17/ecore/event.rb
parent350843476bf1156881a0dd45131f5f6e4efee77f (diff)
downloadffi-efl-cc0f3f9e31ad216224b44f3a7897108cd96e17bb.zip
ffi-efl-cc0f3f9e31ad216224b44f3a7897108cd96e17bb.tar.gz
update ecore event, use FFIHelper, clean spec
Diffstat (limited to 'lib/e17/ecore/event.rb')
-rw-r--r--lib/e17/ecore/event.rb57
1 files changed, 24 insertions, 33 deletions
diff --git a/lib/e17/ecore/event.rb b/lib/e17/ecore/event.rb
index e536875..9465d16 100644
--- a/lib/e17/ecore/event.rb
+++ b/lib/e17/ecore/event.rb
@@ -1,13 +1,17 @@
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
-require 'ffi'
+require 'e17/ffi_helper'
#
module E17
module ECORE
#
+ extend FFIHelper
extend FFI::Library
#
+ ffi_lib 'ecore'
+ #
+# enum :ecore_signals, [:none,0,:signal_user,:signal_hup,:signal_exit,:signal_power,:signal_realtime]
EVENT_NONE = 0
EVENT_SIGNAL_USER = 1 # User signal event
EVENT_SIGNAL_HUP = 2 # Hup signal event
@@ -15,43 +19,30 @@ module E17
EVENT_SIGNAL_POWER = 4 # Power signal event
EVENT_SIGNAL_REALTIME = 5 # Realtime signal event
EVENT_COUNT = 6
- callback :ecore_event_handler_cb, [:pointer, :int, :pointer], :bool
+ #
callback :ecore_end_cb, [:pointer, :pointer], :void
callback :ecore_data_cb, [:pointer], :pointer
callback :ecore_filter_cb, [:pointer, :pointer, :int, :pointer], :bool
+ callback :ecore_event_handler_cb, [:pointer, :int, :pointer], :bool
#
- ffi_lib 'ecore'
- functions = [
- [ :ecore_event_handler_add, [:int, :ecore_event_handler_cb, :pointer], :pointer ],
- [ :ecore_event_handler_del, [:pointer], :void ],
- [ :ecore_event_add, [:int, :pointer, :ecore_end_cb, :pointer], :pointer ],
- [ :ecore_event_del, [:pointer], :void ],
- [ :ecore_event_handler_data_get, [:pointer], :pointer ],
- [ :ecore_event_handler_data_set, [:pointer,:pointer], :void ],
- [ :ecore_event_type_new, [], :int ],
- [ :ecore_event_filter_add, [:ecore_data_cb, :ecore_filter_cb, :ecore_end_cb, :pointer], :pointer ],
- [ :ecore_event_filter_del, [:pointer], :void ],
- [ :ecore_event_current_type_get, [], :int ],
+ fcts = [
+ # http://docs.enlightenment.org/auto/ecore/group__Ecore__Event__Group.html
+ [ :ecore_event_handler_add, [:int, :ecore_event_handler_cb, :pointer], :pointer],
+ [ :ecore_event_handler_del, [:pointer], :pointer],
+ [ :ecore_event_add, [:int, :pointer, :ecore_end_cb, :pointer], :pointer],
+ [ :ecore_event_del, [:pointer], :pointer],
+ [ :ecore_event_handler_data_get, [:pointer], :pointer],
+ [ :ecore_event_handler_data_set, [:pointer,:pointer], :pointer],
+ [ :ecore_event_type_new, [], :int],
+ [ :ecore_event_filter_add, [:ecore_data_cb, :ecore_filter_cb, :ecore_end_cb, :pointer], :pointer],
+ [ :ecore_event_filter_del, [:pointer], :pointer],
+ [ :ecore_event_current_type_get, [], :int],
[ :ecore_event_current_event_get, [], :pointer],
- ].each do |func|
- begin
- attach_function *func
- rescue Object => e
- puts "Could not attach #{func} #{e.message}"
- end
- end
- #
- class << self
- alias event_handler_add ecore_event_handler_add
- alias event_handler_del ecore_event_handler_del
- alias event_add ecore_event_add
- alias event_del ecore_event_del
- alias event_handler_data_get ecore_event_handler_data_get
- alias event_handler_data_set ecore_event_handler_data_set
- alias event_type_new ecore_event_type_new
- alias event_current_type_get ecore_event_current_type_get
- alias event_current_event_get ecore_event_current_event_get
- end
+ ]
+ #
+ attach_fcts fcts
+ #
+ create_aliases 'ecore_'.length, fcts
#
end
end