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

Sign up to get free protection for your applications and to get access to all the features.
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,194 @@
1
+ require 'lib/gecoder/version'
2
+
3
+ PROJECT_NAME = PKG_NAME = 'gecoder'
4
+ PKG_NAME_WITH_GECODE = 'gecoder-with-gecode'
5
+ PKG_VERSION = GecodeR::VERSION
6
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
7
+ PKG_FILE_NAME_WITH_GECODE = "#{PKG_NAME_WITH_GECODE}-#{PKG_VERSION}"
8
+ # The location where the precompiled DLL should be placed.
9
+ DLL_LOCATION = 'lib/gecode.dll'
10
+ EXT_DIR = 'ext'
11
+
12
+ desc 'Generate RDoc'
13
+ rd = Rake::RDocTask.new do |rdoc|
14
+ rdoc.rdoc_dir = 'doc/output/rdoc'
15
+ rdoc.title = 'Gecode/R'
16
+ rdoc.template = 'doc/rdoc/jamis.rb'
17
+ rdoc.options << '--line-numbers' << '--inline-source' <<
18
+ '--accessor' << 'delegate' << '--main' << 'README'
19
+ rdoc.rdoc_files.include('README', 'CHANGES', 'LGPL-LICENSE', 'lib/**/*.rb')
20
+ end
21
+
22
+ TMP_DIR = 'doc/tmp/rdoc_dev'
23
+ desc 'Generate RDoc, ignoring nodoc'
24
+ Rake::RDocTask.new(:rdoc_dev => :prepare_rdoc_dev) do |rdoc|
25
+ rdoc.rdoc_dir = 'doc/output/rdoc_dev'
26
+ rdoc.options << '--title' << 'Gecode/R Developers RDoc' << '--line-numbers' <<
27
+ '--inline-source' << '--accessor' << 'delegate'
28
+
29
+ rdoc.rdoc_files.include("#{TMP_DIR}/**/*.rb")
30
+ end
31
+
32
+ desc 'Copies the files that RDoc should parse, removing #:nodoc:'
33
+ task :prepare_rdoc_dev do
34
+ # Copy the rdoc and remove all #:nodoc: .
35
+ Dir['lib/**/*.rb'].each do |source_name|
36
+ destination_name = source_name.sub('lib', TMP_DIR)
37
+ FileUtils.makedirs File.dirname(destination_name)
38
+ destination = File.open(destination_name, 'w')
39
+ File.open(source_name) do |source|
40
+ source.each{ |line| destination << line.gsub('#:nodoc:', '' ) }
41
+ end
42
+ destination.close
43
+ end
44
+ end
45
+
46
+ spec = Gem::Specification.new do |s|
47
+ s.name = PKG_NAME
48
+ s.version = GecodeR::VERSION
49
+ s.summary = 'Ruby interface to Gecode, an environment for constraint programming.'
50
+ s.description = <<-end_description
51
+ Gecode/R is a Ruby interface to the Gecode constraint programming library.
52
+ Gecode/R is intended for people with no previous experience of constraint
53
+ programming, aiming to be easy to pick up and use.
54
+ end_description
55
+
56
+ s.files = FileList[
57
+ '[A-Z]*',
58
+ 'lib/**/*.rb',
59
+ 'example/**/*.rb',
60
+ 'src/**/*',
61
+ 'vendor/rust/**/*',
62
+ 'tasks/**/*',
63
+ 'specs/**/*',
64
+ 'ext/*.cpp',
65
+ 'ext/*.h',
66
+ 'ext/extconf.rb'
67
+ ].to_a
68
+ s.require_path = 'lib'
69
+ s.extensions << 'ext/extconf.rb'
70
+ s.requirements << 'Gecode 2.1.1'
71
+
72
+ s.has_rdoc = true
73
+ s.rdoc_options = rd.options
74
+ s.extra_rdoc_files = rd.rdoc_files
75
+ s.test_files = FileList['specs/**/*.rb']
76
+
77
+ s.authors = ["Gecode/R Development Team"]
78
+ s.email = "gecoder-users@rubyforge.org"
79
+ s.homepage = "http://gecoder.rubyforge.org"
80
+ s.rubyforge_project = "gecoder"
81
+
82
+ =begin
83
+ # Development dependencies.
84
+ # Not listed: rubygems >= 1.2
85
+ [['rake'],
86
+ ['webgen', '= 0.4.7'],
87
+ ['coderay'],
88
+ ['rspec', '>= 1.0'],
89
+ ['rcov'],
90
+ ['meta_project'],
91
+ ['rubyforge']].each do |dependency|
92
+ s.add_development_dependency(*dependency)
93
+ end
94
+ =end
95
+ end
96
+
97
+ # Create a clone of the gem spec with the precompiled binaries for Windows.
98
+ spec_windows_binary_with_gecode = spec.dup
99
+ spec_windows_binary_with_gecode.name = PKG_NAME_WITH_GECODE
100
+ spec_windows_binary_with_gecode.extensions = []
101
+ spec_windows_binary_with_gecode.requirements = []
102
+ # Add the precompiled Gecode DLLs and precompiled bindings.
103
+ spec_windows_binary_with_gecode.files = spec.files.dup -
104
+ FileList['ext/**/*'].to_a +
105
+ FileList['vendor/gecode/win32/lib/*'].to_a << 'lib/gecode.dll'
106
+ spec_windows_binary_with_gecode.platform = 'x86-mswin32-60' #Gem::Platform::WIN32
107
+
108
+ # Create a clone of the gem spec that includes Gecode.
109
+ spec_with_gecode = spec.dup
110
+ spec_with_gecode.name = PKG_NAME_WITH_GECODE
111
+ spec_with_gecode.extensions =
112
+ spec_with_gecode.extensions.dup.unshift 'ext/gecode-2.1.1/configure'
113
+ spec_with_gecode.requirements = []
114
+ spec_with_gecode.files = spec.files.dup + FileList['ext/gecode-*/**/*'].to_a
115
+
116
+ desc 'Generate Gecode/R Gem'
117
+ Rake::GemPackageTask.new(spec) do |pkg|
118
+ pkg.need_zip = true
119
+ pkg.need_tar = true
120
+ end
121
+
122
+ desc 'Generate Gecode/R + Gecode Gem'
123
+ Rake::GemPackageTask.new(spec_with_gecode) do |pkg|
124
+ pkg.need_zip = true
125
+ pkg.need_tar = true
126
+ end
127
+
128
+ desc 'Generate Gecode/R + Gecode Gem (windows binary)'
129
+ Rake::GemPackageTask.new(spec_windows_binary_with_gecode) do |pkg|
130
+ end
131
+
132
+ desc 'Precompiles the Gecode/R bindings for Windows platforms'
133
+ file 'lib/gecode.dll' do
134
+ cd 'ext' do
135
+ sh 'ruby -Iwin32 extconf-win32.rb'
136
+ sh 'make'
137
+ mv 'gecode.so', "../#{DLL_LOCATION}"
138
+ end
139
+ end
140
+
141
+ desc 'Removes generated distribution files'
142
+ task :clobber do
143
+ rm DLL_LOCATION if File.exists? DLL_LOCATION
144
+ FileList[
145
+ "#{EXT_DIR}/*.o",
146
+ "#{EXT_DIR}/gecode.{cc,hh}",
147
+ "#{EXT_DIR}/Makefile",
148
+ "#{EXT_DIR}/mkmf.log"
149
+ ].to_a.each{ |file| rm file if File.exists? file }
150
+ end
151
+
152
+ desc 'Publish packages on RubyForge'
153
+ task :publish_packages => [:publish_gecoder_packages,
154
+ :publish_gecoder_with_gecode_packages]
155
+
156
+ # Files included in the vanilla Gecode/R release.
157
+ vanilla_release_files = [
158
+ "pkg/#{PKG_FILE_NAME}.gem",
159
+ "pkg/#{PKG_FILE_NAME}.tgz",
160
+ "pkg/#{PKG_FILE_NAME}.zip"
161
+ ]
162
+ desc 'Publish Gecode/R packages on RubyForge'
163
+ task :publish_gecoder_packages => [:verify_user] + vanilla_release_files do
164
+ require 'meta_project'
165
+ require 'rake/contrib/xforge'
166
+
167
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PROJECT_NAME)) do |xf|
168
+ xf.user_name = ENV['RUBYFORGE_USER']
169
+ xf.files = vanilla_release_files.to_a
170
+ xf.release_name = "Gecode/R #{PKG_VERSION}"
171
+ xf.package_name = PKG_NAME
172
+ end
173
+ end
174
+
175
+ # Files included in the release with Gecode.
176
+ gecode_release_files = [
177
+ "pkg/#{PKG_FILE_NAME_WITH_GECODE}.gem",
178
+ #"pkg/#{PKG_FILE_NAME_WITH_GECODE}.tgz",
179
+ #"pkg/#{PKG_FILE_NAME_WITH_GECODE}.zip",
180
+ "pkg/#{PKG_FILE_NAME_WITH_GECODE}-x86-mswin32.gem"
181
+ ]
182
+ desc 'Publish Gecode/R with Gecode packages on RubyForge'
183
+ task :publish_gecoder_with_gecode_packages =>
184
+ [:verify_user] + gecode_release_files do
185
+ require 'meta_project'
186
+ require 'rake/contrib/xforge'
187
+
188
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PROJECT_NAME)) do |xf|
189
+ xf.user_name = ENV['RUBYFORGE_USER']
190
+ xf.files = gecode_release_files.to_a
191
+ xf.release_name = "Gecode/R with Gecode #{PKG_VERSION}"
192
+ xf.package_name = PKG_NAME_WITH_GECODE
193
+ end
194
+ end
data/tasks/rcov.rake ADDED
@@ -0,0 +1,18 @@
1
+ require 'spec/rake/spectask'
2
+ require 'spec/rake/verify_rcov'
3
+
4
+ RCOV_DIR = "#{File.dirname(__FILE__)}/../doc/output/coverage"
5
+
6
+ desc "Run all specs (except examples) with rcov"
7
+ Spec::Rake::SpecTask.new(:rcov) do |t|
8
+ t.spec_files = FileList['specs/**/*.rb']
9
+ t.spec_files.exclude 'examples.rb'
10
+ t.rcov = true
11
+ t.rcov_opts = ['--exclude examples', '--exclude specs']
12
+ t.rcov_dir = RCOV_DIR
13
+ end
14
+
15
+ RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
16
+ t.threshold = 100.0
17
+ t.index_html = "#{RCOV_DIR}/index.html"
18
+ end
data/tasks/specs.rake ADDED
@@ -0,0 +1,21 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ spec_files = FileList['specs/**/*.rb']
4
+
5
+ desc 'Run all specs'
6
+ Spec::Rake::SpecTask.new(:specs) do |t|
7
+ t.libs = ['lib']
8
+ t.spec_files = spec_files
9
+ end
10
+
11
+ desc 'Run specs for the examples'
12
+ Spec::Rake::SpecTask.new(:example_specs) do |t|
13
+ t.libs = ['lib']
14
+ t.spec_files = FileList['specs/examples.rb']
15
+ end
16
+
17
+ desc 'Generate an rspec html report'
18
+ Spec::Rake::SpecTask.new(:spec_html) do |t|
19
+ t.spec_files = spec_files
20
+ t.spec_opts = ['--format html:doc/output/rspec.html','--backtrace']
21
+ end
data/tasks/svn.rake ADDED
@@ -0,0 +1,16 @@
1
+ require 'lib/gecoder/version'
2
+
3
+ desc "Tag the release in svn"
4
+ task :tag do
5
+ base_url = `svn info`.match(/Repository Root: (.*)/n)[1]
6
+ unless base_url.include? ENV['RUBYFORGE_USER']
7
+ base_url.gsub!('rubyforge', "#{ENV['RUBYFORGE_USER']}@rubyforge")
8
+ end
9
+ from = base_url + '/trunk'
10
+ to = base_url + "/tags/gecoder-#{GecodeR::VERSION}"
11
+ options = "-m \"Tag release Gecode/R #{GecodeR::VERSION}\""
12
+
13
+ puts "Creating tag in SVN"
14
+ tag_cmd = "svn cp #{from} #{to} #{options}"
15
+ `#{tag_cmd}` ; raise "ERROR: #{tag_cmd}" unless $? == 0
16
+ end
@@ -0,0 +1,51 @@
1
+ require 'rake/contrib/rubyforgepublisher'
2
+
3
+ desc 'Regenerates the contents of the website'
4
+ task :website do
5
+ mkpath 'doc/output'
6
+ Rake::Task[:spec_html].invoke
7
+ Rake::Task[:rdoc].invoke
8
+ Rake::Task[:rdoc_dev].invoke
9
+ Rake::Task[:rcov].invoke
10
+ WebsiteRakeHelpers.webgen
11
+ end
12
+
13
+ desc 'Removes generated documentation'
14
+ task :clobber do
15
+ WebsiteRakeHelpers.clobber
16
+ end
17
+
18
+ task :verify_user do
19
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
20
+ end
21
+
22
+ desc "Uploads the website to RubyForge"
23
+ task :publish_website => [:verify_user, :website] do
24
+ publisher = Rake::SshDirPublisher.new(
25
+ "#{ENV['RUBYFORGE_USER']}@rubyforge.org",
26
+ "/var/www/gforge-projects/gecoder",
27
+ "doc/output"
28
+ )
29
+ publisher.upload
30
+ end
31
+
32
+ module WebsiteRakeHelpers
33
+ module_function
34
+
35
+ # Remove generated documentation.
36
+ def clobber
37
+ rm_rf 'doc/output'
38
+ rm_rf 'doc/tmp'
39
+ end
40
+
41
+ # Generates the website with webgen.
42
+ def webgen
43
+ Dir.chdir 'doc' do
44
+ output = nil
45
+ IO.popen('webgen 2>&1') do |io|
46
+ output = io.read
47
+ end
48
+ raise "ERROR while running webgen: #{output}" if output =~ /ERROR/n || $? != 0
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,28 @@
1
+ When I wanted to write a GUI tagger for KDE using Korundum (KDE Ruby
2
+ bindings), I discovered to my sadness that most of the tagging
3
+ extensions for Ruby were simple bindings for the C interface of the
4
+ most common TagLib library (that is written in C++ instead); writing
5
+ bindings for the C++ interface was quite a complex task, and boring as
6
+ it was to copy and paste the same code over and over.
7
+
8
+ For this reason I started first writing a simple extensions generator
9
+ that used a YAML description of the namespaces and the classes to
10
+ write bindings for. This method worked fine for what I was working on
11
+ (RubyTag++), and also allowed me to write quite quickly some Ruby
12
+ bindings for Hunspell too.
13
+
14
+ Unfortunately this generator was not adaptable enough to write
15
+ bindings for C libraries that used some object oriented interfaces,
16
+ and was a mess to extend to provide bindings more suitable to some
17
+ different cases than the ones I've already used the script for.
18
+
19
+ For this reason I've started working on Rust: a more flexible
20
+ extensions builder, that allowed to bind even C libraries by faking
21
+ some classes on Ruby (although I haven't implemented this yet).
22
+
23
+ Hopefully in the future Rust can be used to easily produce Ruby
24
+ bindings for a number of libraries that currently aren't available at
25
+ all.
26
+
27
+ To contact me, send me patches or comments, just write to
28
+ <flameeyes@gmail.com> .
@@ -0,0 +1,93 @@
1
+
2
+ require 'rust/cppifaceparser'
3
+
4
+
5
+ if __FILE__ == $0
6
+ def usage
7
+ puts "Use: #{File.basename($0)} [header] [module name] [output file]"
8
+ end
9
+
10
+ parser = Rust::Cpp::IfaceParser.new
11
+
12
+ if ARGV.size != 3 or not File.exists?(ARGV[0].to_s)
13
+ usage
14
+ exit 0
15
+ end
16
+
17
+ header = ARGV[0]
18
+ namespace = ARGV[1]
19
+ outputfile = ARGV[2]
20
+ outputfile += ".rb" if not outputfile =~ /\.rb$/
21
+
22
+ classes = parser.parseFile(header)
23
+
24
+ rust = %@
25
+ require 'rust'
26
+
27
+ Rust::Bindings::create_bindings Rust::Bindings::LangCxx, "#{namespace}" do |b|
28
+ b.include_header '#{header}', Rust::Bindings::HeaderGlobal
29
+ b.add_namespace "#{namespace}", "" do |ns|
30
+ @
31
+ classes.each { |klass|
32
+ rust += %@ ns.add_cxx_class "#{klass[:name]}" do |klass|\n@
33
+ klass[:constructors].each { |constructor|
34
+ rust += " klass.add_constructor "
35
+ if not constructor[:params].empty? and not constructor[:params].detect { |p| p[:type] =~ /void/ }
36
+ rust += "do |method|\n"
37
+ constructor[:params].each { |param|
38
+ rust += %@ method.add_parameter "#{param[:type]}", "#{param[:name]}"\n@
39
+ }
40
+ rust += " end"
41
+ end
42
+ rust += "\n"
43
+ }
44
+
45
+ klass[:methods].each { |method|
46
+ comment_method = false
47
+ if method[:params].detect { |p| p[:type] =~ /\s*\*\s*\*/ }
48
+ $stderr << "Ignoring method: #{method[:name]}\n"
49
+ comment_method = true
50
+ end
51
+
52
+ rust += "# " if comment_method
53
+ rust += %@ klass.add_method "#{method[:name]}", "#{method[:type]}"@
54
+ if not method[:params].empty? and not method[:params].detect { |p| p[:type] =~ /void/ }
55
+ rust += " do |method|\n" if not method[:params].empty?
56
+
57
+
58
+ method[:params].each { |param|
59
+ rust += "# " if comment_method
60
+ rust += %@ method.add_parameter "#{param[:type]}", "#{param[:name]}"\n@
61
+ }
62
+ rust += "# " if comment_method
63
+ rust += " end"
64
+ end
65
+
66
+ rust += "\n"
67
+ }
68
+ rust += " end\n"
69
+ }
70
+
71
+ rust += %@
72
+ end
73
+ end
74
+ @
75
+
76
+ File.open( outputfile, "w" ) { |f|
77
+ f << rust << "\n"
78
+ }
79
+
80
+ # Create configure.rb
81
+ File.open( File.dirname(outputfile)+"/configure.rb", "w" ) { |f|
82
+ f << %@
83
+ require 'mkmf'
84
+ find_header("rust_conversions.hh", "./include" )
85
+ eval File.open("#{File.basename(outputfile)}").readlines.to_s
86
+ create_makefile("#{namespace}")
87
+ @
88
+ }
89
+
90
+ end
91
+
92
+
93
+
@@ -0,0 +1,116 @@
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
+
24
+ #ifndef __RUST_CHECKS__
25
+ #define __RUST_CHECKS__
26
+
27
+ #include <ruby.h>
28
+
29
+ static inline void rust_CheckType(VALUE *a)
30
+ {
31
+ Check_Type(a[0], NUM2INT(a[1]));
32
+ }
33
+
34
+ static inline bool isType(VALUE val, int type)
35
+ {
36
+ int result;
37
+ if( type == 0x0 ) return false;
38
+
39
+ VALUE args[2];
40
+ args[0] = (VALUE)val;
41
+ args[1] = INT2FIX(type);
42
+
43
+ rb_protect( (VALUE(*)(VALUE))rust_CheckType, (VALUE)args, &result);
44
+ return result == 0;
45
+ }
46
+
47
+
48
+ static inline bool is_object(VALUE val)
49
+ {
50
+ return isType(val, T_OBJECT);
51
+ }
52
+
53
+ static inline bool is_class(VALUE val)
54
+ {
55
+ return isType(val, T_CLASS);
56
+ }
57
+
58
+ static inline bool is_module(VALUE val)
59
+ {
60
+ return isType(val, T_MODULE);
61
+ }
62
+
63
+ static inline bool is_fLoat(VALUE val)
64
+ {
65
+ return isType(val, T_FLOAT);
66
+ }
67
+
68
+ static inline bool is_string(VALUE val)
69
+ {
70
+ return isType(val, T_STRING);
71
+ }
72
+
73
+ static inline bool is_regexp(VALUE val)
74
+ {
75
+ return isType(val, T_REGEXP);
76
+ }
77
+
78
+ static inline bool is_array(VALUE val)
79
+ {
80
+ return isType(val, T_ARRAY);
81
+ }
82
+
83
+ static inline bool is_int(VALUE val)
84
+ {
85
+ return isType(val, T_FIXNUM) ||
86
+ (isType(val, T_BIGNUM) && NUM2INT(val) < INT_MAX);
87
+ }
88
+
89
+ static inline bool is_hash(VALUE val)
90
+ {
91
+ return isType(val, T_HASH);
92
+ }
93
+
94
+ static inline bool is_symbol(VALUE val)
95
+ {
96
+ return isType(val, T_SYMBOL);
97
+ }
98
+
99
+ static inline bool is_bool(VALUE val)
100
+ {
101
+ return val == Qtrue || val == Qfalse;
102
+ }
103
+
104
+ static inline bool is_charPtr(VALUE val)
105
+ {
106
+ char *c = 0;
107
+ c = reinterpret_cast<char *>(DATA_PTR(val));
108
+
109
+ return c != 0; // FIXME
110
+ }
111
+
112
+
113
+
114
+
115
+ #endif
116
+