gecoder-with-gecode 0.9.0-x86-mswin32-60

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 (203) hide show
  1. data/CHANGES +137 -0
  2. data/COPYING +17 -0
  3. data/LGPL-LICENSE +458 -0
  4. data/README +58 -0
  5. data/Rakefile +14 -0
  6. data/example/equation_system.rb +15 -0
  7. data/example/example_helper.rb +1 -0
  8. data/example/magic_sequence.rb +43 -0
  9. data/example/money.rb +36 -0
  10. data/example/queens.rb +42 -0
  11. data/example/send_more_money.rb +43 -0
  12. data/example/send_most_money.rb +58 -0
  13. data/example/square_tiling.rb +84 -0
  14. data/example/sudoku-set.rb +106 -0
  15. data/example/sudoku.rb +56 -0
  16. data/lib/gecode.dll +0 -0
  17. data/lib/gecoder.rb +5 -0
  18. data/lib/gecoder/bindings.rb +96 -0
  19. data/lib/gecoder/bindings/bindings.rb +2029 -0
  20. data/lib/gecoder/interface.rb +9 -0
  21. data/lib/gecoder/interface/binding_changes.rb +9 -0
  22. data/lib/gecoder/interface/branch.rb +163 -0
  23. data/lib/gecoder/interface/constraints.rb +471 -0
  24. data/lib/gecoder/interface/constraints/bool/boolean.rb +251 -0
  25. data/lib/gecoder/interface/constraints/bool/channel.rb +7 -0
  26. data/lib/gecoder/interface/constraints/bool/linear.rb +200 -0
  27. data/lib/gecoder/interface/constraints/bool_enum/channel.rb +68 -0
  28. data/lib/gecoder/interface/constraints/bool_enum/extensional.rb +106 -0
  29. data/lib/gecoder/interface/constraints/bool_enum/relation.rb +55 -0
  30. data/lib/gecoder/interface/constraints/bool_enum_constraints.rb +84 -0
  31. data/lib/gecoder/interface/constraints/bool_var_constraints.rb +155 -0
  32. data/lib/gecoder/interface/constraints/extensional_regexp.rb +101 -0
  33. data/lib/gecoder/interface/constraints/fixnum_enum/element.rb +63 -0
  34. data/lib/gecoder/interface/constraints/fixnum_enum/operation.rb +65 -0
  35. data/lib/gecoder/interface/constraints/fixnum_enum_constraints.rb +42 -0
  36. data/lib/gecoder/interface/constraints/int/arithmetic.rb +150 -0
  37. data/lib/gecoder/interface/constraints/int/channel.rb +51 -0
  38. data/lib/gecoder/interface/constraints/int/domain.rb +80 -0
  39. data/lib/gecoder/interface/constraints/int/linear.rb +143 -0
  40. data/lib/gecoder/interface/constraints/int/relation.rb +141 -0
  41. data/lib/gecoder/interface/constraints/int_enum/arithmetic.rb +63 -0
  42. data/lib/gecoder/interface/constraints/int_enum/channel.rb +86 -0
  43. data/lib/gecoder/interface/constraints/int_enum/count.rb +66 -0
  44. data/lib/gecoder/interface/constraints/int_enum/distinct.rb +64 -0
  45. data/lib/gecoder/interface/constraints/int_enum/element.rb +64 -0
  46. data/lib/gecoder/interface/constraints/int_enum/equality.rb +37 -0
  47. data/lib/gecoder/interface/constraints/int_enum/extensional.rb +187 -0
  48. data/lib/gecoder/interface/constraints/int_enum/sort.rb +135 -0
  49. data/lib/gecoder/interface/constraints/int_enum_constraints.rb +95 -0
  50. data/lib/gecoder/interface/constraints/int_var_constraints.rb +230 -0
  51. data/lib/gecoder/interface/constraints/reifiable_constraints.rb +78 -0
  52. data/lib/gecoder/interface/constraints/selected_set/select.rb +120 -0
  53. data/lib/gecoder/interface/constraints/selected_set_constraints.rb +75 -0
  54. data/lib/gecoder/interface/constraints/set/cardinality.rb +65 -0
  55. data/lib/gecoder/interface/constraints/set/channel.rb +51 -0
  56. data/lib/gecoder/interface/constraints/set/connection.rb +130 -0
  57. data/lib/gecoder/interface/constraints/set/domain.rb +156 -0
  58. data/lib/gecoder/interface/constraints/set/include.rb +36 -0
  59. data/lib/gecoder/interface/constraints/set/operation.rb +118 -0
  60. data/lib/gecoder/interface/constraints/set/relation.rb +155 -0
  61. data/lib/gecoder/interface/constraints/set_elements/relation.rb +116 -0
  62. data/lib/gecoder/interface/constraints/set_elements_constraints.rb +97 -0
  63. data/lib/gecoder/interface/constraints/set_enum/channel.rb +45 -0
  64. data/lib/gecoder/interface/constraints/set_enum/distinct.rb +43 -0
  65. data/lib/gecoder/interface/constraints/set_enum/operation.rb +69 -0
  66. data/lib/gecoder/interface/constraints/set_enum/select.rb +79 -0
  67. data/lib/gecoder/interface/constraints/set_enum_constraints.rb +84 -0
  68. data/lib/gecoder/interface/constraints/set_var_constraints.rb +243 -0
  69. data/lib/gecoder/interface/enum_matrix.rb +64 -0
  70. data/lib/gecoder/interface/enum_wrapper.rb +205 -0
  71. data/lib/gecoder/interface/model.rb +453 -0
  72. data/lib/gecoder/interface/model_sugar.rb +84 -0
  73. data/lib/gecoder/interface/search.rb +197 -0
  74. data/lib/gecoder/interface/variables.rb +306 -0
  75. data/lib/gecoder/version.rb +4 -0
  76. data/specs/bool_var.rb +81 -0
  77. data/specs/branch.rb +185 -0
  78. data/specs/constraints/bool/boolean.rb +317 -0
  79. data/specs/constraints/bool/boolean_properties.rb +51 -0
  80. data/specs/constraints/bool/linear.rb +213 -0
  81. data/specs/constraints/bool_enum/bool_enum_relation.rb +117 -0
  82. data/specs/constraints/bool_enum/channel.rb +102 -0
  83. data/specs/constraints/bool_enum/extensional.rb +225 -0
  84. data/specs/constraints/constraint_helper.rb +234 -0
  85. data/specs/constraints/constraint_receivers.rb +103 -0
  86. data/specs/constraints/constraints.rb +26 -0
  87. data/specs/constraints/fixnum_enum/element.rb +58 -0
  88. data/specs/constraints/fixnum_enum/operation.rb +67 -0
  89. data/specs/constraints/int/arithmetic.rb +149 -0
  90. data/specs/constraints/int/channel.rb +101 -0
  91. data/specs/constraints/int/domain.rb +106 -0
  92. data/specs/constraints/int/linear.rb +183 -0
  93. data/specs/constraints/int/linear_properties.rb +97 -0
  94. data/specs/constraints/int/relation.rb +84 -0
  95. data/specs/constraints/int_enum/arithmetic.rb +72 -0
  96. data/specs/constraints/int_enum/channel.rb +57 -0
  97. data/specs/constraints/int_enum/count.rb +72 -0
  98. data/specs/constraints/int_enum/distinct.rb +80 -0
  99. data/specs/constraints/int_enum/element.rb +61 -0
  100. data/specs/constraints/int_enum/equality.rb +29 -0
  101. data/specs/constraints/int_enum/extensional.rb +224 -0
  102. data/specs/constraints/int_enum/sort.rb +167 -0
  103. data/specs/constraints/operands.rb +264 -0
  104. data/specs/constraints/property_helper.rb +443 -0
  105. data/specs/constraints/reification_sugar.rb +69 -0
  106. data/specs/constraints/selected_set/select.rb +56 -0
  107. data/specs/constraints/selected_set/select_properties.rb +157 -0
  108. data/specs/constraints/set/cardinality.rb +58 -0
  109. data/specs/constraints/set/cardinality_properties.rb +46 -0
  110. data/specs/constraints/set/channel.rb +77 -0
  111. data/specs/constraints/set/connection.rb +176 -0
  112. data/specs/constraints/set/domain.rb +197 -0
  113. data/specs/constraints/set/include.rb +36 -0
  114. data/specs/constraints/set/operation.rb +132 -0
  115. data/specs/constraints/set/relation.rb +117 -0
  116. data/specs/constraints/set_elements/relation.rb +84 -0
  117. data/specs/constraints/set_enum/channel.rb +80 -0
  118. data/specs/constraints/set_enum/distinct.rb +59 -0
  119. data/specs/constraints/set_enum/operation.rb +111 -0
  120. data/specs/constraints/set_enum/select.rb +73 -0
  121. data/specs/distribution.rb +14 -0
  122. data/specs/enum_matrix.rb +43 -0
  123. data/specs/enum_wrapper.rb +179 -0
  124. data/specs/examples.rb +17 -0
  125. data/specs/int_var.rb +163 -0
  126. data/specs/logging.rb +24 -0
  127. data/specs/model.rb +325 -0
  128. data/specs/model_sugar.rb +30 -0
  129. data/specs/search.rb +383 -0
  130. data/specs/selected_set.rb +39 -0
  131. data/specs/set_elements.rb +34 -0
  132. data/specs/set_var.rb +82 -0
  133. data/specs/spec_helper.rb +265 -0
  134. data/tasks/all_tasks.rb +1 -0
  135. data/tasks/dependencies.txt +22 -0
  136. data/tasks/distribution.rake +194 -0
  137. data/tasks/rcov.rake +18 -0
  138. data/tasks/specs.rake +21 -0
  139. data/tasks/svn.rake +16 -0
  140. data/tasks/website.rake +51 -0
  141. data/vendor/gecode/win32/lib/libgecodeint.dll +0 -0
  142. data/vendor/gecode/win32/lib/libgecodekernel.dll +0 -0
  143. data/vendor/gecode/win32/lib/libgecodeminimodel.dll +0 -0
  144. data/vendor/gecode/win32/lib/libgecodesearch.dll +0 -0
  145. data/vendor/gecode/win32/lib/libgecodeset.dll +0 -0
  146. data/vendor/gecode/win32/lib/libgecodesupport.dll +0 -0
  147. data/vendor/rust/README +28 -0
  148. data/vendor/rust/bin/cxxgenerator.rb +93 -0
  149. data/vendor/rust/include/rust_checks.hh +116 -0
  150. data/vendor/rust/include/rust_conversions.hh +102 -0
  151. data/vendor/rust/rust.rb +67 -0
  152. data/vendor/rust/rust/attribute.rb +51 -0
  153. data/vendor/rust/rust/bindings.rb +172 -0
  154. data/vendor/rust/rust/class.rb +337 -0
  155. data/vendor/rust/rust/constants.rb +48 -0
  156. data/vendor/rust/rust/container.rb +110 -0
  157. data/vendor/rust/rust/cppifaceparser.rb +129 -0
  158. data/vendor/rust/rust/cwrapper.rb +72 -0
  159. data/vendor/rust/rust/cxxclass.rb +96 -0
  160. data/vendor/rust/rust/element.rb +81 -0
  161. data/vendor/rust/rust/enum.rb +63 -0
  162. data/vendor/rust/rust/function.rb +407 -0
  163. data/vendor/rust/rust/namespace.rb +61 -0
  164. data/vendor/rust/rust/templates/AttributeDefinition.rusttpl +17 -0
  165. data/vendor/rust/rust/templates/AttributeInitBinding.rusttpl +9 -0
  166. data/vendor/rust/rust/templates/BindingsHeader.rusttpl +24 -0
  167. data/vendor/rust/rust/templates/BindingsUnit.rusttpl +46 -0
  168. data/vendor/rust/rust/templates/CWrapperClassDefinitions.rusttpl +64 -0
  169. data/vendor/rust/rust/templates/ClassDeclarations.rusttpl +7 -0
  170. data/vendor/rust/rust/templates/ClassInitialize.rusttpl +6 -0
  171. data/vendor/rust/rust/templates/ConstructorStub.rusttpl +21 -0
  172. data/vendor/rust/rust/templates/CxxClassDefinitions.rusttpl +100 -0
  173. data/vendor/rust/rust/templates/CxxMethodStub.rusttpl +12 -0
  174. data/vendor/rust/rust/templates/CxxStandaloneClassDefinitions.rusttpl +26 -0
  175. data/vendor/rust/rust/templates/EnumDeclarations.rusttpl +3 -0
  176. data/vendor/rust/rust/templates/EnumDefinitions.rusttpl +29 -0
  177. data/vendor/rust/rust/templates/FunctionDefinition.rusttpl +9 -0
  178. data/vendor/rust/rust/templates/FunctionInitAlias.rusttpl +5 -0
  179. data/vendor/rust/rust/templates/FunctionInitBinding.rusttpl +9 -0
  180. data/vendor/rust/rust/templates/MethodInitBinding.rusttpl +9 -0
  181. data/vendor/rust/rust/templates/ModuleDeclarations.rusttpl +3 -0
  182. data/vendor/rust/rust/templates/ModuleDefinitions.rusttpl +3 -0
  183. data/vendor/rust/rust/templates/StandaloneClassDeclarations.rusttpl +7 -0
  184. data/vendor/rust/rust/templates/VariableFunctionCall.rusttpl +14 -0
  185. data/vendor/rust/rust/type.rb +98 -0
  186. data/vendor/rust/test/Makefile +4 -0
  187. data/vendor/rust/test/constants.rb +36 -0
  188. data/vendor/rust/test/cppclass.cc +45 -0
  189. data/vendor/rust/test/cppclass.hh +67 -0
  190. data/vendor/rust/test/cppclass.rb +59 -0
  191. data/vendor/rust/test/cwrapper.c +74 -0
  192. data/vendor/rust/test/cwrapper.h +41 -0
  193. data/vendor/rust/test/cwrapper.rb +56 -0
  194. data/vendor/rust/test/dummyclass.hh +31 -0
  195. data/vendor/rust/test/lib/extension-test.rb +98 -0
  196. data/vendor/rust/test/operators.cc +41 -0
  197. data/vendor/rust/test/operators.hh +39 -0
  198. data/vendor/rust/test/operators.rb +39 -0
  199. data/vendor/rust/test/test-constants.rb +43 -0
  200. data/vendor/rust/test/test-cppclass.rb +82 -0
  201. data/vendor/rust/test/test-cwrapper.rb +80 -0
  202. data/vendor/rust/test/test-operators.rb +42 -0
  203. metadata +393 -0
@@ -0,0 +1,9 @@
1
+ //-*-c++-*-
2
+ // Template of a generic C function call
3
+
4
+ !function_prototype! {
5
+ !function_call!
6
+
7
+ rb_raise(rb_eArgError, "Mandatory parameters missing"); // FIXME
8
+ return Qnil;
9
+ }
@@ -0,0 +1,5 @@
1
+ //-*-c++-*-
2
+ // Template for the init function snipped registering an alias for a
3
+ // function or a method.
4
+
5
+ rb_define_alias(r!parent_varname!, "!function_alias!", "!function_bindname!");
@@ -0,0 +1,9 @@
1
+ //-*-c++-*-
2
+ // Template for the init function snippet registering a function.
3
+ // Note that in the case of a method, !parent_varname! would be a
4
+ // synonim for !class_varname!.
5
+
6
+ rb_define_module_function(r!parent_varname!, "!function_bindname!",
7
+ RUBY_METHOD_FUNC(!function_varname!), !function_paramcount!);
8
+
9
+ !function_aliases!
@@ -0,0 +1,9 @@
1
+ //-*-c++-*-
2
+ // Template for the init function snippet registering a method.
3
+ // Note that in the case of a method, !parent_varname! would be a
4
+ // synonim for !class_varname!.
5
+
6
+ rb_define_method(r!parent_varname!, "!function_bindname!",
7
+ RUBY_METHOD_FUNC(!function_varname!), !function_paramcount!);
8
+
9
+ !function_aliases!
@@ -0,0 +1,3 @@
1
+ //-*-c++-*-
2
+
3
+ extern VALUE r!namespace_varname!;
@@ -0,0 +1,3 @@
1
+ //-*-c++-*-
2
+
3
+ VALUE r!namespace_varname!;
@@ -0,0 +1,7 @@
1
+ //-*-c++-*-
2
+
3
+ typedef std::map<VALUE, !c_class_name!*> T!class_ptrmap!;
4
+ extern T!class_ptrmap! !class_ptrmap!;
5
+ static void !class_varname!_free(void *p);
6
+ static void !class_varname!_mark(void *p);
7
+ static void !class_varname!_free_map_entry(void *p);
@@ -0,0 +1,14 @@
1
+ //-*-c++-*-
2
+ // Template for a variable arguments function call
3
+ bool ok = false;
4
+
5
+ switch(argc) {
6
+ !calls!
7
+ default: ok = false; break;
8
+ }
9
+
10
+ if ( !ok )
11
+ {
12
+ rb_raise(rb_eArgError, "Mandatory parameters missing");
13
+ return Qnil;
14
+ }
@@ -0,0 +1,98 @@
1
+ # Copyright (c) 2007 David Cuadrado <krawek@gmail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge,
7
+ # publish, distribute, sublicense, and/or sell copies of the Software,
8
+ # and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ # BE LIABLE
19
+ # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
+ # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ module Rust
24
+ class Type
25
+ attr_reader :valid_name
26
+ attr_reader :name
27
+
28
+ def initialize(name)
29
+ @name = name
30
+ @valid_name = name.dup.to_s
31
+
32
+ if name.include?("*")
33
+ @is_pointer = true
34
+ @valid_name.gsub!("*", "Ptr")
35
+ else
36
+
37
+ if not name.index(/\[\s*\]/).nil?
38
+ @valid_name.gsub!(/\[\s*\]/, "Array")
39
+ @is_array = true
40
+ end
41
+
42
+ end
43
+
44
+ @valid_name = @valid_name.gsub("::", "_").gsub(/[&\s<>]/, "")
45
+ end
46
+
47
+ def pointer?
48
+ @is_pointer == true
49
+ end
50
+
51
+ def array?
52
+ @is_array == true
53
+ end
54
+
55
+ def native?
56
+ [ /(u){0,1}int(\d\d_t){0,1}\s*\*{0,1}/, /float\s*\*{0,1}/, /double\s*\*{0,1}/, /char\s*\*{0,1}/, /bool/, /(std::){0,1}string/ ].each { |type|
57
+ if @name =~ type
58
+ return true
59
+ end
60
+ }
61
+
62
+ false
63
+ end
64
+
65
+ def ruby_type?
66
+ @name == "VALUE"
67
+ end
68
+
69
+ def to_s
70
+ @valid_name.dup
71
+ end
72
+
73
+ end
74
+ end # module
75
+
76
+
77
+ if __FILE__ == $0 # tests
78
+
79
+ def showtype(type)
80
+ puts "Name: #{type.name}"
81
+ puts "Valid name: #{type.valid_name}"
82
+ puts "Is native: #{type.native?}"
83
+ puts "Is pointer: #{type.pointer?}"
84
+ end
85
+
86
+ showtype Rust::Type.new("int *")
87
+
88
+ showtype Rust::Type.new("Namespace::Class")
89
+
90
+ showtype Rust::Type.new("Namespace::SubNamespace::Class *")
91
+
92
+ end
93
+
94
+
95
+
96
+
97
+
98
+
@@ -0,0 +1,4 @@
1
+ test:
2
+ for test in test-*.rb; do \
3
+ ruby $${test} || exit 0; \
4
+ done
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2007 Diego Pettenò <flameeyes@gmail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge,
7
+ # publish, distribute, sublicense, and/or sell copies of the Software,
8
+ # and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ # BE LIABLE
19
+ # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
+ # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require 'rust'
24
+
25
+ Rust::Bindings::create_bindings Rust::Bindings::LangCxx, "constants_rb" do |b|
26
+ b.include_header 'dummyclass.hh', Rust::Bindings::HeaderLocal
27
+
28
+ b.add_namespace "RustTestConstants", "" do |ns|
29
+ ns.add_cxx_class "DummyClass" do |klass|
30
+ klass.add_constant 'ClassConstant', '123'
31
+ end
32
+
33
+ ns.add_constant 'ModuleConstant', '"foobar"'
34
+ end
35
+ end
36
+
@@ -0,0 +1,45 @@
1
+ /* Copyright (c) 2005-2007 Diego Pettenò <flameeyes@gmail.com>
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining
4
+ * a copy of this software and associated documentation files (the
5
+ * "Software"), to deal in the Software without restriction, including
6
+ * without limitation the rights to use, copy, modify, merge,
7
+ * publish, distribute, sublicense, and/or sell copies of the Software,
8
+ * and to permit persons to whom the Software is furnished to do so,
9
+ * subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be
12
+ * included in all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ * BE LIABLE
19
+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ #include "cppclass.hh"
25
+
26
+ TestClass::TestClass() {
27
+ str = "undefined";
28
+ }
29
+
30
+ TestClass::~TestClass() {
31
+ }
32
+
33
+ void TestClass::action1(uint32_t unused_parameter) {
34
+ val = unused_parameter;
35
+ }
36
+
37
+ void TestClass::action2(char *string) {
38
+ str = string;
39
+ }
40
+
41
+ void TestClass::action3(const TestClass &tc) {
42
+ str = "action3 called";
43
+ }
44
+
45
+
@@ -0,0 +1,67 @@
1
+ /* Copyright (c) 2005-2007 Diego Pettenò <flameeyes@gmail.com>
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining
4
+ * a copy of this software and associated documentation files (the
5
+ * "Software"), to deal in the Software without restriction, including
6
+ * without limitation the rights to use, copy, modify, merge,
7
+ * publish, distribute, sublicense, and/or sell copies of the Software,
8
+ * and to permit persons to whom the Software is furnished to do so,
9
+ * subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be
12
+ * included in all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ * BE LIABLE
19
+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ #include <string>
25
+ #include <stdint.h>
26
+
27
+ class TestClass {
28
+ public:
29
+ TestClass();
30
+ ~TestClass();
31
+
32
+ void action1(uint32_t unused_parameter);
33
+ void action2(char *string);
34
+ void action3(const TestClass &tc);
35
+
36
+ std::string stringValue() {
37
+ return str;
38
+ }
39
+
40
+ uint32_t integerValue() {
41
+ return val;
42
+ }
43
+
44
+ uint32_t variable() {
45
+ return m_variable;
46
+ }
47
+
48
+ uint32_t setVariable(uint32_t value) {
49
+ m_variable = value;
50
+ }
51
+
52
+ enum Test {
53
+ Foo1, Foo2, Foo3, Foo4, Foo6 = 6
54
+ };
55
+
56
+ void testEnum(Test param) {
57
+ }
58
+
59
+ protected:
60
+ uint32_t val;
61
+ std::string str;
62
+
63
+ uint32_t m_variable;
64
+ };
65
+
66
+
67
+
@@ -0,0 +1,59 @@
1
+ # Copyright (c) 2007 Diego Pettenò <flameeyes@gmail.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge,
7
+ # publish, distribute, sublicense, and/or sell copies of the Software,
8
+ # and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ # BE LIABLE
19
+ # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
+ # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require 'rust'
24
+
25
+ Rust::Bindings::create_bindings Rust::Bindings::LangCxx, "cppclass_rb" do |b|
26
+ b.include_header 'cppclass.hh', Rust::Bindings::HeaderLocal
27
+
28
+ b.add_namespace "RustTestCppClass", "" do |ns|
29
+ ns.add_cxx_class "TestClass" do |klass|
30
+ klass.add_constructor do |method|
31
+ end
32
+
33
+ klass.add_method "action1" do |method|
34
+ method.add_parameter "uint32_t", "val"
35
+ end
36
+
37
+ klass.add_method "action2" do |method|
38
+ method.add_parameter "char *", "string"
39
+ end
40
+
41
+ klass.add_method "integerValue", "uint32_t"
42
+ klass.add_method "stringValue", "std::string"
43
+
44
+ klass.add_variable "variable", "uint32_t"
45
+
46
+ klass.add_enum "Test" do |enum|
47
+ enum.add_value 'Foo1'
48
+ enum.add_value 'Foo2'
49
+ enum.add_value 'Foo3'
50
+ enum.add_value 'Foo4'
51
+ enum.add_value 'Foo6'
52
+ end
53
+
54
+ klass.add_method "testEnum" do |method|
55
+ method.add_parameter "TestClass::Test", "param"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,74 @@
1
+ /* Copyright (c) 2005-2007 Diego Pettenò <flameeyes@gmail.com>
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining
4
+ * a copy of this software and associated documentation files (the
5
+ * "Software"), to deal in the Software without restriction, including
6
+ * without limitation the rights to use, copy, modify, merge,
7
+ * publish, distribute, sublicense, and/or sell copies of the Software,
8
+ * and to permit persons to whom the Software is furnished to do so,
9
+ * subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be
12
+ * included in all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
+ * BE LIABLE
19
+ * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ #include "cwrapper.h"
25
+
26
+ #include <stdlib.h>
27
+ #include <string.h>
28
+ #include <stdio.h>
29
+
30
+ test_wrapper_t *cwrapper_alloc() {
31
+ test_wrapper_t *instance = malloc(sizeof(struct test_wrapper_s));
32
+
33
+ instance->integer = 1985;
34
+ instance->string = malloc(256);
35
+ instance->string[0] = '\0';
36
+
37
+ fprintf(stderr, "created: %p\n", instance);
38
+
39
+ return instance;
40
+ }
41
+
42
+ uint32_t cwrapper_get_integer(test_wrapper_t *instance) {
43
+ fprintf(stderr, "instance: %p\n", instance);
44
+ return instance->integer;
45
+ }
46
+
47
+ const char *cwrapper_get_string(test_wrapper_t *instance) {
48
+ fprintf(stderr, "instance: %p\n", instance);
49
+ return instance->string;
50
+ }
51
+
52
+ int cwrapper_set_string(test_wrapper_t *instance, const char *string) {
53
+ fprintf(stderr, "instance: %p\n", instance);
54
+ if (strlen(string) > 255) return 0;
55
+
56
+ strncpy(instance->string, string, 255);
57
+
58
+ return 1;
59
+ }
60
+
61
+ void cwrapper_set_integer(test_wrapper_t *instance, uint32_t integer) {
62
+ fprintf(stderr, "instance: %p\n", instance);
63
+ instance->integer = integer;
64
+ }
65
+
66
+ uint32_t cwrapper_get_default_integer() {
67
+ return 1985;
68
+ }
69
+
70
+ void cwrapper_free(test_wrapper_t *instance) {
71
+ fprintf(stderr, "instance: %p\n", instance);
72
+ free(instance->string);
73
+ free(instance);
74
+ }