reflexion 0.5.2 → 0.6.0

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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.doc/ext/reflex/application.cpp +19 -1
  3. data/.doc/ext/reflex/chase_constraint.cpp +84 -0
  4. data/.doc/ext/reflex/clipboard.cpp +65 -0
  5. data/.doc/ext/reflex/constraint.cpp +135 -0
  6. data/.doc/ext/reflex/key_event.cpp +6 -6
  7. data/.doc/ext/reflex/link_constraint.cpp +178 -0
  8. data/.doc/ext/reflex/menu.cpp +302 -0
  9. data/.doc/ext/reflex/native.cpp +22 -4
  10. data/.doc/ext/reflex/pin.cpp +156 -0
  11. data/.doc/ext/reflex/pointer.cpp +2 -0
  12. data/.doc/ext/reflex/pointer_event.cpp +1 -1
  13. data/.doc/ext/reflex/reflex.cpp +42 -7
  14. data/.doc/ext/reflex/selector.cpp +4 -4
  15. data/.doc/ext/reflex/snap_constraint.cpp +125 -0
  16. data/.doc/ext/reflex/style_length.cpp +3 -2
  17. data/.doc/ext/reflex/view.cpp +96 -23
  18. data/.doc/ext/reflex/wheel_constraint.cpp +142 -0
  19. data/.doc/ext/reflex/window.cpp +59 -17
  20. data/.github/workflows/release-gem.yml +10 -1
  21. data/.github/workflows/test.yml +9 -0
  22. data/ChangeLog.md +30 -0
  23. data/README.md +1 -0
  24. data/VERSION +1 -1
  25. data/ext/reflex/application.cpp +21 -1
  26. data/ext/reflex/chase_constraint.cpp +89 -0
  27. data/ext/reflex/clipboard.cpp +69 -0
  28. data/ext/reflex/constraint.cpp +146 -0
  29. data/ext/reflex/key_event.cpp +6 -6
  30. data/ext/reflex/link_constraint.cpp +194 -0
  31. data/ext/reflex/menu.cpp +330 -0
  32. data/ext/reflex/native.cpp +22 -4
  33. data/ext/reflex/pin.cpp +165 -0
  34. data/ext/reflex/pointer.cpp +2 -0
  35. data/ext/reflex/pointer_event.cpp +1 -1
  36. data/ext/reflex/reflex.cpp +42 -7
  37. data/ext/reflex/selector.cpp +4 -4
  38. data/ext/reflex/selector.h +1 -1
  39. data/ext/reflex/snap_constraint.cpp +135 -0
  40. data/ext/reflex/style_length.cpp +3 -2
  41. data/ext/reflex/view.cpp +117 -37
  42. data/ext/reflex/wheel_constraint.cpp +154 -0
  43. data/ext/reflex/window.cpp +65 -18
  44. data/include/reflex/application.h +9 -0
  45. data/include/reflex/clipboard.h +53 -0
  46. data/include/reflex/constraint.h +275 -0
  47. data/include/reflex/defs.h +204 -195
  48. data/include/reflex/event.h +2 -0
  49. data/include/reflex/menu.h +120 -0
  50. data/include/reflex/pin.h +68 -0
  51. data/include/reflex/pointer.h +4 -0
  52. data/include/reflex/ruby/clipboard.h +23 -0
  53. data/include/reflex/ruby/constraint.h +94 -0
  54. data/include/reflex/ruby/menu.h +103 -0
  55. data/include/reflex/ruby/pin.h +40 -0
  56. data/include/reflex/ruby/view.h +36 -0
  57. data/include/reflex/ruby/window.h +36 -18
  58. data/include/reflex/view.h +39 -12
  59. data/include/reflex/window.h +17 -4
  60. data/include/reflex.h +5 -0
  61. data/lib/reflex/chase_constraint.rb +15 -0
  62. data/lib/reflex/clipboard.rb +19 -0
  63. data/lib/reflex/constraint.rb +29 -0
  64. data/lib/reflex/extension.rb +1 -1
  65. data/lib/reflex/helper.rb +28 -0
  66. data/lib/reflex/key_event.rb +7 -12
  67. data/lib/reflex/link_constraint.rb +31 -0
  68. data/lib/reflex/menu.rb +76 -0
  69. data/lib/reflex/pin.rb +39 -0
  70. data/lib/reflex/pointer.rb +18 -0
  71. data/lib/reflex/pointer_event.rb +1 -1
  72. data/lib/reflex/snap_constraint.rb +28 -0
  73. data/lib/reflex/view.rb +56 -4
  74. data/lib/reflex/wheel_constraint.rb +28 -0
  75. data/lib/reflex/wheel_event.rb +9 -0
  76. data/lib/reflex.rb +15 -6
  77. data/pod.rake +4 -2
  78. data/reflex.gemspec +3 -3
  79. data/samples/constraint.rb +152 -0
  80. data/samples/menu.rb +29 -0
  81. data/src/application.cpp +21 -2
  82. data/src/application.h +5 -0
  83. data/src/clipboard.cpp +81 -0
  84. data/src/constraint.cpp +1662 -0
  85. data/src/constraint.h +64 -0
  86. data/src/event.cpp +7 -1
  87. data/src/event.h +1 -2
  88. data/src/ios/application.mm +5 -0
  89. data/src/ios/clipboard.mm +44 -0
  90. data/src/ios/event.h +6 -2
  91. data/src/ios/event.mm +31 -12
  92. data/src/ios/menu.mm +36 -0
  93. data/src/ios/view_controller.mm +45 -12
  94. data/src/ios/window.mm +6 -0
  95. data/src/menu.cpp +325 -0
  96. data/src/menu.h +65 -0
  97. data/src/osx/app_delegate.mm +74 -125
  98. data/src/osx/application.mm +16 -0
  99. data/src/osx/clipboard.mm +45 -0
  100. data/src/osx/event.mm +40 -10
  101. data/src/osx/menu.h +25 -0
  102. data/src/osx/menu.mm +372 -0
  103. data/src/osx/native_window.mm +27 -0
  104. data/src/osx/opengl_view.mm +51 -0
  105. data/src/osx/window.mm +11 -0
  106. data/src/pin.cpp +137 -0
  107. data/src/pointer.cpp +27 -16
  108. data/src/pointer.h +6 -0
  109. data/src/sdl/application.cpp +5 -0
  110. data/src/sdl/clipboard.cpp +39 -0
  111. data/src/sdl/event.cpp +20 -3
  112. data/src/sdl/event.h +6 -3
  113. data/src/sdl/menu.cpp +35 -0
  114. data/src/sdl/window.cpp +26 -8
  115. data/src/view.cpp +313 -52
  116. data/src/view.h +18 -2
  117. data/src/win32/application.cpp +5 -0
  118. data/src/win32/clipboard.cpp +210 -0
  119. data/src/win32/event.cpp +11 -1
  120. data/src/win32/event.h +2 -0
  121. data/src/win32/menu.cpp +352 -0
  122. data/src/win32/menu.h +27 -0
  123. data/src/win32/window.cpp +62 -0
  124. data/src/win32/window.h +3 -0
  125. data/src/window.cpp +235 -22
  126. data/src/window.h +13 -2
  127. data/src/world.cpp +77 -14
  128. data/src/world.h +9 -2
  129. data/test/helper.rb +7 -0
  130. data/test/test_application.rb +11 -0
  131. data/test/test_chase_constraint.rb +124 -0
  132. data/test/test_clipboard.rb +54 -0
  133. data/test/test_constraint.rb +186 -0
  134. data/test/test_key_event.rb +6 -0
  135. data/test/test_link_constraint.rb +239 -0
  136. data/test/test_menu.rb +207 -0
  137. data/test/test_pin.rb +65 -0
  138. data/test/test_pointer.rb +23 -9
  139. data/test/test_pointer_event.rb +1 -1
  140. data/test/test_snap_constraint.rb +142 -0
  141. data/test/test_view.rb +113 -23
  142. data/test/test_wheel_constraint.rb +127 -0
  143. data/test/test_wheel_event.rb +15 -9
  144. data/test/test_window.rb +10 -0
  145. metadata +82 -8
@@ -0,0 +1,135 @@
1
+ #include "reflex/ruby/constraint.h"
2
+
3
+
4
+ #include "reflex/exception.h"
5
+ #include "defs.h"
6
+
7
+
8
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::SnapConstraint)
9
+
10
+ #define THIS to<Reflex::SnapConstraint*>(self)
11
+
12
+ #define CHECK RUCY_CHECK_OBJ(Reflex::SnapConstraint, self)
13
+
14
+
15
+ static
16
+ RUCY_DEF_ALLOC(alloc, klass)
17
+ {
18
+ Reflex::reflex_error(
19
+ __FILE__, __LINE__, "can not instantiate SnapConstraint class");
20
+ }
21
+ RUCY_END
22
+
23
+ static
24
+ RUCY_DEF2(set_angle, min, max)
25
+ {
26
+ CHECK;
27
+ THIS->set_angle(to<float>(min), to<float>(max));
28
+ }
29
+ RUCY_END
30
+
31
+ static
32
+ RUCY_DEF0(clear_angle)
33
+ {
34
+ CHECK;
35
+ THIS->clear_angle();
36
+ }
37
+ RUCY_END
38
+
39
+ static
40
+ RUCY_DEF0(angle_min)
41
+ {
42
+ CHECK;
43
+ return value(THIS->angle_min());
44
+ }
45
+ RUCY_END
46
+
47
+ static
48
+ RUCY_DEF0(angle_max)
49
+ {
50
+ CHECK;
51
+ return value(THIS->angle_max());
52
+ }
53
+ RUCY_END
54
+
55
+ static
56
+ RUCY_DEF0(has_angle)
57
+ {
58
+ CHECK;
59
+ return value(THIS->has_angle());
60
+ }
61
+ RUCY_END
62
+
63
+ static
64
+ RUCY_DEF1(set_motor, degrees_per_second)
65
+ {
66
+ CHECK;
67
+
68
+ if (degrees_per_second.is_nil())
69
+ THIS->clear_motor();
70
+ else
71
+ THIS->set_motor(to<float>(degrees_per_second));
72
+ }
73
+ RUCY_END
74
+
75
+ static
76
+ RUCY_DEF0(get_motor)
77
+ {
78
+ CHECK;
79
+ return THIS->has_motor() ? value(THIS->motor()) : nil();
80
+ }
81
+ RUCY_END
82
+
83
+ static
84
+ RUCY_DEF1(set_force, max_torque)
85
+ {
86
+ CHECK;
87
+ if (max_torque.is_nil())
88
+ THIS->clear_force();
89
+ else
90
+ THIS->set_force(to<float>(max_torque));
91
+ }
92
+ RUCY_END
93
+
94
+ static
95
+ RUCY_DEF0(get_force)
96
+ {
97
+ CHECK;
98
+ return THIS->has_force() ? value(THIS->force()) : nil();
99
+ }
100
+ RUCY_END
101
+
102
+
103
+ static Class cSnapConstraint;
104
+
105
+ void
106
+ Init_reflex_snap_constraint ()
107
+ {
108
+ Module mReflex = define_module("Reflex");
109
+
110
+ cSnapConstraint = mReflex.define_class("SnapConstraint", Reflex::constraint_class());
111
+ cSnapConstraint.define_alloc_func(alloc);
112
+ cSnapConstraint.define_private_method( "set_angle!", set_angle);
113
+ cSnapConstraint.define_private_method("clear_angle!", clear_angle);
114
+ cSnapConstraint.define_private_method( "angle_min!", angle_min);
115
+ cSnapConstraint.define_private_method( "angle_max!", angle_max);
116
+ cSnapConstraint.define_private_method( "has_angle!", has_angle);
117
+ cSnapConstraint.define_method("motor=", set_motor);
118
+ cSnapConstraint.define_method("motor", get_motor);
119
+ cSnapConstraint.define_method("force=", set_force);
120
+ cSnapConstraint.define_method("force", get_force);
121
+ }
122
+
123
+
124
+ namespace Reflex
125
+ {
126
+
127
+
128
+ Class
129
+ snap_constraint_class ()
130
+ {
131
+ return cSnapConstraint;
132
+ }
133
+
134
+
135
+ }// Reflex
@@ -219,13 +219,14 @@ namespace Rucy
219
219
  template <> REFLEX_EXPORT Reflex::StyleLength
220
220
  value_to<Reflex::StyleLength> (int argc, const Value* argv, bool convert)
221
221
  {
222
- if (argc == 1 && argv->is_array())
222
+ if (argc == 1 && argv && argv->is_array())
223
223
  {
224
224
  argc = argv->size();
225
225
  argv = argv->as_array();
226
226
  }
227
227
 
228
- assert(argc > 0 && argv);
228
+ if (argc <= 0 || !argv)
229
+ argument_error(__FILE__, __LINE__);
229
230
 
230
231
  if (convert)
231
232
  {
data/ext/reflex/view.cpp CHANGED
@@ -10,6 +10,7 @@
10
10
  #include "reflex/ruby/timer.h"
11
11
  #include "reflex/ruby/style.h"
12
12
  #include "reflex/ruby/shape.h"
13
+ #include "reflex/ruby/constraint.h"
13
14
  #include "reflex/ruby/filter.h"
14
15
  #include "reflex/ruby/window.h"
15
16
  #include "defs.h"
@@ -102,7 +103,7 @@ static
102
103
  RUCY_DEFN(start_timer)
103
104
  {
104
105
  CHECK;
105
- check_arg_count(__FILE__, __LINE__, "View#start_timer", argc, 1, 2);
106
+ check_arg_count(__FILE__, __LINE__, "View#start_timer!", argc, 1, 2);
106
107
 
107
108
  Reflex::Timer* timer = THIS->start_timer(
108
109
  to<float>(argv[0]),
@@ -170,10 +171,10 @@ RUCY_DEF1(to_screen, point)
170
171
  RUCY_END
171
172
 
172
173
  static
173
- RUCY_DEF1(add_child, child)
174
+ RUCY_DEF2(add_child, child, index)
174
175
  {
175
176
  CHECK;
176
- THIS->add_child(to<Reflex::View*>(child));
177
+ THIS->add_child(to<Reflex::View*>(child), index.is_nil() ? -1 : to<int>(index));
177
178
  return child;
178
179
  }
179
180
  RUCY_END
@@ -216,9 +217,11 @@ RUCY_DEF0(each_child)
216
217
  {
217
218
  CHECK;
218
219
 
220
+ Reflex::View::ChildList children(THIS->child_begin(), THIS->child_end());
221
+
219
222
  Value ret;
220
- for (auto it = THIS->child_begin(), end = THIS->child_end(); it != end; ++it)
221
- ret = rb_yield(value(it->get()));
223
+ for (auto& child : children)
224
+ ret = yield(value(child.get()));
222
225
  return ret;
223
226
  }
224
227
  RUCY_END
@@ -276,10 +279,11 @@ RUCY_DEF0(each_style)
276
279
  {
277
280
  CHECK;
278
281
 
282
+ Reflex::View::StyleList styles(THIS->style_begin(), THIS->style_end());
283
+
279
284
  Value ret;
280
- Reflex::View::style_iterator end = THIS->style_end();
281
- for (Reflex::View::style_iterator it = THIS->style_begin(); it != end; ++it)
282
- ret = rb_yield(value(*it));
285
+ for (auto& style : styles)
286
+ ret = yield(value(style));
283
287
  return ret;
284
288
  }
285
289
  RUCY_END
@@ -318,10 +322,10 @@ RUCY_DEF0(get_shape)
318
322
  RUCY_END
319
323
 
320
324
  static
321
- RUCY_DEF1(add_shape, shape)
325
+ RUCY_DEF2(add_shape, shape, index)
322
326
  {
323
327
  CHECK;
324
- THIS->add_shape(to_shape(shape));
328
+ THIS->add_shape(to_shape(shape), index.is_nil() ? -1 : to<int>(index));
325
329
  return shape;
326
330
  }
327
331
  RUCY_END
@@ -362,10 +366,48 @@ RUCY_DEF0(each_shape)
362
366
  {
363
367
  CHECK;
364
368
 
369
+ Reflex::View::ShapeList shapes(THIS->shape_begin(), THIS->shape_end());
370
+
365
371
  Value ret;
366
- Reflex::View::shape_iterator end = THIS->shape_end();
367
- for (Reflex::View::shape_iterator it = THIS->shape_begin(); it != end; ++it)
368
- ret = rb_yield(value(it->get()));
372
+ for (auto& shape : shapes)
373
+ ret = yield(value(shape.get()));
374
+ return ret;
375
+ }
376
+ RUCY_END
377
+
378
+ static
379
+ RUCY_DEF0(clear_constraints)
380
+ {
381
+ CHECK;
382
+ THIS->clear_constraints();
383
+ return self;
384
+ }
385
+ RUCY_END
386
+
387
+ static
388
+ RUCY_DEFN(find_constraints)
389
+ {
390
+ CHECK;
391
+ check_arg_count(__FILE__, __LINE__, "View#find_constraints", argc, 1);
392
+
393
+ auto constraints =
394
+ THIS->find_constraints(to<Reflex::Selector>(argv[0])) |
395
+ std::views::transform([](auto& ref) {return value(ref.get());});
396
+ return array(constraints.begin(), constraints.end());
397
+ }
398
+ RUCY_END
399
+
400
+ static
401
+ RUCY_DEF0(each_constraint)
402
+ {
403
+ CHECK;
404
+
405
+ Reflex::View::ConstraintList constraints(
406
+ THIS->constraint_begin(), THIS->constraint_end());
407
+
408
+ Value ret;
409
+ for (auto& constraint : constraints)
410
+ ret = yield(value(constraint.get()));
369
411
  return ret;
370
412
  }
371
413
  RUCY_END
@@ -904,13 +946,11 @@ RUCY_DEF1(create_world, pixels_per_meter)
904
946
  RUCY_END
905
947
 
906
948
  static
907
- RUCY_DEFN(update_world)
949
+ RUCY_DEF0(update_world)
908
950
  {
909
951
  CHECK;
910
- check_arg_count(__FILE__, __LINE__, "View#update_world", argc, 0, 1);
911
952
 
912
- float duration = argc >= 1 ? to<float>(argv[0]) : 0;
913
- THIS->update_world(duration);
953
+ THIS->update_world();
914
954
  return self;
915
955
  }
916
956
  RUCY_END
@@ -1002,6 +1042,22 @@ RUCY_DEF1(on_detach, event)
1002
1042
  }
1003
1043
  RUCY_END
1004
1044
 
1045
+ static
1046
+ RUCY_DEF1(on_activate, event)
1047
+ {
1048
+ CHECK;
1049
+ CALL(on_activate(to<Reflex::Event*>(event)));
1050
+ }
1051
+ RUCY_END
1052
+
1053
+ static
1054
+ RUCY_DEF1(on_deactivate, event)
1055
+ {
1056
+ CHECK;
1057
+ CALL(on_deactivate(to<Reflex::Event*>(event)));
1058
+ }
1059
+ RUCY_END
1060
+
1005
1061
  static
1006
1062
  RUCY_DEF1(on_show, event)
1007
1063
  {
@@ -1146,6 +1202,22 @@ RUCY_DEF1(on_pointer_cancel, event)
1146
1202
  }
1147
1203
  RUCY_END
1148
1204
 
1205
+ static
1206
+ RUCY_DEF1(on_pointer_enter, event)
1207
+ {
1208
+ CHECK;
1209
+ CALL(on_pointer_enter(to<Reflex::PointerEvent*>(event)));
1210
+ }
1211
+ RUCY_END
1212
+
1213
+ static
1214
+ RUCY_DEF1(on_pointer_leave, event)
1215
+ {
1216
+ CHECK;
1217
+ CALL(on_pointer_leave(to<Reflex::PointerEvent*>(event)));
1218
+ }
1219
+ RUCY_END
1220
+
1149
1221
  static
1150
1222
  RUCY_DEF1(on_wheel, event)
1151
1223
  {
@@ -1259,7 +1331,7 @@ Init_reflex_view ()
1259
1331
  cView.define_method("focus", focus);
1260
1332
  cView.define_method("blur", blur);
1261
1333
  cView.define_method("focus?", has_focus);
1262
- cView.define_private_method("start_timer", start_timer);
1334
+ cView.define_private_method("start_timer!", start_timer);
1263
1335
  cView.define_method("update_layout", update_layout);
1264
1336
 
1265
1337
  cView.define_method("from_parent", from_parent);
@@ -1269,25 +1341,29 @@ Init_reflex_view ()
1269
1341
  cView.define_method("from_screen", from_screen);
1270
1342
  cView.define_method( "to_screen", to_screen);
1271
1343
 
1272
- cView.define_method( "add_child", add_child);
1273
- cView.define_method("remove_child", remove_child);
1274
- cView.define_method( "clear_children", clear_children);
1275
- cView.define_method( "find_children", find_children);
1276
- cView.define_method( "each_child", each_child);
1277
-
1278
- cView.define_method( "add_style", add_style);
1279
- cView.define_method("remove_style", remove_style);
1280
- cView.define_method( "get_style", get_style);
1281
- cView.define_method( "find_styles", find_styles);
1282
- cView.define_method( "each_style", each_style);
1283
-
1284
- cView.define_method( "shape=", set_shape);
1285
- cView.define_method( "shape", get_shape);
1286
- cView.define_method( "add_shape", add_shape);
1287
- cView.define_method("remove_shape", remove_shape);
1288
- cView.define_method( "clear_shapes", clear_shapes);
1289
- cView.define_method( "find_shapes", find_shapes);
1290
- cView.define_method( "each_shape", each_shape);
1344
+ cView.define_method( "add_child!", add_child);
1345
+ cView.define_method( "remove_child", remove_child);
1346
+ cView.define_method( "clear_children", clear_children);
1347
+ cView.define_method( "find_children", find_children);
1348
+ cView.define_private_method("each_child!", each_child);
1349
+
1350
+ cView.define_method( "add_style", add_style);
1351
+ cView.define_method( "remove_style", remove_style);
1352
+ cView.define_method( "get_style", get_style);
1353
+ cView.define_method( "find_styles", find_styles);
1354
+ cView.define_private_method("each_style!", each_style);
1355
+
1356
+ cView.define_method( "shape=", set_shape);
1357
+ cView.define_method( "shape", get_shape);
1358
+ cView.define_method( "add_shape!", add_shape);
1359
+ cView.define_method( "remove_shape", remove_shape);
1360
+ cView.define_method( "clear_shapes", clear_shapes);
1361
+ cView.define_method( "find_shapes", find_shapes);
1362
+ cView.define_private_method("each_shape!", each_shape);
1363
+
1364
+ cView.define_method( "clear_constraints", clear_constraints);
1365
+ cView.define_method( "find_constraints", find_constraints);
1366
+ cView.define_private_method("each_constraint!", each_constraint);
1291
1367
 
1292
1368
  cView.define_method("filter=", set_filter);
1293
1369
  cView.define_method("filter", get_filter);
@@ -1356,6 +1432,8 @@ Init_reflex_view ()
1356
1432
 
1357
1433
  cView.define_method("on_attach", on_attach);
1358
1434
  cView.define_method("on_detach", on_detach);
1435
+ cView.define_method("on_activate", on_activate);
1436
+ cView.define_method("on_deactivate", on_deactivate);
1359
1437
  cView.define_method("on_show", on_show);
1360
1438
  cView.define_method("on_hide", on_hide);
1361
1439
  cView.define_method("on_update", on_update);
@@ -1374,6 +1452,8 @@ Init_reflex_view ()
1374
1452
  cView.define_method("on_pointer_up", on_pointer_up);
1375
1453
  cView.define_method("on_pointer_move", on_pointer_move);
1376
1454
  cView.define_method("on_pointer_cancel", on_pointer_cancel);
1455
+ cView.define_method("on_pointer_enter", on_pointer_enter);
1456
+ cView.define_method("on_pointer_leave", on_pointer_leave);
1377
1457
  cView.define_method("on_wheel", on_wheel);
1378
1458
  cView.define_method("on_midi", on_midi);
1379
1459
  cView.define_method("on_note", on_note);
@@ -0,0 +1,154 @@
1
+ #include "reflex/ruby/constraint.h"
2
+
3
+
4
+ #include <rays/ruby/point.h>
5
+ #include "reflex/exception.h"
6
+ #include "defs.h"
7
+
8
+
9
+ RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(REFLEX_EXPORT, Reflex::WheelConstraint)
10
+
11
+ #define THIS to<Reflex::WheelConstraint*>(self)
12
+
13
+ #define CHECK RUCY_CHECK_OBJ(Reflex::WheelConstraint, self)
14
+
15
+
16
+ static
17
+ RUCY_DEF_ALLOC(alloc, klass)
18
+ {
19
+ Reflex::reflex_error(
20
+ __FILE__, __LINE__, "can not instantiate WheelConstraint class");
21
+ }
22
+ RUCY_END
23
+
24
+ static
25
+ RUCY_DEFN(set_axis)
26
+ {
27
+ CHECK;
28
+ THIS->set_axis(to<Rays::Point>(argc, argv));
29
+ }
30
+ RUCY_END
31
+
32
+ static
33
+ RUCY_DEF0(get_axis)
34
+ {
35
+ CHECK;
36
+ return value(THIS->axis());
37
+ }
38
+ RUCY_END
39
+
40
+ static
41
+ RUCY_DEF2(set_range, min, max)
42
+ {
43
+ CHECK;
44
+ THIS->set_range(to<coord>(min), to<coord>(max));
45
+ }
46
+ RUCY_END
47
+
48
+ static
49
+ RUCY_DEF0(clear_range)
50
+ {
51
+ CHECK;
52
+ THIS->clear_range();
53
+ }
54
+ RUCY_END
55
+
56
+ static
57
+ RUCY_DEF0(range_min)
58
+ {
59
+ CHECK;
60
+ return value(THIS->range_min());
61
+ }
62
+ RUCY_END
63
+
64
+ static
65
+ RUCY_DEF0(range_max)
66
+ {
67
+ CHECK;
68
+ return value(THIS->range_max());
69
+ }
70
+ RUCY_END
71
+
72
+ static
73
+ RUCY_DEF0(has_range)
74
+ {
75
+ CHECK;
76
+ return value(THIS->has_range());
77
+ }
78
+ RUCY_END
79
+
80
+ static
81
+ RUCY_DEF1(set_motor, degrees_per_second)
82
+ {
83
+ CHECK;
84
+ if (degrees_per_second.is_nil())
85
+ THIS->clear_motor();
86
+ else
87
+ THIS->set_motor(to<float>(degrees_per_second));
88
+ }
89
+ RUCY_END
90
+
91
+ static
92
+ RUCY_DEF0(get_motor)
93
+ {
94
+ CHECK;
95
+ return THIS->has_motor() ? value(THIS->motor()) : nil();
96
+ }
97
+ RUCY_END
98
+
99
+ static
100
+ RUCY_DEF1(set_force, max_torque)
101
+ {
102
+ CHECK;
103
+ if (max_torque.is_nil())
104
+ THIS->clear_force();
105
+ else
106
+ THIS->set_force(to<float>(max_torque));
107
+ }
108
+ RUCY_END
109
+
110
+ static
111
+ RUCY_DEF0(get_force)
112
+ {
113
+ CHECK;
114
+ return THIS->has_force() ? value(THIS->force()) : nil();
115
+ }
116
+ RUCY_END
117
+
118
+
119
+ static Class cWheelConstraint;
120
+
121
+ void
122
+ Init_reflex_wheel_constraint ()
123
+ {
124
+ Module mReflex = define_module("Reflex");
125
+
126
+ cWheelConstraint = mReflex.define_class(
127
+ "WheelConstraint", Reflex::constraint_class());
128
+ cWheelConstraint.define_alloc_func(alloc);
129
+ cWheelConstraint.define_method("axis=", set_axis);
130
+ cWheelConstraint.define_method("axis", get_axis);
131
+ cWheelConstraint.define_private_method( "set_range!", set_range);
132
+ cWheelConstraint.define_private_method("clear_range!", clear_range);
133
+ cWheelConstraint.define_private_method( "range_min!", range_min);
134
+ cWheelConstraint.define_private_method( "range_max!", range_max);
135
+ cWheelConstraint.define_private_method( "has_range!", has_range);
136
+ cWheelConstraint.define_method("motor=", set_motor);
137
+ cWheelConstraint.define_method("motor", get_motor);
138
+ cWheelConstraint.define_method("force=", set_force);
139
+ cWheelConstraint.define_method("force", get_force);
140
+ }
141
+
142
+
143
+ namespace Reflex
144
+ {
145
+
146
+
147
+ Class
148
+ wheel_constraint_class ()
149
+ {
150
+ return cWheelConstraint;
151
+ }
152
+
153
+
154
+ }// Reflex