wurlinc-rice 1.4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/COPYING +23 -0
  2. data/Doxyfile +1253 -0
  3. data/Makefile.am +26 -0
  4. data/README +1119 -0
  5. data/README.mingw +8 -0
  6. data/Rakefile +33 -0
  7. data/bootstrap +9 -0
  8. data/configure.ac +52 -0
  9. data/doxygen.ac +314 -0
  10. data/doxygen.am +186 -0
  11. data/extconf.rb +41 -0
  12. data/post-autoconf.rb +22 -0
  13. data/post-automake.rb +28 -0
  14. data/rice/Address_Registration_Guard.hpp +7 -0
  15. data/rice/Address_Registration_Guard.ipp +34 -0
  16. data/rice/Address_Registration_Guard_defn.hpp +65 -0
  17. data/rice/Allocation_Strategies.hpp +37 -0
  18. data/rice/Arg.hpp +8 -0
  19. data/rice/Arg_impl.hpp +127 -0
  20. data/rice/Arg_operators.cpp +21 -0
  21. data/rice/Arg_operators.hpp +19 -0
  22. data/rice/Array.hpp +220 -0
  23. data/rice/Array.ipp +263 -0
  24. data/rice/Builtin_Object.hpp +8 -0
  25. data/rice/Builtin_Object.ipp +50 -0
  26. data/rice/Builtin_Object_defn.hpp +51 -0
  27. data/rice/Class.cpp +57 -0
  28. data/rice/Class.hpp +8 -0
  29. data/rice/Class.ipp +6 -0
  30. data/rice/Class_defn.hpp +83 -0
  31. data/rice/Constructor.hpp +367 -0
  32. data/rice/Critical_Guard.hpp +40 -0
  33. data/rice/Critical_Guard.ipp +26 -0
  34. data/rice/Data_Object.hpp +8 -0
  35. data/rice/Data_Object.ipp +133 -0
  36. data/rice/Data_Object_defn.hpp +132 -0
  37. data/rice/Data_Type.cpp +54 -0
  38. data/rice/Data_Type.hpp +8 -0
  39. data/rice/Data_Type.ipp +365 -0
  40. data/rice/Data_Type_defn.hpp +261 -0
  41. data/rice/Data_Type_fwd.hpp +12 -0
  42. data/rice/Director.cpp +13 -0
  43. data/rice/Director.hpp +39 -0
  44. data/rice/Enum.hpp +117 -0
  45. data/rice/Enum.ipp +246 -0
  46. data/rice/Exception.cpp +59 -0
  47. data/rice/Exception.hpp +9 -0
  48. data/rice/Exception_Base.hpp +8 -0
  49. data/rice/Exception_Base.ipp +13 -0
  50. data/rice/Exception_Base_defn.hpp +27 -0
  51. data/rice/Exception_defn.hpp +69 -0
  52. data/rice/Hash.hpp +210 -0
  53. data/rice/Hash.ipp +338 -0
  54. data/rice/Identifier.cpp +8 -0
  55. data/rice/Identifier.hpp +50 -0
  56. data/rice/Identifier.ipp +33 -0
  57. data/rice/Jump_Tag.hpp +24 -0
  58. data/rice/Makefile.am +129 -0
  59. data/rice/Module.cpp +84 -0
  60. data/rice/Module.hpp +8 -0
  61. data/rice/Module.ipp +6 -0
  62. data/rice/Module_defn.hpp +88 -0
  63. data/rice/Module_impl.hpp +281 -0
  64. data/rice/Module_impl.ipp +348 -0
  65. data/rice/Object.cpp +160 -0
  66. data/rice/Object.hpp +8 -0
  67. data/rice/Object.ipp +19 -0
  68. data/rice/Object_defn.hpp +191 -0
  69. data/rice/Require_Guard.hpp +21 -0
  70. data/rice/String.cpp +94 -0
  71. data/rice/String.hpp +89 -0
  72. data/rice/Struct.cpp +117 -0
  73. data/rice/Struct.hpp +162 -0
  74. data/rice/Struct.ipp +26 -0
  75. data/rice/Symbol.cpp +25 -0
  76. data/rice/Symbol.hpp +66 -0
  77. data/rice/Symbol.ipp +44 -0
  78. data/rice/VM.cpp +92 -0
  79. data/rice/VM.hpp +32 -0
  80. data/rice/config.hpp.in +40 -0
  81. data/rice/detail/Arguments.hpp +118 -0
  82. data/rice/detail/Auto_Function_Wrapper.hpp +829 -0
  83. data/rice/detail/Auto_Function_Wrapper.ipp +3391 -0
  84. data/rice/detail/Auto_Member_Function_Wrapper.hpp +828 -0
  85. data/rice/detail/Auto_Member_Function_Wrapper.ipp +2503 -0
  86. data/rice/detail/Caster.hpp +103 -0
  87. data/rice/detail/Exception_Handler.hpp +8 -0
  88. data/rice/detail/Exception_Handler.ipp +68 -0
  89. data/rice/detail/Exception_Handler_defn.hpp +96 -0
  90. data/rice/detail/Iterator.hpp +93 -0
  91. data/rice/detail/Not_Copyable.hpp +25 -0
  92. data/rice/detail/Wrapped_Function.hpp +33 -0
  93. data/rice/detail/cfp.hpp +24 -0
  94. data/rice/detail/cfp.ipp +51 -0
  95. data/rice/detail/check_ruby_type.cpp +27 -0
  96. data/rice/detail/check_ruby_type.hpp +23 -0
  97. data/rice/detail/creation_funcs.hpp +37 -0
  98. data/rice/detail/creation_funcs.ipp +36 -0
  99. data/rice/detail/default_allocation_func.hpp +23 -0
  100. data/rice/detail/default_allocation_func.ipp +11 -0
  101. data/rice/detail/define_method_and_auto_wrap.hpp +31 -0
  102. data/rice/detail/define_method_and_auto_wrap.ipp +30 -0
  103. data/rice/detail/demangle.cpp +56 -0
  104. data/rice/detail/demangle.hpp +19 -0
  105. data/rice/detail/env.hpp +19 -0
  106. data/rice/detail/from_ruby.hpp +43 -0
  107. data/rice/detail/from_ruby.ipp +60 -0
  108. data/rice/detail/method_data.cpp +159 -0
  109. data/rice/detail/method_data.hpp +21 -0
  110. data/rice/detail/mininode.cpp +1220 -0
  111. data/rice/detail/mininode.hpp +320 -0
  112. data/rice/detail/node.hpp +13 -0
  113. data/rice/detail/object_call.hpp +68 -0
  114. data/rice/detail/object_call.ipp +131 -0
  115. data/rice/detail/protect.cpp +29 -0
  116. data/rice/detail/protect.hpp +34 -0
  117. data/rice/detail/ruby.hpp +93 -0
  118. data/rice/detail/ruby_version_code.hpp.in +6 -0
  119. data/rice/detail/rubysig.hpp +19 -0
  120. data/rice/detail/st.hpp +60 -0
  121. data/rice/detail/to_ruby.hpp +22 -0
  122. data/rice/detail/to_ruby.ipp +36 -0
  123. data/rice/detail/traits.hpp +43 -0
  124. data/rice/detail/win32.hpp +16 -0
  125. data/rice/detail/wrap_function.hpp +341 -0
  126. data/rice/detail/wrap_function.ipp +514 -0
  127. data/rice/global_function.hpp +33 -0
  128. data/rice/global_function.ipp +22 -0
  129. data/rice/protect.hpp +91 -0
  130. data/rice/protect.ipp +1133 -0
  131. data/rice/ruby_mark.hpp +13 -0
  132. data/rice/ruby_try_catch.hpp +86 -0
  133. data/rice/rubypp.rb +97 -0
  134. data/rice/to_from_ruby.hpp +8 -0
  135. data/rice/to_from_ruby.ipp +297 -0
  136. data/rice/to_from_ruby_defn.hpp +71 -0
  137. data/ruby/Makefile.am +1 -0
  138. data/ruby/lib/Makefile.am +3 -0
  139. data/ruby/lib/mkmf-rice.rb.in +216 -0
  140. data/ruby/lib/version.rb +3 -0
  141. data/ruby.ac +136 -0
  142. data/sample/Makefile.am +47 -0
  143. data/sample/enum/extconf.rb +3 -0
  144. data/sample/enum/sample_enum.cpp +54 -0
  145. data/sample/enum/test.rb +8 -0
  146. data/sample/inheritance/animals.cpp +98 -0
  147. data/sample/inheritance/extconf.rb +3 -0
  148. data/sample/inheritance/test.rb +7 -0
  149. data/sample/map/extconf.rb +3 -0
  150. data/sample/map/map.cpp +81 -0
  151. data/sample/map/test.rb +7 -0
  152. data/test/Makefile.am +78 -0
  153. data/test/ext/Makefile.am +43 -0
  154. data/test/ext/t1/Foo.hpp +10 -0
  155. data/test/ext/t1/extconf.rb +2 -0
  156. data/test/ext/t1/t1.cpp +15 -0
  157. data/test/ext/t2/extconf.rb +2 -0
  158. data/test/ext/t2/t2.cpp +11 -0
  159. data/test/test_Address_Registration_Guard.cpp +43 -0
  160. data/test/test_Allocation_Strategies.cpp +77 -0
  161. data/test/test_Array.cpp +241 -0
  162. data/test/test_Builtin_Object.cpp +72 -0
  163. data/test/test_Class.cpp +498 -0
  164. data/test/test_Constructor.cpp +128 -0
  165. data/test/test_Critical_Guard.cpp +51 -0
  166. data/test/test_Data_Object.cpp +275 -0
  167. data/test/test_Data_Type.cpp +348 -0
  168. data/test/test_Director.cpp +301 -0
  169. data/test/test_Enum.cpp +195 -0
  170. data/test/test_Exception.cpp +46 -0
  171. data/test/test_Hash.cpp +195 -0
  172. data/test/test_Identifier.cpp +70 -0
  173. data/test/test_Jump_Tag.cpp +17 -0
  174. data/test/test_Memory_Management.cpp +50 -0
  175. data/test/test_Module.cpp +481 -0
  176. data/test/test_Object.cpp +148 -0
  177. data/test/test_String.cpp +94 -0
  178. data/test/test_Struct.cpp +192 -0
  179. data/test/test_Symbol.cpp +63 -0
  180. data/test/test_To_From_Ruby.cpp +263 -0
  181. data/test/test_VM.cpp +26 -0
  182. data/test/test_global_functions.cpp +114 -0
  183. data/test/test_rice.rb +43 -0
  184. data/test/unittest.cpp +136 -0
  185. data/test/unittest.hpp +292 -0
  186. metadata +276 -0
@@ -0,0 +1,195 @@
1
+ #include "unittest.hpp"
2
+ #include "rice/Hash.hpp"
3
+ #include <vector>
4
+ #include <map>
5
+ #include <algorithm>
6
+
7
+ using namespace Rice;
8
+
9
+ TESTSUITE(Hash);
10
+
11
+ SETUP(Hash)
12
+ {
13
+ ruby_init();
14
+ }
15
+
16
+ TESTCASE(default_construct)
17
+ {
18
+ Hash h;
19
+ ASSERT_EQUAL(T_HASH, rb_type(h));
20
+ ASSERT_EQUAL(0, RHASH_TBL(h.value())->num_entries);
21
+ }
22
+
23
+ TESTCASE(construct_from_object)
24
+ {
25
+ Object o(rb_hash_new());
26
+ Hash h(o);
27
+ ASSERT_EQUAL(T_HASH, rb_type(h));
28
+ ASSERT_EQUAL(0, RHASH_TBL(h.value())->num_entries);
29
+ }
30
+
31
+ TESTCASE(construct_from_value)
32
+ {
33
+ VALUE v(rb_hash_new());
34
+ Hash h(v);
35
+ ASSERT_EQUAL(T_HASH, rb_type(h));
36
+ ASSERT_EQUAL(0, RHASH_TBL(h.value())->num_entries);
37
+ }
38
+
39
+ TESTCASE(copy_construct)
40
+ {
41
+ Hash h;
42
+ Hash h2(h);
43
+ ASSERT_EQUAL(h.value(), h2.value());
44
+ }
45
+
46
+ TESTCASE(assignment)
47
+ {
48
+ Hash h;
49
+ Hash h2;
50
+ h = h2;
51
+ }
52
+
53
+ TESTCASE(size)
54
+ {
55
+ Hash h;
56
+ ASSERT_EQUAL(0u, h.size());
57
+ h[1] = 5;
58
+ ASSERT_EQUAL(1u, h.size());
59
+ h[6] = 9;
60
+ ASSERT_EQUAL(2u, h.size());
61
+ h[42] = 42;
62
+ ASSERT_EQUAL(3u, h.size());
63
+ h[6] = 1;
64
+ ASSERT_EQUAL(3u, h.size());
65
+ }
66
+
67
+ TESTCASE(bracket)
68
+ {
69
+ Hash h;
70
+ h[1] = 5;
71
+ h[6] = 9;
72
+ h[42] = 42;
73
+ h[6] = 1;
74
+ ASSERT_EQUAL(to_ruby(5), Object(h[1]));
75
+ ASSERT_EQUAL(to_ruby(42), Object(h[42]));
76
+ ASSERT_EQUAL(to_ruby(1), Object(h[6]));
77
+ }
78
+
79
+ TESTCASE(get)
80
+ {
81
+ Hash h;
82
+ h[1] = 5;
83
+ h[6] = 9;
84
+ h[42] = 42;
85
+ h[6] = 1;
86
+ ASSERT_EQUAL(5, h.get<int>(1));
87
+ ASSERT_EQUAL(42, h.get<int>(42));
88
+ ASSERT_EQUAL(1, h.get<int>(6));
89
+ }
90
+
91
+ TESTCASE(construct_vector_from_hash_iterators)
92
+ {
93
+ Hash h;
94
+ h[1] = 5;
95
+ h[6] = 9;
96
+ h[42] = 42;
97
+ h[6] = 1;
98
+ std::vector<Hash::Entry> v(h.begin(), h.end());
99
+ std::sort(v.begin(), v.end());
100
+ ASSERT_EQUAL(3u, v.size());
101
+ ASSERT_EQUAL(v[0].key, to_ruby(1));
102
+ ASSERT_EQUAL(v[1].key, to_ruby(6));
103
+ ASSERT_EQUAL(v[2].key, to_ruby(42));
104
+ ASSERT_EQUAL(&v[0].key, &v[0].first);
105
+ ASSERT_EQUAL(&v[1].key, &v[1].first);
106
+ ASSERT_EQUAL(&v[2].key, &v[2].first);
107
+ ASSERT_EQUAL(v[0].value, to_ruby(5));
108
+ ASSERT_EQUAL(v[1].value, to_ruby(1));
109
+ ASSERT_EQUAL(v[2].value, to_ruby(42));
110
+ ASSERT_EQUAL(&v[0].value, &v[0].second);
111
+ ASSERT_EQUAL(&v[1].value, &v[1].second);
112
+ ASSERT_EQUAL(&v[2].value, &v[2].second);
113
+ }
114
+
115
+ TESTCASE(iterate)
116
+ {
117
+ Hash h;
118
+ h[1] = 5;
119
+ h[6] = 9;
120
+ h[42] = 42;
121
+ h[6] = 1;
122
+ std::vector<Hash::Entry> v;
123
+ Hash::iterator it = h.begin();
124
+ Hash::iterator end = h.end();
125
+ for(; it != end; ++it)
126
+ {
127
+ v.push_back(*it);
128
+ }
129
+ std::sort(v.begin(), v.end());
130
+ ASSERT_EQUAL(3u, v.size());
131
+ ASSERT_EQUAL(v[0].key, to_ruby(1));
132
+ ASSERT_EQUAL(v[1].key, to_ruby(6));
133
+ ASSERT_EQUAL(v[2].key, to_ruby(42));
134
+ ASSERT_EQUAL(&v[0].key, &v[0].first);
135
+ ASSERT_EQUAL(&v[1].key, &v[1].first);
136
+ ASSERT_EQUAL(&v[2].key, &v[2].first);
137
+ ASSERT_EQUAL(v[0].value, to_ruby(5));
138
+ ASSERT_EQUAL(v[1].value, to_ruby(1));
139
+ ASSERT_EQUAL(v[2].value, to_ruby(42));
140
+ ASSERT_EQUAL(&v[0].value, &v[0].second);
141
+ ASSERT_EQUAL(&v[1].value, &v[1].second);
142
+ ASSERT_EQUAL(&v[2].value, &v[2].second);
143
+ }
144
+
145
+ TESTCASE(const_iterate)
146
+ {
147
+ Hash h;
148
+ h[1] = 5;
149
+ h[6] = 9;
150
+ h[42] = 42;
151
+ h[6] = 1;
152
+ std::vector<Hash::Entry> v;
153
+ Hash::const_iterator it = h.begin();
154
+ Hash::const_iterator end = h.end();
155
+ for(; it != end; ++it)
156
+ {
157
+ v.push_back(*it);
158
+ }
159
+ std::sort(v.begin(), v.end());
160
+ ASSERT_EQUAL(3u, v.size());
161
+ ASSERT_EQUAL(v[0].key, to_ruby(1));
162
+ ASSERT_EQUAL(v[1].key, to_ruby(6));
163
+ ASSERT_EQUAL(v[2].key, to_ruby(42));
164
+ ASSERT_EQUAL(&v[0].key, &v[0].first);
165
+ ASSERT_EQUAL(&v[1].key, &v[1].first);
166
+ ASSERT_EQUAL(&v[2].key, &v[2].first);
167
+ ASSERT_EQUAL(v[0].value, to_ruby(5));
168
+ ASSERT_EQUAL(v[1].value, to_ruby(1));
169
+ ASSERT_EQUAL(v[2].value, to_ruby(42));
170
+ ASSERT_EQUAL(&v[0].value, &v[0].value);
171
+ ASSERT_EQUAL(&v[1].value, &v[1].value);
172
+ ASSERT_EQUAL(&v[2].value, &v[2].value);
173
+ }
174
+
175
+ TESTCASE(iterate_and_change)
176
+ {
177
+ Hash h;
178
+ h[1] = 5;
179
+ h[6] = 9;
180
+ h[42] = 42;
181
+ h[6] = 1;
182
+ Hash::const_iterator it = h.begin();
183
+ Hash::const_iterator end = h.end();
184
+ std::map<int, int> m;
185
+ for(int j = 0; it != end; ++j, ++it)
186
+ {
187
+ it->second = j;
188
+ m[from_ruby<int>(it->first)] = j;
189
+ }
190
+ ASSERT_EQUAL(3u, m.size());
191
+ ASSERT_EQUAL(to_ruby(m[1]), h[1]);
192
+ ASSERT_EQUAL(to_ruby(m[6]), h[6]);
193
+ ASSERT_EQUAL(to_ruby(m[42]), h[42]);
194
+ }
195
+
@@ -0,0 +1,70 @@
1
+ #include "unittest.hpp"
2
+ #include "rice/Identifier.hpp"
3
+ #include "rice/Symbol.hpp"
4
+
5
+ using namespace Rice;
6
+
7
+ TESTSUITE(Identifier);
8
+
9
+ SETUP(Identifier)
10
+ {
11
+ ruby_init();
12
+ }
13
+
14
+ TESTCASE(construct_from_id)
15
+ {
16
+ ID id = rb_intern("foo");
17
+ Identifier identifier(id);
18
+ ASSERT_EQUAL(id, identifier.id());
19
+ }
20
+
21
+ TESTCASE(construct_from_symbol)
22
+ {
23
+ Symbol symbol("FOO");
24
+ Identifier identifier(symbol);
25
+ ASSERT_EQUAL(rb_intern("FOO"), identifier.id());
26
+ }
27
+
28
+ TESTCASE(construct_from_c_string)
29
+ {
30
+ Identifier identifier("Foo");
31
+ ASSERT_EQUAL(rb_intern("Foo"), identifier.id());
32
+ }
33
+
34
+ TESTCASE(default_construct)
35
+ {
36
+ Identifier identifier;
37
+ ASSERT_EQUAL(rb_intern(""), identifier.id());
38
+ }
39
+
40
+ TESTCASE(copy_construct)
41
+ {
42
+ Identifier identifier1("Foo");
43
+ Identifier identifier2(identifier1);
44
+ ASSERT_EQUAL(rb_intern("Foo"), identifier2.id());
45
+ }
46
+
47
+ TESTCASE(c_str)
48
+ {
49
+ Identifier identifier("Foo");
50
+ ASSERT_EQUAL("Foo", identifier.c_str());
51
+ }
52
+
53
+ TESTCASE(str)
54
+ {
55
+ Identifier identifier("Foo");
56
+ ASSERT_EQUAL(std::string("Foo"), identifier.str());
57
+ }
58
+
59
+ TESTCASE(implicit_conversion_to_id)
60
+ {
61
+ Identifier identifier("Foo");
62
+ ASSERT_EQUAL(rb_intern("Foo"), static_cast<ID>(identifier));
63
+ }
64
+
65
+ TESTCASE(to_sym)
66
+ {
67
+ Identifier identifier("Foo");
68
+ ASSERT_EQUAL(Symbol("Foo"), Symbol(identifier.to_sym()));
69
+ }
70
+
@@ -0,0 +1,17 @@
1
+ #include "unittest.hpp"
2
+ #include "rice/Jump_Tag.hpp"
3
+
4
+ using namespace Rice;
5
+
6
+ TESTSUITE(Jump_Tag);
7
+
8
+ SETUP(Jump_Tag)
9
+ {
10
+ }
11
+
12
+ TESTCASE(construct)
13
+ {
14
+ Jump_Tag jump_tag(42);
15
+ ASSERT_EQUAL(42, jump_tag.tag);
16
+ }
17
+
@@ -0,0 +1,50 @@
1
+ #include "unittest.hpp"
2
+ #include "rice/String.hpp"
3
+ #include "rice/Class.hpp"
4
+ #include "rice/global_function.hpp"
5
+
6
+ using namespace Rice;
7
+
8
+ TESTSUITE(Memory_Management);
9
+
10
+ SETUP(Memory_Management)
11
+ {
12
+ ruby_init();
13
+ }
14
+
15
+ namespace
16
+ {
17
+ class TestClass {
18
+ double tmp;
19
+ public:
20
+ TestClass() {tmp=0;}
21
+
22
+ double getTmp() {
23
+ return tmp;
24
+ }
25
+
26
+ void setTmp(double x) {
27
+ tmp = x;
28
+ }
29
+ };
30
+
31
+ TestClass returnTestClass() {
32
+ TestClass x = TestClass();
33
+ x.setTmp(8);
34
+ return x;
35
+ }
36
+ }
37
+
38
+ TESTCASE(allows_copy_contructors_to_work)
39
+ {
40
+ define_class<TestClass>("TestClass")
41
+ .define_method("tmp=", &TestClass::setTmp)
42
+ .define_method("tmp", &TestClass::getTmp);
43
+
44
+ define_global_function("return_test_class", &returnTestClass);
45
+
46
+ Module m = define_module("TestingModule");
47
+
48
+ Object result = m.instance_eval("return_test_class.tmp");
49
+ ASSERT_EQUAL(8.0, from_ruby<double>(result.value()));
50
+ }