reflexion 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/body.cpp +53 -0
- data/.doc/ext/reflex/native.cpp +0 -4
- data/.doc/ext/reflex/selector.cpp +3 -3
- data/.doc/ext/reflex/style.cpp +390 -30
- data/.doc/ext/reflex/style_length.cpp +1 -1
- data/.doc/ext/reflex/view.cpp +24 -6
- data/VERSION +1 -1
- data/ext/reflex/body.cpp +59 -0
- data/ext/reflex/native.cpp +0 -4
- data/ext/reflex/selector.cpp +3 -3
- data/ext/reflex/style.cpp +432 -32
- data/ext/reflex/style_length.cpp +1 -1
- data/ext/reflex/view.cpp +25 -5
- data/include/reflex/body.h +16 -0
- data/include/reflex/ruby.h +5 -3
- data/include/reflex/ruby/style.h +11 -0
- data/include/reflex/selector.h +7 -1
- data/include/reflex/style.h +93 -27
- data/include/reflex/view.h +8 -4
- data/lib/reflex.rb +0 -2
- data/lib/reflex/body.rb +1 -0
- data/lib/reflex/button.rb +1 -0
- data/lib/reflex/selector.rb +10 -1
- data/lib/reflex/style.rb +15 -0
- data/lib/reflex/style_length.rb +1 -1
- data/lib/reflex/view.rb +5 -2
- data/lib/reflex/window.rb +2 -2
- data/samples/reflexion/breakout.rb +4 -9
- data/src/body.cpp +61 -0
- data/src/ios/event.mm +1 -3
- data/src/ios/native_window.mm +3 -20
- data/src/ios/opengl_view.mm +1 -1
- data/src/ios/window.mm +7 -0
- data/src/selector.cpp +38 -16
- data/src/style.cpp +515 -161
- data/src/view.cpp +371 -242
- data/src/world.cpp +8 -0
- data/test/test_selector.rb +14 -12
- data/test/test_style.rb +11 -6
- data/test/test_style_length.rb +5 -6
- data/test/test_view.rb +8 -7
- metadata +2 -17
- data/.doc/ext/reflex/style_length2.cpp +0 -149
- data/.doc/ext/reflex/style_length4.cpp +0 -192
- data/ext/reflex/style_length2.cpp +0 -157
- data/ext/reflex/style_length4.cpp +0 -204
- data/include/reflex/ruby/style_length.h +0 -63
- data/include/reflex/style_length.h +0 -147
- data/lib/reflex/style_length2.rb +0 -34
- data/lib/reflex/style_length4.rb +0 -38
- data/src/style_length.cpp +0 -341
- data/test/test_style_length2.rb +0 -50
- data/test/test_style_length4.rb +0 -56
data/src/world.cpp
CHANGED
@@ -250,6 +250,8 @@ namespace Reflex
|
|
250
250
|
return debug_draw;
|
251
251
|
}
|
252
252
|
|
253
|
+
bool is_view_active (View* view);
|
254
|
+
|
253
255
|
void
|
254
256
|
World::BeginContact (b2Contact* contact)
|
255
257
|
{
|
@@ -259,6 +261,9 @@ namespace Reflex
|
|
259
261
|
View* v2 = (View*) contact->GetFixtureB()->GetBody()->GetUserData();
|
260
262
|
if (!v2) return;
|
261
263
|
|
264
|
+
if (!is_view_active(v1) || !is_view_active(v2))
|
265
|
+
return;
|
266
|
+
|
262
267
|
ContactEvent e1(ContactEvent::BEGIN, v2);
|
263
268
|
v1->on_contact(&e1);
|
264
269
|
|
@@ -275,6 +280,9 @@ namespace Reflex
|
|
275
280
|
View* v2 = (View*) contact->GetFixtureB()->GetBody()->GetUserData();
|
276
281
|
if (!v2) return;
|
277
282
|
|
283
|
+
if (!is_view_active(v1) || !is_view_active(v2))
|
284
|
+
return;
|
285
|
+
|
278
286
|
ContactEvent e1(ContactEvent::END, v2);
|
279
287
|
v1->on_contact(&e1);
|
280
288
|
|
data/test/test_selector.rb
CHANGED
@@ -21,7 +21,7 @@ class TestSelector < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
def test_name ()
|
23
23
|
s = sel
|
24
|
-
assert_equal
|
24
|
+
assert_equal '', s.name
|
25
25
|
s.name = 'Test'
|
26
26
|
assert_equal 'Test', s.name
|
27
27
|
end
|
@@ -46,17 +46,19 @@ class TestSelector < Test::Unit::TestCase
|
|
46
46
|
assert_equal [], s.tags.to_a
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
50
|
-
assert_not sel.
|
51
|
-
assert sel(name: :A).
|
52
|
-
assert_not sel(name: :A).
|
53
|
-
assert sel(tag: :T1).
|
54
|
-
assert_not sel(tag: :T1).
|
55
|
-
assert sel(tag: :T1).
|
56
|
-
assert_not sel(tag:
|
57
|
-
assert sel(name: :A, tag: :T1).
|
58
|
-
|
59
|
-
|
49
|
+
def test_contains ()
|
50
|
+
assert_not sel.contains(sel name: :A, tag: :T)
|
51
|
+
assert sel(name: :A).contains(sel name: :A)
|
52
|
+
assert_not sel(name: :A).contains(sel name: :B)
|
53
|
+
assert sel(tag: :T1).contains(sel tag: :T1)
|
54
|
+
assert_not sel(tag: :T1).contains(sel tag: :T2)
|
55
|
+
assert sel(tag: [:T1, :T2]).contains(sel tag: :T1)
|
56
|
+
assert_not sel(tag: :T1).contains(sel tag: [:T1, :T2])
|
57
|
+
assert sel(name: :A, tag: :T1).contains(sel name: :A, tag: :T1)
|
58
|
+
assert sel(name: :A, tag: :T1).contains(sel name: :A)
|
59
|
+
assert sel(name: :A, tag: :T1).contains(sel tag: :T1)
|
60
|
+
assert_not sel(name: :A).contains(sel name: :A, tag: :T1)
|
61
|
+
assert_not sel(tag: :T1).contains(sel name: :A, tag: :T1)
|
60
62
|
end
|
61
63
|
|
62
64
|
def test_compare ()
|
data/test/test_style.rb
CHANGED
@@ -11,7 +11,7 @@ class TestStyle < Test::Unit::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_initialize ()
|
14
|
-
assert_equal
|
14
|
+
assert_equal '', style.name
|
15
15
|
assert_equal 'A', style(name: :A).name
|
16
16
|
assert_equal 'A', style{self.name = :A}.name
|
17
17
|
end
|
@@ -24,7 +24,7 @@ class TestStyle < Test::Unit::TestCase
|
|
24
24
|
def test_flow ()
|
25
25
|
s = style
|
26
26
|
|
27
|
-
assert_equal [:
|
27
|
+
assert_equal [:right, :down], s.flow
|
28
28
|
s.flow = :up
|
29
29
|
assert_equal [:up, :none], s.flow
|
30
30
|
s.flow = [:left, :down]
|
@@ -39,6 +39,7 @@ class TestStyle < Test::Unit::TestCase
|
|
39
39
|
s = style
|
40
40
|
|
41
41
|
assert_equal [0, 0, 0, 0], s.margin.to_a.map(&:value)
|
42
|
+
=begin
|
42
43
|
s.margin = [1]
|
43
44
|
assert_equal [1, 1, 1, 1], s.margin.to_a.map(&:value)
|
44
45
|
s.margin = [1, 2]
|
@@ -47,8 +48,10 @@ class TestStyle < Test::Unit::TestCase
|
|
47
48
|
assert_equal [1, 2, 3, 2], s.margin.to_a.map(&:value)
|
48
49
|
s.margin = [1, 2, 3, 4]
|
49
50
|
assert_equal [1, 2, 3, 4], s.margin.to_a.map(&:value)
|
51
|
+
=end
|
50
52
|
|
51
53
|
assert_equal [0, 0, 0, 0], s.padding.to_a.map(&:value)
|
54
|
+
=begin
|
52
55
|
s.padding = [1]
|
53
56
|
assert_equal [1, 1, 1, 1], s.padding.to_a.map(&:value)
|
54
57
|
s.padding = [1, 2]
|
@@ -57,14 +60,16 @@ class TestStyle < Test::Unit::TestCase
|
|
57
60
|
assert_equal [1, 2, 3, 2], s.padding.to_a.map(&:value)
|
58
61
|
s.padding = [1, 2, 3, 4]
|
59
62
|
assert_equal [1, 2, 3, 4], s.padding.to_a.map(&:value)
|
63
|
+
=end
|
60
64
|
end
|
61
65
|
|
62
|
-
def
|
63
|
-
assert_equal [0, 0, 0, 1], style.
|
66
|
+
def test_fill_stroke ()
|
67
|
+
assert_equal [0, 0, 0, 1], style.fill.to_a
|
68
|
+
assert_equal [0, 0, 0, 1], style.stroke.to_a
|
64
69
|
end
|
65
70
|
|
66
|
-
def
|
67
|
-
assert_equal nil, style.
|
71
|
+
def test_image ()
|
72
|
+
assert_equal nil, style.image
|
68
73
|
end
|
69
74
|
|
70
75
|
end# TestStyle
|
data/test/test_style_length.rb
CHANGED
@@ -17,18 +17,17 @@ class TestStyleLength < Test::Unit::TestCase
|
|
17
17
|
assert_equal :px, len(100).unit
|
18
18
|
assert_equal 100, len(100, :px).value
|
19
19
|
assert_equal :px, len(100, :px).unit
|
20
|
-
|
20
|
+
assert_equal :%, len(100, :%).unit
|
21
21
|
assert_equal 100, len('100px').value
|
22
22
|
assert_equal :px, len('100px').unit
|
23
|
-
|
23
|
+
assert_equal :%, len('100%').unit
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_to_s ()
|
27
27
|
assert_equal '100px', len(100, :px).to_s
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
assert ((len.to_s rescue $!.message)) =~ /InvalidStateError/
|
28
|
+
assert_equal '100%', len(100, :%).to_s
|
29
|
+
assert_equal '100.5%', len(100.5, :%).to_s
|
30
|
+
assert_equal '', len.to_s
|
32
31
|
end
|
33
32
|
|
34
33
|
def test_inspect ()
|
data/test/test_view.rb
CHANGED
@@ -84,13 +84,14 @@ class TestView < Test::Unit::TestCase
|
|
84
84
|
def test_style ()
|
85
85
|
v = view
|
86
86
|
s = v.style
|
87
|
-
assert_equal 0, s.
|
88
|
-
assert_equal nil, s.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
assert_equal
|
93
|
-
assert_equal
|
87
|
+
assert_equal 0, s.margin_left.value
|
88
|
+
assert_equal nil, s.margin_left.unit
|
89
|
+
assert_equal '', s.margin_left.to_s
|
90
|
+
|
91
|
+
s.margin_left = '100px'
|
92
|
+
assert_equal 100, s.margin_left.value
|
93
|
+
assert_equal :px, s.margin_left.unit
|
94
|
+
assert_equal '100px', s.margin_left.to_s
|
94
95
|
end
|
95
96
|
|
96
97
|
def test_add_remove_style ()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reflexion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- snori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -108,8 +108,6 @@ extra_rdoc_files:
|
|
108
108
|
- ".doc/ext/reflex/shape_view.cpp"
|
109
109
|
- ".doc/ext/reflex/style.cpp"
|
110
110
|
- ".doc/ext/reflex/style_length.cpp"
|
111
|
-
- ".doc/ext/reflex/style_length2.cpp"
|
112
|
-
- ".doc/ext/reflex/style_length4.cpp"
|
113
111
|
- ".doc/ext/reflex/update_event.cpp"
|
114
112
|
- ".doc/ext/reflex/view.cpp"
|
115
113
|
- ".doc/ext/reflex/wheel_event.cpp"
|
@@ -142,8 +140,6 @@ files:
|
|
142
140
|
- ext/reflex/shape_view.cpp
|
143
141
|
- ext/reflex/style.cpp
|
144
142
|
- ext/reflex/style_length.cpp
|
145
|
-
- ext/reflex/style_length2.cpp
|
146
|
-
- ext/reflex/style_length4.cpp
|
147
143
|
- ext/reflex/update_event.cpp
|
148
144
|
- ext/reflex/view.cpp
|
149
145
|
- ext/reflex/wheel_event.cpp
|
@@ -176,14 +172,12 @@ files:
|
|
176
172
|
- include/reflex/ruby/selector.h
|
177
173
|
- include/reflex/ruby/shape_view.h
|
178
174
|
- include/reflex/ruby/style.h
|
179
|
-
- include/reflex/ruby/style_length.h
|
180
175
|
- include/reflex/ruby/view.h
|
181
176
|
- include/reflex/ruby/window.h
|
182
177
|
- include/reflex/selector.h
|
183
178
|
- include/reflex/shader.h
|
184
179
|
- include/reflex/shape_view.h
|
185
180
|
- include/reflex/style.h
|
186
|
-
- include/reflex/style_length.h
|
187
181
|
- include/reflex/texture.h
|
188
182
|
- include/reflex/view.h
|
189
183
|
- include/reflex/window.h
|
@@ -224,8 +218,6 @@ files:
|
|
224
218
|
- lib/reflex/shape_view.rb
|
225
219
|
- lib/reflex/style.rb
|
226
220
|
- lib/reflex/style_length.rb
|
227
|
-
- lib/reflex/style_length2.rb
|
228
|
-
- lib/reflex/style_length4.rb
|
229
221
|
- lib/reflex/text_view.rb
|
230
222
|
- lib/reflex/texture.rb
|
231
223
|
- lib/reflex/update_event.rb
|
@@ -400,7 +392,6 @@ files:
|
|
400
392
|
- src/selector.cpp
|
401
393
|
- src/shape_view.cpp
|
402
394
|
- src/style.cpp
|
403
|
-
- src/style_length.cpp
|
404
395
|
- src/view.cpp
|
405
396
|
- src/win32/application.cpp
|
406
397
|
- src/win32/defs.cpp
|
@@ -424,8 +415,6 @@ files:
|
|
424
415
|
- test/test_selector.rb
|
425
416
|
- test/test_style.rb
|
426
417
|
- test/test_style_length.rb
|
427
|
-
- test/test_style_length2.rb
|
428
|
-
- test/test_style_length4.rb
|
429
418
|
- test/test_view.rb
|
430
419
|
- test/test_window.rb
|
431
420
|
- ".doc/ext/reflex/application.cpp"
|
@@ -450,8 +439,6 @@ files:
|
|
450
439
|
- ".doc/ext/reflex/shape_view.cpp"
|
451
440
|
- ".doc/ext/reflex/style.cpp"
|
452
441
|
- ".doc/ext/reflex/style_length.cpp"
|
453
|
-
- ".doc/ext/reflex/style_length2.cpp"
|
454
|
-
- ".doc/ext/reflex/style_length4.cpp"
|
455
442
|
- ".doc/ext/reflex/update_event.cpp"
|
456
443
|
- ".doc/ext/reflex/view.cpp"
|
457
444
|
- ".doc/ext/reflex/wheel_event.cpp"
|
@@ -491,7 +478,5 @@ test_files:
|
|
491
478
|
- test/test_selector.rb
|
492
479
|
- test/test_style.rb
|
493
480
|
- test/test_style_length.rb
|
494
|
-
- test/test_style_length2.rb
|
495
|
-
- test/test_style_length4.rb
|
496
481
|
- test/test_view.rb
|
497
482
|
- test/test_window.rb
|
@@ -1,149 +0,0 @@
|
|
1
|
-
#include "reflex/ruby/style_length.h"
|
2
|
-
|
3
|
-
|
4
|
-
#include <rucy.h>
|
5
|
-
#include "defs.h"
|
6
|
-
|
7
|
-
|
8
|
-
using namespace Rucy;
|
9
|
-
|
10
|
-
|
11
|
-
RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength2)
|
12
|
-
|
13
|
-
#define THIS to<Reflex::StyleLength2*>(self)
|
14
|
-
|
15
|
-
#define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength2, self)
|
16
|
-
|
17
|
-
|
18
|
-
static
|
19
|
-
VALUE alloc(VALUE klass)
|
20
|
-
{
|
21
|
-
return new_type<Reflex::StyleLength2>(klass);
|
22
|
-
}
|
23
|
-
|
24
|
-
static
|
25
|
-
VALUE initialize_copy(VALUE self, VALUE obj)
|
26
|
-
{
|
27
|
-
CHECK;
|
28
|
-
*THIS = to<Reflex::StyleLength2&>(obj).copy();
|
29
|
-
return self;
|
30
|
-
}
|
31
|
-
|
32
|
-
static
|
33
|
-
VALUE set_width(VALUE self, VALUE width)
|
34
|
-
{
|
35
|
-
CHECK;
|
36
|
-
THIS->set_width(to<Reflex::StyleLength>(width));
|
37
|
-
}
|
38
|
-
|
39
|
-
static
|
40
|
-
VALUE get_width(VALUE self)
|
41
|
-
{
|
42
|
-
CHECK;
|
43
|
-
return value(THIS->width());
|
44
|
-
}
|
45
|
-
|
46
|
-
static
|
47
|
-
VALUE set_height(VALUE self, VALUE height)
|
48
|
-
{
|
49
|
-
CHECK;
|
50
|
-
THIS->set_height(to<Reflex::StyleLength>(height));
|
51
|
-
}
|
52
|
-
|
53
|
-
static
|
54
|
-
VALUE get_height(VALUE self)
|
55
|
-
{
|
56
|
-
CHECK;
|
57
|
-
return value(THIS->height());
|
58
|
-
}
|
59
|
-
|
60
|
-
static
|
61
|
-
VALUE set_at(VALUE self, VALUE index, VALUE length)
|
62
|
-
{
|
63
|
-
CHECK;
|
64
|
-
|
65
|
-
int i = index.as_i(), size = (int) THIS->size();
|
66
|
-
while (i < 0) i += size;
|
67
|
-
|
68
|
-
if (i >= size)
|
69
|
-
index_error(__FILE__, __LINE__);
|
70
|
-
|
71
|
-
(*THIS)[i] = to<Reflex::StyleLength>(length);
|
72
|
-
}
|
73
|
-
|
74
|
-
static
|
75
|
-
VALUE get_at(VALUE self, VALUE index)
|
76
|
-
{
|
77
|
-
CHECK;
|
78
|
-
|
79
|
-
int i = index.as_i(), size = (int) THIS->size();
|
80
|
-
while (i < 0) i += size;
|
81
|
-
|
82
|
-
if (i >= size)
|
83
|
-
index_error(__FILE__, __LINE__);
|
84
|
-
|
85
|
-
return value((*THIS)[i]);
|
86
|
-
}
|
87
|
-
|
88
|
-
|
89
|
-
static Class cStyleLength2;
|
90
|
-
|
91
|
-
void
|
92
|
-
Init_style_length2 ()
|
93
|
-
{
|
94
|
-
Module mReflex = rb_define_module("Reflex");
|
95
|
-
|
96
|
-
cStyleLength2 = rb_define_class_under(mReflex, "StyleLength2", rb_cObject);
|
97
|
-
rb_define_alloc_func(cStyleLength2, alloc);
|
98
|
-
rb_define_private_method(cStyleLength2, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
99
|
-
rb_define_method(cStyleLength2, "width=", RUBY_METHOD_FUNC(set_width), 1);
|
100
|
-
rb_define_method(cStyleLength2, "width", RUBY_METHOD_FUNC(get_width), 0);
|
101
|
-
rb_define_method(cStyleLength2, "height=", RUBY_METHOD_FUNC(set_height), 1);
|
102
|
-
rb_define_method(cStyleLength2, "height", RUBY_METHOD_FUNC(get_height), 0);
|
103
|
-
cStyleLength2.define_method("[]=", set_at);
|
104
|
-
cStyleLength2.define_method("[]", get_at);
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
namespace Rucy
|
109
|
-
{
|
110
|
-
|
111
|
-
|
112
|
-
template <> Reflex::StyleLength2
|
113
|
-
value_to<Reflex::StyleLength2> (Value value, bool convert)
|
114
|
-
{
|
115
|
-
if (convert && value.is_array())
|
116
|
-
{
|
117
|
-
Value* a = value.as_array();
|
118
|
-
switch (value.size())
|
119
|
-
{
|
120
|
-
case 1: return Reflex::StyleLength2(
|
121
|
-
to<Reflex::StyleLength>(a[0]));
|
122
|
-
|
123
|
-
case 2: return Reflex::StyleLength2(
|
124
|
-
to<Reflex::StyleLength>(a[0]),
|
125
|
-
to<Reflex::StyleLength>(a[1]));
|
126
|
-
|
127
|
-
default: argument_error(__FILE__, __LINE__);
|
128
|
-
}
|
129
|
-
}
|
130
|
-
|
131
|
-
return value_to<Reflex::StyleLength2&>(value, convert);
|
132
|
-
}
|
133
|
-
|
134
|
-
|
135
|
-
}// Rucy
|
136
|
-
|
137
|
-
|
138
|
-
namespace Reflex
|
139
|
-
{
|
140
|
-
|
141
|
-
|
142
|
-
Class
|
143
|
-
style_length2_class ()
|
144
|
-
{
|
145
|
-
return cStyleLength2;
|
146
|
-
}
|
147
|
-
|
148
|
-
|
149
|
-
}// Reflex
|
@@ -1,192 +0,0 @@
|
|
1
|
-
#include "reflex/ruby/style_length.h"
|
2
|
-
|
3
|
-
|
4
|
-
#include <rucy.h>
|
5
|
-
#include "defs.h"
|
6
|
-
|
7
|
-
|
8
|
-
using namespace Rucy;
|
9
|
-
|
10
|
-
|
11
|
-
RUCY_DEFINE_VALUE_FROM_TO(Reflex::StyleLength4)
|
12
|
-
|
13
|
-
#define THIS to<Reflex::StyleLength4*>(self)
|
14
|
-
|
15
|
-
#define CHECK RUCY_CHECK_OBJ(Reflex::StyleLength4, self)
|
16
|
-
|
17
|
-
|
18
|
-
static
|
19
|
-
VALUE alloc(VALUE klass)
|
20
|
-
{
|
21
|
-
return new_type<Reflex::StyleLength4>(klass);
|
22
|
-
}
|
23
|
-
|
24
|
-
static
|
25
|
-
VALUE initialize_copy(VALUE self, VALUE obj)
|
26
|
-
{
|
27
|
-
CHECK;
|
28
|
-
*THIS = to<Reflex::StyleLength4&>(obj).copy();
|
29
|
-
return self;
|
30
|
-
}
|
31
|
-
|
32
|
-
static
|
33
|
-
VALUE set_left(VALUE self, VALUE left)
|
34
|
-
{
|
35
|
-
CHECK;
|
36
|
-
THIS->set_left(to<Reflex::StyleLength>(left));
|
37
|
-
}
|
38
|
-
|
39
|
-
static
|
40
|
-
VALUE get_left(VALUE self)
|
41
|
-
{
|
42
|
-
CHECK;
|
43
|
-
return value(THIS->left());
|
44
|
-
}
|
45
|
-
|
46
|
-
static
|
47
|
-
VALUE set_top(VALUE self, VALUE top)
|
48
|
-
{
|
49
|
-
CHECK;
|
50
|
-
THIS->set_top(to<Reflex::StyleLength>(top));
|
51
|
-
}
|
52
|
-
|
53
|
-
static
|
54
|
-
VALUE get_top(VALUE self)
|
55
|
-
{
|
56
|
-
CHECK;
|
57
|
-
return value(THIS->top());
|
58
|
-
}
|
59
|
-
|
60
|
-
static
|
61
|
-
VALUE set_right(VALUE self, VALUE right)
|
62
|
-
{
|
63
|
-
CHECK;
|
64
|
-
THIS->set_right(to<Reflex::StyleLength>(right));
|
65
|
-
}
|
66
|
-
|
67
|
-
static
|
68
|
-
VALUE get_right(VALUE self)
|
69
|
-
{
|
70
|
-
CHECK;
|
71
|
-
return value(THIS->right());
|
72
|
-
}
|
73
|
-
|
74
|
-
static
|
75
|
-
VALUE set_bottom(VALUE self, VALUE bottom)
|
76
|
-
{
|
77
|
-
CHECK;
|
78
|
-
THIS->set_bottom(to<Reflex::StyleLength>(bottom));
|
79
|
-
}
|
80
|
-
|
81
|
-
static
|
82
|
-
VALUE get_bottom(VALUE self)
|
83
|
-
{
|
84
|
-
CHECK;
|
85
|
-
return value(THIS->bottom());
|
86
|
-
}
|
87
|
-
|
88
|
-
static
|
89
|
-
VALUE set_at(VALUE self, VALUE index, VALUE length)
|
90
|
-
{
|
91
|
-
CHECK;
|
92
|
-
|
93
|
-
int i = index.as_i(), size = (int) THIS->size();
|
94
|
-
while (i < 0) i += size;
|
95
|
-
|
96
|
-
if (i >= size)
|
97
|
-
index_error(__FILE__, __LINE__);
|
98
|
-
|
99
|
-
(*THIS)[i] = to<Reflex::StyleLength>(length);
|
100
|
-
}
|
101
|
-
|
102
|
-
static
|
103
|
-
VALUE get_at(VALUE self, VALUE index)
|
104
|
-
{
|
105
|
-
CHECK;
|
106
|
-
|
107
|
-
int i = index.as_i(), size = (int) THIS->size();
|
108
|
-
while (i < 0) i += size;
|
109
|
-
|
110
|
-
if (i >= size)
|
111
|
-
index_error(__FILE__, __LINE__);
|
112
|
-
|
113
|
-
return value((*THIS)[i]);
|
114
|
-
}
|
115
|
-
|
116
|
-
|
117
|
-
static Class cStyleLength4;
|
118
|
-
|
119
|
-
void
|
120
|
-
Init_style_length4 ()
|
121
|
-
{
|
122
|
-
Module mReflex = rb_define_module("Reflex");
|
123
|
-
|
124
|
-
cStyleLength4 = rb_define_class_under(mReflex, "StyleLength4", rb_cObject);
|
125
|
-
rb_define_alloc_func(cStyleLength4, alloc);
|
126
|
-
rb_define_private_method(cStyleLength4, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
127
|
-
rb_define_method(cStyleLength4, "left=", RUBY_METHOD_FUNC(set_left), 1);
|
128
|
-
rb_define_method(cStyleLength4, "left", RUBY_METHOD_FUNC(get_left), 0);
|
129
|
-
rb_define_method(cStyleLength4, "top=", RUBY_METHOD_FUNC(set_top), 1);
|
130
|
-
rb_define_method(cStyleLength4, "top", RUBY_METHOD_FUNC(get_top), 0);
|
131
|
-
rb_define_method(cStyleLength4, "right=", RUBY_METHOD_FUNC(set_right), 1);
|
132
|
-
rb_define_method(cStyleLength4, "right", RUBY_METHOD_FUNC(get_right), 0);
|
133
|
-
rb_define_method(cStyleLength4, "bottom=", RUBY_METHOD_FUNC(set_bottom), 1);
|
134
|
-
rb_define_method(cStyleLength4, "bottom", RUBY_METHOD_FUNC(get_bottom), 0);
|
135
|
-
cStyleLength4.define_method("[]=", set_at);
|
136
|
-
cStyleLength4.define_method("[]", get_at);
|
137
|
-
}
|
138
|
-
|
139
|
-
|
140
|
-
namespace Rucy
|
141
|
-
{
|
142
|
-
|
143
|
-
|
144
|
-
template <> Reflex::StyleLength4
|
145
|
-
value_to<Reflex::StyleLength4> (Value value, bool convert)
|
146
|
-
{
|
147
|
-
if (convert && value.is_array())
|
148
|
-
{
|
149
|
-
Value* a = value.as_array();
|
150
|
-
switch (value.size())
|
151
|
-
{
|
152
|
-
case 1: return Reflex::StyleLength4(
|
153
|
-
to<Reflex::StyleLength>(a[0]));
|
154
|
-
|
155
|
-
case 2: return Reflex::StyleLength4(
|
156
|
-
to<Reflex::StyleLength>(a[0]),
|
157
|
-
to<Reflex::StyleLength>(a[1]));
|
158
|
-
|
159
|
-
case 3: return Reflex::StyleLength4(
|
160
|
-
to<Reflex::StyleLength>(a[0]),
|
161
|
-
to<Reflex::StyleLength>(a[1]),
|
162
|
-
to<Reflex::StyleLength>(a[2]));
|
163
|
-
|
164
|
-
case 4: return Reflex::StyleLength4(
|
165
|
-
to<Reflex::StyleLength>(a[0]),
|
166
|
-
to<Reflex::StyleLength>(a[1]),
|
167
|
-
to<Reflex::StyleLength>(a[2]),
|
168
|
-
to<Reflex::StyleLength>(a[3]));
|
169
|
-
|
170
|
-
default: argument_error(__FILE__, __LINE__);
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
|
-
return value_to<Reflex::StyleLength4&>(value, convert);
|
175
|
-
}
|
176
|
-
|
177
|
-
|
178
|
-
}// Rucy
|
179
|
-
|
180
|
-
|
181
|
-
namespace Reflex
|
182
|
-
{
|
183
|
-
|
184
|
-
|
185
|
-
Class
|
186
|
-
style_length4_class ()
|
187
|
-
{
|
188
|
-
return cStyleLength4;
|
189
|
-
}
|
190
|
-
|
191
|
-
|
192
|
-
}// Reflex
|