gecoder 0.2.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 (75) hide show
  1. data/COPYING +17 -0
  2. data/LGPL-LICENSE +458 -0
  3. data/README +20 -0
  4. data/Rakefile +6 -0
  5. data/ext/extconf.rb +29 -0
  6. data/ext/missing.cpp +295 -0
  7. data/ext/missing.h +116 -0
  8. data/ext/vararray.cpp +312 -0
  9. data/ext/vararray.h +146 -0
  10. data/lib/gecoder.rb +4 -0
  11. data/lib/gecoder/bindings.rb +7 -0
  12. data/lib/gecoder/bindings/bindings.rb +2055 -0
  13. data/lib/gecoder/interface.rb +6 -0
  14. data/lib/gecoder/interface/binding_changes.rb +111 -0
  15. data/lib/gecoder/interface/branch.rb +102 -0
  16. data/lib/gecoder/interface/constraints.rb +10 -0
  17. data/lib/gecoder/interface/constraints/distinct.rb +15 -0
  18. data/lib/gecoder/interface/constraints/linear.rb +158 -0
  19. data/lib/gecoder/interface/constraints/relation.rb +76 -0
  20. data/lib/gecoder/interface/enum_wrapper.rb +64 -0
  21. data/lib/gecoder/interface/model.rb +130 -0
  22. data/lib/gecoder/interface/search.rb +23 -0
  23. data/vendor/rust/README +28 -0
  24. data/vendor/rust/bin/cxxgenerator.rb +93 -0
  25. data/vendor/rust/include/rust_checks.hh +115 -0
  26. data/vendor/rust/include/rust_conversions.hh +103 -0
  27. data/vendor/rust/rust.rb +67 -0
  28. data/vendor/rust/rust/attribute.rb +51 -0
  29. data/vendor/rust/rust/bindings.rb +172 -0
  30. data/vendor/rust/rust/class.rb +334 -0
  31. data/vendor/rust/rust/constants.rb +48 -0
  32. data/vendor/rust/rust/container.rb +110 -0
  33. data/vendor/rust/rust/cppifaceparser.rb +129 -0
  34. data/vendor/rust/rust/cwrapper.rb +72 -0
  35. data/vendor/rust/rust/cxxclass.rb +98 -0
  36. data/vendor/rust/rust/element.rb +81 -0
  37. data/vendor/rust/rust/enum.rb +63 -0
  38. data/vendor/rust/rust/function.rb +407 -0
  39. data/vendor/rust/rust/namespace.rb +61 -0
  40. data/vendor/rust/rust/templates/AttributeDefinition.rusttpl +17 -0
  41. data/vendor/rust/rust/templates/AttributeInitBinding.rusttpl +9 -0
  42. data/vendor/rust/rust/templates/BindingsHeader.rusttpl +24 -0
  43. data/vendor/rust/rust/templates/BindingsUnit.rusttpl +46 -0
  44. data/vendor/rust/rust/templates/CWrapperClassDefinitions.rusttpl +64 -0
  45. data/vendor/rust/rust/templates/ClassDeclarations.rusttpl +7 -0
  46. data/vendor/rust/rust/templates/ClassInitialize.rusttpl +6 -0
  47. data/vendor/rust/rust/templates/ConstructorStub.rusttpl +21 -0
  48. data/vendor/rust/rust/templates/CxxClassDefinitions.rusttpl +91 -0
  49. data/vendor/rust/rust/templates/CxxMethodStub.rusttpl +12 -0
  50. data/vendor/rust/rust/templates/CxxStandaloneClassDefinitions.rusttpl +12 -0
  51. data/vendor/rust/rust/templates/EnumDeclarations.rusttpl +3 -0
  52. data/vendor/rust/rust/templates/EnumDefinitions.rusttpl +29 -0
  53. data/vendor/rust/rust/templates/FunctionDefinition.rusttpl +9 -0
  54. data/vendor/rust/rust/templates/FunctionInitAlias.rusttpl +5 -0
  55. data/vendor/rust/rust/templates/FunctionInitBinding.rusttpl +9 -0
  56. data/vendor/rust/rust/templates/MethodInitBinding.rusttpl +9 -0
  57. data/vendor/rust/rust/templates/ModuleDeclarations.rusttpl +3 -0
  58. data/vendor/rust/rust/templates/ModuleDefinitions.rusttpl +3 -0
  59. data/vendor/rust/rust/templates/StandaloneClassDeclarations.rusttpl +5 -0
  60. data/vendor/rust/rust/templates/VariableFunctionCall.rusttpl +14 -0
  61. data/vendor/rust/rust/type.rb +98 -0
  62. data/vendor/rust/test/Makefile +4 -0
  63. data/vendor/rust/test/constants.rb +35 -0
  64. data/vendor/rust/test/cppclass.cc +40 -0
  65. data/vendor/rust/test/cppclass.hh +63 -0
  66. data/vendor/rust/test/cppclass.rb +59 -0
  67. data/vendor/rust/test/cwrapper.c +74 -0
  68. data/vendor/rust/test/cwrapper.h +41 -0
  69. data/vendor/rust/test/cwrapper.rb +56 -0
  70. data/vendor/rust/test/dummyclass.hh +31 -0
  71. data/vendor/rust/test/lib/extension-test.rb +98 -0
  72. data/vendor/rust/test/test-constants.rb +43 -0
  73. data/vendor/rust/test/test-cppclass.rb +82 -0
  74. data/vendor/rust/test/test-cwrapper.rb +77 -0
  75. metadata +144 -0
data/ext/vararray.cpp ADDED
@@ -0,0 +1,312 @@
1
+ /** Copyright (c) 2007, David Cuadrado <krawek@gmail.com>
2
+ * All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ *
7
+ * 1. Redistributions of source code must retain the above copyright notice,
8
+ * this list of conditions and the following disclaimer.
9
+ * 2. Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ *
13
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
+ * POSSIBILITY OF SUCH DAMAGE.
24
+ **/
25
+
26
+ #include "vararray.h"
27
+
28
+ namespace Gecode {
29
+
30
+
31
+ struct MVarArray::Private
32
+ {
33
+ int count;
34
+ int size;
35
+ };
36
+
37
+ MVarArray::MVarArray() : d(new Private)
38
+ {
39
+ }
40
+
41
+ MVarArray::~MVarArray()
42
+ {
43
+ delete d;
44
+ }
45
+
46
+ int MVarArray::count() const
47
+ {
48
+ return d->count;
49
+ }
50
+
51
+ int MVarArray::size() const
52
+ {
53
+ return d->size;
54
+ }
55
+
56
+ void MVarArray::setCount(int c)
57
+ {
58
+ d->count = c;
59
+ }
60
+
61
+ void MVarArray::setSize(int n)
62
+ {
63
+ d->size = n;
64
+ }
65
+
66
+
67
+ // MINTVARARRAY
68
+
69
+ struct MIntVarArray::Private
70
+ {
71
+ Gecode::IntVarArray array;
72
+ };
73
+
74
+
75
+ MIntVarArray::MIntVarArray() : d(new Private)
76
+ {
77
+ setArray(Gecode::IntVarArray());
78
+ }
79
+
80
+ MIntVarArray::MIntVarArray(const Gecode::IntVarArray &arr) : d(new Private)
81
+ {
82
+ setArray(arr);
83
+ setCount(0);
84
+ }
85
+
86
+ MIntVarArray::MIntVarArray (Space *home, int n) : d(new Private)
87
+ {
88
+ setArray(Gecode::IntVarArray(home, n));
89
+ }
90
+
91
+ MIntVarArray::MIntVarArray (Space *home, int n, int min, int max) : d(new Private)
92
+ {
93
+ setArray(Gecode::IntVarArray(home, n, min, max));
94
+ }
95
+
96
+ MIntVarArray::MIntVarArray (Space *home, int n, const IntSet &s) : d(new Private)
97
+ {
98
+ setArray(Gecode::IntVarArray(home, n, s));
99
+ }
100
+
101
+
102
+ MIntVarArray::~MIntVarArray()
103
+ {
104
+ delete d;
105
+ }
106
+
107
+ void MIntVarArray::setArray(const Gecode::IntVarArray &arr)
108
+ {
109
+ d->array = arr;
110
+ setSize(arr.size());
111
+ }
112
+
113
+ void MIntVarArray::enlargeArray(Gecode::Space *parent, int n)
114
+ {
115
+ Gecode::IntVarArray na(parent, size()+n, 0, 0);
116
+ for(int i = count(); i--; )
117
+ na[i] = d->array[i];
118
+
119
+ d->array = na;
120
+
121
+ setSize(size() + n);
122
+ }
123
+
124
+ Gecode::IntVarArray *MIntVarArray::ptr() const
125
+ {
126
+ return &d->array;
127
+ }
128
+
129
+ Gecode::IntVar &MIntVarArray::at(int index)
130
+ {
131
+ return d->array[index];
132
+ }
133
+
134
+ IntVar &MIntVarArray::operator [](int index)
135
+ {
136
+ return d->array[index];
137
+ }
138
+
139
+ void MIntVarArray::debug() const
140
+ {
141
+ for(int i = 0; i < d->array.size(); i++)
142
+ {
143
+ std::cout << d->array[i] << " ";
144
+ }
145
+ std::cout << std::endl;
146
+ }
147
+
148
+
149
+ // MBOOLVARARRAY
150
+
151
+ struct MBoolVarArray::Private
152
+ {
153
+ Gecode::BoolVarArray array;
154
+ };
155
+
156
+
157
+ MBoolVarArray::MBoolVarArray() : d(new Private)
158
+ {
159
+ }
160
+
161
+ MBoolVarArray::MBoolVarArray(const Gecode::BoolVarArray &arr) : d(new Private)
162
+ {
163
+ d->array = arr;
164
+ setSize(arr.size());
165
+ setCount(0);
166
+ }
167
+
168
+ MBoolVarArray::~MBoolVarArray()
169
+ {
170
+ delete d;
171
+ }
172
+
173
+ void MBoolVarArray::setArray(const Gecode::BoolVarArray &arr)
174
+ {
175
+ d->array = arr;
176
+ setSize(arr.size());
177
+ }
178
+
179
+ void MBoolVarArray::enlargeArray(Gecode::Space *parent, int n)
180
+ {
181
+ Gecode::BoolVarArray na(parent, size()+n, 0, 0);
182
+ for(int i = count(); i--; )
183
+ na[i] = d->array[i];
184
+
185
+ d->array = na;
186
+
187
+ setSize(size() + n);
188
+ }
189
+
190
+ Gecode::BoolVarArray *MBoolVarArray::ptr() const
191
+ {
192
+ return &d->array;
193
+ }
194
+
195
+ Gecode::BoolVar &MBoolVarArray::at(int index)
196
+ {
197
+ return d->array[index];
198
+ }
199
+
200
+ Gecode::BoolVar &MBoolVarArray::operator[](int index)
201
+ {
202
+ return d->array[index];
203
+ }
204
+
205
+ void MBoolVarArray::debug() const
206
+ {
207
+ for(int i = 0; i < d->array.size(); i++)
208
+ {
209
+ std::cout << d->array[i] << " ";
210
+ }
211
+ std::cout << std::endl;
212
+ }
213
+
214
+
215
+ // SETVARARRAY
216
+
217
+ struct MSetVarArray::Private
218
+ {
219
+ Gecode::SetVarArray array;
220
+ };
221
+
222
+ MSetVarArray::MSetVarArray() : d(new Private)
223
+ {
224
+ }
225
+
226
+ MSetVarArray::MSetVarArray(const Gecode::SetVarArray &arr) : d(new Private)
227
+ {
228
+ d->array = arr;
229
+ setSize(arr.size());
230
+ setCount(0);
231
+ }
232
+
233
+ MSetVarArray::MSetVarArray(Space *home, int n) : d(new Private)
234
+ {
235
+ setArray(Gecode::SetVarArray(home, n));
236
+ }
237
+
238
+ MSetVarArray::MSetVarArray(Gecode::Space *home, int n, int glbMin, int glbMax, int lubMin, int lubMax, unsigned int minCard, unsigned int maxCard) : d(new Private)
239
+ {
240
+ setArray(Gecode::SetVarArray(home, n, glbMin, glbMax, lubMin, lubMax, minCard, maxCard));
241
+ }
242
+
243
+ MSetVarArray::MSetVarArray(Gecode::Space *home, int n, const Gecode::IntSet &glb, int lubMin, int lubMax, unsigned int minCard, unsigned int maxCard) : d(new Private)
244
+ {
245
+ setArray(Gecode::SetVarArray(home, n, glb, lubMin, lubMax, minCard, maxCard));
246
+ }
247
+
248
+ MSetVarArray::MSetVarArray(Gecode::Space *home, int n, int glbMin, int glbMax, const Gecode::IntSet &lub, unsigned int minCard, unsigned int maxCard) : d(new Private)
249
+ {
250
+ setArray(Gecode::SetVarArray(home, n, glbMin, glbMax, lub, minCard, maxCard));
251
+ }
252
+
253
+ MSetVarArray::MSetVarArray(Gecode::Space *home, int n, const Gecode::IntSet &glb, const Gecode::IntSet &lub, unsigned int minCard, unsigned int maxCard) : d(new Private)
254
+ {
255
+ setArray(Gecode::SetVarArray(home, n, glb, lub, minCard, maxCard));
256
+ }
257
+
258
+ MSetVarArray::~MSetVarArray()
259
+ {
260
+ delete d;
261
+ }
262
+
263
+ void MSetVarArray::setArray(const Gecode::SetVarArray &arr)
264
+ {
265
+ d->array = arr;
266
+ setSize(arr.size());
267
+ }
268
+
269
+ void MSetVarArray::enlargeArray(Gecode::Space *parent, int n)
270
+ {
271
+ Gecode::SetVarArray na(parent, size()*n);
272
+ for (int i = count(); i--; )
273
+ na[i] = d->array[i];
274
+
275
+ d->array = na;
276
+
277
+ setSize(size() + n);
278
+ }
279
+
280
+ Gecode::SetVarArray *MSetVarArray::ptr() const
281
+ {
282
+ return &d->array;
283
+ }
284
+
285
+ Gecode::SetVar &MSetVarArray::at(int index)
286
+ {
287
+ return d->array[index];
288
+ }
289
+
290
+ Gecode::SetVar &MSetVarArray::operator[](int index)
291
+ {
292
+ return d->array[index];
293
+ }
294
+
295
+ void MSetVarArray::debug() const
296
+ {
297
+ for(int i = 0; i < d->array.size(); i++)
298
+ {
299
+ std::cout << d->array[i] << " ";
300
+ }
301
+ std::cout << std::endl;
302
+ }
303
+
304
+
305
+ }
306
+
307
+
308
+
309
+
310
+
311
+
312
+
data/ext/vararray.h ADDED
@@ -0,0 +1,146 @@
1
+ /** Copyright (c) 2007, David Cuadrado <krawek@gmail.com>
2
+ * All rights reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ *
7
+ * 1. Redistributions of source code must retain the above copyright notice,
8
+ * this list of conditions and the following disclaimer.
9
+ * 2. Redistributions in binary form must reproduce the above copyright
10
+ * notice, this list of conditions and the following disclaimer in the
11
+ * documentation and/or other materials provided with the distribution.
12
+ *
13
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
17
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23
+ * POSSIBILITY OF SUCH DAMAGE.
24
+ **/
25
+
26
+ #ifndef _VARARRAY_H
27
+ #define _VARARRAT_H
28
+
29
+ #include <gecode/int.hh>
30
+ #include <gecode/set.hh>
31
+
32
+
33
+ namespace Gecode {
34
+
35
+ class MVarArray
36
+ {
37
+ public:
38
+ MVarArray();
39
+ virtual ~MVarArray();
40
+ virtual void enlargeArray(Gecode::Space *parent, int n = 1) = 0;
41
+
42
+ int count() const;
43
+ int size() const;
44
+
45
+ void setCount(int c);
46
+ void setSize(int n);
47
+
48
+ private:
49
+ struct Private;
50
+ Private *const d;
51
+ };
52
+
53
+ class MIntVarArray : public MVarArray
54
+ {
55
+ public:
56
+ MIntVarArray();
57
+ MIntVarArray(const Gecode::IntVarArray &arr);
58
+ MIntVarArray(Space *home, int n);
59
+ MIntVarArray(Space *home, int n, int min, int max);
60
+ MIntVarArray(Space *home, int n, const IntSet &s);
61
+
62
+ ~MIntVarArray();
63
+
64
+ void enlargeArray(Gecode::Space *parent, int n = 1);
65
+
66
+ void setArray(const Gecode::IntVarArray &arr);
67
+ Gecode::IntVarArray *ptr() const;
68
+
69
+ Gecode::IntVar &at(int index);
70
+ void push(const Gecode::IntVar& intvar);
71
+
72
+ void debug() const;
73
+
74
+ IntVar &operator [](int index);
75
+
76
+ private:
77
+ struct Private;
78
+ Private *const d;
79
+ };
80
+
81
+ class MBoolVarArray : public MVarArray
82
+ {
83
+ public:
84
+ MBoolVarArray();
85
+ MBoolVarArray(const Gecode::BoolVarArray &arr);
86
+
87
+ ~MBoolVarArray();
88
+
89
+ void enlargeArray(Gecode::Space *parent, int n = 1);
90
+
91
+ void setArray(const Gecode::BoolVarArray &arr);
92
+ Gecode::BoolVarArray *ptr() const;
93
+
94
+ Gecode::BoolVar &at(int index);
95
+ Gecode::BoolVar &operator[](int index);
96
+
97
+ void push(const Gecode::BoolVar& intvar);
98
+
99
+ void debug() const;
100
+
101
+ private:
102
+ struct Private;
103
+ Private *const d;
104
+ };
105
+
106
+
107
+
108
+ class MSetVarArray : public MVarArray
109
+ {
110
+ public:
111
+ MSetVarArray();
112
+ MSetVarArray(const Gecode::SetVarArray &arr);
113
+
114
+ MSetVarArray(Space *home, int n);
115
+ MSetVarArray(Space *home, int n, int glbMin, int glbMax, int lubMin, int lubMax, unsigned int minCard=0, unsigned int maxCard=Limits::Set::card_max);
116
+
117
+ MSetVarArray(Space *home, int n, const IntSet &glb, int lubMin, int lubMax, unsigned int minCard=0, unsigned int maxCard=Limits::Set::card_max);
118
+
119
+ MSetVarArray(Space *home, int n, int glbMin, int glbMax, const IntSet &lub, unsigned int minCard=0, unsigned int maxCard=Limits::Set::card_max);
120
+
121
+ MSetVarArray(Space *home, int n, const IntSet &glb, const IntSet &lub, unsigned int minCard=0, unsigned int maxCard=Limits::Set::card_max);
122
+
123
+ ~MSetVarArray();
124
+
125
+
126
+
127
+ void enlargeArray(Gecode::Space *parent, int n = 1);
128
+
129
+ void setArray(const Gecode::SetVarArray &arr);
130
+ Gecode::SetVarArray *ptr() const;
131
+
132
+ Gecode::SetVar &at(int index);
133
+ Gecode::SetVar &operator[](int index);
134
+
135
+ void debug() const;
136
+
137
+ private:
138
+ struct Private;
139
+ Private *const d;
140
+ };
141
+
142
+ }
143
+
144
+
145
+ #endif
146
+