reflexion 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5161374ea08be1889e5cc2efe3e1428e8d9d620f8bac6073e5b010bd10bedebe
4
- data.tar.gz: 2ba43dca1df02955b05cf58f6a9046f21941a605f8c9d8c1bdc744fb8d808ab2
3
+ metadata.gz: 79fd61794a59ff8ba0b15f2f32515ef63064bc1e62c92adc081712bac777fa4d
4
+ data.tar.gz: 3a7fdb5fd13bcecebf019185329450ee92b09d18c9b2c5ecefcc8c08d562469c
5
5
  SHA512:
6
- metadata.gz: 4e237f277deb2ca92edee8663023891f3bba4cc8d2ac8e54ed7317f1dee8907c159afb3e20a7b6c5d798e0d0979b8bec709cf19a18decba5578d782e36c1e8d8
7
- data.tar.gz: 61430437a4717c0547f3fb8432e0faa0532391e1bee56fa46083986e4f1c68d7aa194d261264144c1f7416f4c1926e6f7ca4e32a0ca371835337e9a57b5abb65
6
+ metadata.gz: 78e88670abd02997ea2e9aee2b373687109e9fb78f1f951f74277506f2f4ad2e83fe65cd85847a1be812d34e914671ba186a522db944423df4e8e940d99d3c81
7
+ data.tar.gz: 9d334478e511ff0d6aea0575d6a11b093e652209693e1d04775eff4807479fba836759eb800f526b48715e7fa854ebbcc54e638101739e24d4695734774912f5
@@ -19,13 +19,12 @@ VALUE alloc(VALUE klass)
19
19
  }
20
20
 
21
21
  static
22
- VALUE initialize(VALUE self)
22
+ VALUE initialize(VALUE self, VALUE begin, VALUE end)
23
23
  {
24
24
  CHECK;
25
- check_arg_count(__FILE__, __LINE__, "CaptureEvent#initialize", argc, 0, 1, 2);
26
25
 
27
- THIS->begin = (argc >= 1) ? to<uint>(argv[0]) : 0;
28
- THIS->end = (argc >= 2) ? to<uint>(argv[1]) : 0;
26
+ THIS->begin = to<uint>(begin);
27
+ THIS->end = to<uint>(end);
29
28
 
30
29
  return rb_call_super(0, NULL);
31
30
  }
@@ -62,7 +61,7 @@ Init_capture_event ()
62
61
 
63
62
  cCaptureEvent = mReflex.define_class("CaptureEvent", Reflex::event_class());
64
63
  rb_define_alloc_func(cCaptureEvent, alloc);
65
- rb_define_private_method(cCaptureEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
64
+ rb_define_private_method(cCaptureEvent, "initialize", RUBY_METHOD_FUNC(initialize), 2);
66
65
  rb_define_private_method(cCaptureEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
67
66
  rb_define_private_method(cCaptureEvent, "get_begin", RUBY_METHOD_FUNC(begin), 0);
68
67
  rb_define_private_method(cCaptureEvent, "get_end", RUBY_METHOD_FUNC(end), 0);
@@ -20,15 +20,12 @@ VALUE alloc(VALUE klass)
20
20
  }
21
21
 
22
22
  static
23
- VALUE initialize(VALUE self)
23
+ VALUE initialize(VALUE self, VALUE type, VALUE shape)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "ContactEvent#initialize", argc, 0, 2);
27
26
 
28
- THIS->type = (argc >= 1)
29
- ? (Reflex::ContactEvent::Type) to<int>(argv[0])
30
- : Reflex::ContactEvent::NONE;
31
- THIS->shape = (argc >= 2) ? to<Reflex::Shape*>(argv[1]) : NULL;
27
+ THIS->type = (Reflex::ContactEvent::Type) to<int>(type);
28
+ THIS->shape = to<Reflex::Shape*>(shape);
32
29
 
33
30
  return rb_call_super(0, NULL);
34
31
  }
@@ -72,7 +69,7 @@ Init_contact_event ()
72
69
 
73
70
  cContactEvent = mReflex.define_class("ContactEvent", Reflex::event_class());
74
71
  rb_define_alloc_func(cContactEvent, alloc);
75
- rb_define_private_method(cContactEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
72
+ rb_define_private_method(cContactEvent, "initialize", RUBY_METHOD_FUNC(initialize), 2);
76
73
  rb_define_private_method(cContactEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
77
74
  rb_define_method(cContactEvent, "type", RUBY_METHOD_FUNC(type), 0);
78
75
  rb_define_method(cContactEvent, "shape", RUBY_METHOD_FUNC(shape), 0);
@@ -20,12 +20,11 @@ VALUE alloc(VALUE klass)
20
20
  }
21
21
 
22
22
  static
23
- VALUE initialize(VALUE self)
23
+ VALUE initialize(VALUE self, VALUE dt)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "DrawEvent#initialize", argc, 0, 1);
27
26
 
28
- THIS->dt = (argc >= 1) ? to<float>(argv[0]) : 0;
27
+ THIS->dt = to<float>(dt);
29
28
 
30
29
  return rb_call_super(0, NULL);
31
30
  }
@@ -76,7 +75,7 @@ Init_draw_event ()
76
75
 
77
76
  cDrawEvent = mReflex.define_class("DrawEvent", Reflex::event_class());
78
77
  rb_define_alloc_func(cDrawEvent, alloc);
79
- rb_define_private_method(cDrawEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
78
+ rb_define_private_method(cDrawEvent, "initialize", RUBY_METHOD_FUNC(initialize), 1);
80
79
  rb_define_private_method(cDrawEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
81
80
  rb_define_method(cDrawEvent, "painter", RUBY_METHOD_FUNC(painter), 0);
82
81
  rb_define_method(cDrawEvent, "bounds", RUBY_METHOD_FUNC(bounds), 0);
@@ -20,16 +20,15 @@ VALUE alloc(VALUE klass)
20
20
  }
21
21
 
22
22
  static
23
- VALUE initialize(VALUE self)
23
+ VALUE initialize(VALUE self, VALUE frame, VALUE dx, VALUE dy, VALUE dwidth, VALUE dheight)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "FrameEvent#initialize", argc, 0, 1, 2, 3, 4, 5);
27
26
 
28
- THIS->frame = (argc >= 1) ? to<Rays::Bounds&>(argv[0]) : Rays::Bounds(0);
29
- THIS->dx = (argc >= 2) ? to<coord>(argv[1]) : 0;
30
- THIS->dy = (argc >= 3) ? to<coord>(argv[2]) : 0;
31
- THIS->dwidth = (argc >= 4) ? to<coord>(argv[3]) : 0;
32
- THIS->dheight = (argc >= 5) ? to<coord>(argv[4]) : 0;
27
+ THIS->frame = to<Rays::Bounds>(frame);
28
+ THIS->dx = to<coord>(dx);
29
+ THIS->dy = to<coord>(dy);
30
+ THIS->dwidth = to<coord>(dwidth);
31
+ THIS->dheight = to<coord>(dheight);
33
32
 
34
33
  return rb_call_super(0, NULL);
35
34
  }
@@ -136,7 +135,7 @@ Init_frame_event ()
136
135
 
137
136
  cFrameEvent = mReflex.define_class("FrameEvent", Reflex::event_class());
138
137
  rb_define_alloc_func(cFrameEvent, alloc);
139
- rb_define_private_method(cFrameEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
138
+ rb_define_private_method(cFrameEvent, "initialize", RUBY_METHOD_FUNC(initialize), 5);
140
139
  rb_define_private_method(cFrameEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
141
140
  rb_define_method(cFrameEvent, "frame", RUBY_METHOD_FUNC(frame), 0);
142
141
  rb_define_method(cFrameEvent, "dx", RUBY_METHOD_FUNC(dx), 0);
@@ -18,16 +18,15 @@ VALUE alloc(VALUE klass)
18
18
  }
19
19
 
20
20
  static
21
- VALUE initialize(VALUE self)
21
+ VALUE initialize(VALUE self, VALUE type, VALUE chars, VALUE code, VALUE repeat, VALUE modifiers)
22
22
  {
23
23
  CHECK;
24
- check_arg_count(__FILE__, __LINE__, "KeyEvent#initialize", argc, 0, 1, 2, 3, 4, 5);
25
24
 
26
- THIS->type = (argc >= 1) ? (Reflex::KeyEvent::Type) to<int>(argv[0]) : Reflex::KeyEvent::NONE;
27
- THIS->chars = (argc >= 2) ? argv[1].c_str() : NULL;
28
- THIS->code = (argc >= 3) ? to<int>(argv[2]) : Reflex::KEY_NONE;
29
- THIS->repeat = (argc >= 4) ? to<int>(argv[3]) : 1;
30
- THIS->modifiers = (argc >= 5) ? to<uint>(argv[4]) : (uint) Reflex::MOD_NONE;
25
+ THIS->type = (Reflex::KeyEvent::Type) to<int>(type);
26
+ THIS->chars = chars.c_str();
27
+ THIS->code = to<int>(code);
28
+ THIS->repeat = to<int>(repeat);
29
+ THIS->modifiers = to<uint>(modifiers);
31
30
 
32
31
  return rb_call_super(0, NULL);
33
32
  }
@@ -92,7 +91,7 @@ Init_key_event ()
92
91
 
93
92
  cKeyEvent = mReflex.define_class("KeyEvent", Reflex::event_class());
94
93
  rb_define_alloc_func(cKeyEvent, alloc);
95
- rb_define_private_method(cKeyEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
94
+ rb_define_private_method(cKeyEvent, "initialize", RUBY_METHOD_FUNC(initialize), 5);
96
95
  rb_define_private_method(cKeyEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
97
96
  rb_define_method(cKeyEvent, "type", RUBY_METHOD_FUNC(type), 0);
98
97
  rb_define_method(cKeyEvent, "chars", RUBY_METHOD_FUNC(chars), 0);
@@ -19,13 +19,11 @@ VALUE alloc(VALUE klass)
19
19
  }
20
20
 
21
21
  static
22
- VALUE initialize(VALUE self)
22
+ VALUE initialize(VALUE self, VALUE gravity)
23
23
  {
24
24
  CHECK;
25
- check_arg_count(__FILE__, __LINE__, "MotionEvent#initialize", argc, 0, 1);
26
25
 
27
- if (argc >= 1)
28
- THIS->gravity = to<Rays::Point>(argv[0]);
26
+ THIS->gravity = to<Rays::Point>(gravity);
29
27
 
30
28
  return rb_call_super(0, NULL);
31
29
  }
@@ -55,7 +53,7 @@ Init_motion_event ()
55
53
 
56
54
  cMotionEvent = mReflex.define_class("MotionEvent", Reflex::event_class());
57
55
  rb_define_alloc_func(cMotionEvent, alloc);
58
- rb_define_private_method(cMotionEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
56
+ rb_define_private_method(cMotionEvent, "initialize", RUBY_METHOD_FUNC(initialize), 1);
59
57
  rb_define_private_method(cMotionEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
60
58
  rb_define_method(cMotionEvent, "gravity", RUBY_METHOD_FUNC(gravity), 0);
61
59
  }
@@ -19,19 +19,23 @@ VALUE alloc(VALUE klass)
19
19
  }
20
20
 
21
21
  static
22
- VALUE initialize(VALUE self)
22
+ VALUE initialize(VALUE self, VALUE type, VALUE pointer_type, VALUE modifiers, VALUE count, VALUE drag, VALUE positions)
23
23
  {
24
24
  CHECK;
25
- check_arg_count(__FILE__, __LINE__, "PointerEvent#initialize", argc, 0, 1, 2, 3, 4, 5, 6, 7);
26
25
 
27
- THIS->type = (argc >= 1) ? (Reflex::PointerEvent::Type) to<int>(argv[0]) : Reflex::PointerEvent::NONE;
28
- THIS->pointer_type = (argc >= 2) ? to<uint>(argv[1]) : Reflex::POINTER_NONE;
29
- THIS->x = (argc >= 3) ? to<coord>(argv[2]) : 0;
30
- THIS->y = (argc >= 4) ? to<coord>(argv[3]) : 0;
31
- THIS->size = 1;
32
- THIS->modifiers = (argc >= 5) ? to<uint>(argv[4]) : (uint) Reflex::MOD_NONE;
33
- THIS->count = (argc >= 6) ? to<uint>(argv[5]) : 0;
34
- THIS->drag = (argc >= 7) ? to<bool>(argv[6]) : false;
26
+ int size = positions.size();
27
+ if (size <= 0 || Reflex::PointerEvent::MAX < size)
28
+ argument_error(__FILE__, __LINE__);
29
+
30
+ THIS->type = (Reflex::PointerEvent::Type) to<int>(type);
31
+ THIS->pointer_type = to<uint>(pointer_type);
32
+ THIS->modifiers = to<uint>(modifiers);
33
+ THIS->count = to<uint>(count);
34
+ THIS->drag = to<bool>(drag);
35
+ THIS->size = (size_t) size;
36
+
37
+ for (int i = 0; i < size; ++i)
38
+ THIS->positions[i] = to<Rays::Point>(positions[i]);
35
39
 
36
40
  return rb_call_super(0, NULL);
37
41
  }
@@ -118,10 +122,15 @@ VALUE position(VALUE self)
118
122
  }
119
123
 
120
124
  static
121
- VALUE array_get(VALUE self, VALUE index)
125
+ VALUE get_at(VALUE self, VALUE index)
122
126
  {
123
127
  CHECK;
124
- return value((*THIS)[to<int>(index)]);
128
+
129
+ int i = to<int>(index);
130
+ if (i < 0 || THIS->size <= (size_t) i)
131
+ index_error(__FILE__, __LINE__);
132
+
133
+ return value((*THIS)[i]);
125
134
  }
126
135
 
127
136
 
@@ -134,7 +143,7 @@ Init_pointer_event ()
134
143
 
135
144
  cPointerEvent = mReflex.define_class("PointerEvent", Reflex::event_class());
136
145
  rb_define_alloc_func(cPointerEvent, alloc);
137
- rb_define_private_method(cPointerEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
146
+ rb_define_private_method(cPointerEvent, "initialize", RUBY_METHOD_FUNC(initialize), 6);
138
147
  rb_define_private_method(cPointerEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
139
148
  rb_define_method(cPointerEvent, "type", RUBY_METHOD_FUNC(type), 0);
140
149
  rb_define_method(cPointerEvent, "pointer_type", RUBY_METHOD_FUNC(pointer_type), 0);
@@ -146,7 +155,7 @@ Init_pointer_event ()
146
155
  rb_define_method(cPointerEvent, "x", RUBY_METHOD_FUNC(x), 0);
147
156
  rb_define_method(cPointerEvent, "y", RUBY_METHOD_FUNC(y), 0);
148
157
  rb_define_method(cPointerEvent, "position", RUBY_METHOD_FUNC(position), -1);
149
- cPointerEvent.define_method("[]", array_get);
158
+ cPointerEvent.define_method("[]", get_at);
150
159
  cPointerEvent.define_const("TYPE_NONE", Reflex::PointerEvent::NONE);
151
160
  cPointerEvent.define_const("TYPE_DOWN", Reflex::PointerEvent::DOWN);
152
161
  cPointerEvent.define_const("TYPE_UP", Reflex::PointerEvent::UP);
@@ -19,17 +19,16 @@ VALUE alloc(VALUE klass)
19
19
  }
20
20
 
21
21
  static
22
- VALUE initialize(VALUE self)
22
+ VALUE initialize(VALUE self, VALUE x, VALUE y, VALUE z, VALUE dx, VALUE dy, VALUE dz)
23
23
  {
24
24
  CHECK;
25
- check_arg_count(__FILE__, __LINE__, "ScrollEvent#initialize", argc, 0, 1, 2, 3, 4, 5, 6);
26
25
 
27
- THIS->x = (argc >= 1) ? to<coord>(argv[0]) : 0;
28
- THIS->y = (argc >= 2) ? to<coord>(argv[1]) : 0;
29
- THIS->z = (argc >= 3) ? to<coord>(argv[2]) : 0;
30
- THIS->dx = (argc >= 4) ? to<coord>(argv[3]) : 0;
31
- THIS->dy = (argc >= 5) ? to<coord>(argv[4]) : 0;
32
- THIS->dz = (argc >= 6) ? to<coord>(argv[5]) : 0;
26
+ THIS->x = to<coord>(x);
27
+ THIS->y = to<coord>(y);
28
+ THIS->z = to<coord>(z);
29
+ THIS->dx = to<coord>(dx);
30
+ THIS->dy = to<coord>(dy);
31
+ THIS->dz = to<coord>(dz);
33
32
 
34
33
  return rb_call_super(0, NULL);
35
34
  }
@@ -108,7 +107,7 @@ Init_scroll_event ()
108
107
 
109
108
  cScrollEvent = mReflex.define_class("ScrollEvent", Reflex::event_class());
110
109
  rb_define_alloc_func(cScrollEvent, alloc);
111
- rb_define_private_method(cScrollEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
110
+ rb_define_private_method(cScrollEvent, "initialize", RUBY_METHOD_FUNC(initialize), 6);
112
111
  rb_define_private_method(cScrollEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
113
112
  rb_define_method(cScrollEvent, "x", RUBY_METHOD_FUNC(x), 0);
114
113
  rb_define_method(cScrollEvent, "y", RUBY_METHOD_FUNC(y), 0);
@@ -18,13 +18,12 @@ VALUE alloc(VALUE klass)
18
18
  }
19
19
 
20
20
  static
21
- VALUE initialize(VALUE self)
21
+ VALUE initialize(VALUE self, VALUE now, VALUE dt)
22
22
  {
23
23
  CHECK;
24
- check_arg_count(__FILE__, __LINE__, "UpdateEvent#initialize", argc, 0, 1, 2);
25
24
 
26
- THIS->now = (argc >= 1) ? to<double>(argv[0]) : 0;
27
- THIS->dt = (argc >= 2) ? to<float>(argv[1]) : 0;
25
+ THIS->now = to<double>(now);
26
+ THIS->dt = to<float>(dt);
28
27
 
29
28
  return rb_call_super(0, NULL);
30
29
  }
@@ -61,7 +60,7 @@ Init_update_event ()
61
60
 
62
61
  cUpdateEvent = mReflex.define_class("UpdateEvent", Reflex::event_class());
63
62
  rb_define_alloc_func(cUpdateEvent, alloc);
64
- rb_define_private_method(cUpdateEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
63
+ rb_define_private_method(cUpdateEvent, "initialize", RUBY_METHOD_FUNC(initialize), 2);
65
64
  rb_define_private_method(cUpdateEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
66
65
  rb_define_method(cUpdateEvent, "now", RUBY_METHOD_FUNC(now), 0);
67
66
  rb_define_method(cUpdateEvent, "dt", RUBY_METHOD_FUNC(dt), 0);
@@ -19,14 +19,13 @@ VALUE alloc(VALUE klass)
19
19
  }
20
20
 
21
21
  static
22
- VALUE initialize(VALUE self)
22
+ VALUE initialize(VALUE self, VALUE dx, VALUE dy, VALUE dz)
23
23
  {
24
24
  CHECK;
25
- check_arg_count(__FILE__, __LINE__, "WheelEvent#initialize", argc, 0, 1, 2, 3);
26
25
 
27
- THIS->dx = (argc >= 1) ? to<coord>(argv[0]) : 0;
28
- THIS->dy = (argc >= 2) ? to<coord>(argv[1]) : 0;
29
- THIS->dz = (argc >= 3) ? to<coord>(argv[2]) : 0;
26
+ THIS->dx = to<coord>(dx);
27
+ THIS->dy = to<coord>(dy);
28
+ THIS->dz = to<coord>(dz);
30
29
 
31
30
  return rb_call_super(0, NULL);
32
31
  }
@@ -98,7 +97,7 @@ Init_wheel_event ()
98
97
 
99
98
  cWheelEvent = mReflex.define_class("WheelEvent", Reflex::event_class());
100
99
  rb_define_alloc_func(cWheelEvent, alloc);
101
- rb_define_private_method(cWheelEvent, "initialize", RUBY_METHOD_FUNC(initialize), -1);
100
+ rb_define_private_method(cWheelEvent, "initialize", RUBY_METHOD_FUNC(initialize), 3);
102
101
  rb_define_private_method(cWheelEvent, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
103
102
  rb_define_method(cWheelEvent, "dx", RUBY_METHOD_FUNC(dx), 0);
104
103
  rb_define_method(cWheelEvent, "dy", RUBY_METHOD_FUNC(dy), 0);
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.15
1
+ 0.1.16
@@ -20,13 +20,12 @@ RUCY_DEF_ALLOC(alloc, klass)
20
20
  RUCY_END
21
21
 
22
22
  static
23
- RUCY_DEFN(initialize)
23
+ RUCY_DEF2(initialize, begin, end)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "CaptureEvent#initialize", argc, 0, 1, 2);
27
26
 
28
- THIS->begin = (argc >= 1) ? to<uint>(argv[0]) : 0;
29
- THIS->end = (argc >= 2) ? to<uint>(argv[1]) : 0;
27
+ THIS->begin = to<uint>(begin);
28
+ THIS->end = to<uint>(end);
30
29
 
31
30
  return rb_call_super(0, NULL);
32
31
  }
@@ -21,15 +21,12 @@ RUCY_DEF_ALLOC(alloc, klass)
21
21
  RUCY_END
22
22
 
23
23
  static
24
- RUCY_DEFN(initialize)
24
+ RUCY_DEF2(initialize, type, shape)
25
25
  {
26
26
  CHECK;
27
- check_arg_count(__FILE__, __LINE__, "ContactEvent#initialize", argc, 0, 2);
28
27
 
29
- THIS->type = (argc >= 1)
30
- ? (Reflex::ContactEvent::Type) to<int>(argv[0])
31
- : Reflex::ContactEvent::NONE;
32
- THIS->shape = (argc >= 2) ? to<Reflex::Shape*>(argv[1]) : NULL;
28
+ THIS->type = (Reflex::ContactEvent::Type) to<int>(type);
29
+ THIS->shape = to<Reflex::Shape*>(shape);
33
30
 
34
31
  return rb_call_super(0, NULL);
35
32
  }
@@ -21,12 +21,11 @@ RUCY_DEF_ALLOC(alloc, klass)
21
21
  RUCY_END
22
22
 
23
23
  static
24
- RUCY_DEFN(initialize)
24
+ RUCY_DEF1(initialize, dt)
25
25
  {
26
26
  CHECK;
27
- check_arg_count(__FILE__, __LINE__, "DrawEvent#initialize", argc, 0, 1);
28
27
 
29
- THIS->dt = (argc >= 1) ? to<float>(argv[0]) : 0;
28
+ THIS->dt = to<float>(dt);
30
29
 
31
30
  return rb_call_super(0, NULL);
32
31
  }
@@ -21,16 +21,15 @@ RUCY_DEF_ALLOC(alloc, klass)
21
21
  RUCY_END
22
22
 
23
23
  static
24
- RUCY_DEFN(initialize)
24
+ RUCY_DEF5(initialize, frame, dx, dy, dwidth, dheight)
25
25
  {
26
26
  CHECK;
27
- check_arg_count(__FILE__, __LINE__, "FrameEvent#initialize", argc, 0, 1, 2, 3, 4, 5);
28
27
 
29
- THIS->frame = (argc >= 1) ? to<Rays::Bounds&>(argv[0]) : Rays::Bounds(0);
30
- THIS->dx = (argc >= 2) ? to<coord>(argv[1]) : 0;
31
- THIS->dy = (argc >= 3) ? to<coord>(argv[2]) : 0;
32
- THIS->dwidth = (argc >= 4) ? to<coord>(argv[3]) : 0;
33
- THIS->dheight = (argc >= 5) ? to<coord>(argv[4]) : 0;
28
+ THIS->frame = to<Rays::Bounds>(frame);
29
+ THIS->dx = to<coord>(dx);
30
+ THIS->dy = to<coord>(dy);
31
+ THIS->dwidth = to<coord>(dwidth);
32
+ THIS->dheight = to<coord>(dheight);
34
33
 
35
34
  return rb_call_super(0, NULL);
36
35
  }
@@ -19,16 +19,15 @@ RUCY_DEF_ALLOC(alloc, klass)
19
19
  RUCY_END
20
20
 
21
21
  static
22
- RUCY_DEFN(initialize)
22
+ RUCY_DEF5(initialize, type, chars, code, repeat, modifiers)
23
23
  {
24
24
  CHECK;
25
- check_arg_count(__FILE__, __LINE__, "KeyEvent#initialize", argc, 0, 1, 2, 3, 4, 5);
26
25
 
27
- THIS->type = (argc >= 1) ? (Reflex::KeyEvent::Type) to<int>(argv[0]) : Reflex::KeyEvent::NONE;
28
- THIS->chars = (argc >= 2) ? argv[1].c_str() : NULL;
29
- THIS->code = (argc >= 3) ? to<int>(argv[2]) : Reflex::KEY_NONE;
30
- THIS->repeat = (argc >= 4) ? to<int>(argv[3]) : 1;
31
- THIS->modifiers = (argc >= 5) ? to<uint>(argv[4]) : (uint) Reflex::MOD_NONE;
26
+ THIS->type = (Reflex::KeyEvent::Type) to<int>(type);
27
+ THIS->chars = chars.c_str();
28
+ THIS->code = to<int>(code);
29
+ THIS->repeat = to<int>(repeat);
30
+ THIS->modifiers = to<uint>(modifiers);
32
31
 
33
32
  return rb_call_super(0, NULL);
34
33
  }
@@ -20,13 +20,11 @@ RUCY_DEF_ALLOC(alloc, klass)
20
20
  RUCY_END
21
21
 
22
22
  static
23
- RUCY_DEFN(initialize)
23
+ RUCY_DEF1(initialize, gravity)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "MotionEvent#initialize", argc, 0, 1);
27
26
 
28
- if (argc >= 1)
29
- THIS->gravity = to<Rays::Point>(argv[0]);
27
+ THIS->gravity = to<Rays::Point>(gravity);
30
28
 
31
29
  return rb_call_super(0, NULL);
32
30
  }
@@ -20,19 +20,23 @@ RUCY_DEF_ALLOC(alloc, klass)
20
20
  RUCY_END
21
21
 
22
22
  static
23
- RUCY_DEFN(initialize)
23
+ RUCY_DEF6(initialize, type, pointer_type, modifiers, count, drag, positions)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "PointerEvent#initialize", argc, 0, 1, 2, 3, 4, 5, 6, 7);
27
26
 
28
- THIS->type = (argc >= 1) ? (Reflex::PointerEvent::Type) to<int>(argv[0]) : Reflex::PointerEvent::NONE;
29
- THIS->pointer_type = (argc >= 2) ? to<uint>(argv[1]) : Reflex::POINTER_NONE;
30
- THIS->x = (argc >= 3) ? to<coord>(argv[2]) : 0;
31
- THIS->y = (argc >= 4) ? to<coord>(argv[3]) : 0;
32
- THIS->size = 1;
33
- THIS->modifiers = (argc >= 5) ? to<uint>(argv[4]) : (uint) Reflex::MOD_NONE;
34
- THIS->count = (argc >= 6) ? to<uint>(argv[5]) : 0;
35
- THIS->drag = (argc >= 7) ? to<bool>(argv[6]) : false;
27
+ int size = positions.size();
28
+ if (size <= 0 || Reflex::PointerEvent::MAX < size)
29
+ argument_error(__FILE__, __LINE__);
30
+
31
+ THIS->type = (Reflex::PointerEvent::Type) to<int>(type);
32
+ THIS->pointer_type = to<uint>(pointer_type);
33
+ THIS->modifiers = to<uint>(modifiers);
34
+ THIS->count = to<uint>(count);
35
+ THIS->drag = to<bool>(drag);
36
+ THIS->size = (size_t) size;
37
+
38
+ for (int i = 0; i < size; ++i)
39
+ THIS->positions[i] = to<Rays::Point>(positions[i]);
36
40
 
37
41
  return rb_call_super(0, NULL);
38
42
  }
@@ -131,10 +135,15 @@ RUCY_DEFN(position)
131
135
  RUCY_END
132
136
 
133
137
  static
134
- RUCY_DEF1(array_get, index)
138
+ RUCY_DEF1(get_at, index)
135
139
  {
136
140
  CHECK;
137
- return value((*THIS)[to<int>(index)]);
141
+
142
+ int i = to<int>(index);
143
+ if (i < 0 || THIS->size <= (size_t) i)
144
+ index_error(__FILE__, __LINE__);
145
+
146
+ return value((*THIS)[i]);
138
147
  }
139
148
  RUCY_END
140
149
 
@@ -160,7 +169,7 @@ Init_pointer_event ()
160
169
  cPointerEvent.define_method("x", x);
161
170
  cPointerEvent.define_method("y", y);
162
171
  cPointerEvent.define_method("position", position);
163
- cPointerEvent.define_method("[]", array_get);
172
+ cPointerEvent.define_method("[]", get_at);
164
173
  cPointerEvent.define_const("TYPE_NONE", Reflex::PointerEvent::NONE);
165
174
  cPointerEvent.define_const("TYPE_DOWN", Reflex::PointerEvent::DOWN);
166
175
  cPointerEvent.define_const("TYPE_UP", Reflex::PointerEvent::UP);
@@ -20,17 +20,16 @@ RUCY_DEF_ALLOC(alloc, klass)
20
20
  RUCY_END
21
21
 
22
22
  static
23
- RUCY_DEFN(initialize)
23
+ RUCY_DEF6(initialize, x, y, z, dx, dy, dz)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "ScrollEvent#initialize", argc, 0, 1, 2, 3, 4, 5, 6);
27
-
28
- THIS->x = (argc >= 1) ? to<coord>(argv[0]) : 0;
29
- THIS->y = (argc >= 2) ? to<coord>(argv[1]) : 0;
30
- THIS->z = (argc >= 3) ? to<coord>(argv[2]) : 0;
31
- THIS->dx = (argc >= 4) ? to<coord>(argv[3]) : 0;
32
- THIS->dy = (argc >= 5) ? to<coord>(argv[4]) : 0;
33
- THIS->dz = (argc >= 6) ? to<coord>(argv[5]) : 0;
26
+
27
+ THIS->x = to<coord>(x);
28
+ THIS->y = to<coord>(y);
29
+ THIS->z = to<coord>(z);
30
+ THIS->dx = to<coord>(dx);
31
+ THIS->dy = to<coord>(dy);
32
+ THIS->dz = to<coord>(dz);
34
33
 
35
34
  return rb_call_super(0, NULL);
36
35
  }
@@ -19,13 +19,12 @@ RUCY_DEF_ALLOC(alloc, klass)
19
19
  RUCY_END
20
20
 
21
21
  static
22
- RUCY_DEFN(initialize)
22
+ RUCY_DEF2(initialize, now, dt)
23
23
  {
24
24
  CHECK;
25
- check_arg_count(__FILE__, __LINE__, "UpdateEvent#initialize", argc, 0, 1, 2);
26
25
 
27
- THIS->now = (argc >= 1) ? to<double>(argv[0]) : 0;
28
- THIS->dt = (argc >= 2) ? to<float>(argv[1]) : 0;
26
+ THIS->now = to<double>(now);
27
+ THIS->dt = to<float>(dt);
29
28
 
30
29
  return rb_call_super(0, NULL);
31
30
  }
@@ -20,14 +20,13 @@ RUCY_DEF_ALLOC(alloc, klass)
20
20
  RUCY_END
21
21
 
22
22
  static
23
- RUCY_DEFN(initialize)
23
+ RUCY_DEF3(initialize, dx, dy, dz)
24
24
  {
25
25
  CHECK;
26
- check_arg_count(__FILE__, __LINE__, "WheelEvent#initialize", argc, 0, 1, 2, 3);
27
26
 
28
- THIS->dx = (argc >= 1) ? to<coord>(argv[0]) : 0;
29
- THIS->dy = (argc >= 2) ? to<coord>(argv[1]) : 0;
30
- THIS->dz = (argc >= 3) ? to<coord>(argv[2]) : 0;
27
+ THIS->dx = to<coord>(dx);
28
+ THIS->dy = to<coord>(dy);
29
+ THIS->dz = to<coord>(dz);
31
30
 
32
31
  return rb_call_super(0, NULL);
33
32
  }
@@ -37,16 +37,6 @@ namespace Reflex
37
37
  };// Event
38
38
 
39
39
 
40
- struct MotionEvent : public Event
41
- {
42
-
43
- Point gravity;
44
-
45
- MotionEvent (const Point& gravity = Point(0, 9.8));
46
-
47
- };// MotionEvent
48
-
49
-
50
40
  struct UpdateEvent : public Event
51
41
  {
52
42
 
@@ -115,14 +105,14 @@ namespace Reflex
115
105
  {
116
106
  struct {coord x, y, z;};
117
107
 
118
- Rays::Coord3 scroll_;
108
+ Coord3 scroll_;
119
109
  };
120
110
 
121
111
  union
122
112
  {
123
113
  struct {coord dx, dy, dz;};
124
114
 
125
- Rays::Coord3 delta_;
115
+ Coord3 delta_;
126
116
  };
127
117
 
128
118
  ScrollEvent ();
@@ -203,7 +193,7 @@ namespace Reflex
203
193
  {
204
194
  struct {coord x, y, z;};
205
195
 
206
- Rays::Coord3 positions[MAX];
196
+ Coord3 positions[MAX];
207
197
  };
208
198
 
209
199
  PointerEvent ();
@@ -234,14 +224,14 @@ namespace Reflex
234
224
  {
235
225
  struct {coord dx, dy, dz;};
236
226
 
237
- Rays::Coord3 delta_;
227
+ Coord3 delta_;
238
228
  };
239
229
 
240
230
  union
241
231
  {
242
232
  struct {coord x, y, z;};
243
233
 
244
- Rays::Coord3 position_;
234
+ Coord3 position_;
245
235
  };
246
236
 
247
237
  uint modifiers;
@@ -315,6 +305,16 @@ namespace Reflex
315
305
  };// ContactEvent
316
306
 
317
307
 
308
+ struct MotionEvent : public Event
309
+ {
310
+
311
+ Point gravity;
312
+
313
+ MotionEvent (const Point& gravity = Point(0, 9.8));
314
+
315
+ };// MotionEvent
316
+
317
+
318
318
  }// Reflex
319
319
 
320
320
 
@@ -38,11 +38,17 @@ namespace Reflex
38
38
 
39
39
  using namespace Xot::ErrorFunctions;
40
40
 
41
- void reflex_error (const char* file, int line, const char* format = NULL, ...);
41
+ [[noreturn]]
42
+ void reflex_error (
43
+ const char* file, int line, const char* format = NULL, ...);
42
44
 
43
- void layout_error (const char* file, int line, const char* format = NULL, ...);
45
+ [[noreturn]]
46
+ void layout_error (
47
+ const char* file, int line, const char* format = NULL, ...);
44
48
 
45
- void physics_error (const char* file, int line, const char* format = NULL, ...);
49
+ [[noreturn]]
50
+ void physics_error (
51
+ const char* file, int line, const char* format = NULL, ...);
46
52
 
47
53
  }// ErrorFunctions
48
54
 
@@ -17,9 +17,6 @@ namespace Reflex
17
17
  Rucy::Class event_class ();
18
18
  // class Reflex::Event
19
19
 
20
- Rucy::Class motion_event_class ();
21
- // class Reflex::MotionEvent
22
-
23
20
  Rucy::Class update_event_class ();
24
21
  // class Reflex::UpdateEvent
25
22
 
@@ -53,14 +50,15 @@ namespace Reflex
53
50
  Rucy::Class contact_event_class ();
54
51
  // class Reflex::ContactEvent
55
52
 
53
+ Rucy::Class motion_event_class ();
54
+ // class Reflex::MotionEvent
55
+
56
56
 
57
57
  }// Reflex
58
58
 
59
59
 
60
60
  RUCY_DECLARE_VALUE_FROM_TO(Reflex::Event)
61
61
 
62
- RUCY_DECLARE_VALUE_FROM_TO(Reflex::MotionEvent)
63
-
64
62
  RUCY_DECLARE_VALUE_FROM_TO(Reflex::UpdateEvent)
65
63
 
66
64
  RUCY_DECLARE_VALUE_FROM_TO(Reflex::DrawEvent)
@@ -83,6 +81,8 @@ RUCY_DECLARE_VALUE_FROM_TO(Reflex::TimerEvent)
83
81
 
84
82
  RUCY_DECLARE_VALUE_FROM_TO(Reflex::ContactEvent)
85
83
 
84
+ RUCY_DECLARE_VALUE_FROM_TO(Reflex::MotionEvent)
85
+
86
86
 
87
87
  namespace Rucy
88
88
  {
@@ -94,12 +94,6 @@ namespace Rucy
94
94
  return Reflex::event_class();
95
95
  }
96
96
 
97
- template <> inline Class
98
- get_ruby_class<Reflex::MotionEvent> ()
99
- {
100
- return Reflex::motion_event_class();
101
- }
102
-
103
97
  template <> inline Class
104
98
  get_ruby_class<Reflex::UpdateEvent> ()
105
99
  {
@@ -166,6 +160,12 @@ namespace Rucy
166
160
  return Reflex::contact_event_class();
167
161
  }
168
162
 
163
+ template <> inline Class
164
+ get_ruby_class<Reflex::MotionEvent> ()
165
+ {
166
+ return Reflex::motion_event_class();
167
+ }
168
+
169
169
 
170
170
  }// Rucy
171
171
 
@@ -9,13 +9,14 @@ require 'reflex/bounds'
9
9
  require 'reflex/color'
10
10
  require 'reflex/color_space'
11
11
  require 'reflex/matrix'
12
+ require 'reflex/painter'
12
13
  require 'reflex/polyline'
13
14
  require 'reflex/polygon'
14
15
  require 'reflex/bitmap'
15
16
  require 'reflex/image'
16
17
  require 'reflex/font'
17
18
  require 'reflex/shader'
18
- require 'reflex/painter'
19
+ require 'reflex/camera'
19
20
 
20
21
  require 'reflex/reflex'
21
22
  require 'reflex/helper'
@@ -0,0 +1,13 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require 'rays/camera'
5
+
6
+
7
+ module Reflex
8
+
9
+
10
+ Camera = Rays::Camera
11
+
12
+
13
+ end# Reflex
@@ -64,6 +64,10 @@ module Reflex
64
64
  (get_pointer_type & POINTER_PEN) != 0
65
65
  end
66
66
 
67
+ def positions ()
68
+ size.times.map {|i| position i}
69
+ end
70
+
67
71
  def inspect ()
68
72
  "#<Reflex::PointerEvent type:#{type}/#{pointer_type} x:#{x} y:#{y} size:#{size} mod:#{modifiers} count:#{count} drag:#{drag?}>"
69
73
  end
@@ -0,0 +1,32 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ %w[xot rays reflex]
5
+ .map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
+
8
+ require 'reflex'
9
+
10
+
11
+ class Win < Reflex::Window
12
+
13
+ def initialize ()
14
+ super title: "Camera Example", frame: [100, 100, 800, 600]
15
+ @camera = Rays::Camera.new {start}
16
+ end
17
+
18
+ def on_draw (e)
19
+ p = e.painter
20
+ p.image @camera.image, 0, 0 if @camera.image
21
+ p.text "#{e.fps.to_i} FPS", 10, 10
22
+ end
23
+
24
+ def on_update (e)
25
+ redraw
26
+ end
27
+
28
+ end
29
+
30
+ Reflex.start do
31
+ Win.new.show
32
+ end
@@ -28,12 +28,6 @@ namespace Reflex
28
28
  }
29
29
 
30
30
 
31
- MotionEvent::MotionEvent (const Point& gravity)
32
- : gravity(gravity)
33
- {
34
- }
35
-
36
-
37
31
  UpdateEvent::UpdateEvent (double now, float dt)
38
32
  : now(now), dt(dt)
39
33
  {
@@ -170,7 +164,7 @@ namespace Reflex
170
164
  if (positions_)
171
165
  {
172
166
  for (size_t i = 0; i < size; ++i)
173
- positions[i] = *(Rays::Coord3*) &positions_[i];
167
+ positions[i] = *(Coord3*) &positions_[i];
174
168
  }
175
169
  }
176
170
 
@@ -302,4 +296,10 @@ namespace Reflex
302
296
  }
303
297
 
304
298
 
299
+ MotionEvent::MotionEvent (const Point& gravity)
300
+ : gravity(gravity)
301
+ {
302
+ }
303
+
304
+
305
305
  }// Reflex
@@ -162,8 +162,7 @@ namespace Reflex
162
162
  {
163
163
  assert(timer && *timer);
164
164
 
165
- List::iterator end = timers.end();
166
- for (List::iterator it = timers.begin(); it != end; ++it)
165
+ for (auto it = timers.begin(), end = timers.end(); it != end; ++it)
167
166
  {
168
167
  if (timer->self->next_time < (*it)->self->next_time)
169
168
  {
@@ -219,8 +218,7 @@ namespace Reflex
219
218
  if (!timer)
220
219
  argument_error(__FILE__, __LINE__);
221
220
 
222
- List::iterator end = timers.end();
223
- for (List::iterator it = timers.begin(); it != end; ++it)
221
+ for (auto it = timers.begin(), end = timers.end(); it != end; ++it)
224
222
  {
225
223
  if (timer->id() == (*it)->id())
226
224
  timers.erase(it);
@@ -261,8 +259,7 @@ namespace Reflex
261
259
  void
262
260
  Timers::fire (double now)
263
261
  {
264
- List::iterator end = timers.end();
265
- for (List::iterator it = timers.begin(); it != end; ++it)
262
+ for (auto it = timers.begin(), end = timers.end(); it != end; ++it)
266
263
  {
267
264
  Timer* timer = it->get();
268
265
  if (!is_time_to_fire(timer, now))
@@ -6,80 +6,125 @@ require_relative 'helper'
6
6
 
7
7
  class TestPointerEvent < Test::Unit::TestCase
8
8
 
9
+ E = Reflex::PointerEvent
9
10
  T = true
10
11
  F = false
11
12
 
12
- def event (*args)
13
- Reflex::PointerEvent.new *args
13
+ TYPE_NONE = E::TYPE_NONE
14
+ DOWN = E::TYPE_DOWN
15
+ UP = E::TYPE_UP
16
+ MOVE = E::TYPE_MOVE
17
+
18
+ POINTER_NONE = E::POINTER_NONE
19
+ LEFT = E::POINTER_MOUSE_LEFT
20
+ RIGHT = E::POINTER_MOUSE_RIGHT
21
+ MIDDLE = E::POINTER_MOUSE_MIDDLE
22
+ TOUCH = E::POINTER_TOUCH
23
+ PEN = E::POINTER_PEN
24
+
25
+ def event (
26
+ type = TYPE_NONE, pointer_type = POINTER_NONE,
27
+ modifiers = 0, count = 0, drag = false,
28
+ positions: [0])
29
+
30
+ Reflex::PointerEvent.new type, pointer_type, modifiers, count, drag, positions
14
31
  end
15
32
 
16
- def type (arg)
17
- event(arg).tap do |o|
18
- def o.test ()
19
- [type, down?, up?, move?]
20
- end
21
- end
33
+ def test_initialize ()
34
+ assert_nothing_raised {event positions: 10.times.to_a}
35
+ assert_raise(ArgumentError) {event positions: 11.times.to_a}
36
+ assert_raise(ArgumentError) {event positions: []}
22
37
  end
23
38
 
24
39
  def test_type ()
25
- o = type Reflex::PointerEvent::TYPE_NONE
40
+ def type (arg)
41
+ event(arg).tap do |o|
42
+ def o.test ()
43
+ [type, down?, up?, move?]
44
+ end
45
+ end
46
+ end
47
+
48
+ o = type TYPE_NONE
26
49
  assert_equal [:none, F, F, F], o.test
27
50
 
28
- o = type Reflex::PointerEvent::TYPE_DOWN
51
+ o = type DOWN
29
52
  assert_equal [:down, T, F, F], o.test
30
53
 
31
- o = type Reflex::PointerEvent::TYPE_UP
54
+ o = type UP
32
55
  assert_equal [:up, F, T, F], o.test
33
56
 
34
- o = type Reflex::PointerEvent::TYPE_MOVE
57
+ o = type MOVE
35
58
  assert_equal [:move, F, F, T], o.test
36
59
  end
37
60
 
38
- def pointer_type (arg)
39
- event(Reflex::PointerEvent::TYPE_NONE, arg).tap do |o|
40
- def o.test ()
41
- [pointer_type, left?, right?, middle?, touch?, pen?]
61
+ def test_pointer_type ()
62
+ def pointer_type (arg)
63
+ event(TYPE_NONE, arg).tap do |o|
64
+ def o.test ()
65
+ [pointer_type, left?, right?, middle?, touch?, pen?]
66
+ end
42
67
  end
43
68
  end
44
- end
45
69
 
46
- def test_pointer_type ()
47
- o = pointer_type Reflex::PointerEvent::POINTER_NONE
70
+ o = pointer_type POINTER_NONE
48
71
  assert_equal [[], F, F, F, F, F], o.test
49
72
 
50
- o = pointer_type Reflex::PointerEvent::POINTER_MOUSE_LEFT
73
+ o = pointer_type LEFT
51
74
  assert_equal [[:mouse_left], T, F, F, F, F], o.test
52
75
 
53
- o = pointer_type Reflex::PointerEvent::POINTER_MOUSE_RIGHT
76
+ o = pointer_type RIGHT
54
77
  assert_equal [[:mouse_right], F, T, F, F, F], o.test
55
78
 
56
- o = pointer_type Reflex::PointerEvent::POINTER_MOUSE_MIDDLE
79
+ o = pointer_type MIDDLE
57
80
  assert_equal [[:mouse_middle], F, F, T, F, F], o.test
58
81
 
59
- o = pointer_type Reflex::PointerEvent::POINTER_TOUCH
82
+ o = pointer_type TOUCH
60
83
  assert_equal [[:touch], F, F, F, T, F], o.test
61
84
 
62
- o = pointer_type Reflex::PointerEvent::POINTER_PEN
85
+ o = pointer_type PEN
63
86
  assert_equal [[:pen], F, F, F, F, T], o.test
64
87
 
65
- o = pointer_type Reflex::PointerEvent::POINTER_MOUSE_LEFT |
66
- Reflex::PointerEvent::POINTER_MOUSE_RIGHT
88
+ o = pointer_type LEFT | RIGHT
67
89
  types = [:mouse_left, :mouse_right]
68
90
  assert_equal [types, T, T, F, F, F], o.test
69
91
 
70
- o = pointer_type Reflex::PointerEvent::POINTER_MOUSE_LEFT |
71
- Reflex::PointerEvent::POINTER_MOUSE_RIGHT |
72
- Reflex::PointerEvent::POINTER_MOUSE_MIDDLE
92
+ o = pointer_type LEFT | RIGHT | MIDDLE
73
93
  types = [:mouse_left, :mouse_right, :mouse_middle]
74
94
  assert_equal [types, T, T, T, F, F], o.test
75
95
 
76
- o = pointer_type Reflex::PointerEvent::POINTER_MOUSE_LEFT |
77
- Reflex::PointerEvent::POINTER_MOUSE_RIGHT |
78
- Reflex::PointerEvent::POINTER_MOUSE_MIDDLE |
79
- Reflex::PointerEvent::POINTER_TOUCH |
80
- Reflex::PointerEvent::POINTER_PEN
96
+ o = pointer_type LEFT | RIGHT | MIDDLE | TOUCH | PEN
81
97
  types = [:mouse_left, :mouse_right, :mouse_middle, :touch, :pen]
82
98
  assert_equal [types, T, T, T, T, T], o.test
83
99
  end
84
100
 
101
+ def test_size ()
102
+ assert_equal 1, event(positions: [0] ).size
103
+ assert_equal 2, event(positions: [0, 1]).size
104
+ end
105
+
106
+ def test_xy ()
107
+ assert_equal 0, event(positions: [[0, 1], [2, 3]]).x
108
+ assert_equal 1, event(positions: [[0, 1], [2, 3]]).y
109
+ end
110
+
111
+ def test_position ()
112
+ assert_equal [0, 1], event(positions: [[0, 1], [2, 3]]).position.to_a
113
+ end
114
+
115
+ def test_positions ()
116
+ assert_equal [[0, 0]], event(positions: [0] ).positions.map(&:to_a)
117
+ assert_equal [[0, 0], [1, 1]], event(positions: [0, 1]).positions.map(&:to_a)
118
+
119
+ assert_equal [[0, 1]], event(positions: [[0, 1]] ).positions.map(&:to_a)
120
+ assert_equal [[0, 1], [2, 3]], event(positions: [[0, 1], [2, 3]]).positions.map(&:to_a)
121
+ end
122
+
123
+ def test_at ()
124
+ assert_equal [0, 1], event(positions: [[0, 1], [2, 3]])[0].to_a
125
+ assert_equal [2, 3], event(positions: [[0, 1], [2, 3]])[1].to_a
126
+ assert_raise(IndexError) {event(positions: [[0, 1], [2, 3]])[-1]}
127
+ assert_raise(IndexError) {event(positions: [[0, 1], [2, 3]])[2]}
128
+ end
129
+
85
130
  end# TestPointerEvent
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.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-16 00:00:00.000000000 Z
11
+ date: 2020-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -200,6 +200,7 @@ files:
200
200
  - lib/reflex/bitmap.rb
201
201
  - lib/reflex/bounds.rb
202
202
  - lib/reflex/button.rb
203
+ - lib/reflex/camera.rb
203
204
  - lib/reflex/capture_event.rb
204
205
  - lib/reflex/color.rb
205
206
  - lib/reflex/color_space.rb
@@ -249,6 +250,7 @@ files:
249
250
  - reflex.gemspec
250
251
  - samples/app.rb
251
252
  - samples/bats.rb
253
+ - samples/camera.rb
252
254
  - samples/checker.rb
253
255
  - samples/fans.rb
254
256
  - samples/fps.rb
@@ -359,7 +361,7 @@ files:
359
361
  homepage: https://github.com/xord/reflex
360
362
  licenses: []
361
363
  metadata: {}
362
- post_install_message:
364
+ post_install_message:
363
365
  rdoc_options: []
364
366
  require_paths:
365
367
  - lib
@@ -375,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
377
  version: '0'
376
378
  requirements: []
377
379
  rubygems_version: 3.0.3
378
- signing_key:
380
+ signing_key:
379
381
  specification_version: 4
380
382
  summary: A Graphical User Interface Tool Kit.
381
383
  test_files: