autoc 1.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +3 -0
- data/README.md +149 -0
- data/cmake/AutoC.cmake +39 -0
- data/lib/autoc/allocators.rb +51 -0
- data/lib/autoc/association.rb +126 -0
- data/lib/autoc/box.rb +311 -0
- data/lib/autoc/cmake.rb +54 -0
- data/lib/autoc/collection.rb +83 -110
- data/lib/autoc/composite.rb +333 -0
- data/lib/autoc/cstring.rb +263 -0
- data/lib/autoc/function.rb +247 -0
- data/lib/autoc/hash_map.rb +328 -0
- data/lib/autoc/hash_set.rb +339 -0
- data/lib/autoc/hashers.rb +102 -0
- data/lib/autoc/list.rb +444 -0
- data/lib/autoc/module.rb +434 -0
- data/lib/autoc/openmp.rb +15 -0
- data/lib/autoc/primitive.rb +27 -0
- data/lib/autoc/ranges.rb +707 -0
- data/lib/autoc/record.rb +247 -0
- data/lib/autoc/scaffold/docs.rb +117 -0
- data/lib/autoc/scaffold/generic_value.rb +86 -0
- data/lib/autoc/scaffold/project.rb +75 -0
- data/lib/autoc/scaffold/test_cstring.rb +113 -0
- data/lib/autoc/scaffold/test_cstring_hash_set.rb +35 -0
- data/lib/autoc/scaffold/test_int_box.rb +22 -0
- data/lib/autoc/scaffold/test_int_hash_set.rb +448 -0
- data/lib/autoc/scaffold/test_int_list.rb +106 -0
- data/lib/autoc/scaffold/test_int_vector.rb +83 -0
- data/lib/autoc/scaffold/test_v2v_hash_map.rb +83 -0
- data/lib/autoc/scaffold/test_value_hash_set.rb +60 -0
- data/lib/autoc/scaffold/test_value_vector.rb +146 -0
- data/{test/test.rb → lib/autoc/scaffold/tests.rb} +179 -158
- data/lib/autoc/scaffold.rb +12 -0
- data/lib/autoc/sequential.rb +99 -0
- data/lib/autoc/set.rb +331 -0
- data/lib/autoc/std.rb +149 -0
- data/lib/autoc/type.rb +93 -531
- data/lib/autoc/vector.rb +290 -0
- data/lib/autoc.rb +4 -35
- metadata +55 -85
- data/.yardopts +0 -4
- data/CHANGES +0 -23
- data/README +0 -28
- data/doc/AutoC/Code.html +0 -523
- data/doc/AutoC/Collection.html +0 -1214
- data/doc/AutoC/HashMap.html +0 -1441
- data/doc/AutoC/HashSet.html +0 -916
- data/doc/AutoC/Iterators/Bidirectional.html +0 -204
- data/doc/AutoC/Iterators/Unidirectional.html +0 -200
- data/doc/AutoC/Iterators.html +0 -126
- data/doc/AutoC/List.html +0 -1039
- data/doc/AutoC/Maps.html +0 -290
- data/doc/AutoC/Module/File.html +0 -415
- data/doc/AutoC/Module/Header.html +0 -437
- data/doc/AutoC/Module/Source.html +0 -707
- data/doc/AutoC/Module.html +0 -948
- data/doc/AutoC/Priority.html +0 -138
- data/doc/AutoC/Queue.html +0 -1172
- data/doc/AutoC/Reference.html +0 -735
- data/doc/AutoC/Sets.html +0 -520
- data/doc/AutoC/String.html +0 -1394
- data/doc/AutoC/TreeMap.html +0 -1565
- data/doc/AutoC/TreeSet.html +0 -1447
- data/doc/AutoC/Type.html +0 -2148
- data/doc/AutoC/UserDefinedType.html +0 -1047
- data/doc/AutoC/Vector.html +0 -987
- data/doc/AutoC.html +0 -331
- data/doc/_index.html +0 -388
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -481
- data/doc/file.CHANGES.html +0 -117
- data/doc/file.README.html +0 -116
- data/doc/file_list.html +0 -61
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -116
- data/doc/js/app.js +0 -243
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -1307
- data/doc/top-level-namespace.html +0 -112
- data/lib/autoc/code.rb +0 -237
- data/lib/autoc/collection/hash_map.rb +0 -385
- data/lib/autoc/collection/hash_set.rb +0 -337
- data/lib/autoc/collection/iterator.rb +0 -39
- data/lib/autoc/collection/list.rb +0 -429
- data/lib/autoc/collection/map.rb +0 -41
- data/lib/autoc/collection/queue.rb +0 -517
- data/lib/autoc/collection/set.rb +0 -134
- data/lib/autoc/collection/tree_map.rb +0 -464
- data/lib/autoc/collection/tree_set.rb +0 -611
- data/lib/autoc/collection/vector.rb +0 -336
- data/lib/autoc/string.rb +0 -492
- data/test/test_auto.c +0 -7141
- data/test/test_auto.h +0 -753
- data/test/test_char_string.rb +0 -270
- data/test/test_int_list.rb +0 -35
- data/test/test_int_tree_set.rb +0 -111
- data/test/test_int_vector.rb +0 -34
- data/test/test_value_hash_map.rb +0 -162
- data/test/test_value_hash_set.rb +0 -173
- data/test/test_value_list.rb +0 -193
- data/test/test_value_queue.rb +0 -275
- data/test/test_value_tree_map.rb +0 -176
- data/test/test_value_tree_set.rb +0 -173
- data/test/test_value_vector.rb +0 -155
- data/test/value.rb +0 -80
data/test/test_value_tree_map.rb
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
require "value"
|
2
|
-
|
3
|
-
type_test(AutoC::TreeMap, :ValueTreeMap, Value, Value) do
|
4
|
-
|
5
|
-
def write_defs(stream)
|
6
|
-
stream << %~
|
7
|
-
#undef PUT
|
8
|
-
#define PUT(t, k, v) {#{key.type} ek; #{value.type} ev; #{key.ctorEx}(ek, k); #{value.ctorEx}(ev, v); #{put}(t, ek, ev); #{key.dtor}(ek); #{value.dtor}(ev);}
|
9
|
-
~
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
setup %~#{type} t;~
|
14
|
-
cleanup %~#{dtor}(&t);~
|
15
|
-
|
16
|
-
test :create, %~
|
17
|
-
#{ctor}(&t);
|
18
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
19
|
-
TEST_TRUE( #{empty}(&t) );
|
20
|
-
~
|
21
|
-
|
22
|
-
test :purge, %~
|
23
|
-
#{ctor}(&t);
|
24
|
-
PUT(&t, 0, 0);
|
25
|
-
TEST_FALSE( #{empty}(&t) );
|
26
|
-
#{purge}(&t);
|
27
|
-
TEST_TRUE( #{empty}(&t) );
|
28
|
-
~
|
29
|
-
|
30
|
-
test :empty, %~
|
31
|
-
#{ctor}(&t);
|
32
|
-
TEST_TRUE( #{empty}(&t) );
|
33
|
-
PUT(&t, 1, -1);
|
34
|
-
TEST_FALSE( #{empty}(&t) );
|
35
|
-
~
|
36
|
-
|
37
|
-
test :size, %~
|
38
|
-
#{ctor}(&t);
|
39
|
-
TEST_TRUE( #{empty}(&t) );
|
40
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
41
|
-
PUT(&t, 1, -1);
|
42
|
-
TEST_FALSE( #{empty}(&t) );
|
43
|
-
TEST_EQUAL( #{size}(&t), 1 );
|
44
|
-
~
|
45
|
-
|
46
|
-
setup %~
|
47
|
-
/* {i => -i} */
|
48
|
-
int i, c = 3;
|
49
|
-
#{type} t;
|
50
|
-
#{key.type} k;
|
51
|
-
#{element.type} v;
|
52
|
-
#{ctor}(&t);
|
53
|
-
for(i = 1; i <= c; i++) {
|
54
|
-
PUT(&t, i, -i);
|
55
|
-
}
|
56
|
-
~
|
57
|
-
cleanup %~
|
58
|
-
#{dtor}(&t);
|
59
|
-
~
|
60
|
-
|
61
|
-
test :copy, %~
|
62
|
-
#{type} t2;
|
63
|
-
#{copy}(&t2, &t);
|
64
|
-
TEST_TRUE( #{equal}(&t2, &t) );
|
65
|
-
#{dtor}(&t2);
|
66
|
-
~
|
67
|
-
|
68
|
-
test :equal, %~
|
69
|
-
#{type} t2;
|
70
|
-
#{copy}(&t2, &t);
|
71
|
-
TEST_TRUE( #{equal}(&t2, &t) );
|
72
|
-
PUT(&t2, -1, 1);
|
73
|
-
TEST_FALSE( #{equal}(&t2, &t) );
|
74
|
-
#{dtor}(&t2);
|
75
|
-
~
|
76
|
-
|
77
|
-
test :containsKey, %~
|
78
|
-
#{element.ctor(:k)};
|
79
|
-
#{element.set}(k, 0);
|
80
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
81
|
-
#{element.set}(k, 1);
|
82
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
83
|
-
#{element.dtor(:k)};
|
84
|
-
~
|
85
|
-
|
86
|
-
test :get, %~
|
87
|
-
#{element.ctor(:k)};
|
88
|
-
#{element.set}(k, 3);
|
89
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
90
|
-
v = #{get}(&t, k);
|
91
|
-
TEST_EQUAL( #{element.get}(v), -3 );
|
92
|
-
#{element.dtor(:v)};
|
93
|
-
#{element.dtor(:k)};
|
94
|
-
~
|
95
|
-
|
96
|
-
test :putNew, %~
|
97
|
-
#{element.ctor(:k)};
|
98
|
-
#{element.set}(k, 0);
|
99
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
100
|
-
TEST_TRUE( #{put}(&t, k, k) ) ;
|
101
|
-
#{element.dtor(:k)};
|
102
|
-
~
|
103
|
-
|
104
|
-
test :putExisting, %~
|
105
|
-
#{element.ctor(:k)};
|
106
|
-
#{element.set}(k, 1);
|
107
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
108
|
-
TEST_FALSE( #{put}(&t, k, k) ) ;
|
109
|
-
#{element.dtor(:k)};
|
110
|
-
~
|
111
|
-
|
112
|
-
test :remove, %~
|
113
|
-
#{element.ctor(:k)};
|
114
|
-
#{element.set}(k, 1);
|
115
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
116
|
-
TEST_TRUE( #{remove}(&t, k) ) ;
|
117
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
118
|
-
#{element.dtor(:k)};
|
119
|
-
~
|
120
|
-
|
121
|
-
test :removeNone, %~
|
122
|
-
#{element.ctor(:k)};
|
123
|
-
#{element.set}(k, 0);
|
124
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
125
|
-
TEST_FALSE( #{remove}(&t, k) ) ;
|
126
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
127
|
-
#{element.dtor(:k)};
|
128
|
-
~
|
129
|
-
|
130
|
-
test :replace, %~
|
131
|
-
#{element.ctor(:k)};
|
132
|
-
#{element.set}(k, 1);
|
133
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
134
|
-
TEST_TRUE( #{replace}(&t, k, k) ) ;
|
135
|
-
TEST_TRUE( #{containsKey}(&t, k) );
|
136
|
-
#{element.dtor(:k)};
|
137
|
-
~
|
138
|
-
|
139
|
-
test :replaceNone, %~
|
140
|
-
#{element.ctor(:k)};
|
141
|
-
#{element.set}(k, 0);
|
142
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
143
|
-
TEST_FALSE( #{replace}(&t, k, k) ) ;
|
144
|
-
TEST_FALSE( #{containsKey}(&t, k) );
|
145
|
-
#{element.dtor(:k)};
|
146
|
-
~
|
147
|
-
|
148
|
-
test :iterateAscending, %~
|
149
|
-
#{it} it;
|
150
|
-
#{itCtor}(&it, &t);
|
151
|
-
while(#{itMove}(&it)) {
|
152
|
-
#{key.type} k;
|
153
|
-
#{element.type} v;
|
154
|
-
k = #{itGetKey}(&it);
|
155
|
-
v = #{itGetElement}(&it);
|
156
|
-
TEST_EQUAL( #{key.get}(k), -#{value.get}(v) );
|
157
|
-
#{key.dtor}(k);
|
158
|
-
#{value.dtor}(v);
|
159
|
-
}
|
160
|
-
~
|
161
|
-
|
162
|
-
test :iterateDescending, %~
|
163
|
-
#{it} it;
|
164
|
-
#{itCtorEx}(&it, &t, 0);
|
165
|
-
while(#{itMove}(&it)) {
|
166
|
-
#{key.type} k;
|
167
|
-
#{element.type} v;
|
168
|
-
k = #{itGetKey}(&it);
|
169
|
-
v = #{itGetElement}(&it);
|
170
|
-
TEST_EQUAL( #{key.get}(k), -#{value.get}(v) );
|
171
|
-
#{key.dtor}(k);
|
172
|
-
#{value.dtor}(v);
|
173
|
-
}
|
174
|
-
~
|
175
|
-
|
176
|
-
end
|
data/test/test_value_tree_set.rb
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
require "value"
|
2
|
-
|
3
|
-
type_test(AutoC::TreeSet, :ValueTreeSet, Value) do
|
4
|
-
|
5
|
-
def write_defs(stream)
|
6
|
-
stream << %~
|
7
|
-
#undef PUT
|
8
|
-
#define PUT(t, v) {#{element.type} e; #{element.ctorEx}(e, v); #{put}(t, e); #{element.dtor}(e);}
|
9
|
-
~
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
setup %~#{type} t;~
|
14
|
-
cleanup %~#{dtor}(&t);~
|
15
|
-
|
16
|
-
test :create, %~
|
17
|
-
#{ctor}(&t);
|
18
|
-
TEST_EQUAL( #{size}(&t), 0 );
|
19
|
-
TEST_TRUE( #{empty}(&t) );
|
20
|
-
~
|
21
|
-
|
22
|
-
test :purge, %~
|
23
|
-
#{ctor}(&t);
|
24
|
-
PUT(&t, 0);
|
25
|
-
TEST_FALSE( #{empty}(&t) );
|
26
|
-
#{purge}(&t);
|
27
|
-
TEST_TRUE( #{empty}(&t) );
|
28
|
-
~
|
29
|
-
|
30
|
-
setup %~
|
31
|
-
/* a: [1,2,3], e: 0 */
|
32
|
-
#{type} a;
|
33
|
-
#{element.type} e;
|
34
|
-
#{element.ctor(:e)};
|
35
|
-
#{ctor}(&a);
|
36
|
-
PUT(&a, 1); PUT(&a, 2); PUT(&a, 3);
|
37
|
-
~
|
38
|
-
cleanup %~
|
39
|
-
#{dtor}(&a);
|
40
|
-
#{element.dtor(:e)};
|
41
|
-
~
|
42
|
-
|
43
|
-
test :contains, %~
|
44
|
-
TEST_FALSE( #{contains}(&a, e) );
|
45
|
-
#{element.set}(e, 1);
|
46
|
-
TEST_TRUE( #{contains}(&a, e) );
|
47
|
-
~
|
48
|
-
|
49
|
-
test :get, %~
|
50
|
-
#{element.type} e2;
|
51
|
-
#{element.set}(e, -1);
|
52
|
-
#{put}(&a, e);
|
53
|
-
e2 = #{get}(&a, e);
|
54
|
-
TEST_TRUE( #{element.equal}(e, e2) );
|
55
|
-
#{element.dtor(:e2)};
|
56
|
-
~
|
57
|
-
|
58
|
-
test :putNew, %~
|
59
|
-
#{element.set}(e, -1);
|
60
|
-
TEST_FALSE( #{contains}(&a, e) );
|
61
|
-
TEST_TRUE( #{put}(&a, e) );
|
62
|
-
TEST_TRUE( #{contains}(&a, e) );
|
63
|
-
~
|
64
|
-
|
65
|
-
test :putExisting, %~
|
66
|
-
#{element.set}(e, -1);
|
67
|
-
TEST_FALSE( #{contains}(&a, e) );
|
68
|
-
TEST_TRUE( #{put}(&a, e) );
|
69
|
-
TEST_TRUE( #{contains}(&a, e) );
|
70
|
-
TEST_FALSE( #{put}(&a, e) );
|
71
|
-
~
|
72
|
-
|
73
|
-
test :replace, %~
|
74
|
-
#{element.set}(e, 1);
|
75
|
-
TEST_TRUE( #{contains}(&a, e) );
|
76
|
-
TEST_TRUE( #{replace}(&a, e) );
|
77
|
-
TEST_TRUE( #{contains}(&a, e) );
|
78
|
-
~
|
79
|
-
|
80
|
-
test :replaceNone, %~
|
81
|
-
#{element.set}(e, -1);
|
82
|
-
TEST_FALSE( #{contains}(&a, e) );
|
83
|
-
TEST_FALSE( #{replace}(&a, e) );
|
84
|
-
TEST_FALSE( #{contains}(&a, e) );
|
85
|
-
~
|
86
|
-
|
87
|
-
test :remove, %~
|
88
|
-
#{element.set}(e, 1);
|
89
|
-
TEST_TRUE( #{contains}(&a, e) );
|
90
|
-
TEST_TRUE( #{remove}(&a, e) );
|
91
|
-
TEST_FALSE( #{contains}(&a, e) );
|
92
|
-
~
|
93
|
-
|
94
|
-
test :removeNone, %~
|
95
|
-
#{element.set}(e, -1);
|
96
|
-
TEST_FALSE( #{contains}(&a, e) );
|
97
|
-
TEST_FALSE( #{remove}(&a, e) );
|
98
|
-
~
|
99
|
-
|
100
|
-
test :iterate, %~
|
101
|
-
#{it} it;
|
102
|
-
size_t i = 0;
|
103
|
-
#{itCtor}(&it, &a);
|
104
|
-
while(#{itMove}(&it)) {
|
105
|
-
#{element.type} e2 = #{itGet}(&it);
|
106
|
-
#{element.dtor(:e2)};
|
107
|
-
i++;
|
108
|
-
}
|
109
|
-
TEST_EQUAL( #{size}(&a), i );
|
110
|
-
~
|
111
|
-
|
112
|
-
setup %~
|
113
|
-
/* a: [1,2,3] */
|
114
|
-
#{type} a, b;
|
115
|
-
#{ctor}(&a);
|
116
|
-
PUT(&a, 1); PUT(&a, 2); PUT(&a, 3);
|
117
|
-
~
|
118
|
-
cleanup %~
|
119
|
-
#{dtor}(&a);
|
120
|
-
#{dtor}(&b);
|
121
|
-
~
|
122
|
-
|
123
|
-
test :copy, %~
|
124
|
-
#{copy}(&b, &a);
|
125
|
-
TEST_TRUE( #{equal}(&a, &b) );
|
126
|
-
~
|
127
|
-
|
128
|
-
test :empty, %~
|
129
|
-
#{ctor}(&b);
|
130
|
-
TEST_FALSE( #{empty}(&a) );
|
131
|
-
TEST_TRUE( #{empty}(&b) );
|
132
|
-
~
|
133
|
-
|
134
|
-
setup %~
|
135
|
-
/* a: [1,2,3], b: [2,3,4] */
|
136
|
-
#{type} a, b, c;
|
137
|
-
#{ctor}(&a);
|
138
|
-
#{ctor}(&b);
|
139
|
-
#{ctor}(&c);
|
140
|
-
PUT(&a, 1); PUT(&a, 2); PUT(&a, 3);
|
141
|
-
PUT(&b, 4); PUT(&b, 2); PUT(&b, 3);
|
142
|
-
~
|
143
|
-
cleanup %~
|
144
|
-
#{dtor}(&a);
|
145
|
-
#{dtor}(&b);
|
146
|
-
#{dtor}(&c);
|
147
|
-
~
|
148
|
-
|
149
|
-
test :exclude, %~
|
150
|
-
PUT(&c, 1);
|
151
|
-
#{exclude}(&a, &b);
|
152
|
-
TEST_TRUE( #{equal}(&a, &c) );
|
153
|
-
~
|
154
|
-
|
155
|
-
test :include, %~
|
156
|
-
PUT(&c, 1); PUT(&c, 2); PUT(&c, 3); PUT(&c, 4);
|
157
|
-
#{include}(&a, &b);
|
158
|
-
TEST_TRUE( #{equal}(&a, &c) );
|
159
|
-
~
|
160
|
-
|
161
|
-
test :invert, %~
|
162
|
-
PUT(&c, 1); PUT(&c, 4);
|
163
|
-
#{invert}(&a, &b);
|
164
|
-
TEST_TRUE( #{equal}(&a, &c) );
|
165
|
-
~
|
166
|
-
|
167
|
-
test :retain, %~
|
168
|
-
PUT(&c, 2); PUT(&c, 3);
|
169
|
-
#{retain}(&a, &b);
|
170
|
-
TEST_TRUE( #{equal}(&a, &c) );
|
171
|
-
~
|
172
|
-
|
173
|
-
end
|
data/test/test_value_vector.rb
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
require "value"
|
2
|
-
|
3
|
-
|
4
|
-
type_test(AutoC::Vector, :ValueVector, Value) do
|
5
|
-
|
6
|
-
setup %~#{type} t;~
|
7
|
-
cleanup %~#{dtor}(&t);~
|
8
|
-
|
9
|
-
test :createSmallest, %~
|
10
|
-
#{ctor}(&t, 1);
|
11
|
-
TEST_EQUAL( #{size}(&t), 1 );
|
12
|
-
~
|
13
|
-
|
14
|
-
test :createLarge, %~
|
15
|
-
#{ctor}(&t, 1024);
|
16
|
-
TEST_EQUAL( #{size}(&t), 1024 );
|
17
|
-
~
|
18
|
-
|
19
|
-
setup %~
|
20
|
-
#{type} t;
|
21
|
-
#{element.type} e;
|
22
|
-
int i, c = 3;
|
23
|
-
#{ctor}(&t, c);
|
24
|
-
for(i = 0; i < c; ++i) {
|
25
|
-
#{element.ctorEx}(e, i);
|
26
|
-
#{set}(&t, i, e);
|
27
|
-
#{element.dtor}(e);
|
28
|
-
}
|
29
|
-
~
|
30
|
-
cleanup %~#{dtor}(&t);~
|
31
|
-
|
32
|
-
|
33
|
-
test :get, %~
|
34
|
-
#{element.type} e2;
|
35
|
-
#{element.ctorEx}(e, 2);
|
36
|
-
e2 = #{get}(&t, 2);
|
37
|
-
TEST_TRUE( #{element.equal}(e, e2) );
|
38
|
-
#{element.dtor}(e);
|
39
|
-
#{element.dtor}(e2);
|
40
|
-
~
|
41
|
-
|
42
|
-
test :set, %~
|
43
|
-
#{element.type} e2;
|
44
|
-
#{element.ctorEx}(e, -1);
|
45
|
-
#{set}(&t, 2, e);
|
46
|
-
e2 = #{get}(&t, 2);
|
47
|
-
TEST_TRUE( #{element.equal}(e, e2) );
|
48
|
-
#{element.dtor}(e);
|
49
|
-
#{element.dtor}(e2);
|
50
|
-
~
|
51
|
-
|
52
|
-
test :within, %~
|
53
|
-
TEST_TRUE( #{within}(&t, 0) );
|
54
|
-
TEST_TRUE( #{within}(&t, 2) );
|
55
|
-
TEST_FALSE( #{within}(&t, 3) );
|
56
|
-
~
|
57
|
-
|
58
|
-
test :iterateForward, %~
|
59
|
-
#{it} it;
|
60
|
-
#{itCtor}(&it, &t);
|
61
|
-
i = 0;
|
62
|
-
while(#{itMove}(&it)) {
|
63
|
-
e = #{itGet}(&it);
|
64
|
-
TEST_EQUAL( #{element.get}(e), i++ );
|
65
|
-
#{element.dtor}(e);
|
66
|
-
}
|
67
|
-
~
|
68
|
-
|
69
|
-
test :iterateExactForward, %~
|
70
|
-
#{it} it;
|
71
|
-
#{itCtorEx}(&it, &t, 1);
|
72
|
-
i = 0;
|
73
|
-
while(#{itMove}(&it)) {
|
74
|
-
e = #{itGet}(&it);
|
75
|
-
TEST_EQUAL( #{element.get}(e), i++ );
|
76
|
-
#{element.dtor}(e);
|
77
|
-
}
|
78
|
-
~
|
79
|
-
|
80
|
-
test :iterateBackward, %~
|
81
|
-
#{it} it;
|
82
|
-
#{itCtorEx}(&it, &t, 0);
|
83
|
-
i = c-1;
|
84
|
-
while(#{itMove}(&it)) {
|
85
|
-
e = #{itGet}(&it);
|
86
|
-
TEST_EQUAL( #{element.get}(e), i-- );
|
87
|
-
#{element.dtor}(e);
|
88
|
-
}
|
89
|
-
~
|
90
|
-
|
91
|
-
setup %~
|
92
|
-
#{type} t1, t2;
|
93
|
-
#{element.type} e;
|
94
|
-
int i, c = 3;
|
95
|
-
#{ctor}(&t1, c);
|
96
|
-
#{ctor}(&t2, c);
|
97
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
98
|
-
for(i = 0; i < c; ++i) {
|
99
|
-
#{element.ctorEx}(e, i);
|
100
|
-
#{set}(&t1, i, e);
|
101
|
-
#{set}(&t2, i, e);
|
102
|
-
#{element.dtor}(e);
|
103
|
-
}
|
104
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
105
|
-
~
|
106
|
-
cleanup %~
|
107
|
-
#{dtor}(&t1);
|
108
|
-
#{dtor}(&t2);
|
109
|
-
~
|
110
|
-
|
111
|
-
test :size, %~
|
112
|
-
TEST_EQUAL( #{size}(&t1), 3 );
|
113
|
-
TEST_EQUAL( #{size}(&t1), #{size}(&t2) );
|
114
|
-
#{resize}(&t2, 1);
|
115
|
-
TEST_EQUAL( #{size}(&t2), 1 );
|
116
|
-
TEST_NOT_EQUAL( #{size}(&t1), #{size}(&t2) );
|
117
|
-
~
|
118
|
-
|
119
|
-
test :equal, %~
|
120
|
-
#{element.ctorEx}(e, -1);
|
121
|
-
#{set}(&t1, 0, e);
|
122
|
-
#{element.dtor}(e);
|
123
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
124
|
-
~
|
125
|
-
|
126
|
-
test :resizeShrink, %~
|
127
|
-
#{resize}(&t2, 2);
|
128
|
-
TEST_EQUAL( #{size}(&t2), 2 );
|
129
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
130
|
-
~
|
131
|
-
|
132
|
-
test :resizeExpand, %~
|
133
|
-
#{resize}(&t2, 4);
|
134
|
-
TEST_EQUAL( #{size}(&t2), 4 );
|
135
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
136
|
-
e = #{get}(&t2, 3);
|
137
|
-
TEST_EQUAL( #{element.get}(e), 0 );
|
138
|
-
TEST_NOT_EQUAL( #{element.get}(e), 1 );
|
139
|
-
#{element.dtor}(e);
|
140
|
-
~
|
141
|
-
|
142
|
-
test :sort, %~
|
143
|
-
#{sort}(&t2);
|
144
|
-
TEST_TRUE( #{equal}(&t1, &t2) );
|
145
|
-
e = #{get}(&t2, 0);
|
146
|
-
TEST_EQUAL( #{element.get}(e), 0 );
|
147
|
-
#{element.dtor}(e);
|
148
|
-
#{sortEx}(&t2, 0);
|
149
|
-
TEST_FALSE( #{equal}(&t1, &t2) );
|
150
|
-
e = #{get}(&t2, 0);
|
151
|
-
TEST_EQUAL( #{element.get}(e), 2 );
|
152
|
-
#{element.dtor}(e);
|
153
|
-
~
|
154
|
-
|
155
|
-
end
|
data/test/value.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require "autoc"
|
2
|
-
|
3
|
-
|
4
|
-
Value = Class.new(AutoC::UserDefinedType) do
|
5
|
-
def write_intf(stream)
|
6
|
-
super
|
7
|
-
stream << %~
|
8
|
-
typedef struct {
|
9
|
-
int* value;
|
10
|
-
} Value;
|
11
|
-
#define ValueCtor(self) _ValueCtor(&self)
|
12
|
-
#define ValueCtorEx(self, v) _ValueCtorEx(&self, v)
|
13
|
-
#define ValueDtor(self) _ValueDtor(&self)
|
14
|
-
#define ValueCopy(dst, src) _ValueCopy(&dst, &src)
|
15
|
-
#define ValueEqual(lt, rt) _ValueEqual(<, &rt)
|
16
|
-
#define ValueLess(lt, rt) _ValueLess(<, &rt)
|
17
|
-
#define ValueIdentify(self) _ValueIdentify(&self)
|
18
|
-
#define ValueGet(self) *(self).value
|
19
|
-
#define ValueSet(self, x) *(self).value = (x)
|
20
|
-
void _ValueCtor(Value*);
|
21
|
-
void _ValueCtorEx(Value*, int);
|
22
|
-
void _ValueDtor(Value*);
|
23
|
-
void _ValueCopy(Value*, Value*);
|
24
|
-
int _ValueEqual(Value*, Value*);
|
25
|
-
int _ValueLess(Value*, Value*);
|
26
|
-
size_t _ValueIdentify(Value*);
|
27
|
-
~
|
28
|
-
end
|
29
|
-
def write_defs(stream)
|
30
|
-
super
|
31
|
-
stream << %~
|
32
|
-
void _ValueCtor(Value* self) {
|
33
|
-
#{assert}(self);
|
34
|
-
self->value = #{calloc}(1, sizeof(int)); #{assert}(self->value);
|
35
|
-
}
|
36
|
-
void _ValueCtorEx(Value* self, int value) {
|
37
|
-
#{assert}(self);
|
38
|
-
ValueCtor(*self);
|
39
|
-
*self->value = value;
|
40
|
-
}
|
41
|
-
void _ValueDtor(Value* self) {
|
42
|
-
#{assert}(self);
|
43
|
-
#{free}(self->value);
|
44
|
-
}
|
45
|
-
void _ValueCopy(Value* dst, Value* src) {
|
46
|
-
#{assert}(src);
|
47
|
-
#{assert}(dst);
|
48
|
-
#{assert}(src->value);
|
49
|
-
ValueCtorEx(*dst, *src->value);
|
50
|
-
}
|
51
|
-
int _ValueEqual(Value* lt, Value* rt) {
|
52
|
-
#{assert}(lt);
|
53
|
-
#{assert}(rt);
|
54
|
-
#{assert}(lt->value);
|
55
|
-
#{assert}(rt->value);
|
56
|
-
return *lt->value == *rt->value;
|
57
|
-
}
|
58
|
-
int _ValueLess(Value* lt, Value* rt) {
|
59
|
-
#{assert}(lt);
|
60
|
-
#{assert}(rt);
|
61
|
-
#{assert}(lt->value);
|
62
|
-
#{assert}(rt->value);
|
63
|
-
return *lt->value < *rt->value;
|
64
|
-
}
|
65
|
-
size_t _ValueIdentify(Value* self) {
|
66
|
-
#{assert}(self);
|
67
|
-
#{assert}(self->value);
|
68
|
-
return *self->value ^ 0xAAAA;
|
69
|
-
}
|
70
|
-
~
|
71
|
-
end
|
72
|
-
end.new(
|
73
|
-
:type => :Value,
|
74
|
-
:ctor => :ValueCtor,
|
75
|
-
:dtor => :ValueDtor,
|
76
|
-
:copy => :ValueCopy,
|
77
|
-
:equal => :ValueEqual,
|
78
|
-
:less => :ValueLess,
|
79
|
-
:identify => :ValueIdentify
|
80
|
-
)
|