reflexion 0.1.1

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 (74) hide show
  1. data/ChangeLog +8 -0
  2. data/README +4 -0
  3. data/Rakefile +70 -0
  4. data/VERSION +1 -0
  5. data/examples/hello/Rakefile +41 -0
  6. data/examples/hello/main.cpp +18 -0
  7. data/examples/ruby/app.rb +13 -0
  8. data/examples/ruby/checker.rb +41 -0
  9. data/examples/ruby/fps.rb +49 -0
  10. data/examples/ruby/hello.rb +38 -0
  11. data/examples/ruby/key.rb +44 -0
  12. data/examples/ruby/shapes.rb +124 -0
  13. data/examples/ruby/text.rb +35 -0
  14. data/ext/reflex/application.cpp +151 -0
  15. data/ext/reflex/extconf.rb +57 -0
  16. data/ext/reflex/key.cpp +128 -0
  17. data/ext/reflex/native.cpp +22 -0
  18. data/ext/reflex/points.cpp +160 -0
  19. data/ext/reflex/reflex.cpp +83 -0
  20. data/ext/reflex/reflex.h +39 -0
  21. data/ext/reflex/window.cpp +357 -0
  22. data/include/reflex/application.h +50 -0
  23. data/include/reflex/defs.h +258 -0
  24. data/include/reflex/helpers.h +32 -0
  25. data/include/reflex/reflex.h +26 -0
  26. data/include/reflex/ruby/application.h +39 -0
  27. data/include/reflex/ruby/key.h +39 -0
  28. data/include/reflex/ruby/points.h +39 -0
  29. data/include/reflex/ruby/reflex.h +21 -0
  30. data/include/reflex/ruby/window.h +39 -0
  31. data/include/reflex/ruby.h +14 -0
  32. data/include/reflex/window.h +79 -0
  33. data/include/reflex.h +13 -0
  34. data/lib/reflex/application.rb +25 -0
  35. data/lib/reflex/autoinit.rb +11 -0
  36. data/lib/reflex/bounds.rb +133 -0
  37. data/lib/reflex/helpers.rb +52 -0
  38. data/lib/reflex/module.rb +30 -0
  39. data/lib/reflex/point.rb +69 -0
  40. data/lib/reflex/reflex.rb +21 -0
  41. data/lib/reflex/window.rb +65 -0
  42. data/lib/reflex.rb +11 -0
  43. data/reflex.gemspec +57 -0
  44. data/src/cocoa/application.mm +90 -0
  45. data/src/cocoa/applicationdata.h +51 -0
  46. data/src/cocoa/cocoaapplication.h +19 -0
  47. data/src/cocoa/cocoaapplication.mm +180 -0
  48. data/src/cocoa/cocoawindow.h +44 -0
  49. data/src/cocoa/cocoawindow.mm +171 -0
  50. data/src/cocoa/defs.h +34 -0
  51. data/src/cocoa/defs.mm +84 -0
  52. data/src/cocoa/openglview.h +17 -0
  53. data/src/cocoa/openglview.mm +186 -0
  54. data/src/cocoa/reflex.mm +68 -0
  55. data/src/cocoa/window.mm +118 -0
  56. data/src/cocoa/windowdata.h +51 -0
  57. data/src/defs.cpp +47 -0
  58. data/src/win32/defs.cpp +150 -0
  59. data/src/win32/opengl.cpp +95 -0
  60. data/src/win32/opengl.h +50 -0
  61. data/src/win32/reflex.cpp +65 -0
  62. data/src/win32/window.cpp +480 -0
  63. data/src/window.cpp +60 -0
  64. data/support.rb +56 -0
  65. data/task/ext.rake +42 -0
  66. data/task/gem.rake +33 -0
  67. data/task/git.rake +22 -0
  68. data/task/lib.rake +54 -0
  69. data/test/helpers.rb +15 -0
  70. data/test/test_bounds.rb +163 -0
  71. data/test/test_point.rb +81 -0
  72. data/test/test_reflex.rb +17 -0
  73. data/test/test_window.rb +39 -0
  74. metadata +173 -0
@@ -0,0 +1,128 @@
1
+ #include "reflex/ruby/key.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "reflex.h"
6
+
7
+
8
+ using namespace Rucy;
9
+
10
+
11
+ namespace Reflex
12
+ {
13
+
14
+
15
+ Class
16
+ key_class ()
17
+ {
18
+ static Class c = reflex_module().define_class("Key");
19
+ return c;
20
+ }
21
+
22
+
23
+ }// Reflex
24
+
25
+
26
+ namespace Rucy
27
+ {
28
+
29
+
30
+ Value
31
+ value (const Reflex::Key& key)
32
+ {
33
+ return new_type<Reflex::Key>(
34
+ Reflex::key_class(), new Reflex::Key(key));
35
+ }
36
+
37
+
38
+ }// Rucy
39
+
40
+
41
+ struct RubyKey : public Reflex::Key
42
+ {
43
+
44
+ operator bool () const
45
+ {
46
+ return true;
47
+ }
48
+
49
+ bool operator ! () const
50
+ {
51
+ return !operator bool();
52
+ }
53
+
54
+ };// RubyKey
55
+
56
+
57
+ #define this ((RubyKey*) to<Reflex::Key*>(self))
58
+
59
+ #define CHECK CHECK_OBJECT(self, RubyKey, Reflex::key_class())
60
+
61
+
62
+ static
63
+ RUBY_DEF_ALLOC(alloc, klass)
64
+ {
65
+ return new_type<RubyKey>(klass, new RubyKey);
66
+ }
67
+ RUBY_END
68
+
69
+ static
70
+ RUBY_DEFN(initialize)
71
+ {
72
+ CHECK_OBJ(self, RubyKey, Reflex::key_class());
73
+ if (argc < 0 || 4 < argc)
74
+ argument_error("Key#initialize", argc, 0, 1, 2);
75
+
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;
80
+
81
+ return self;
82
+ }
83
+ RUBY_END
84
+
85
+ static
86
+ RUBY_DEF0(chars)
87
+ {
88
+ CHECK;
89
+ return value(this->chars.c_str());
90
+ }
91
+ RUBY_END
92
+
93
+ static
94
+ RUBY_DEF0(code)
95
+ {
96
+ CHECK;
97
+ return value(this->code);
98
+ }
99
+ RUBY_END
100
+
101
+ static
102
+ RUBY_DEF0(repeat)
103
+ {
104
+ CHECK;
105
+ return value(this->repeat);
106
+ }
107
+ RUBY_END
108
+
109
+ static
110
+ RUBY_DEF0(modifiers)
111
+ {
112
+ CHECK;
113
+ return value(this->modifiers);
114
+ }
115
+ RUBY_END
116
+
117
+
118
+ void
119
+ Init_key ()
120
+ {
121
+ Reflex::key_class()
122
+ .define_alloc_func(alloc)
123
+ .define_method("initialize", initialize)
124
+ .define_method("chars", chars)
125
+ .define_method("code", code)
126
+ .define_method("repeat", repeat)
127
+ .define_method("modifiers", modifiers);
128
+ }
@@ -0,0 +1,22 @@
1
+ #include <rucy.h>
2
+
3
+
4
+ void Init_reflex ();
5
+ void Init_application ();
6
+ void Init_window ();
7
+ void Init_key ();
8
+ void Init_points ();
9
+
10
+
11
+ extern "C" void
12
+ Init_native ()
13
+ {
14
+ if (!Rucy::init())
15
+ Rucy::raise(rb_eLoadError, "Rucy::init() failed.");
16
+
17
+ Init_reflex();
18
+ Init_application();
19
+ Init_window();
20
+ Init_key();
21
+ Init_points();
22
+ }
@@ -0,0 +1,160 @@
1
+ #include "reflex/ruby/points.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "reflex.h"
6
+
7
+
8
+ using namespace Rucy;
9
+
10
+ using Reflex::coord;
11
+
12
+
13
+ namespace Reflex
14
+ {
15
+
16
+
17
+ Class
18
+ points_class ()
19
+ {
20
+ static Class c = reflex_module().define_class("Points");
21
+ return c;
22
+ }
23
+
24
+
25
+ }// Reflex
26
+
27
+
28
+ namespace Rucy
29
+ {
30
+
31
+
32
+ Value
33
+ value (const Reflex::Points& points)
34
+ {
35
+ return new_type<Reflex::Points>(
36
+ Reflex::points_class(), new Reflex::Points(points));
37
+ }
38
+
39
+
40
+ }// Rucy
41
+
42
+
43
+ struct RubyPoints : public Reflex::Points
44
+ {
45
+
46
+ operator bool () const
47
+ {
48
+ return true;
49
+ }
50
+
51
+ bool operator ! () const
52
+ {
53
+ return !operator bool();
54
+ }
55
+
56
+ };// RubyPoints
57
+
58
+
59
+ #define this ((RubyPoints*) to<Reflex::Points*>(self))
60
+
61
+ #define CHECK CHECK_OBJECT(self, RubyPoints, Reflex::points_class())
62
+
63
+
64
+ static
65
+ RUBY_DEF_ALLOC(alloc, klass)
66
+ {
67
+ return new_type<RubyPoints>(klass, new RubyPoints);
68
+ }
69
+ RUBY_END
70
+
71
+ static
72
+ RUBY_DEFN(initialize)
73
+ {
74
+ CHECK_OBJ(self, RubyPoints, Reflex::points_class());
75
+ if (argc < 0 || 6 < argc)
76
+ arg_count_error("Points#initialize", argc, 0, 1, 2, 3, 4, 5, 6);
77
+
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;
85
+
86
+ return self;
87
+ }
88
+ RUBY_END
89
+
90
+ static
91
+ RUBY_DEF0(type)
92
+ {
93
+ CHECK;
94
+ return value(this->type);
95
+ }
96
+ RUBY_END
97
+
98
+ static
99
+ RUBY_DEF0(x)
100
+ {
101
+ CHECK;
102
+ return value(this->x);
103
+ }
104
+ RUBY_END
105
+
106
+ static
107
+ RUBY_DEF0(y)
108
+ {
109
+ CHECK;
110
+ return value(this->y);
111
+ }
112
+ RUBY_END
113
+
114
+ static
115
+ RUBY_DEF0(size)
116
+ {
117
+ CHECK;
118
+ return value(this->size);
119
+ }
120
+ RUBY_END
121
+
122
+ static
123
+ RUBY_DEF0(modifiers)
124
+ {
125
+ CHECK;
126
+ return value(this->modifiers);
127
+ }
128
+ RUBY_END
129
+
130
+ static
131
+ RUBY_DEF0(count)
132
+ {
133
+ CHECK;
134
+ return value(this->count);
135
+ }
136
+ RUBY_END
137
+
138
+ static
139
+ RUBY_DEF0(drag)
140
+ {
141
+ CHECK;
142
+ return value(this->drag);
143
+ }
144
+ RUBY_END
145
+
146
+
147
+ void
148
+ Init_points ()
149
+ {
150
+ Reflex::points_class()
151
+ .define_alloc_func(alloc)
152
+ .define_method("initialize", initialize)
153
+ .define_method("type", type)
154
+ .define_method("x", x)
155
+ .define_method("y", y)
156
+ .define_method("size", size)
157
+ .define_method("modifiers", modifiers)
158
+ .define_method("count", count)
159
+ .define_method("drag", drag);
160
+ }
@@ -0,0 +1,83 @@
1
+ #include <rucy.h>
2
+ #include <reflex/reflex.h>
3
+ #include "reflex.h"
4
+
5
+
6
+ using namespace Rucy;
7
+
8
+
9
+ namespace Reflex
10
+ {
11
+
12
+
13
+ Module
14
+ reflex_module ()
15
+ {
16
+ static Module m = define_module("Reflex");
17
+ return m;
18
+ }
19
+
20
+ Class
21
+ reflex_error_class ()
22
+ {
23
+ static Class c =
24
+ reflex_module().define_class("ReflexError", native_error_class());
25
+ return c;
26
+ }
27
+
28
+
29
+ }// Reflex
30
+
31
+
32
+ static
33
+ RUBY_DEF0(init)
34
+ {
35
+ if (!Reflex::init())
36
+ error("Reflex::init() failed.");
37
+
38
+ return self;
39
+ }
40
+ RUBY_END
41
+
42
+ static
43
+ RUBY_DEF0(fin)
44
+ {
45
+ if (!Reflex::fin())
46
+ error("Reflex::fin() failed.");
47
+
48
+ return self;
49
+ }
50
+ RUBY_END
51
+
52
+ static
53
+ RUBY_DEF1(run, name)
54
+ {
55
+ if (!Reflex::run(name ? name.c_str() : NULL))
56
+ error("Reflex::run() failed.");
57
+
58
+ return self;
59
+ }
60
+ RUBY_END
61
+
62
+ static
63
+ RUBY_DEF0(quit)
64
+ {
65
+ if (!Reflex::quit())
66
+ error("Reflex::quit() failed.");
67
+
68
+ return self;
69
+ }
70
+ RUBY_END
71
+
72
+
73
+ void
74
+ Init_reflex ()
75
+ {
76
+ Reflex::reflex_error_class();
77
+
78
+ Reflex::reflex_module()
79
+ .define_singleton_method("init!", init)
80
+ .define_singleton_method("fin!", fin)
81
+ .define_singleton_method("run!", run)
82
+ .define_singleton_method("quit", quit);
83
+ }
@@ -0,0 +1,39 @@
1
+ // -*- c++ -*-
2
+ #pragma once
3
+ #ifndef __REFLEX_EXT_REFLEX_H__
4
+ #define __REFLEX_EXT_REFLEX_H__
5
+
6
+
7
+ #include <rucy/class.h>
8
+ #include "reflex/ruby/reflex.h"
9
+
10
+
11
+ namespace Reflex
12
+ {
13
+
14
+
15
+ Rucy::Class reflex_error_class ();
16
+ // class Reflex::ReflexError < Rucy::NativeError
17
+
18
+
19
+ }// Reflex
20
+
21
+
22
+ #define CHECK_OBJ(obj, type, klass) \
23
+ do \
24
+ { \
25
+ type* p = Rucy::get_type<type>(obj, klass); \
26
+ if (!p) Rucy::invalid_object_error(); \
27
+ } \
28
+ while(0)
29
+
30
+ #define CHECK_OBJECT(obj, type, klass) \
31
+ do \
32
+ { \
33
+ type* p = Rucy::get_type<type>(obj, klass); \
34
+ if (!p || !*p) Rucy::invalid_object_error(); \
35
+ } \
36
+ while(0)
37
+
38
+
39
+ #endif//EOH