1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
require 'e17/ffi_helper'
#
module E17
module ECORE
#
extend FFIHelper
extend FFI::Library
#
ffi_lib 'ecore'
#
callback :ecore_pipe_cb, [:pointer, :pointer, :int], :void
callback :ecore_select_function, [:int, :pointer, :pointer, :pointer, :pointer], :int
callback :ecore_fd_prep_cb, [:pointer, :pointer], :void
#
fcts = [
# 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, [:ecore_select_function], :void], # TODO spec
[ :ecore_main_loop_select_func_get, [], :ecore_select_function], # TODO spec
[ :ecore_main_fd_handler_prepare_callback_set, [:pointer, :ecore_fd_prep_cb, :pointer], :void], # TODO spec
]
#
attach_fcts fcts
#
create_aliases 'ecore_'.length, fcts
#
class EcorePipe
def initialize cb, data
@ptr = ECORE.ecore_pipe_add cb, data
end
def del; ECORE.ecore_pipe_del @ptr; end
def read_close; ECORE.ecore_pipe_read_close @ptr; end
def write_close; ECORE.ecore_pipe_write_close @ptr; end
def write data
ECORE.ecore_pipe_write @ptr, FFI::MemoryPointer.from_string(data.to_s), data.to_s.length+1
end
end
end
end
#
# EOF
|