reflexion 0.1.3 → 0.1.4

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 (88) hide show
  1. data/.doc/ext/reflex/application.cpp +35 -76
  2. data/.doc/ext/reflex/defs.cpp +8 -0
  3. data/.doc/ext/reflex/key.cpp +38 -43
  4. data/.doc/ext/reflex/native.cpp +6 -4
  5. data/.doc/ext/reflex/points.cpp +47 -52
  6. data/.doc/ext/reflex/reflex.cpp +12 -13
  7. data/.doc/ext/reflex/view.cpp +242 -0
  8. data/.doc/ext/reflex/window.cpp +87 -178
  9. data/.gitignore +14 -0
  10. data/Rakefile +6 -31
  11. data/VERSION +1 -1
  12. data/examples/hello/.gitignore +2 -0
  13. data/examples/ruby/app.rb +2 -2
  14. data/examples/ruby/checker.rb +3 -3
  15. data/examples/ruby/fps.rb +14 -14
  16. data/examples/ruby/grid.rb +65 -0
  17. data/examples/ruby/hello.rb +19 -7
  18. data/examples/ruby/key.rb +4 -4
  19. data/examples/ruby/shapes.rb +6 -6
  20. data/examples/ruby/text.rb +20 -17
  21. data/examples/ruby/views.rb +88 -0
  22. data/examples/ruby/visuals.rb +27 -0
  23. data/ext/reflex/application.cpp +36 -76
  24. data/ext/reflex/defs.cpp +8 -0
  25. data/ext/reflex/defs.h +1 -18
  26. data/ext/reflex/extconf.rb +16 -8
  27. data/ext/reflex/key.cpp +39 -43
  28. data/ext/reflex/native.cpp +6 -4
  29. data/ext/reflex/points.cpp +48 -52
  30. data/ext/reflex/reflex.cpp +12 -13
  31. data/ext/reflex/view.cpp +260 -0
  32. data/ext/reflex/window.cpp +89 -178
  33. data/include/reflex/application.h +14 -7
  34. data/include/reflex/defs.h +8 -6
  35. data/include/reflex/exception.h +1 -1
  36. data/include/reflex/ruby/application.h +31 -10
  37. data/include/reflex/ruby/key.h +3 -3
  38. data/include/reflex/ruby/points.h +3 -3
  39. data/include/reflex/ruby/view.h +106 -0
  40. data/include/reflex/ruby/window.h +83 -12
  41. data/include/reflex/ruby.h +3 -2
  42. data/include/reflex/view.h +103 -0
  43. data/include/reflex/window.h +43 -18
  44. data/include/reflex.h +2 -1
  45. data/lib/reflex/application.rb +8 -7
  46. data/lib/reflex/autoinit.rb +1 -1
  47. data/lib/reflex/bitmap.rb +13 -0
  48. data/lib/reflex/bounds.rb +2 -122
  49. data/lib/reflex/ext.rb +5 -0
  50. data/lib/reflex/helpers.rb +36 -31
  51. data/lib/reflex/image.rb +13 -0
  52. data/lib/reflex/module.rb +9 -2
  53. data/lib/reflex/painter.rb +13 -0
  54. data/lib/reflex/point.rb +3 -59
  55. data/lib/reflex/reflex.rb +1 -1
  56. data/lib/reflex/texture.rb +13 -0
  57. data/lib/reflex/view.rb +33 -0
  58. data/lib/reflex/visuals/string.rb +53 -0
  59. data/lib/reflex/window.rb +18 -43
  60. data/lib/reflex.rb +3 -3
  61. data/reflex.gemspec +16 -42
  62. data/src/cocoa/application.mm +17 -23
  63. data/src/cocoa/applicationdata.h +3 -9
  64. data/src/cocoa/cocoaapplication.h +6 -4
  65. data/src/cocoa/cocoaapplication.mm +61 -19
  66. data/src/cocoa/cocoawindow.h +7 -5
  67. data/src/cocoa/cocoawindow.mm +109 -50
  68. data/src/cocoa/defs.mm +5 -2
  69. data/src/cocoa/window.mm +71 -41
  70. data/src/cocoa/windowdata.h +14 -9
  71. data/src/defs.cpp +1 -1
  72. data/src/exception.cpp +3 -18
  73. data/src/helpers.h +12 -0
  74. data/src/reflex.cpp +11 -5
  75. data/src/view.cpp +326 -0
  76. data/src/win32/application.cpp +7 -8
  77. data/src/win32/defs.h +1 -1
  78. data/src/win32/window.cpp +137 -41
  79. data/src/window.cpp +38 -1
  80. data/test/helpers.rb +2 -5
  81. data/test/test_application.rb +17 -0
  82. data/test/test_reflex.rb +4 -2
  83. data/test/test_view.rb +74 -0
  84. data/test/test_window.rb +33 -2
  85. metadata +157 -97
  86. data/include/reflex/helpers.h +0 -32
  87. data/test/test_bounds.rb +0 -163
  88. data/test/test_point.rb +0 -81
@@ -8,12 +8,13 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
+ static Class cApplication;
12
+
13
+
11
14
  namespace Reflex
12
15
  {
13
16
 
14
17
 
15
- static Class cApplication;
16
-
17
18
  Class
18
19
  application_class ()
19
20
  {
@@ -24,73 +25,27 @@ namespace Reflex
24
25
  }// Reflex
25
26
 
26
27
 
27
- namespace Rucy
28
- {
29
-
30
-
31
- Value
32
- value (const Reflex::Application& application)
33
- {
34
- return new_type<Reflex::Application>(
35
- Reflex::application_class(), new Reflex::Application(application));
36
- }
37
-
38
-
39
- }// Rucy
40
-
41
-
42
- class RubyApplication : public Reflex::Application
43
- {
44
-
45
- public:
46
-
47
- typedef Reflex::Application Super;
48
-
49
- Value self;
50
-
51
- void mark ()
52
- {
53
- self.mark();
54
- }
28
+ typedef Reflex::RubyApplication<Reflex::Application> RubyApplication;
55
29
 
56
- virtual bool run ()
57
- {
58
- SYM(run);
59
- return self.call(run);
60
- }
61
30
 
62
- virtual bool quit ()
63
- {
64
- SYM(quit);
65
- return self.call(quit);
66
- }
31
+ #define THIS to<Reflex::Application*>(self)
67
32
 
68
- virtual bool about ()
69
- {
70
- SYM(about);
71
- return self.call(about);
72
- }
33
+ #define CHECK RUCY_CHECK_OBJECT(self, Reflex::Application, cApplication)
73
34
 
74
- };// RubyApplication
75
-
76
-
77
- #define this ((RubyApplication*) to<Reflex::Application*>(self))
78
-
79
- #define CHECK CHECK_OBJECT(self, RubyApplication, Reflex::application_class())
35
+ #define CALL(fun) RUCY_WRAPPER_CALL(RubyApplication, THIS, fun)
80
36
 
81
37
 
82
38
  static
83
39
  VALUE alloc(VALUE klass)
84
40
  {
85
- RubyApplication* app = new RubyApplication;
86
- return app->self = new_type<RubyApplication>(klass, app, mark_type<RubyApplication>);
41
+ return value(new RubyApplication, klass);
87
42
  }
88
43
 
89
44
  static
90
45
  VALUE run(VALUE self)
91
46
  {
92
47
  CHECK;
93
- if (!this->Super::run())
48
+ if (!CALL(run()))
94
49
  system_error("failed to run application.");
95
50
  return self;
96
51
  }
@@ -99,7 +54,7 @@ static
99
54
  VALUE quit(VALUE self)
100
55
  {
101
56
  CHECK;
102
- if (!this->Super::quit())
57
+ if (!CALL(quit()))
103
58
  system_error("failed to quit application.");
104
59
  return self;
105
60
  }
@@ -108,43 +63,47 @@ static
108
63
  VALUE about(VALUE self)
109
64
  {
110
65
  CHECK;
111
- if (!this->Super::about())
66
+ if (!CALL(about()))
112
67
  system_error("failed to show about application.");
113
68
  return self;
114
69
  }
115
70
 
116
71
  static
117
- VALUE get_name(VALUE self)
72
+ VALUE set_name(VALUE self, VALUE name)
118
73
  {
119
74
  CHECK;
120
- String s;
121
- if (!this->get_name(&s))
122
- system_error("failed to get name of application.");
123
- return Value(s.c_str());
75
+ if (!THIS->set_name(name.c_str()))
76
+ system_error("failed to set name of application.");
77
+ return name;
124
78
  }
125
79
 
126
80
  static
127
- VALUE set_name(VALUE self, VALUE name)
81
+ VALUE get_name(VALUE self)
128
82
  {
129
83
  CHECK;
130
- if (!this->set_name(name.c_str()))
131
- system_error("failed to set name of application.");
132
- return name;
84
+ const char* s = THIS->name();
85
+ if (!s) system_error("failed to get name of application.");
86
+ return value(s);
87
+ }
88
+
89
+ static
90
+ VALUE instance(VALUE self)
91
+ {
92
+ return value(Reflex::app());
133
93
  }
134
94
 
135
95
 
136
96
  void
137
97
  Init_application ()
138
98
  {
139
- Module m = rb_define_module("Reflex");
140
-
141
- Class c = rb_define_class_under(m, "Application", rb_cObject);
142
- Reflex::cApplication = c;
143
-
144
- rb_define_alloc_func(c, alloc);
145
- rb_define_method(c, "run", RUBY_METHOD_FUNC(run), 0);
146
- rb_define_method(c, "quit", RUBY_METHOD_FUNC(quit), 0);
147
- rb_define_method(c, "about", RUBY_METHOD_FUNC(about), 0);
148
- rb_define_method(c, "name", RUBY_METHOD_FUNC(get_name), 0);
149
- rb_define_method(c, "name=", RUBY_METHOD_FUNC(set_name), 1);
99
+ Module mReflex = rb_define_module("Reflex");
100
+
101
+ cApplication = rb_define_class_under(mReflex, "Application", rb_cObject);
102
+ rb_define_alloc_func(cApplication, alloc);
103
+ rb_define_method(cApplication, "run", RUBY_METHOD_FUNC(run), 0);
104
+ rb_define_method(cApplication, "quit", RUBY_METHOD_FUNC(quit), 0);
105
+ rb_define_method(cApplication, "about", RUBY_METHOD_FUNC(about), 0);
106
+ rb_define_method(cApplication, "name=", RUBY_METHOD_FUNC(set_name), 1);
107
+ rb_define_method(cApplication, "name", RUBY_METHOD_FUNC(get_name), 0);
108
+ rb_define_singleton_method(cApplication, "instance", RUBY_METHOD_FUNC(instance), 0);
150
109
  }
@@ -0,0 +1,8 @@
1
+ #include "defs.h"
2
+
3
+
4
+ #include <rucy/value.h>
5
+ #include <reflex/defs.h>
6
+
7
+
8
+ using namespace Rucy;
@@ -8,12 +8,13 @@
8
8
  using namespace Rucy;
9
9
 
10
10
 
11
+ static Class cKey;
12
+
13
+
11
14
  namespace Reflex
12
15
  {
13
16
 
14
17
 
15
- static Class cKey;
16
-
17
18
  Class
18
19
  key_class ()
19
20
  {
@@ -31,97 +32,91 @@ namespace Rucy
31
32
  Value
32
33
  value (const Reflex::Key& key)
33
34
  {
34
- return new_type<Reflex::Key>(
35
- Reflex::key_class(), new Reflex::Key(key));
35
+ return new_type(cKey, new Reflex::Key(key));
36
36
  }
37
37
 
38
38
 
39
39
  }// Rucy
40
40
 
41
41
 
42
- struct RubyKey : public Reflex::Key
43
- {
44
-
45
- operator bool () const
46
- {
47
- return true;
48
- }
49
-
50
- bool operator ! () const
51
- {
52
- return !operator bool();
53
- }
54
-
55
- };// RubyKey
56
-
57
-
58
- #define this ((RubyKey*) to<Reflex::Key*>(self))
42
+ #define THIS to<Reflex::Key*>(self)
59
43
 
60
- #define CHECK CHECK_OBJECT(self, RubyKey, Reflex::key_class())
44
+ #define CHECK RUCY_CHECK_OBJ(self, Reflex::Key, cKey)
61
45
 
62
46
 
63
47
  static
64
48
  VALUE alloc(VALUE klass)
65
49
  {
66
- return new_type<RubyKey>(klass, new RubyKey);
50
+ return new_type<Reflex::Key>(klass);
67
51
  }
68
52
 
69
53
  static
70
54
  VALUE initialize(VALUE self)
71
55
  {
72
- CHECK_OBJ(self, RubyKey, Reflex::key_class());
56
+ RUCY_CHECK_OBJ(self, Reflex::Key, cKey);
73
57
  if (argc < 0 || 4 < argc)
74
58
  argument_error("Key#initialize", argc, 0, 1, 2);
75
59
 
76
- this->chars = (argc >= 1) ? argv[0].c_str() : NULL;
77
- this->code = (argc >= 2) ? to<int>(argv[1]) : Reflex::KEY_NONE;
78
- this->repeat = (argc >= 3) ? to<int>(argv[2]) : 1;
79
- this->modifiers = (argc >= 4) ? to<uint>(argv[3]) : (uint) Reflex::MOD_NONE;
60
+ THIS->chars = (argc >= 1) ? argv[0].c_str() : NULL;
61
+ THIS->code = (argc >= 2) ? to<int>(argv[1]) : Reflex::KEY_NONE;
62
+ THIS->repeat = (argc >= 3) ? to<int>(argv[2]) : 1;
63
+ THIS->modifiers = (argc >= 4) ? to<uint>(argv[3]) : (uint) Reflex::MOD_NONE;
80
64
 
81
65
  return self;
82
66
  }
83
67
 
68
+ static
69
+ VALUE initialize_copy(VALUE self, VALUE obj)
70
+ {
71
+ RUCY_CHECK_OBJ(self, Reflex::Key, cKey);
72
+
73
+ Reflex::Key* key = to<Reflex::Key*>(obj);
74
+ if (!key) argument_error();
75
+
76
+ *THIS = *key;
77
+ return self;
78
+ }
79
+
84
80
  static
85
81
  VALUE chars(VALUE self)
86
82
  {
87
83
  CHECK;
88
- return value(this->chars.c_str());
84
+ return value(THIS->chars.c_str());
89
85
  }
90
86
 
91
87
  static
92
88
  VALUE code(VALUE self)
93
89
  {
94
90
  CHECK;
95
- return value(this->code);
91
+ return value(THIS->code);
96
92
  }
97
93
 
98
94
  static
99
95
  VALUE repeat(VALUE self)
100
96
  {
101
97
  CHECK;
102
- return value(this->repeat);
98
+ return value(THIS->repeat);
103
99
  }
104
100
 
105
101
  static
106
102
  VALUE modifiers(VALUE self)
107
103
  {
108
104
  CHECK;
109
- return value(this->modifiers);
105
+ return value(THIS->modifiers);
110
106
  }
111
107
 
112
108
 
113
109
  void
114
110
  Init_key ()
115
111
  {
116
- Module m = rb_define_module("Reflex");
117
-
118
- Class c = rb_define_class_under(m, "Key", rb_cObject);
119
- Reflex::cKey = c;
120
-
121
- rb_define_alloc_func(c, alloc);
122
- rb_define_method(c, "initialize", RUBY_METHOD_FUNC(initialize), -1);
123
- rb_define_method(c, "chars", RUBY_METHOD_FUNC(chars), 0);
124
- rb_define_method(c, "code", RUBY_METHOD_FUNC(code), 0);
125
- rb_define_method(c, "repeat", RUBY_METHOD_FUNC(repeat), 0);
126
- rb_define_method(c, "modifiers", RUBY_METHOD_FUNC(modifiers), 0);
112
+ Module mReflex = rb_define_module("Reflex");
113
+
114
+ cKey = rb_define_class_under(mReflex, "Key", rb_cObject);
115
+ rb_define_alloc_func(cKey, alloc);
116
+ rb_define_private_method(cKey, "initialize", RUBY_METHOD_FUNC(initialize), -1);
117
+ rb_define_private_method(cKey, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
118
+ rb_define_method(cKey, "chars", RUBY_METHOD_FUNC(chars), 0);
119
+ rb_define_method(cKey, "code", RUBY_METHOD_FUNC(code), 0);
120
+ rb_define_method(cKey, "repeat", RUBY_METHOD_FUNC(repeat), 0);
121
+ rb_define_method(cKey, "modifiers", RUBY_METHOD_FUNC(modifiers), 0);
127
122
  }
@@ -6,10 +6,11 @@ using namespace Rucy;
6
6
 
7
7
 
8
8
  void Init_reflex ();
9
- void Init_application ();
10
- void Init_window ();
11
9
  void Init_key ();
12
10
  void Init_points ();
11
+ void Init_application ();
12
+ void Init_window ();
13
+ void Init_view ();
13
14
 
14
15
 
15
16
  extern "C" void
@@ -19,8 +20,9 @@ Init_native ()
19
20
  raise(rb_eLoadError, "Rucy::init() failed.");
20
21
 
21
22
  Init_reflex();
22
- Init_application();
23
- Init_window();
24
23
  Init_key();
25
24
  Init_points();
25
+ Init_application();
26
+ Init_window();
27
+ Init_view();
26
28
  }
@@ -10,12 +10,13 @@ using namespace Rucy;
10
10
  using Reflex::coord;
11
11
 
12
12
 
13
+ static Class cPoints;
14
+
15
+
13
16
  namespace Reflex
14
17
  {
15
18
 
16
19
 
17
- static Class cPoints;
18
-
19
20
  Class
20
21
  points_class ()
21
22
  {
@@ -33,56 +34,51 @@ namespace Rucy
33
34
  Value
34
35
  value (const Reflex::Points& points)
35
36
  {
36
- return new_type<Reflex::Points>(
37
- Reflex::points_class(), new Reflex::Points(points));
37
+ return new_type(cPoints, new Reflex::Points(points));
38
38
  }
39
39
 
40
40
 
41
41
  }// Rucy
42
42
 
43
43
 
44
- struct RubyPoints : public Reflex::Points
45
- {
46
-
47
- operator bool () const
48
- {
49
- return true;
50
- }
51
-
52
- bool operator ! () const
53
- {
54
- return !operator bool();
55
- }
56
-
57
- };// RubyPoints
58
-
59
-
60
- #define this ((RubyPoints*) to<Reflex::Points*>(self))
44
+ #define THIS to<Reflex::Points*>(self)
61
45
 
62
- #define CHECK CHECK_OBJECT(self, RubyPoints, Reflex::points_class())
46
+ #define CHECK RUCY_CHECK_OBJ(self, Reflex::Points, cPoints)
63
47
 
64
48
 
65
49
  static
66
50
  VALUE alloc(VALUE klass)
67
51
  {
68
- return new_type<RubyPoints>(klass, new RubyPoints);
52
+ return new_type<Reflex::Points>(klass);
69
53
  }
70
54
 
71
55
  static
72
56
  VALUE initialize(VALUE self)
73
57
  {
74
- CHECK_OBJ(self, RubyPoints, Reflex::points_class());
58
+ RUCY_CHECK_OBJ(self, Reflex::Points, cPoints);
75
59
  if (argc < 0 || 6 < argc)
76
60
  arg_count_error("Points#initialize", argc, 0, 1, 2, 3, 4, 5, 6);
77
61
 
78
- this->type = (argc >= 1) ? to<int>(argv[0]) : Reflex::POINT_NONE;
79
- this->x = (argc >= 2) ? to<coord>(argv[1]) : 0;
80
- this->y = (argc >= 3) ? to<coord>(argv[2]) : 0;
81
- this->size = 1;
82
- this->modifiers = (argc >= 4) ? to<uint>(argv[3]) : (uint) Reflex::MOD_NONE;
83
- this->count = (argc >= 5) ? to<uint>(argv[4]) : 0;
84
- this->drag = (argc >= 6) ? to<bool>(argv[5]) : false;
62
+ THIS->type = (argc >= 1) ? to<int>(argv[0]) : Reflex::POINT_NONE;
63
+ THIS->x = (argc >= 2) ? to<coord>(argv[1]) : 0;
64
+ THIS->y = (argc >= 3) ? to<coord>(argv[2]) : 0;
65
+ THIS->size = 1;
66
+ THIS->modifiers = (argc >= 4) ? to<uint>(argv[3]) : (uint) Reflex::MOD_NONE;
67
+ THIS->count = (argc >= 5) ? to<uint>(argv[4]) : 0;
68
+ THIS->drag = (argc >= 6) ? to<bool>(argv[5]) : false;
69
+
70
+ return self;
71
+ }
72
+
73
+ static
74
+ VALUE initialize_copy(VALUE self, VALUE obj)
75
+ {
76
+ RUCY_CHECK_OBJ(self, Reflex::Points, cPoints);
77
+
78
+ Reflex::Points* points = to<Reflex::Points*>(obj);
79
+ if (!points) argument_error();
85
80
 
81
+ *THIS = *points;
86
82
  return self;
87
83
  }
88
84
 
@@ -90,67 +86,66 @@ static
90
86
  VALUE type(VALUE self)
91
87
  {
92
88
  CHECK;
93
- return value(this->type);
89
+ return value(THIS->type);
94
90
  }
95
91
 
96
92
  static
97
93
  VALUE x(VALUE self)
98
94
  {
99
95
  CHECK;
100
- return value(this->x);
96
+ return value(THIS->x);
101
97
  }
102
98
 
103
99
  static
104
100
  VALUE y(VALUE self)
105
101
  {
106
102
  CHECK;
107
- return value(this->y);
103
+ return value(THIS->y);
108
104
  }
109
105
 
110
106
  static
111
107
  VALUE size(VALUE self)
112
108
  {
113
109
  CHECK;
114
- return value(this->size);
110
+ return value(THIS->size);
115
111
  }
116
112
 
117
113
  static
118
114
  VALUE modifiers(VALUE self)
119
115
  {
120
116
  CHECK;
121
- return value(this->modifiers);
117
+ return value(THIS->modifiers);
122
118
  }
123
119
 
124
120
  static
125
121
  VALUE count(VALUE self)
126
122
  {
127
123
  CHECK;
128
- return value(this->count);
124
+ return value(THIS->count);
129
125
  }
130
126
 
131
127
  static
132
128
  VALUE drag(VALUE self)
133
129
  {
134
130
  CHECK;
135
- return value(this->drag);
131
+ return value(THIS->drag);
136
132
  }
137
133
 
138
134
 
139
135
  void
140
136
  Init_points ()
141
137
  {
142
- Module m = rb_define_module("Reflex");
143
-
144
- Class c = rb_define_class_under(m, "Points", rb_cObject);
145
- Reflex::cPoints = c;
146
-
147
- rb_define_alloc_func(c, alloc);
148
- rb_define_method(c, "initialize", RUBY_METHOD_FUNC(initialize), -1);
149
- rb_define_method(c, "type", RUBY_METHOD_FUNC(type), 0);
150
- rb_define_method(c, "x", RUBY_METHOD_FUNC(x), 0);
151
- rb_define_method(c, "y", RUBY_METHOD_FUNC(y), 0);
152
- rb_define_method(c, "size", RUBY_METHOD_FUNC(size), 0);
153
- rb_define_method(c, "modifiers", RUBY_METHOD_FUNC(modifiers), 0);
154
- rb_define_method(c, "count", RUBY_METHOD_FUNC(count), 0);
155
- rb_define_method(c, "drag", RUBY_METHOD_FUNC(drag), 0);
138
+ Module mReflex = rb_define_module("Reflex");
139
+
140
+ cPoints = rb_define_class_under(mReflex, "Points", rb_cObject);
141
+ rb_define_alloc_func(cPoints, alloc);
142
+ rb_define_private_method(cPoints, "initialize", RUBY_METHOD_FUNC(initialize), -1);
143
+ rb_define_private_method(cPoints, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
144
+ rb_define_method(cPoints, "type", RUBY_METHOD_FUNC(type), 0);
145
+ rb_define_method(cPoints, "x", RUBY_METHOD_FUNC(x), 0);
146
+ rb_define_method(cPoints, "y", RUBY_METHOD_FUNC(y), 0);
147
+ rb_define_method(cPoints, "size", RUBY_METHOD_FUNC(size), 0);
148
+ rb_define_method(cPoints, "modifiers", RUBY_METHOD_FUNC(modifiers), 0);
149
+ rb_define_method(cPoints, "count", RUBY_METHOD_FUNC(count), 0);
150
+ rb_define_method(cPoints, "drag", RUBY_METHOD_FUNC(drag), 0);
156
151
  }
@@ -6,12 +6,13 @@
6
6
  using namespace Rucy;
7
7
 
8
8
 
9
+ static Module mReflex;
10
+
11
+
9
12
  namespace Reflex
10
13
  {
11
14
 
12
15
 
13
- static Module mReflex;
14
-
15
16
  Module
16
17
  reflex_module ()
17
18
  {
@@ -26,7 +27,7 @@ static
26
27
  VALUE init(VALUE self)
27
28
  {
28
29
  if (!Reflex::init())
29
- error("Reflex::init() failed.");
30
+ reflex_error("Reflex::init() failed.");
30
31
 
31
32
  return self;
32
33
  }
@@ -35,7 +36,7 @@ static
35
36
  VALUE fin(VALUE self)
36
37
  {
37
38
  if (!Reflex::fin())
38
- error("Reflex::fin() failed.");
39
+ reflex_error("Reflex::fin() failed.");
39
40
 
40
41
  return self;
41
42
  }
@@ -44,7 +45,7 @@ static
44
45
  VALUE run(VALUE self, VALUE name)
45
46
  {
46
47
  if (!Reflex::run(name ? name.c_str() : NULL))
47
- error("Reflex::run() failed.");
48
+ reflex_error("Reflex::run() failed.");
48
49
 
49
50
  return self;
50
51
  }
@@ -53,7 +54,7 @@ static
53
54
  VALUE quit(VALUE self)
54
55
  {
55
56
  if (!Reflex::quit())
56
- error("Reflex::quit() failed.");
57
+ reflex_error("Reflex::quit() failed.");
57
58
 
58
59
  return self;
59
60
  }
@@ -62,11 +63,9 @@ VALUE quit(VALUE self)
62
63
  void
63
64
  Init_reflex ()
64
65
  {
65
- Module m = rb_define_module("Reflex");
66
- Reflex::mReflex = m;
67
-
68
- m.define_singleton_method("init!", init);
69
- m.define_singleton_method("fin!", fin);
70
- m.define_singleton_method("run!", run);
71
- rb_define_singleton_method(m, "quit", RUBY_METHOD_FUNC(quit), 0);
66
+ mReflex = rb_define_module("Reflex");
67
+ mReflex.define_singleton_method("init!", init);
68
+ mReflex.define_singleton_method("fin!", fin);
69
+ mReflex.define_singleton_method("run!", run);
70
+ rb_define_singleton_method(mReflex, "quit", RUBY_METHOD_FUNC(quit), 0);
72
71
  }