ffi-efl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +2 -0
- data/MIT-LICENSE +18 -0
- data/README.rdoc +56 -0
- data/Rakefile +56 -0
- data/lib/efl/ecore/ecore-ffi.rb +390 -0
- data/lib/efl/ecore/ecore_evas-ffi.rb +378 -0
- data/lib/efl/ecore/ecore_getopt-ffi.rb +68 -0
- data/lib/efl/ecore/ecore_input-ffi.rb +78 -0
- data/lib/efl/ecore.rb +34 -0
- data/lib/efl/ecore_getopt.rb +43 -0
- data/lib/efl/edje/edje-ffi.rb +459 -0
- data/lib/efl/edje.rb +12 -0
- data/lib/efl/eet/eet-ffi.rb +333 -0
- data/lib/efl/eet.rb +58 -0
- data/lib/efl/eina/eina_types-ffi.rb +44 -0
- data/lib/efl/elementary/elementary-ffi.rb +3179 -0
- data/lib/efl/elementary.rb +43 -0
- data/lib/efl/evas/evas-ffi.rb +1294 -0
- data/lib/efl/evas.rb +108 -0
- data/lib/efl/ffi.rb +63 -0
- data/lib/efl.rb +14 -0
- data/spec/ecore_getopt_spec.rb +43 -0
- data/spec/ecore_spec.rb +151 -0
- data/spec/edje_spec.rb +22 -0
- data/spec/eet_spec.rb +107 -0
- data/spec/evas_spec.rb +103 -0
- data/tasks/ann.rake +83 -0
- data/tasks/constants.rb +114 -0
- data/tasks/ffi.rake +22 -0
- data/tasks/gem.rake +197 -0
- data/tasks/git.rake +38 -0
- data/tasks/helpers.rb +130 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +35 -0
- data/tasks/rdoc.rake +46 -0
- data/tasks/rubyforge.rake +54 -0
- data/tasks/setup.rb +129 -0
- data/tasks/spec.rake +44 -0
- data/tasks/svn.rake +48 -0
- data/tasks/test.rake +41 -0
- data/test/test_elm_win.rb +38 -0
- data/test/test_elm_win_class.rb +49 -0
- metadata +124 -0
data/lib/efl/evas.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
require 'efl/evas/evas-ffi'
|
5
|
+
#
|
6
|
+
module Efl
|
7
|
+
module Evas
|
8
|
+
#
|
9
|
+
class Evas
|
10
|
+
include Efl::Helper
|
11
|
+
@func_prefixes = [ 'evas_' ].freeze
|
12
|
+
def initialize o=nil
|
13
|
+
@ptr = (
|
14
|
+
case o
|
15
|
+
when NilClass
|
16
|
+
FFI::AutoPointer.new Efl::API.evas_new, method(:free)
|
17
|
+
when self.class
|
18
|
+
o.ptr
|
19
|
+
when FFI::AutoPointer
|
20
|
+
o
|
21
|
+
when FFI::Pointer
|
22
|
+
FFI::AutoPointer.new o, method(:free)
|
23
|
+
else
|
24
|
+
raise ArgumentError.new "#{ptr.class} valid argument"
|
25
|
+
end
|
26
|
+
)
|
27
|
+
yield self if block_given?
|
28
|
+
end
|
29
|
+
def free
|
30
|
+
Efl::API.evas_free @ptr
|
31
|
+
@ptr=nil
|
32
|
+
end
|
33
|
+
def === o
|
34
|
+
@ptr === o.ptr
|
35
|
+
end
|
36
|
+
def output_size_get
|
37
|
+
x = FFI::MemoryPointer.new :int
|
38
|
+
y = FFI::MemoryPointer.new :int
|
39
|
+
Efl::API.evas_output_size_get @ptr, x, y
|
40
|
+
[ x.read_int, y.read_int ]
|
41
|
+
end
|
42
|
+
def output_viewport_get
|
43
|
+
x = FFI::MemoryPointer.new :int
|
44
|
+
y = FFI::MemoryPointer.new :int
|
45
|
+
w = FFI::MemoryPointer.new :int
|
46
|
+
h = FFI::MemoryPointer.new :int
|
47
|
+
Efl::API.evas_output_viewport_get @ptr, x, y, w, h
|
48
|
+
[ x.read_int, y.read_int, w.read_int, h.read_int ]
|
49
|
+
end
|
50
|
+
def pointer_output_xy_get
|
51
|
+
x = FFI::MemoryPointer.new :int
|
52
|
+
y = FFI::MemoryPointer.new :int
|
53
|
+
Efl::API.evas_pointer_output_xy_get @ptr, x, y
|
54
|
+
[ x.read_int, y.read_int ]
|
55
|
+
end
|
56
|
+
def pointer_canvas_xy_get
|
57
|
+
x = FFI::MemoryPointer.new :int
|
58
|
+
y = FFI::MemoryPointer.new :int
|
59
|
+
Efl::API.evas_pointer_canvas_xy_get @ptr, x, y
|
60
|
+
[ x.read_int, y.read_int ]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
#
|
64
|
+
class EvasObject
|
65
|
+
include Efl::Helper
|
66
|
+
@func_prefixes = [ 'evas_object_', 'evas_' ].freeze
|
67
|
+
def initialize o=nil
|
68
|
+
@ptr = (
|
69
|
+
case o
|
70
|
+
when NilClass
|
71
|
+
FFI::AutoPointer.new Efl::API.evas_new, method(:free)
|
72
|
+
when self.class
|
73
|
+
o.ptr
|
74
|
+
when FFI::AutoPointer
|
75
|
+
o
|
76
|
+
when FFI::Pointer
|
77
|
+
FFI::AutoPointer.new o, method(:free)
|
78
|
+
else
|
79
|
+
raise ArgumentError.new "#{ptr.class} valid argument"
|
80
|
+
end
|
81
|
+
)
|
82
|
+
yield self if block_given?
|
83
|
+
end
|
84
|
+
def free
|
85
|
+
Efl::API.evas_object_del @ptr
|
86
|
+
@ptr=nil
|
87
|
+
end
|
88
|
+
def geometry_get
|
89
|
+
x = FFI::MemoryPointer.new :int
|
90
|
+
y = FFI::MemoryPointer.new :int
|
91
|
+
w = FFI::MemoryPointer.new :int
|
92
|
+
h = FFI::MemoryPointer.new :int
|
93
|
+
Efl::API.evas_object_geometry_get @evas, x, y, w, h
|
94
|
+
[ x.read_int, y.read_int, w.read_int, h.read_int ]
|
95
|
+
end
|
96
|
+
def color_get
|
97
|
+
r = FFI::MemoryPointer.new :int
|
98
|
+
g = FFI::MemoryPointer.new :int
|
99
|
+
b = FFI::MemoryPointer.new :int
|
100
|
+
a = FFI::MemoryPointer.new :int
|
101
|
+
Efl::API.evas_object_color_get @evas, r, g, b, a
|
102
|
+
[ r.read_int, g.read_int, b.read_int, a.read_int ]
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
#
|
108
|
+
# EOF
|
data/lib/efl/ffi.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
require 'ffi'
|
5
|
+
#
|
6
|
+
module Efl
|
7
|
+
#
|
8
|
+
module API
|
9
|
+
#
|
10
|
+
extend FFI::Library
|
11
|
+
#
|
12
|
+
def attach_fcts fcts
|
13
|
+
fcts.each do |func|
|
14
|
+
begin
|
15
|
+
attach_function(*func)
|
16
|
+
rescue Object => e
|
17
|
+
puts "Could not attach #{func} #{e.message}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
module_function :attach_fcts
|
22
|
+
#
|
23
|
+
typedef :pointer, :int_p
|
24
|
+
typedef :pointer, :uint_p
|
25
|
+
typedef :pointer, :void_p
|
26
|
+
typedef :pointer, :uchar_p
|
27
|
+
typedef :pointer, :float_p
|
28
|
+
typedef :pointer, :double_p
|
29
|
+
typedef :pointer, :string_array
|
30
|
+
typedef :pointer, :string_array_p
|
31
|
+
#
|
32
|
+
typedef :pointer, :eina_list_p
|
33
|
+
typedef :pointer, :eina_iterator_p
|
34
|
+
typedef :pointer, :eina_accessor_p
|
35
|
+
typedef :pointer, :evas_p
|
36
|
+
typedef :pointer, :evas_object_p
|
37
|
+
#
|
38
|
+
end
|
39
|
+
#
|
40
|
+
module Helper
|
41
|
+
def self.included m
|
42
|
+
m.class_eval "def ptr; @ptr; end"
|
43
|
+
m.class_eval "def self.func_prefixes; @func_prefixes; end"
|
44
|
+
m.class_eval "def self.inherited sub; sub.class_eval 'def self.func_prefixes; superclass.func_prefixes; end'; end"
|
45
|
+
end
|
46
|
+
def method_missing m, *args, &block
|
47
|
+
self.class.func_prefixes.each do |p|
|
48
|
+
sym = p+m.to_s
|
49
|
+
if Efl::API.respond_to? sym
|
50
|
+
self.class.class_eval "def #{m} *args, █ r=Efl::API.#{sym}(@ptr,*args); yield r if block_given?; r; end"
|
51
|
+
return self.send m, *args, &block
|
52
|
+
end
|
53
|
+
end
|
54
|
+
r = Efl::API.send m, @ptr, *args
|
55
|
+
self.class.class_eval "def #{m} *args, █ r=Efl::API.#{m}(@ptr,*args); yield r if block_given?; r; end"
|
56
|
+
r
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
#
|
61
|
+
require 'efl/eina/eina_types-ffi'
|
62
|
+
#
|
63
|
+
# EOF
|
data/lib/efl.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
#
|
5
|
+
module Efl
|
6
|
+
# autoload :Eina, './lib/efl/eina.rb'
|
7
|
+
autoload :Eet, './lib/efl/eet.rb'
|
8
|
+
autoload :Evas, './lib/efl/evas.rb'
|
9
|
+
autoload :Ecore, './lib/efl/ecore.rb'
|
10
|
+
autoload :Edje, './lib/efl/edje.rb'
|
11
|
+
autoload :Elm, './lib/efl/elementary.rb'
|
12
|
+
end
|
13
|
+
#
|
14
|
+
# EOF
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
require 'efl/ecore_getopt'
|
5
|
+
#
|
6
|
+
describe Efl::EcoreGetopt do
|
7
|
+
#
|
8
|
+
it "should run a single iteration of the mainloop" do
|
9
|
+
Efl::Ecore.init
|
10
|
+
# puts Efl::EcoreGetopt::EcoreGetopt.methods.sort
|
11
|
+
# eg = Efl::EcoreGetopt::EcoreGetopt.new
|
12
|
+
# val1 = Efl::API::Ecore_Getopt_Value.new
|
13
|
+
# val1[:val] =
|
14
|
+
# val2 = Efl::API::Ecore_Getopt_Value.new
|
15
|
+
#
|
16
|
+
verbosity = 0
|
17
|
+
egd = Efl::API::Ecore_Getopt_Desc.new
|
18
|
+
egd[:shortname] = "V".to_i
|
19
|
+
egd[:longname] = FFI::MemoryPointer.from_string "verbose"
|
20
|
+
egd[:help] = FFI::MemoryPointer.from_string "increase log verbosity"
|
21
|
+
egd[:metavar] = 0
|
22
|
+
egd[:action] = 1 #:ecore_getopt_type_bool
|
23
|
+
egd[:action_param] = 0
|
24
|
+
|
25
|
+
descs = FFI::MemoryPointer.new :pointer, 2, false
|
26
|
+
descs[0] = egd
|
27
|
+
descs[1] = FFI::Pointer::NULL
|
28
|
+
#
|
29
|
+
pointer = FFI::MemoryPointer.new :char, Efl::API::EcoreGetopt.size, false
|
30
|
+
ego = Efl::API::EcoreGetopt.new pointer
|
31
|
+
ego[:prog] = FFI::MemoryPointer.from_string "Prog"
|
32
|
+
ego[:usage] = FFI::MemoryPointer.from_string "Usage"
|
33
|
+
ego[:version] = FFI::MemoryPointer.from_string "0.0.0"
|
34
|
+
ego[:copyright] = FFI::MemoryPointer.from_string "less"
|
35
|
+
ego[:license] = FFI::MemoryPointer.from_string "MIT"
|
36
|
+
ego[:description] = FFI::MemoryPointer.from_string "description"
|
37
|
+
ego[:strict] = 1
|
38
|
+
ego[:descs] = descs
|
39
|
+
args = Efl::EcoreGetopt.parse(ego.to_ptr, FFI::MemoryPointer::NULL, 1, "--help");
|
40
|
+
Efl::Ecore.shutdown
|
41
|
+
end
|
42
|
+
#
|
43
|
+
end
|
data/spec/ecore_spec.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
require 'efl/ecore'
|
5
|
+
#
|
6
|
+
describe Efl::Ecore do
|
7
|
+
#
|
8
|
+
include Efl
|
9
|
+
#
|
10
|
+
before(:all) do
|
11
|
+
USER_SIGNAL_CB = Proc.new do |data, type, event|
|
12
|
+
data.read_string.should eql "ok"
|
13
|
+
type.should eql Ecore::EVENT_SIGNAL_USER
|
14
|
+
event.read_int.should eql 666
|
15
|
+
Ecore.event_current_type_get.should eql Ecore::EVENT_SIGNAL_USER
|
16
|
+
Ecore.event_current_event_get.address.should eql event.address
|
17
|
+
Ecore.main_loop_quit
|
18
|
+
end
|
19
|
+
EVENT_FREE_CB = Proc.new do |data,event|
|
20
|
+
data.read_string.should eql "none"
|
21
|
+
event.read_int.should eql 666
|
22
|
+
end
|
23
|
+
OK = FFI::MemoryPointer.from_string "ok"
|
24
|
+
KO = FFI::MemoryPointer.from_string "ko"
|
25
|
+
NONE = FFI::MemoryPointer.from_string "none"
|
26
|
+
end
|
27
|
+
#
|
28
|
+
it "should init" do
|
29
|
+
Ecore.init.should eql 1
|
30
|
+
Ecore.init.should eql 2
|
31
|
+
Ecore.init.should eql 3
|
32
|
+
end
|
33
|
+
#
|
34
|
+
it "should shutdown" do
|
35
|
+
Ecore.shutdown.should eql 2
|
36
|
+
Ecore.shutdown.should eql 1
|
37
|
+
Ecore.shutdown.should eql 0
|
38
|
+
end
|
39
|
+
#
|
40
|
+
it "should run a single iteration of the mainloop" do
|
41
|
+
Ecore.init
|
42
|
+
Ecore.main_loop_iterate
|
43
|
+
Ecore.shutdown
|
44
|
+
end
|
45
|
+
#
|
46
|
+
it 'should write and read data from pipe' do
|
47
|
+
data = FFI::MemoryPointer.from_string("none")
|
48
|
+
cb = Proc.new do |data,buffer,bytes|
|
49
|
+
data.read_string.should eql 'none'
|
50
|
+
buffer.read_string.should eql 'hello world'
|
51
|
+
bytes.should eql 12
|
52
|
+
end
|
53
|
+
Ecore.init
|
54
|
+
pipe = Ecore::EcorePipe.new cb, data
|
55
|
+
pipe.write("hello world").should be_true
|
56
|
+
Ecore.main_loop_iterate
|
57
|
+
pipe.read_close
|
58
|
+
pipe.write_close
|
59
|
+
pipe.del.address.should eql data.address
|
60
|
+
Ecore.shutdown
|
61
|
+
end
|
62
|
+
#
|
63
|
+
it 'should be able to add, del event hanlder and process event' do
|
64
|
+
Ecore.init
|
65
|
+
evt = FFI::MemoryPointer.new(:int)
|
66
|
+
evt.write_int 666
|
67
|
+
# add, del, add event handler
|
68
|
+
evt_handler = Ecore.event_handler_add Ecore::EVENT_SIGNAL_USER, USER_SIGNAL_CB, KO
|
69
|
+
evt_handler.null?.should be_false
|
70
|
+
Ecore.event_handler_del(evt_handler).address.should eql KO.address
|
71
|
+
evt_handler = Ecore.event_handler_add Ecore::EVENT_SIGNAL_USER, USER_SIGNAL_CB, OK
|
72
|
+
evt_handler.null?.should be_false
|
73
|
+
# add, del, add event
|
74
|
+
ecore_evt = Ecore.event_add Ecore::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE
|
75
|
+
ecore_evt.null?.should be_false
|
76
|
+
Ecore.event_del(ecore_evt).address.should eql NONE.address
|
77
|
+
ecore_evt = Ecore.event_add Ecore::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE
|
78
|
+
ecore_evt.null?.should be_false
|
79
|
+
Ecore.main_loop_begin # process event
|
80
|
+
Ecore.shutdown
|
81
|
+
end
|
82
|
+
#
|
83
|
+
it "should be able to get and set event handler data" do
|
84
|
+
Ecore.init
|
85
|
+
evt = FFI::MemoryPointer.new(:int)
|
86
|
+
evt.write_int 666
|
87
|
+
evt_handler = Ecore.event_handler_add Ecore::EVENT_SIGNAL_USER, USER_SIGNAL_CB, KO
|
88
|
+
evt_handler.null?.should be_false
|
89
|
+
Ecore.event_handler_data_get(evt_handler).read_string.should eql "ko"
|
90
|
+
Ecore.event_handler_data_set(evt_handler, OK).address.should eql KO.address
|
91
|
+
Ecore.event_handler_data_get(evt_handler).read_string.should eql "ok"
|
92
|
+
ecore_evt = Ecore.event_add Ecore::EVENT_SIGNAL_USER, evt, EVENT_FREE_CB, NONE
|
93
|
+
ecore_evt.null?.should be_false
|
94
|
+
Ecore.main_loop_begin # process event
|
95
|
+
Ecore.shutdown
|
96
|
+
end
|
97
|
+
#
|
98
|
+
it "should be able to create new event type" do
|
99
|
+
Ecore.init
|
100
|
+
Ecore.event_type_new.should_not eql 0
|
101
|
+
Ecore.event_type_new.should_not eql 0
|
102
|
+
Ecore.event_type_new.should_not eql 0
|
103
|
+
Ecore.shutdown
|
104
|
+
end
|
105
|
+
#
|
106
|
+
it "should be possible to add and del event filters" do
|
107
|
+
Ecore.init
|
108
|
+
loop_data = FFI::MemoryPointer.from_string("loop_data")
|
109
|
+
event_free_cb = Proc.new do |data,event|
|
110
|
+
data.read_string.should eql "ko"
|
111
|
+
event.read_int.should eql 69
|
112
|
+
end
|
113
|
+
start_cb = Proc.new do |data|
|
114
|
+
data.read_string.should eql "ok"
|
115
|
+
loop_data
|
116
|
+
end
|
117
|
+
count = 0
|
118
|
+
filter_cb = Proc.new do |data,loop_data,type,event|
|
119
|
+
data.read_string.should eql "ok"
|
120
|
+
loop_data.read_string.should eql "loop_data"
|
121
|
+
type.should eql Ecore::EVENT_SIGNAL_USER
|
122
|
+
count += 1
|
123
|
+
if event.read_int == 69
|
124
|
+
count.should eql 1
|
125
|
+
false # drop first event
|
126
|
+
else
|
127
|
+
count.should eql 2
|
128
|
+
event.read_int.should eql 666
|
129
|
+
true
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end_cb = Proc.new do |data,loop_data|
|
133
|
+
data.read_string.should eql "ok"
|
134
|
+
loop_data.read_string.should eql "loop_data"
|
135
|
+
end
|
136
|
+
filter = Ecore.event_filter_add start_cb, filter_cb, end_cb, OK
|
137
|
+
Ecore.event_handler_add Ecore::EVENT_SIGNAL_USER, USER_SIGNAL_CB, OK
|
138
|
+
e1 = FFI::MemoryPointer.new(:int)
|
139
|
+
e1.write_int 69
|
140
|
+
evt1 = Ecore.event_add Ecore::EVENT_SIGNAL_USER, e1, event_free_cb, KO
|
141
|
+
e2 = FFI::MemoryPointer.new(:int)
|
142
|
+
e2.write_int 666
|
143
|
+
evt2 = Ecore.event_add Ecore::EVENT_SIGNAL_USER, e2, EVENT_FREE_CB, NONE
|
144
|
+
Ecore.main_loop_begin # process event
|
145
|
+
Ecore.event_filter_del(filter).address.should eql OK.address
|
146
|
+
evt2 = Ecore.event_add Ecore::EVENT_SIGNAL_USER, e2, EVENT_FREE_CB, NONE
|
147
|
+
Ecore.main_loop_begin # process event
|
148
|
+
Ecore.shutdown
|
149
|
+
end
|
150
|
+
#
|
151
|
+
end
|
data/spec/edje_spec.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
require 'efl/edje'
|
5
|
+
#
|
6
|
+
describe Efl::Edje do
|
7
|
+
#
|
8
|
+
include Efl
|
9
|
+
#
|
10
|
+
it "should init" do
|
11
|
+
Edje.init.should eql 1
|
12
|
+
Edje.init.should eql 2
|
13
|
+
Edje.init.should eql 3
|
14
|
+
end
|
15
|
+
#
|
16
|
+
it "should shutdown" do
|
17
|
+
Edje.shutdown.should eql 2
|
18
|
+
Edje.shutdown.should eql 1
|
19
|
+
Edje.shutdown.should eql 0
|
20
|
+
end
|
21
|
+
#
|
22
|
+
end
|
data/spec/eet_spec.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
require 'efl/eet'
|
5
|
+
#
|
6
|
+
describe Efl::Eet do
|
7
|
+
#
|
8
|
+
include Efl
|
9
|
+
#
|
10
|
+
FP = '/tmp/_eet.cfg'
|
11
|
+
#
|
12
|
+
it "should init" do
|
13
|
+
Eet.init.should eql 1
|
14
|
+
Eet.init.should eql 2
|
15
|
+
Eet.init.should eql 3
|
16
|
+
end
|
17
|
+
#
|
18
|
+
it "should shutdown" do
|
19
|
+
Eet.shutdown.should eql 2
|
20
|
+
Eet.shutdown.should eql 1
|
21
|
+
Eet.shutdown.should eql 0
|
22
|
+
end
|
23
|
+
#
|
24
|
+
it "should clearcache" do
|
25
|
+
Eet.clearcache
|
26
|
+
Eet.clearcache
|
27
|
+
Eet.clearcache
|
28
|
+
end
|
29
|
+
#
|
30
|
+
it "should have good enums" do
|
31
|
+
Efl::API.enum_type(:eet_file_mode)[:eet_file_mode_invalid].should eql -1
|
32
|
+
Efl::API.enum_type(:eet_file_mode)[:eet_file_mode_read].should eql 0
|
33
|
+
Efl::API.enum_type(:eet_file_mode)[:eet_file_mode_write].should eql 1
|
34
|
+
Efl::API.enum_type(:eet_file_mode)[:eet_file_mode_read_write].should eql 2
|
35
|
+
end
|
36
|
+
#
|
37
|
+
it "should open and close" do
|
38
|
+
Eet.init
|
39
|
+
f = Eet.open FP, Efl::API.enum_type(:eet_file_mode)[:eet_file_mode_write]
|
40
|
+
f.write 'fake', 'value'
|
41
|
+
f.close
|
42
|
+
Eet.shutdown
|
43
|
+
end
|
44
|
+
#
|
45
|
+
it "should be able to get file access mode" do
|
46
|
+
Eet.init
|
47
|
+
Efl::API.enum_type(:eet_file_mode).symbols.each do |m|
|
48
|
+
next if m==:eet_file_mode_invalid
|
49
|
+
Eet.open FP, Efl::API.enum_type(:eet_file_mode)[m] do |f|
|
50
|
+
f.mode_get.should eql m
|
51
|
+
end
|
52
|
+
end
|
53
|
+
Eet.shutdown
|
54
|
+
end
|
55
|
+
#
|
56
|
+
it "should write" do
|
57
|
+
Eet.init
|
58
|
+
f = Eet.open FP, :eet_file_mode_write
|
59
|
+
f.mode_get.should eql :eet_file_mode_write
|
60
|
+
f.write 'config', 'test key'
|
61
|
+
f.close
|
62
|
+
Eet.shutdown
|
63
|
+
end
|
64
|
+
#
|
65
|
+
it "should read" do
|
66
|
+
Eet.init
|
67
|
+
f = Eet.open FP, :eet_file_mode_read
|
68
|
+
f.mode_get.should eql :eet_file_mode_read
|
69
|
+
f.read('config').should eql 'test key'
|
70
|
+
f.close
|
71
|
+
Eet.shutdown
|
72
|
+
end
|
73
|
+
#
|
74
|
+
it "should read/write" do
|
75
|
+
Eet.init
|
76
|
+
f = Eet.open FP, :eet_file_mode_read_write
|
77
|
+
f.write 'configg', 'test key'
|
78
|
+
f.read('configg').should eql 'test key'
|
79
|
+
f.close
|
80
|
+
Eet.shutdown
|
81
|
+
end
|
82
|
+
#
|
83
|
+
it "should write in block" do
|
84
|
+
Eet.init
|
85
|
+
Eet.open FP, :eet_file_mode_write do |f|
|
86
|
+
f.write 'config2', 'test--key'
|
87
|
+
end
|
88
|
+
Eet.shutdown
|
89
|
+
end
|
90
|
+
#
|
91
|
+
it "should read in block" do
|
92
|
+
Eet.init
|
93
|
+
Eet.open FP, :eet_file_mode_read do |f|
|
94
|
+
f.read('config2').should eql 'test--key'
|
95
|
+
end
|
96
|
+
Eet.shutdown
|
97
|
+
end
|
98
|
+
#
|
99
|
+
it "should read/write in block" do
|
100
|
+
Eet.init
|
101
|
+
Eet.open FP, :eet_file_mode_read_write do |f|
|
102
|
+
f.write 'config22', 'test--key'
|
103
|
+
f.read('config22').should eql 'test--key'
|
104
|
+
end
|
105
|
+
Eet.shutdown
|
106
|
+
end
|
107
|
+
end
|
data/spec/evas_spec.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
#
|
4
|
+
require 'efl/evas'
|
5
|
+
#
|
6
|
+
describe Efl::Evas do
|
7
|
+
#
|
8
|
+
include Efl
|
9
|
+
#
|
10
|
+
it "should init" do
|
11
|
+
Evas.init.should eql 1
|
12
|
+
Evas.init.should eql 2
|
13
|
+
Evas.init.should eql 3
|
14
|
+
end
|
15
|
+
#
|
16
|
+
it "should shutdown" do
|
17
|
+
Evas.shutdown.should eql 2
|
18
|
+
Evas.shutdown.should eql 1
|
19
|
+
Evas.shutdown.should eql 0
|
20
|
+
end
|
21
|
+
#
|
22
|
+
it "evas alloc error enum is ok" do
|
23
|
+
Efl::API.enum_value(:evas_alloc_error_none).should eql 0
|
24
|
+
Efl::API.enum_value(:evas_alloc_error_fatal).should eql 1
|
25
|
+
Efl::API.enum_value(:evas_alloc_error_recovered).should eql 2
|
26
|
+
Efl::API.enum_type(:evas_alloc_error)[0].should eql :evas_alloc_error_none
|
27
|
+
Efl::API.enum_type(:evas_alloc_error)[1].should eql :evas_alloc_error_fatal
|
28
|
+
Efl::API.enum_type(:evas_alloc_error)[2].should eql :evas_alloc_error_recovered
|
29
|
+
Efl::API.enum_type(:evas_alloc_error)[:evas_alloc_error_none].should eql 0
|
30
|
+
Efl::API.enum_type(:evas_alloc_error)[:evas_alloc_error_fatal].should eql 1
|
31
|
+
Efl::API.enum_type(:evas_alloc_error)[:evas_alloc_error_recovered].should eql 2
|
32
|
+
end
|
33
|
+
#
|
34
|
+
it "should have no memory allocation error occured" do
|
35
|
+
Evas.init
|
36
|
+
Evas.alloc_error.should eql :evas_alloc_error_none
|
37
|
+
Evas.shutdown
|
38
|
+
end
|
39
|
+
#
|
40
|
+
it "should process async events" do
|
41
|
+
cb = Proc.new do |target,type,evt|
|
42
|
+
target.read_string.should eql "target"
|
43
|
+
type.should eql :evas_callback_show
|
44
|
+
evt.read_string.should eql "work"
|
45
|
+
end
|
46
|
+
Evas.init
|
47
|
+
target = FFI::MemoryPointer.from_string("target")
|
48
|
+
work = FFI::MemoryPointer.from_string("work")
|
49
|
+
Evas.async_events_put target, :evas_callback_show, work, cb
|
50
|
+
Evas.async_events_process.should eql 1
|
51
|
+
Evas.async_events_process.should eql 0
|
52
|
+
Evas.shutdown
|
53
|
+
end
|
54
|
+
#
|
55
|
+
describe Efl::Evas::Evas do
|
56
|
+
it "should be able to create and destroy evas" do
|
57
|
+
e1 = Evas::Evas.new
|
58
|
+
e1.ptr.address.should_not eql 0
|
59
|
+
e2 = Evas::Evas.new e1
|
60
|
+
e1.ptr.address.should eql e2.ptr.address
|
61
|
+
e3 = Evas::Evas.new e1.ptr
|
62
|
+
e1.ptr.address.should eql e3.ptr.address
|
63
|
+
e2.ptr.address.should eql e3.ptr.address
|
64
|
+
(e1==e2).should be_false
|
65
|
+
(e2==e3).should be_false
|
66
|
+
(e1==e3).should be_false
|
67
|
+
(e1===e2).should be_true
|
68
|
+
(e2===e3).should be_true
|
69
|
+
(e1===e3).should be_true
|
70
|
+
e1.free
|
71
|
+
e1.ptr.should be_nil
|
72
|
+
e4 = Evas::Evas.new Efl::API.evas_new
|
73
|
+
e4.ptr.address.should_not eql 0
|
74
|
+
e5 = e4.dup
|
75
|
+
e4.ptr.address.should eql e5.ptr.address
|
76
|
+
e6 = e4.clone
|
77
|
+
e4.ptr.address.should eql e6.ptr.address
|
78
|
+
e4.free
|
79
|
+
e4.ptr.should be_nil
|
80
|
+
end
|
81
|
+
#
|
82
|
+
it "focus should work" do
|
83
|
+
e = Evas::Evas.new
|
84
|
+
Efl::API.evas_focus_in e.ptr
|
85
|
+
Efl::API.evas_focus_state_get(e.ptr).should be_true
|
86
|
+
Efl::API.evas_focus_out e.ptr
|
87
|
+
Efl::API.evas_focus_state_get(e.ptr).should be_false
|
88
|
+
Efl::Evas.focus_in e.ptr
|
89
|
+
Efl::Evas.focus_state_get(e.ptr).should be_true
|
90
|
+
Efl::Evas.focus_out e.ptr
|
91
|
+
Efl::Evas.focus_state_get(e.ptr).should be_false
|
92
|
+
e.focus_in { |r| r.should be_nil }
|
93
|
+
e.focus_state_get.should be_true
|
94
|
+
e.focus_state_get { |r| r.should be_true }
|
95
|
+
e.focus_out.should be_nil
|
96
|
+
e.focus_state_get.should be_false
|
97
|
+
e.focus_state_get { |r| r.should be_false }
|
98
|
+
e.free
|
99
|
+
end
|
100
|
+
#
|
101
|
+
end
|
102
|
+
#
|
103
|
+
end
|
data/tasks/ann.rake
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
#
|
3
|
+
begin
|
4
|
+
require 'bones/smtp_tls'
|
5
|
+
rescue LoadError
|
6
|
+
require 'net/smtp'
|
7
|
+
end
|
8
|
+
require 'time'
|
9
|
+
|
10
|
+
namespace :ann do
|
11
|
+
|
12
|
+
# A prerequisites task that all other tasks depend upon
|
13
|
+
task :prereqs
|
14
|
+
file PROJ.ann.file do
|
15
|
+
ann = PROJ.ann
|
16
|
+
puts "Generating #{ann.file}"
|
17
|
+
File.open(ann.file,'w') do |fd|
|
18
|
+
fd.puts("#{PROJ.name} version #{PROJ.version}")
|
19
|
+
fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
|
20
|
+
fd.puts(" #{PROJ.url}") if PROJ.url.valid?
|
21
|
+
fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
|
22
|
+
fd.puts
|
23
|
+
fd.puts("== DESCRIPTION")
|
24
|
+
fd.puts
|
25
|
+
fd.puts(PROJ.description)
|
26
|
+
fd.puts
|
27
|
+
fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
|
28
|
+
fd.puts
|
29
|
+
ann.paragraphs.each do |p|
|
30
|
+
fd.puts "== #{p.upcase}"
|
31
|
+
fd.puts
|
32
|
+
fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
|
33
|
+
fd.puts
|
34
|
+
end
|
35
|
+
fd.puts ann.text if ann.text
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Create an announcement file"
|
40
|
+
task :announcement => ['ann:prereqs', PROJ.ann.file]
|
41
|
+
|
42
|
+
desc "Send an email announcement"
|
43
|
+
task :email => ['ann:prereqs', PROJ.ann.file] do
|
44
|
+
ann = PROJ.ann
|
45
|
+
from = ann.email[:from] || Array(PROJ.authors).first || PROJ.email
|
46
|
+
to = Array(ann.email[:to])
|
47
|
+
|
48
|
+
### build a mail header for RFC 822
|
49
|
+
rfc822msg = "From: #{from}\n"
|
50
|
+
rfc822msg << "To: #{to.join(',')}\n"
|
51
|
+
rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
|
52
|
+
rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
|
53
|
+
rfc822msg << "\n"
|
54
|
+
rfc822msg << "Date: #{Time.new.rfc822}\n"
|
55
|
+
rfc822msg << "Message-Id: "
|
56
|
+
rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
|
57
|
+
rfc822msg << File.read(ann.file)
|
58
|
+
|
59
|
+
params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
|
60
|
+
ann.email[key]
|
61
|
+
end
|
62
|
+
|
63
|
+
params[3] = (PROJ.ann.email[:from] || PROJ.email) if params[3].nil?
|
64
|
+
|
65
|
+
# if ann.email[:tls] and params[4].nil?
|
66
|
+
if params[4].nil?
|
67
|
+
STDOUT.write "Please enter your e-mail password (#{params[3]}): "
|
68
|
+
params[4] = STDIN.gets.chomp
|
69
|
+
end
|
70
|
+
# params = params.shift 2 if not ann.email[:tls]
|
71
|
+
|
72
|
+
### send email
|
73
|
+
# TODO find a way to bypass /var/lib/gems/1.9/gems/bones-3.6.5/lib/bones/smtp_tls.rb which forces starttls usage
|
74
|
+
Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
|
75
|
+
end
|
76
|
+
end # namespace :ann
|
77
|
+
|
78
|
+
desc 'Alias to ann:announcement'
|
79
|
+
task :ann => 'ann:announcement'
|
80
|
+
|
81
|
+
CLOBBER << PROJ.ann.file
|
82
|
+
|
83
|
+
# EOF
|