reflexion 0.1.21 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/capture_event.cpp +6 -5
  3. data/.doc/ext/reflex/contact_event.cpp +18 -16
  4. data/.doc/ext/reflex/draw_event.cpp +10 -8
  5. data/.doc/ext/reflex/event.cpp +10 -10
  6. data/.doc/ext/reflex/focus_event.cpp +18 -17
  7. data/.doc/ext/reflex/frame_event.cpp +17 -17
  8. data/.doc/ext/reflex/key_event.cpp +227 -28
  9. data/.doc/ext/reflex/native.cpp +2 -0
  10. data/.doc/ext/reflex/pointer.cpp +158 -0
  11. data/.doc/ext/reflex/pointer_event.cpp +32 -91
  12. data/.doc/ext/reflex/scroll_event.cpp +14 -17
  13. data/.doc/ext/reflex/selector.cpp +8 -0
  14. data/.doc/ext/reflex/timer.cpp +9 -1
  15. data/.doc/ext/reflex/timer_event.cpp +4 -13
  16. data/.doc/ext/reflex/update_event.cpp +6 -5
  17. data/.doc/ext/reflex/view.cpp +57 -0
  18. data/.doc/ext/reflex/wheel_event.cpp +39 -22
  19. data/.doc/ext/reflex/window.cpp +24 -0
  20. data/VERSION +1 -1
  21. data/ext/reflex/capture_event.cpp +6 -5
  22. data/ext/reflex/contact_event.cpp +18 -16
  23. data/ext/reflex/draw_event.cpp +9 -7
  24. data/ext/reflex/event.cpp +11 -11
  25. data/ext/reflex/focus_event.cpp +18 -17
  26. data/ext/reflex/frame_event.cpp +16 -16
  27. data/ext/reflex/key_event.cpp +228 -28
  28. data/ext/reflex/native.cpp +2 -0
  29. data/ext/reflex/pointer.cpp +170 -0
  30. data/ext/reflex/pointer_event.cpp +31 -96
  31. data/ext/reflex/scroll_event.cpp +15 -18
  32. data/ext/reflex/selector.cpp +9 -0
  33. data/ext/reflex/timer.cpp +15 -6
  34. data/ext/reflex/timer_event.cpp +9 -19
  35. data/ext/reflex/update_event.cpp +6 -5
  36. data/ext/reflex/view.cpp +67 -3
  37. data/ext/reflex/wheel_event.cpp +40 -21
  38. data/ext/reflex/window.cpp +30 -3
  39. data/include/reflex/defs.h +140 -106
  40. data/include/reflex/event.h +232 -124
  41. data/include/reflex/pointer.h +107 -0
  42. data/include/reflex/ruby/pointer.h +41 -0
  43. data/include/reflex/ruby/view.h +9 -0
  44. data/include/reflex/ruby/window.h +9 -0
  45. data/include/reflex/selector.h +1 -1
  46. data/include/reflex/shape.h +2 -2
  47. data/include/reflex/view.h +6 -4
  48. data/include/reflex/window.h +10 -8
  49. data/lib/reflex/application.rb +3 -3
  50. data/lib/reflex/autoinit.rb +1 -1
  51. data/lib/reflex/button.rb +7 -7
  52. data/lib/reflex/capture_event.rb +7 -7
  53. data/lib/reflex/contact_event.rb +10 -10
  54. data/lib/reflex/draw_event.rb +2 -2
  55. data/lib/reflex/ellipse_shape.rb +2 -2
  56. data/lib/reflex/focus_event.rb +11 -11
  57. data/lib/reflex/frame_event.rb +5 -5
  58. data/lib/reflex/helper.rb +20 -20
  59. data/lib/reflex/image_view.rb +2 -2
  60. data/lib/reflex/key_event.rb +12 -12
  61. data/lib/reflex/model.rb +22 -22
  62. data/lib/reflex/model_owner.rb +7 -7
  63. data/lib/reflex/model_view.rb +1 -1
  64. data/lib/reflex/module.rb +5 -5
  65. data/lib/reflex/pointer.rb +107 -0
  66. data/lib/reflex/pointer_event.rb +16 -54
  67. data/lib/reflex/polygon_shape.rb +2 -2
  68. data/lib/reflex/reflex.rb +3 -3
  69. data/lib/reflex/scroll_event.rb +1 -1
  70. data/lib/reflex/selector.rb +4 -4
  71. data/lib/reflex/shape.rb +13 -13
  72. data/lib/reflex/style.rb +11 -11
  73. data/lib/reflex/style_length.rb +1 -1
  74. data/lib/reflex/text_view.rb +2 -2
  75. data/lib/reflex/timer.rb +2 -2
  76. data/lib/reflex/timer_event.rb +3 -2
  77. data/lib/reflex/update_event.rb +1 -1
  78. data/lib/reflex/view.rb +32 -32
  79. data/lib/reflex/wheel_event.rb +2 -10
  80. data/lib/reflex/window.rb +6 -6
  81. data/lib/reflex.rb +1 -0
  82. data/lib/reflexion.rb +17 -17
  83. data/reflex.gemspec +5 -5
  84. data/samples/reflexion/noise.rb +1 -1
  85. data/samples/tree.rb +1 -1
  86. data/src/event.cpp +792 -86
  87. data/src/event.h +47 -0
  88. data/src/image_view.cpp +2 -2
  89. data/src/ios/event.h +15 -3
  90. data/src/ios/event.mm +126 -11
  91. data/src/ios/view_controller.mm +50 -22
  92. data/src/ios/window.mm +1 -1
  93. data/src/osx/event.h +15 -4
  94. data/src/osx/event.mm +214 -24
  95. data/src/osx/native_window.mm +84 -17
  96. data/src/pointer.cpp +203 -0
  97. data/src/pointer.h +26 -0
  98. data/src/selector.cpp +1 -1
  99. data/src/shape.cpp +11 -13
  100. data/src/shape.h +1 -1
  101. data/src/view.cpp +205 -118
  102. data/src/view.h +5 -10
  103. data/src/window.cpp +334 -104
  104. data/src/window.h +22 -3
  105. data/src/world.cpp +6 -4
  106. data/test/helper.rb +3 -3
  107. data/test/test_application.rb +1 -1
  108. data/test/test_capture_event.rb +22 -6
  109. data/test/test_contact_event.rb +40 -0
  110. data/test/test_draw_event.rb +35 -0
  111. data/test/test_event.rb +33 -5
  112. data/test/test_focus_event.rb +34 -0
  113. data/test/test_frame_event.rb +38 -0
  114. data/test/test_has_frame.rb +11 -11
  115. data/test/test_key_event.rb +33 -0
  116. data/test/test_pointer.rb +149 -0
  117. data/test/test_pointer_event.rb +70 -104
  118. data/test/test_reflex.rb +1 -1
  119. data/test/test_scroll_event.rb +39 -0
  120. data/test/test_selector.rb +15 -8
  121. data/test/test_shape.rb +8 -8
  122. data/test/test_style.rb +13 -13
  123. data/test/test_style_length.rb +5 -5
  124. data/test/test_timer_event.rb +38 -0
  125. data/test/test_update_event.rb +29 -0
  126. data/test/test_view.rb +57 -30
  127. data/test/test_wheel_event.rb +40 -0
  128. data/test/test_window.rb +29 -27
  129. metadata +64 -35
@@ -0,0 +1,170 @@
1
+ #include "reflex/ruby/pointer.h"
2
+
3
+
4
+ #include <rays/ruby/point.h>
5
+ #include "defs.h"
6
+
7
+
8
+ RUCY_DEFINE_VALUE_FROM_TO(Reflex::Pointer)
9
+
10
+ #define THIS to<Reflex::Pointer*>(self)
11
+
12
+ #define CHECK RUCY_CHECK_OBJ(Reflex::Pointer, self)
13
+
14
+
15
+ static
16
+ RUCY_DEF_ALLOC(alloc, klass)
17
+ {
18
+ return new_type<Reflex::Pointer>(klass);
19
+ }
20
+ RUCY_END
21
+
22
+ static
23
+ RUCY_DEF8(initialize,
24
+ id, type, action, position, modifiers, click_count, drag, time)
25
+ {
26
+ CHECK;
27
+
28
+ *THIS = Reflex::Pointer(
29
+ to<Reflex::Pointer::ID>(id),
30
+ to<uint>(type),
31
+ (Reflex::Pointer::Action) to<int>(action),
32
+ to<Rays::Point>(position),
33
+ to<uint>(modifiers),
34
+ to<uint>(click_count),
35
+ to<bool>(drag),
36
+ to<double>(time));
37
+ return self;
38
+ }
39
+ RUCY_END
40
+
41
+ static
42
+ RUCY_DEF1(initialize_copy, obj)
43
+ {
44
+ CHECK;
45
+ *THIS = to<Reflex::Pointer&>(obj);
46
+ return self;
47
+ }
48
+ RUCY_END
49
+
50
+ static
51
+ RUCY_DEF0(get_id)
52
+ {
53
+ CHECK;
54
+ return value(THIS->id());
55
+ }
56
+ RUCY_END
57
+
58
+ static
59
+ RUCY_DEF0(get_type)
60
+ {
61
+ CHECK;
62
+ return value(THIS->type());
63
+ }
64
+ RUCY_END
65
+
66
+ static
67
+ RUCY_DEF0(get_action)
68
+ {
69
+ CHECK;
70
+ return value(THIS->action());
71
+ }
72
+ RUCY_END
73
+
74
+ static
75
+ RUCY_DEF0(get_position)
76
+ {
77
+ CHECK;
78
+ return value(THIS->position());
79
+ }
80
+ RUCY_END
81
+
82
+ static
83
+ RUCY_DEF0(get_modifiers)
84
+ {
85
+ CHECK;
86
+ return value(THIS->modifiers());
87
+ }
88
+ RUCY_END
89
+
90
+ static
91
+ RUCY_DEF0(get_click_count)
92
+ {
93
+ CHECK;
94
+ return value(THIS->click_count());
95
+ }
96
+ RUCY_END
97
+
98
+ static
99
+ RUCY_DEF0(is_drag)
100
+ {
101
+ CHECK;
102
+ return value(THIS->is_drag());
103
+ }
104
+ RUCY_END
105
+
106
+ static
107
+ RUCY_DEF0(get_time)
108
+ {
109
+ CHECK;
110
+ return value(THIS->time());
111
+ }
112
+ RUCY_END
113
+
114
+ static
115
+ RUCY_DEF0(get_prev)
116
+ {
117
+ CHECK;
118
+ return value(THIS->prev());
119
+ }
120
+ RUCY_END
121
+
122
+
123
+ static Class cPointer;
124
+
125
+ void
126
+ Init_pointer ()
127
+ {
128
+ Module mReflex = define_module("Reflex");
129
+
130
+ cPointer = mReflex.define_class("Pointer");
131
+ cPointer.define_alloc_func(alloc);
132
+ cPointer.define_private_method("initialize", initialize);
133
+ cPointer.define_private_method("initialize_copy", initialize_copy);
134
+ cPointer.define_method("id", get_id);
135
+ cPointer.define_private_method("get_type", get_type);
136
+ cPointer.define_private_method("get_action", get_action);
137
+ cPointer.define_method("position", get_position);
138
+ cPointer.define_method("modifiers", get_modifiers);
139
+ cPointer.define_method("click_count", get_click_count);
140
+ cPointer.define_method("drag?", is_drag);
141
+ cPointer.define_method("time", get_time);
142
+ cPointer.define_method("prev", get_prev);
143
+ cPointer.define_const("TYPE_NONE", Reflex::Pointer::TYPE_NONE);
144
+ cPointer.define_const("MOUSE", Reflex::Pointer::MOUSE);
145
+ cPointer.define_const("MOUSE_LEFT", Reflex::Pointer::MOUSE_LEFT);
146
+ cPointer.define_const("MOUSE_RIGHT", Reflex::Pointer::MOUSE_RIGHT);
147
+ cPointer.define_const("MOUSE_MIDDLE", Reflex::Pointer::MOUSE_MIDDLE);
148
+ cPointer.define_const("TOUCH", Reflex::Pointer::TOUCH);
149
+ cPointer.define_const("PEN", Reflex::Pointer::PEN);
150
+ cPointer.define_const("ACTION_NONE", Reflex::Pointer::ACTION_NONE);
151
+ cPointer.define_const("DOWN", Reflex::Pointer::DOWN);
152
+ cPointer.define_const("UP", Reflex::Pointer::UP);
153
+ cPointer.define_const("MOVE", Reflex::Pointer::MOVE);
154
+ cPointer.define_const("CANCEL", Reflex::Pointer::CANCEL);
155
+ cPointer.define_const("STAY", Reflex::Pointer::STAY);
156
+ }
157
+
158
+
159
+ namespace Reflex
160
+ {
161
+
162
+
163
+ Class
164
+ pointer_class ()
165
+ {
166
+ return cPointer;
167
+ }
168
+
169
+
170
+ }// Reflex
@@ -1,7 +1,9 @@
1
1
  #include "reflex/ruby/event.h"
2
2
 
3
3
 
4
+ #include <vector>
4
5
  #include <rays/ruby/point.h>
6
+ #include "reflex/ruby/pointer.h"
5
7
  #include "defs.h"
6
8
 
7
9
 
@@ -20,23 +22,18 @@ RUCY_DEF_ALLOC(alloc, klass)
20
22
  RUCY_END
21
23
 
22
24
  static
23
- RUCY_DEF6(initialize, type, pointer_type, modifiers, count, drag, positions)
25
+ RUCY_DEFN(initialize)
24
26
  {
25
27
  CHECK;
26
28
 
27
- int size = positions.size();
28
- if (size <= 0 || Reflex::PointerEvent::MAX < size)
29
+ if (argc == 0)
29
30
  argument_error(__FILE__, __LINE__);
30
31
 
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;
32
+ std::vector<Reflex::Pointer> pointers;
33
+ for (size_t i = 0; i < argc; ++i)
34
+ pointers.emplace_back(to<Reflex::Pointer&>(argv[i]));
37
35
 
38
- for (int i = 0; i < size; ++i)
39
- THIS->positions[i] = to<Rays::Point>(positions[i]);
36
+ *THIS = Reflex::PointerEvent(&pointers[0], pointers.size());
40
37
 
41
38
  return rb_call_super(0, NULL);
42
39
  }
@@ -46,104 +43,58 @@ static
46
43
  RUCY_DEF1(initialize_copy, obj)
47
44
  {
48
45
  CHECK;
49
- *THIS = to<Reflex::PointerEvent&>(obj);
46
+ *THIS = to<Reflex::PointerEvent&>(obj).dup();
50
47
  return self;
51
48
  }
52
49
  RUCY_END
53
50
 
54
51
  static
55
- RUCY_DEF0(type)
52
+ RUCY_DEF0(get_size)
56
53
  {
57
54
  CHECK;
58
- return value(THIS->type);
55
+ return value(THIS->size());
59
56
  }
60
57
  RUCY_END
61
58
 
62
59
  static
63
- RUCY_DEF0(pointer_type)
60
+ RUCY_DEF0(is_empty)
64
61
  {
65
62
  CHECK;
66
- return value(THIS->pointer_type);
63
+ return value(THIS->empty());
67
64
  }
68
65
  RUCY_END
69
66
 
70
67
  static
71
- RUCY_DEF0(size)
68
+ RUCY_DEF0(is_captured)
72
69
  {
73
70
  CHECK;
74
- return value(THIS->size);
71
+ return value(THIS->is_captured());
75
72
  }
76
73
  RUCY_END
77
74
 
78
75
  static
79
- RUCY_DEF0(modifiers)
80
- {
81
- CHECK;
82
- return value(THIS->modifiers);
83
- }
84
- RUCY_END
85
-
86
- static
87
- RUCY_DEF0(count)
88
- {
89
- CHECK;
90
- return value(THIS->count);
91
- }
92
- RUCY_END
93
-
94
- static
95
- RUCY_DEF0(drag)
96
- {
97
- CHECK;
98
- return value(THIS->drag);
99
- }
100
- RUCY_END
101
-
102
- static
103
- RUCY_DEF0(capture)
104
- {
105
- CHECK;
106
- return value(THIS->capture);
107
- }
108
- RUCY_END
109
-
110
- static
111
- RUCY_DEF0(x)
112
- {
113
- CHECK;
114
- return value(THIS->x);
115
- }
116
- RUCY_END
117
-
118
- static
119
- RUCY_DEF0(y)
76
+ RUCY_DEF1(get_at, index)
120
77
  {
121
78
  CHECK;
122
- return value(THIS->y);
123
- }
124
- RUCY_END
125
79
 
126
- static
127
- RUCY_DEFN(position)
128
- {
129
- CHECK;
130
- check_arg_count(__FILE__, __LINE__, "PointerEvent#position", argc, 0, 1);
80
+ int size = (int) THIS->size();
81
+ int i = to<int>(index);
82
+ if (i < -size || size <= i)
83
+ return Qnil;
131
84
 
132
- size_t index = argc >= 1 ? to<int>(argv[0]) : 0;
133
- return value(THIS->position(index));
85
+ return value((*THIS)[i >= 0 ? i : i + size]);
134
86
  }
135
87
  RUCY_END
136
88
 
137
89
  static
138
- RUCY_DEF1(get_at, index)
90
+ RUCY_DEF0(each)
139
91
  {
140
92
  CHECK;
141
93
 
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]);
94
+ Value ret;
95
+ for (size_t i = 0, size = THIS->size(); i < size; ++i)
96
+ ret = rb_yield(value((*THIS)[i]));
97
+ return ret;
147
98
  }
148
99
  RUCY_END
149
100
 
@@ -159,27 +110,11 @@ Init_pointer_event ()
159
110
  cPointerEvent.define_alloc_func(alloc);
160
111
  cPointerEvent.define_private_method("initialize", initialize);
161
112
  cPointerEvent.define_private_method("initialize_copy", initialize_copy);
162
- cPointerEvent.define_method("type", type);
163
- cPointerEvent.define_method("pointer_type", pointer_type);
164
- cPointerEvent.define_method("size", size);
165
- cPointerEvent.define_method("modifiers", modifiers);
166
- cPointerEvent.define_method("count", count);
167
- cPointerEvent.define_method("drag?", drag);
168
- cPointerEvent.define_method("capture?", capture);
169
- cPointerEvent.define_method("x", x);
170
- cPointerEvent.define_method("y", y);
171
- cPointerEvent.define_method("position", position);
172
- cPointerEvent.define_method("[]", get_at);
173
- cPointerEvent.define_const("TYPE_NONE", Reflex::PointerEvent::NONE);
174
- cPointerEvent.define_const("TYPE_DOWN", Reflex::PointerEvent::DOWN);
175
- cPointerEvent.define_const("TYPE_UP", Reflex::PointerEvent::UP);
176
- cPointerEvent.define_const("TYPE_MOVE", Reflex::PointerEvent::MOVE);
177
- cPointerEvent.define_const("POINTER_NONE", Reflex::POINTER_NONE);
178
- cPointerEvent.define_const("POINTER_MOUSE_LEFT", Reflex::POINTER_MOUSE_LEFT);
179
- cPointerEvent.define_const("POINTER_MOUSE_RIGHT", Reflex::POINTER_MOUSE_RIGHT);
180
- cPointerEvent.define_const("POINTER_MOUSE_MIDDLE", Reflex::POINTER_MOUSE_MIDDLE);
181
- cPointerEvent.define_const("POINTER_TOUCH", Reflex::POINTER_TOUCH);
182
- cPointerEvent.define_const("POINTER_PEN", Reflex::POINTER_PEN);
113
+ cPointerEvent.define_method("size", get_size);
114
+ cPointerEvent.define_method("empty?", is_empty);
115
+ cPointerEvent.define_method("captured?", is_captured);
116
+ cPointerEvent.define_method("[]", get_at);
117
+ cPointerEvent.define_method("each", each);
183
118
  }
184
119
 
185
120
 
@@ -24,12 +24,9 @@ RUCY_DEF6(initialize, x, y, z, dx, dy, dz)
24
24
  {
25
25
  CHECK;
26
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);
27
+ *THIS = Reflex::ScrollEvent(
28
+ to<coord>( x), to<coord>( y), to<coord>( z),
29
+ to<coord>(dx), to<coord>(dy), to<coord>(dz));
33
30
 
34
31
  return rb_call_super(0, NULL);
35
32
  }
@@ -39,7 +36,7 @@ static
39
36
  RUCY_DEF1(initialize_copy, obj)
40
37
  {
41
38
  CHECK;
42
- *THIS = to<Reflex::ScrollEvent&>(obj);
39
+ *THIS = to<Reflex::ScrollEvent&>(obj).dup();
43
40
  return self;
44
41
  }
45
42
  RUCY_END
@@ -48,7 +45,7 @@ static
48
45
  RUCY_DEF0(x)
49
46
  {
50
47
  CHECK;
51
- return value(THIS->x);
48
+ return value(THIS->scroll().x);
52
49
  }
53
50
  RUCY_END
54
51
 
@@ -56,7 +53,7 @@ static
56
53
  RUCY_DEF0(y)
57
54
  {
58
55
  CHECK;
59
- return value(THIS->y);
56
+ return value(THIS->scroll().y);
60
57
  }
61
58
  RUCY_END
62
59
 
@@ -64,7 +61,7 @@ static
64
61
  RUCY_DEF0(z)
65
62
  {
66
63
  CHECK;
67
- return value(THIS->z);
64
+ return value(THIS->scroll().z);
68
65
  }
69
66
  RUCY_END
70
67
 
@@ -72,7 +69,7 @@ static
72
69
  RUCY_DEF0(dx)
73
70
  {
74
71
  CHECK;
75
- return value(THIS->dx);
72
+ return value(THIS->dscroll().x);
76
73
  }
77
74
  RUCY_END
78
75
 
@@ -80,7 +77,7 @@ static
80
77
  RUCY_DEF0(dy)
81
78
  {
82
79
  CHECK;
83
- return value(THIS->dy);
80
+ return value(THIS->dscroll().y);
84
81
  }
85
82
  RUCY_END
86
83
 
@@ -88,7 +85,7 @@ static
88
85
  RUCY_DEF0(dz)
89
86
  {
90
87
  CHECK;
91
- return value(THIS->dz);
88
+ return value(THIS->dscroll().z);
92
89
  }
93
90
  RUCY_END
94
91
 
@@ -96,15 +93,15 @@ static
96
93
  RUCY_DEF0(scroll)
97
94
  {
98
95
  CHECK;
99
- return value(Rays::Point(THIS->x, THIS->y, THIS->z));
96
+ return value(THIS->scroll());
100
97
  }
101
98
  RUCY_END
102
99
 
103
100
  static
104
- RUCY_DEF0(delta)
101
+ RUCY_DEF0(dscroll)
105
102
  {
106
103
  CHECK;
107
- return value(Rays::Point(THIS->dx, THIS->dy, THIS->dz));
104
+ return value(THIS->dscroll());
108
105
  }
109
106
  RUCY_END
110
107
 
@@ -126,8 +123,8 @@ Init_scroll_event ()
126
123
  cScrollEvent.define_method("dx", dx);
127
124
  cScrollEvent.define_method("dy", dy);
128
125
  cScrollEvent.define_method("dz", dz);
129
- cScrollEvent.define_method("scroll", scroll);
130
- cScrollEvent.define_method("delta", delta);
126
+ cScrollEvent.define_method( "scroll", scroll);
127
+ cScrollEvent.define_method("dscroll", dscroll);
131
128
  }
132
129
 
133
130
 
@@ -90,6 +90,14 @@ RUCY_DEF0(each_tag)
90
90
  }
91
91
  RUCY_END
92
92
 
93
+ static
94
+ RUCY_DEF0(is_empty)
95
+ {
96
+ CHECK;
97
+ return value(C_THIS->empty());
98
+ }
99
+ RUCY_END
100
+
93
101
  static
94
102
  RUCY_DEF1(contains, selector)
95
103
  {
@@ -124,6 +132,7 @@ Init_selector ()
124
132
  cSelector.define_method("clear_tags", clear_tags);
125
133
  cSelector.define_method("tag?", has_tag);
126
134
  cSelector.define_method("each_tag", each_tag);
135
+ cSelector.define_method("empty?", is_empty);
127
136
  cSelector.define_method("contains", contains);
128
137
  cSelector.define_method("==", equal);
129
138
  }
data/ext/reflex/timer.cpp CHANGED
@@ -1,6 +1,7 @@
1
1
  #include "reflex/ruby/timer.h"
2
2
 
3
3
 
4
+ #include "reflex/exception.h"
4
5
  #include "reflex/ruby/view.h"
5
6
  #include "reflex/ruby/selector.h"
6
7
  #include "defs.h"
@@ -16,6 +17,13 @@ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::Timer)
16
17
  #define CALL(fun) RUCY_CALL_SUPER(THIS, fun)
17
18
 
18
19
 
20
+ static
21
+ RUCY_DEF_ALLOC(alloc, klass)
22
+ {
23
+ Reflex::reflex_error(__FILE__, __LINE__, "can not instantiate Timer class.");
24
+ }
25
+ RUCY_END
26
+
19
27
  static
20
28
  RUCY_DEF0(stop)
21
29
  {
@@ -82,13 +90,14 @@ Init_timer ()
82
90
  Module mReflex = define_module("Reflex");
83
91
 
84
92
  cTimer = mReflex.define_class("Timer");
93
+ cTimer.define_alloc_func(alloc);
85
94
  cTimer.define_method("stop", stop);
86
- cTimer.define_method("owner", get_owner);
87
- cTimer.define_method("id", get_id);
88
- cTimer.define_method("interval", get_interval);
89
- cTimer.define_method("count=", set_count);
90
- cTimer.define_method("count", get_count);
91
- cTimer.define_method("finish?", is_finished);
95
+ cTimer.define_method("owner", get_owner);
96
+ cTimer.define_method("id", get_id);
97
+ cTimer.define_method("interval", get_interval);
98
+ cTimer.define_method("count=", set_count);
99
+ cTimer.define_method("count", get_count);
100
+ cTimer.define_method("finished?", is_finished);
92
101
 
93
102
  define_selector_methods<Reflex::Timer>(cTimer);
94
103
  }
@@ -25,7 +25,7 @@ RUCY_DEF1(initialize, timer)
25
25
  {
26
26
  CHECK;
27
27
 
28
- THIS->timer = to<Reflex::Timer*>(timer);
28
+ *THIS = Reflex::TimerEvent(to<Reflex::Timer*>(timer));
29
29
 
30
30
  return rb_call_super(0, NULL);
31
31
  }
@@ -35,7 +35,7 @@ static
35
35
  RUCY_DEF1(initialize_copy, obj)
36
36
  {
37
37
  CHECK;
38
- *THIS = to<Reflex::TimerEvent&>(obj);
38
+ *THIS = to<Reflex::TimerEvent&>(obj).dup();
39
39
  return self;
40
40
  }
41
41
  RUCY_END
@@ -44,7 +44,7 @@ static
44
44
  RUCY_DEF0(timer)
45
45
  {
46
46
  CHECK;
47
- return value(THIS->timer);
47
+ return value(THIS->timer());
48
48
  }
49
49
  RUCY_END
50
50
 
@@ -72,15 +72,6 @@ RUCY_DEF0(interval)
72
72
  }
73
73
  RUCY_END
74
74
 
75
- static
76
- RUCY_DEF1(set_count, count)
77
- {
78
- CHECK;
79
- THIS->set_count(to<int>(count));
80
- return count;
81
- }
82
- RUCY_END
83
-
84
75
  static
85
76
  RUCY_DEF0(count)
86
77
  {
@@ -109,13 +100,12 @@ Init_timer_event ()
109
100
  cTimerEvent.define_alloc_func(alloc);
110
101
  cTimerEvent.define_private_method("initialize", initialize);
111
102
  cTimerEvent.define_private_method("initialize_copy", initialize_copy);
112
- cTimerEvent.define_method("timer", timer);
113
- cTimerEvent.define_method("owner", owner);
114
- cTimerEvent.define_method("id", id);
115
- cTimerEvent.define_method("interval", interval);
116
- cTimerEvent.define_method("count=", set_count);
117
- cTimerEvent.define_method("count", count);
118
- cTimerEvent.define_method("finish?", is_finished);
103
+ cTimerEvent.define_method("timer", timer);
104
+ cTimerEvent.define_method("owner", owner);
105
+ cTimerEvent.define_method("id", id);
106
+ cTimerEvent.define_method("interval", interval);
107
+ cTimerEvent.define_method("count", count);
108
+ cTimerEvent.define_method("finished?", is_finished);
119
109
  }
120
110
 
121
111
 
@@ -23,8 +23,9 @@ RUCY_DEF2(initialize, now, dt)
23
23
  {
24
24
  CHECK;
25
25
 
26
- THIS->now = to<double>(now);
27
- THIS->dt = to<float>(dt);
26
+ *THIS = Reflex::UpdateEvent(
27
+ to<double>(now),
28
+ to<float>(dt));
28
29
 
29
30
  return rb_call_super(0, NULL);
30
31
  }
@@ -34,7 +35,7 @@ static
34
35
  RUCY_DEF1(initialize_copy, obj)
35
36
  {
36
37
  CHECK;
37
- *THIS = to<Reflex::UpdateEvent&>(obj);
38
+ *THIS = to<Reflex::UpdateEvent&>(obj).dup();
38
39
  return self;
39
40
  }
40
41
  RUCY_END
@@ -43,7 +44,7 @@ static
43
44
  RUCY_DEF0(now)
44
45
  {
45
46
  CHECK;
46
- return value(THIS->now);
47
+ return value(THIS->now());
47
48
  }
48
49
  RUCY_END
49
50
 
@@ -51,7 +52,7 @@ static
51
52
  RUCY_DEF0(dt)
52
53
  {
53
54
  CHECK;
54
- return value(THIS->dt);
55
+ return value(THIS->dt());
55
56
  }
56
57
  RUCY_END
57
58