summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/e17/evas.rb37
-rw-r--r--spec/evas_spec.rb14
2 files changed, 26 insertions, 25 deletions
diff --git a/lib/e17/evas.rb b/lib/e17/evas.rb
index 7a8d488..07c5924 100644
--- a/lib/e17/evas.rb
+++ b/lib/e17/evas.rb
@@ -1,44 +1,33 @@
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
-require 'ffi'
+require 'e17/ffi_helper'
#
module E17
module EVAS
#
+ extend FFIHelper
extend FFI::Library
#
+ ffi_lib 'evas'
+ #
+ enum :evas_alloc_error, [:none,0,:fatal,:recovered]
+ #
callback :evas_async_events_put_cb, [:pointer, :int, :pointer], :void
#
- ffi_lib 'evas'
- [
+ @fcts = [
# http://docs.enlightenment.org/auto/evas/group__Evas__Group.html
[ :evas_init, [], :int],
[ :evas_shutdown, [], :int],
- [ :evas_alloc_error, [], :int],
+ [ :evas_alloc_error, [], :evas_alloc_error],
[ :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
- rescue Object => e
- puts "Could not attach #{func} #{e.message}"
- 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
+ ]
+ #
+ attach_fcts
+ #
+ create_aliases 'evas_'.length
#
end
end
diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb
index a708833..f26b29c 100644
--- a/spec/evas_spec.rb
+++ b/spec/evas_spec.rb
@@ -19,9 +19,21 @@ describe E17::EVAS do
EVAS.shutdown.should eql 0
end
#
+ it "evas alloc error enum is ok" do
+ EVAS.enum_value(:none).should eql 0
+ EVAS.enum_value(:fatal).should eql 1
+ EVAS.enum_value(:recovered).should eql 2
+ EVAS.enum_type(:evas_alloc_error)[0].should eql :none
+ EVAS.enum_type(:evas_alloc_error)[1].should eql :fatal
+ EVAS.enum_type(:evas_alloc_error)[2].should eql :recovered
+ EVAS.enum_type(:evas_alloc_error)[:none].should eql 0
+ EVAS.enum_type(:evas_alloc_error)[:fatal].should eql 1
+ EVAS.enum_type(:evas_alloc_error)[:recovered].should eql 2
+ end
+ #
it "should have no memory allocation error occured" do
EVAS.init
- EVAS.alloc_error.should eql EVAS::ALLOC_ERROR_NONE
+ EVAS.alloc_error.should eql :none
EVAS.shutdown
end
#