win32-api 1.4.8 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (564) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +212 -144
  3. data/Dockerfile +99 -0
  4. data/Dockerfile.trunk +17 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +24 -0
  7. data/MANIFEST +9 -9
  8. data/{README → README.md} +136 -106
  9. data/RELEASE.md +32 -0
  10. data/Rakefile +261 -128
  11. data/appveyor.yml +46 -0
  12. data/build-gem.bat +3 -0
  13. data/ext/Makefile +267 -0
  14. data/ext/api-x64-mingw32.def +2 -0
  15. data/ext/api.o +0 -0
  16. data/ext/api.so +0 -0
  17. data/ext/extconf.rb +15 -11
  18. data/ext/mkmf.log +38 -0
  19. data/ext/win32/api.c +1102 -949
  20. data/ext/win32/api.so +0 -0
  21. data/test.rb +10 -0
  22. data/test/test_win32_api.rb +145 -148
  23. data/test/test_win32_api_callback.rb +74 -74
  24. data/test/test_win32_api_function.rb +66 -66
  25. data/vendor/bundle/ruby/2.5.0/bin/rake +27 -0
  26. data/vendor/bundle/ruby/2.5.0/bin/rake-compiler-dock +27 -0
  27. data/vendor/bundle/ruby/2.5.0/bin/rake-compiler-dock.bat +6 -0
  28. data/vendor/bundle/ruby/2.5.0/bin/rake.bat +6 -0
  29. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/BSDL +22 -0
  30. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/COPYING +57 -0
  31. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/Gemfile +9 -0
  32. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/LEGAL +4 -0
  33. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/README.rdoc +81 -0
  34. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/Rakefile +59 -0
  35. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/bin/console +12 -0
  36. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/bin/setup +6 -0
  37. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert.rb +98 -0
  38. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert/colorize.rb +9 -0
  39. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert/configuration.rb +46 -0
  40. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert/context.rb +235 -0
  41. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert/enable_tracepoint_events.rb +91 -0
  42. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert/inspector.rb +61 -0
  43. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert/parser.rb +251 -0
  44. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/lib/power_assert/version.rb +3 -0
  45. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.5/power_assert.gemspec +31 -0
  46. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/BSDL +22 -0
  47. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/COPYING +57 -0
  48. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/Gemfile +9 -0
  49. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/LEGAL +4 -0
  50. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/README.rdoc +81 -0
  51. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/Rakefile +59 -0
  52. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/bin/console +12 -0
  53. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/bin/setup +6 -0
  54. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert.rb +98 -0
  55. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert/colorize.rb +9 -0
  56. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert/configuration.rb +46 -0
  57. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert/context.rb +238 -0
  58. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert/enable_tracepoint_events.rb +91 -0
  59. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert/inspector.rb +61 -0
  60. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert/parser.rb +251 -0
  61. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/lib/power_assert/version.rb +3 -0
  62. data/vendor/bundle/ruby/2.5.0/gems/power_assert-1.1.7/power_assert.gemspec +31 -0
  63. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/CONTRIBUTING.rdoc +43 -0
  64. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/Gemfile +10 -0
  65. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/History.rdoc +2368 -0
  66. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/MIT-LICENSE +21 -0
  67. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/README.rdoc +155 -0
  68. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/Rakefile +41 -0
  69. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/bin/bundle +105 -0
  70. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/bin/console +7 -0
  71. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/bin/rake +29 -0
  72. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/bin/rdoc +29 -0
  73. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/bin/rubocop +29 -0
  74. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/bin/setup +6 -0
  75. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/command_line_usage.rdoc +158 -0
  76. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/example/Rakefile1 +38 -0
  77. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/example/Rakefile2 +35 -0
  78. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/example/a.c +6 -0
  79. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/example/b.c +6 -0
  80. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/example/main.c +11 -0
  81. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/glossary.rdoc +42 -0
  82. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/jamis.rb +592 -0
  83. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/proto_rake.rdoc +127 -0
  84. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/rake.1 +156 -0
  85. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/rakefile.rdoc +622 -0
  86. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/doc/rational.rdoc +151 -0
  87. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake +27 -0
  88. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake.rb +71 -0
  89. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/application.rb +824 -0
  90. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/backtrace.rb +24 -0
  91. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/clean.rb +78 -0
  92. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/cloneable.rb +17 -0
  93. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/cpu_counter.rb +107 -0
  94. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/default_loader.rb +15 -0
  95. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/dsl_definition.rb +195 -0
  96. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/early_time.rb +22 -0
  97. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/ext/core.rb +26 -0
  98. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/ext/string.rb +176 -0
  99. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/file_creation_task.rb +25 -0
  100. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/file_list.rb +435 -0
  101. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/file_task.rb +54 -0
  102. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/file_utils.rb +134 -0
  103. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/file_utils_ext.rb +134 -0
  104. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/invocation_chain.rb +57 -0
  105. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/invocation_exception_mixin.rb +17 -0
  106. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/late_time.rb +18 -0
  107. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/linked_list.rb +112 -0
  108. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/loaders/makefile.rb +54 -0
  109. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/multi_task.rb +14 -0
  110. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/name_space.rb +38 -0
  111. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/packagetask.rb +222 -0
  112. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/phony.rb +16 -0
  113. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/private_reader.rb +21 -0
  114. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/promise.rb +100 -0
  115. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/pseudo_status.rb +30 -0
  116. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/rake_module.rb +67 -0
  117. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/rake_test_loader.rb +27 -0
  118. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/rule_recursion_overflow_error.rb +20 -0
  119. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/scope.rb +43 -0
  120. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/task.rb +434 -0
  121. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/task_argument_error.rb +8 -0
  122. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/task_arguments.rb +109 -0
  123. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/task_manager.rb +331 -0
  124. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/tasklib.rb +12 -0
  125. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/testtask.rb +224 -0
  126. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/thread_history_display.rb +49 -0
  127. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/thread_pool.rb +163 -0
  128. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/trace_output.rb +23 -0
  129. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/version.rb +10 -0
  130. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/lib/rake/win32.rb +51 -0
  131. data/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/rake.gemspec +43 -0
  132. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/Dockerfile.jruby +61 -0
  133. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/Dockerfile.mri +122 -0
  134. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/Gemfile +8 -0
  135. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/History.md +130 -0
  136. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/LICENSE.txt +22 -0
  137. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/README.md +162 -0
  138. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/Rakefile +36 -0
  139. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/bin/rake-compiler-dock +18 -0
  140. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/mk_i686.rb +16 -0
  141. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/patches/rake-compiler-1.0.7/enable-static.diff +13 -0
  142. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/patches/ruby-2.5.3/no_sendfile.patch +24 -0
  143. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/runas +12 -0
  144. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/sigfw.c +45 -0
  145. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/strip_wrapper +30 -0
  146. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/sudoers +1 -0
  147. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/lib/rake_compiler_dock.rb +66 -0
  148. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/lib/rake_compiler_dock/colors.rb +43 -0
  149. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/lib/rake_compiler_dock/docker_check.rb +350 -0
  150. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/lib/rake_compiler_dock/gem_helper.rb +73 -0
  151. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/lib/rake_compiler_dock/predefined_user_group.rb +5 -0
  152. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/lib/rake_compiler_dock/starter.rb +155 -0
  153. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/lib/rake_compiler_dock/version.rb +4 -0
  154. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/rake-compiler-dock.gemspec +28 -0
  155. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/test/test_environment_variables.rb +54 -0
  156. data/vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/test/test_starter.rb +33 -0
  157. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/COPYING +67 -0
  158. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/GPL +339 -0
  159. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/LGPL +502 -0
  160. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/PSFL +271 -0
  161. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/README.md +101 -0
  162. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/Rakefile +80 -0
  163. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/doc/text/getting-started.md +246 -0
  164. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/doc/text/how-to.md +90 -0
  165. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/doc/text/news.md +1453 -0
  166. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test-unit.rb +34 -0
  167. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit.rb +514 -0
  168. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/assertion-failed-error.rb +25 -0
  169. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/assertions.rb +2256 -0
  170. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/attribute-matcher.rb +26 -0
  171. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/attribute.rb +227 -0
  172. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/auto-runner-loader.rb +17 -0
  173. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/autorunner.rb +537 -0
  174. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/code-snippet-fetcher.rb +56 -0
  175. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/collector.rb +73 -0
  176. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/collector/descendant.rb +19 -0
  177. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/collector/dir.rb +108 -0
  178. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/collector/load.rb +197 -0
  179. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/collector/objectspace.rb +34 -0
  180. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/collector/xml.rb +249 -0
  181. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/color-scheme.rb +198 -0
  182. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/color.rb +134 -0
  183. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/data-sets.rb +116 -0
  184. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/data.rb +371 -0
  185. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/diff.rb +746 -0
  186. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/error.rb +158 -0
  187. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/exception-handler.rb +82 -0
  188. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/failure.rb +169 -0
  189. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/fault-location-detector.rb +100 -0
  190. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/fixture.rb +298 -0
  191. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/notification.rb +138 -0
  192. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/omission.rb +198 -0
  193. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/pending.rb +155 -0
  194. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/priority.rb +196 -0
  195. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/runner/console.rb +84 -0
  196. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/runner/emacs.rb +8 -0
  197. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/runner/xml.rb +15 -0
  198. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/test-suite-creator.rb +103 -0
  199. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/testcase.rb +899 -0
  200. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/testresult.rb +132 -0
  201. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/testsuite.rb +175 -0
  202. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/ui/console/outputlevel.rb +15 -0
  203. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/ui/console/testrunner.rb +750 -0
  204. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  205. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/ui/testrunner.rb +53 -0
  206. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/ui/testrunnermediator.rb +114 -0
  207. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  208. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/ui/xml/testrunner.rb +224 -0
  209. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/util/backtracefilter.rb +59 -0
  210. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/util/method-owner-finder.rb +28 -0
  211. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/util/observable.rb +90 -0
  212. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/util/output.rb +32 -0
  213. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/util/procwrapper.rb +48 -0
  214. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/lib/test/unit/version.rb +5 -0
  215. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/sample/adder.rb +13 -0
  216. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/sample/subtracter.rb +12 -0
  217. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/sample/test_adder.rb +20 -0
  218. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/sample/test_subtracter.rb +20 -0
  219. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/sample/test_user.rb +23 -0
  220. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/collector/test-descendant.rb +182 -0
  221. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/collector/test-load.rb +475 -0
  222. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/collector/test_dir.rb +407 -0
  223. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/collector/test_objectspace.rb +102 -0
  224. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/fixtures/header-label.csv +3 -0
  225. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/fixtures/header-label.tsv +3 -0
  226. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/fixtures/header.csv +3 -0
  227. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/fixtures/header.tsv +3 -0
  228. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/fixtures/no-header.csv +2 -0
  229. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/fixtures/no-header.tsv +2 -0
  230. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/fixtures/plus.csv +3 -0
  231. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/run-test.rb +22 -0
  232. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-assertions.rb +2187 -0
  233. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-attribute-matcher.rb +38 -0
  234. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-attribute.rb +123 -0
  235. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-code-snippet.rb +79 -0
  236. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-color-scheme.rb +82 -0
  237. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-color.rb +47 -0
  238. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-data.rb +419 -0
  239. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-diff.rb +518 -0
  240. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-emacs-runner.rb +60 -0
  241. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-error.rb +26 -0
  242. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-failure.rb +33 -0
  243. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-fault-location-detector.rb +163 -0
  244. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-fixture.rb +713 -0
  245. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-notification.rb +33 -0
  246. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-omission.rb +81 -0
  247. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-pending.rb +70 -0
  248. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-priority.rb +184 -0
  249. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-test-case.rb +1279 -0
  250. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-test-result.rb +113 -0
  251. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-test-suite-creator.rb +97 -0
  252. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/test-test-suite.rb +151 -0
  253. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/testunit-test-util.rb +33 -0
  254. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/ui/test_testrunmediator.rb +20 -0
  255. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/util/test-method-owner-finder.rb +38 -0
  256. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/util/test-output.rb +11 -0
  257. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/util/test_backtracefilter.rb +52 -0
  258. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/util/test_observable.rb +102 -0
  259. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.4/test/util/test_procwrapper.rb +36 -0
  260. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/COPYING +67 -0
  261. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/GPL +339 -0
  262. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/LGPL +502 -0
  263. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/PSFL +271 -0
  264. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/README.md +101 -0
  265. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/Rakefile +80 -0
  266. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/doc/text/getting-started.md +246 -0
  267. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/doc/text/how-to.md +90 -0
  268. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/doc/text/news.md +1464 -0
  269. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test-unit.rb +34 -0
  270. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit.rb +514 -0
  271. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/assertion-failed-error.rb +25 -0
  272. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/assertions.rb +2256 -0
  273. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/attribute-matcher.rb +26 -0
  274. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/attribute.rb +227 -0
  275. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/auto-runner-loader.rb +17 -0
  276. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/autorunner.rb +537 -0
  277. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/code-snippet-fetcher.rb +58 -0
  278. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/collector.rb +73 -0
  279. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/collector/descendant.rb +19 -0
  280. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/collector/dir.rb +108 -0
  281. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/collector/load.rb +197 -0
  282. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/collector/objectspace.rb +34 -0
  283. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/collector/xml.rb +249 -0
  284. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/color-scheme.rb +198 -0
  285. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/color.rb +134 -0
  286. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/data-sets.rb +116 -0
  287. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/data.rb +371 -0
  288. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/diff.rb +746 -0
  289. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/error.rb +158 -0
  290. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/exception-handler.rb +82 -0
  291. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/failure.rb +169 -0
  292. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/fault-location-detector.rb +100 -0
  293. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/fixture.rb +298 -0
  294. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/notification.rb +138 -0
  295. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/omission.rb +198 -0
  296. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/pending.rb +155 -0
  297. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/priority.rb +196 -0
  298. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/runner/console.rb +84 -0
  299. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/runner/emacs.rb +8 -0
  300. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/runner/xml.rb +15 -0
  301. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/test-suite-creator.rb +103 -0
  302. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/testcase.rb +899 -0
  303. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/testresult.rb +132 -0
  304. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/testsuite.rb +175 -0
  305. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/ui/console/outputlevel.rb +15 -0
  306. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/ui/console/testrunner.rb +750 -0
  307. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  308. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/ui/testrunner.rb +53 -0
  309. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/ui/testrunnermediator.rb +114 -0
  310. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  311. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/ui/xml/testrunner.rb +224 -0
  312. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/util/backtracefilter.rb +59 -0
  313. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/util/method-owner-finder.rb +28 -0
  314. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/util/observable.rb +90 -0
  315. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/util/output.rb +32 -0
  316. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/util/procwrapper.rb +48 -0
  317. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/lib/test/unit/version.rb +5 -0
  318. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/sample/adder.rb +13 -0
  319. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/sample/subtracter.rb +12 -0
  320. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/sample/test_adder.rb +20 -0
  321. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/sample/test_subtracter.rb +20 -0
  322. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/sample/test_user.rb +23 -0
  323. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/collector/test-descendant.rb +182 -0
  324. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/collector/test-load.rb +475 -0
  325. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/collector/test_dir.rb +407 -0
  326. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/collector/test_objectspace.rb +102 -0
  327. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/fixtures/header-label.csv +3 -0
  328. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/fixtures/header-label.tsv +3 -0
  329. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/fixtures/header.csv +3 -0
  330. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/fixtures/header.tsv +3 -0
  331. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/fixtures/no-header.csv +2 -0
  332. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/fixtures/no-header.tsv +2 -0
  333. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/fixtures/plus.csv +3 -0
  334. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/run-test.rb +22 -0
  335. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-assertions.rb +2187 -0
  336. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-attribute-matcher.rb +38 -0
  337. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-attribute.rb +123 -0
  338. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-code-snippet.rb +79 -0
  339. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-color-scheme.rb +82 -0
  340. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-color.rb +47 -0
  341. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-data.rb +419 -0
  342. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-diff.rb +518 -0
  343. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-emacs-runner.rb +60 -0
  344. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-error.rb +26 -0
  345. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-failure.rb +33 -0
  346. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-fault-location-detector.rb +163 -0
  347. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-fixture.rb +713 -0
  348. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-notification.rb +33 -0
  349. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-omission.rb +81 -0
  350. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-pending.rb +70 -0
  351. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-priority.rb +184 -0
  352. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-test-case.rb +1279 -0
  353. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-test-result.rb +113 -0
  354. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-test-suite-creator.rb +97 -0
  355. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/test-test-suite.rb +151 -0
  356. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/testunit-test-util.rb +33 -0
  357. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/ui/test_testrunmediator.rb +20 -0
  358. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/util/test-method-owner-finder.rb +38 -0
  359. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/util/test-output.rb +11 -0
  360. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/util/test_backtracefilter.rb +52 -0
  361. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/util/test_observable.rb +102 -0
  362. data/vendor/bundle/ruby/2.5.0/gems/test-unit-3.3.5/test/util/test_procwrapper.rb +36 -0
  363. data/vendor/bundle/ruby/2.5.0/specifications/power_assert-1.1.5.gemspec +54 -0
  364. data/vendor/bundle/ruby/2.5.0/specifications/power_assert-1.1.7.gemspec +54 -0
  365. data/vendor/bundle/ruby/2.5.0/specifications/rake-13.0.1.gemspec +26 -0
  366. data/vendor/bundle/ruby/2.5.0/specifications/rake-compiler-dock-0.7.2.gemspec +40 -0
  367. data/vendor/bundle/ruby/2.5.0/specifications/test-unit-3.3.4.gemspec +48 -0
  368. data/vendor/bundle/ruby/2.5.0/specifications/test-unit-3.3.5.gemspec +48 -0
  369. data/vendor/bundle/ruby/2.7.0/bin/rake +27 -0
  370. data/vendor/bundle/ruby/2.7.0/bin/rake.bat +2 -0
  371. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/BSDL +22 -0
  372. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/COPYING +57 -0
  373. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/Gemfile +9 -0
  374. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/LEGAL +4 -0
  375. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/README.rdoc +81 -0
  376. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/Rakefile +59 -0
  377. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/bin/console +12 -0
  378. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/bin/setup +6 -0
  379. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert.rb +98 -0
  380. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert/colorize.rb +9 -0
  381. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert/configuration.rb +46 -0
  382. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert/context.rb +238 -0
  383. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert/enable_tracepoint_events.rb +91 -0
  384. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert/inspector.rb +61 -0
  385. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert/parser.rb +251 -0
  386. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/lib/power_assert/version.rb +3 -0
  387. data/vendor/bundle/ruby/2.7.0/gems/power_assert-1.1.7/power_assert.gemspec +31 -0
  388. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/CONTRIBUTING.rdoc +43 -0
  389. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/Gemfile +10 -0
  390. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/History.rdoc +2368 -0
  391. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/MIT-LICENSE +21 -0
  392. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/README.rdoc +155 -0
  393. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/Rakefile +41 -0
  394. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/bin/bundle +105 -0
  395. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/bin/console +7 -0
  396. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/bin/rake +29 -0
  397. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/bin/rdoc +29 -0
  398. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/bin/rubocop +29 -0
  399. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/bin/setup +6 -0
  400. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/command_line_usage.rdoc +158 -0
  401. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/example/Rakefile1 +38 -0
  402. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/example/Rakefile2 +35 -0
  403. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/example/a.c +6 -0
  404. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/example/b.c +6 -0
  405. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/example/main.c +11 -0
  406. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/glossary.rdoc +42 -0
  407. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/jamis.rb +592 -0
  408. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/proto_rake.rdoc +127 -0
  409. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/rake.1 +156 -0
  410. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/rakefile.rdoc +622 -0
  411. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/doc/rational.rdoc +151 -0
  412. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/exe/rake +27 -0
  413. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake.rb +71 -0
  414. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/application.rb +824 -0
  415. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/backtrace.rb +24 -0
  416. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/clean.rb +78 -0
  417. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/cloneable.rb +17 -0
  418. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/cpu_counter.rb +107 -0
  419. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/default_loader.rb +15 -0
  420. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/dsl_definition.rb +195 -0
  421. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/early_time.rb +22 -0
  422. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/ext/core.rb +26 -0
  423. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/ext/string.rb +176 -0
  424. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/file_creation_task.rb +25 -0
  425. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/file_list.rb +435 -0
  426. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/file_task.rb +54 -0
  427. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/file_utils.rb +134 -0
  428. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/file_utils_ext.rb +134 -0
  429. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/invocation_chain.rb +57 -0
  430. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/invocation_exception_mixin.rb +17 -0
  431. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/late_time.rb +18 -0
  432. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/linked_list.rb +112 -0
  433. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/loaders/makefile.rb +54 -0
  434. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/multi_task.rb +14 -0
  435. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/name_space.rb +38 -0
  436. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/packagetask.rb +222 -0
  437. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/phony.rb +16 -0
  438. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/private_reader.rb +21 -0
  439. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/promise.rb +100 -0
  440. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/pseudo_status.rb +30 -0
  441. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/rake_module.rb +67 -0
  442. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/rake_test_loader.rb +27 -0
  443. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/rule_recursion_overflow_error.rb +20 -0
  444. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/scope.rb +43 -0
  445. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/task.rb +434 -0
  446. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/task_argument_error.rb +8 -0
  447. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/task_arguments.rb +109 -0
  448. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/task_manager.rb +331 -0
  449. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/tasklib.rb +12 -0
  450. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/testtask.rb +224 -0
  451. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/thread_history_display.rb +49 -0
  452. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/thread_pool.rb +163 -0
  453. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/trace_output.rb +23 -0
  454. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/version.rb +10 -0
  455. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/lib/rake/win32.rb +51 -0
  456. data/vendor/bundle/ruby/2.7.0/gems/rake-13.0.1/rake.gemspec +43 -0
  457. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/COPYING +67 -0
  458. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/GPL +339 -0
  459. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/LGPL +502 -0
  460. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/PSFL +271 -0
  461. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/README.md +101 -0
  462. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/Rakefile +80 -0
  463. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/doc/text/getting-started.md +246 -0
  464. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/doc/text/how-to.md +90 -0
  465. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/doc/text/news.md +1464 -0
  466. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test-unit.rb +34 -0
  467. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit.rb +514 -0
  468. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/assertion-failed-error.rb +25 -0
  469. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/assertions.rb +2256 -0
  470. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/attribute-matcher.rb +26 -0
  471. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/attribute.rb +227 -0
  472. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/auto-runner-loader.rb +17 -0
  473. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/autorunner.rb +537 -0
  474. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/code-snippet-fetcher.rb +58 -0
  475. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/collector.rb +73 -0
  476. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/collector/descendant.rb +19 -0
  477. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/collector/dir.rb +108 -0
  478. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/collector/load.rb +197 -0
  479. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/collector/objectspace.rb +34 -0
  480. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/collector/xml.rb +249 -0
  481. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/color-scheme.rb +198 -0
  482. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/color.rb +134 -0
  483. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/data-sets.rb +116 -0
  484. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/data.rb +371 -0
  485. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/diff.rb +746 -0
  486. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/error.rb +158 -0
  487. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/exception-handler.rb +82 -0
  488. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/failure.rb +169 -0
  489. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/fault-location-detector.rb +100 -0
  490. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/fixture.rb +298 -0
  491. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/notification.rb +138 -0
  492. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/omission.rb +198 -0
  493. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/pending.rb +155 -0
  494. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/priority.rb +196 -0
  495. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/runner/console.rb +84 -0
  496. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/runner/emacs.rb +8 -0
  497. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/runner/xml.rb +15 -0
  498. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/test-suite-creator.rb +103 -0
  499. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/testcase.rb +899 -0
  500. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/testresult.rb +132 -0
  501. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/testsuite.rb +175 -0
  502. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/ui/console/outputlevel.rb +15 -0
  503. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/ui/console/testrunner.rb +750 -0
  504. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  505. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/ui/testrunner.rb +53 -0
  506. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/ui/testrunnermediator.rb +114 -0
  507. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  508. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/ui/xml/testrunner.rb +224 -0
  509. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/util/backtracefilter.rb +59 -0
  510. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/util/method-owner-finder.rb +28 -0
  511. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/util/observable.rb +90 -0
  512. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/util/output.rb +32 -0
  513. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/util/procwrapper.rb +48 -0
  514. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/lib/test/unit/version.rb +5 -0
  515. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/sample/adder.rb +13 -0
  516. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/sample/subtracter.rb +12 -0
  517. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/sample/test_adder.rb +20 -0
  518. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/sample/test_subtracter.rb +20 -0
  519. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/sample/test_user.rb +23 -0
  520. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/collector/test-descendant.rb +182 -0
  521. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/collector/test-load.rb +475 -0
  522. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/collector/test_dir.rb +407 -0
  523. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/collector/test_objectspace.rb +102 -0
  524. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/fixtures/header-label.csv +3 -0
  525. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/fixtures/header-label.tsv +3 -0
  526. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/fixtures/header.csv +3 -0
  527. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/fixtures/header.tsv +3 -0
  528. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/fixtures/no-header.csv +2 -0
  529. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/fixtures/no-header.tsv +2 -0
  530. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/fixtures/plus.csv +3 -0
  531. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/run-test.rb +22 -0
  532. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-assertions.rb +2187 -0
  533. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-attribute-matcher.rb +38 -0
  534. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-attribute.rb +123 -0
  535. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-code-snippet.rb +79 -0
  536. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-color-scheme.rb +82 -0
  537. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-color.rb +47 -0
  538. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-data.rb +419 -0
  539. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-diff.rb +518 -0
  540. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-emacs-runner.rb +60 -0
  541. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-error.rb +26 -0
  542. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-failure.rb +33 -0
  543. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-fault-location-detector.rb +163 -0
  544. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-fixture.rb +713 -0
  545. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-notification.rb +33 -0
  546. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-omission.rb +81 -0
  547. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-pending.rb +70 -0
  548. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-priority.rb +184 -0
  549. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-test-case.rb +1279 -0
  550. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-test-result.rb +113 -0
  551. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-test-suite-creator.rb +97 -0
  552. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/test-test-suite.rb +151 -0
  553. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/testunit-test-util.rb +33 -0
  554. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/ui/test_testrunmediator.rb +20 -0
  555. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/util/test-method-owner-finder.rb +38 -0
  556. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/util/test-output.rb +11 -0
  557. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/util/test_backtracefilter.rb +52 -0
  558. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/util/test_observable.rb +102 -0
  559. data/vendor/bundle/ruby/2.7.0/gems/test-unit-3.3.5/test/util/test_procwrapper.rb +36 -0
  560. data/vendor/bundle/ruby/2.7.0/specifications/power_assert-1.1.7.gemspec +46 -0
  561. data/vendor/bundle/ruby/2.7.0/specifications/rake-13.0.1.gemspec +26 -0
  562. data/vendor/bundle/ruby/2.7.0/specifications/test-unit-3.3.5.gemspec +41 -0
  563. data/win32-api.gemspec +27 -29
  564. metadata +610 -63
@@ -0,0 +1,46 @@
1
+ version: '{build}'
2
+
3
+ init:
4
+ # use a minimal path
5
+ - set PATH=C:\ruby%ruby_version%\bin;C:\Program Files\7-Zip;C:\Program Files\AppVeyor\BuildAgent;C:\Program Files\Git\cmd;C:\Windows\system32
6
+ # Load ruby trunk build
7
+ - if %ruby_version%==_trunk (
8
+ appveyor DownloadFile https://ci.appveyor.com/api/projects/MSP-Greg/ruby-loco/artifacts/ruby_trunk.7z -FileName C:\ruby_trunk.7z &
9
+ 7z x C:\ruby_trunk.7z -oC:\ruby_trunk
10
+ )
11
+
12
+ platform: x64
13
+
14
+ install:
15
+ - ruby --version
16
+ - gem --version
17
+ # Assume we can use the version of bundler that Appveyor has packaged with each ruby version
18
+ - bundle install
19
+
20
+ build: off
21
+
22
+ test_script:
23
+ - rake gem:binary
24
+ - rake -rdevkit test:all
25
+
26
+ environment:
27
+ matrix:
28
+ - ruby_version: _trunk
29
+ - ruby_version: 26-x64
30
+ - ruby_version: 26
31
+ - ruby_version: 25-x64
32
+ - ruby_version: 25
33
+ - ruby_version: 24-x64
34
+ - ruby_version: 24
35
+ - ruby_version: 23-x64
36
+ - ruby_version: 23
37
+ - ruby_version: 22-x64
38
+ - ruby_version: 22
39
+ - ruby_version: 21-x64
40
+ - ruby_version: 21
41
+ - ruby_version: 200-x64
42
+ - ruby_version: 200
43
+
44
+ matrix:
45
+ allow_failures:
46
+ - ruby_version: _trunk
@@ -0,0 +1,3 @@
1
+ git clone https://github.com/cosmo0920/win32-api win32-api
2
+ cd win32-api
3
+ rake -rdevkit gem:binary
@@ -0,0 +1,267 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ Q1 = $(V:1=)
7
+ Q = $(Q1:0=@)
8
+ ECHO1 = $(V:1=@ :)
9
+ ECHO = $(ECHO1:0=@ echo)
10
+ NULLCMD = :
11
+
12
+ #### Start of system configuration section. ####
13
+
14
+ srcdir = win32
15
+ topdir = /c/Ruby25-x64/include/ruby-2.5.0
16
+ hdrdir = $(topdir)
17
+ arch_hdrdir = c:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32
18
+ PATH_SEPARATOR = :
19
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
20
+ prefix = $(DESTDIR)/c/Ruby25-x64
21
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
22
+ rubyarchprefix = $(rubylibprefix)/$(arch)
23
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
24
+ exec_prefix = $(prefix)
25
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
26
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
27
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
28
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
29
+ sitehdrdir = $(rubyhdrdir)/site_ruby
30
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
31
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
32
+ vendorlibdir = $(vendordir)/$(ruby_version)
33
+ vendordir = $(rubylibprefix)/vendor_ruby
34
+ sitearchdir = $(sitelibdir)/$(sitearch)
35
+ sitelibdir = $(sitedir)/$(ruby_version)
36
+ sitedir = $(rubylibprefix)/site_ruby
37
+ rubyarchdir = $(rubylibdir)/$(arch)
38
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
39
+ sitearchincludedir = $(includedir)/$(sitearch)
40
+ archincludedir = $(includedir)/$(arch)
41
+ sitearchlibdir = $(libdir)/$(sitearch)
42
+ archlibdir = $(libdir)/$(arch)
43
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
44
+ mandir = $(datarootdir)/man
45
+ localedir = $(datarootdir)/locale
46
+ libdir = $(exec_prefix)/lib
47
+ psdir = $(docdir)
48
+ pdfdir = $(docdir)
49
+ dvidir = $(docdir)
50
+ htmldir = $(docdir)
51
+ infodir = $(datarootdir)/info
52
+ docdir = $(datarootdir)/doc/$(PACKAGE)
53
+ oldincludedir = $(DESTDIR)/usr/include
54
+ includedir = $(prefix)/include
55
+ localstatedir = $(prefix)/var
56
+ sharedstatedir = $(prefix)/com
57
+ sysconfdir = $(DESTDIR)
58
+ datadir = $(datarootdir)
59
+ datarootdir = $(prefix)/share
60
+ libexecdir = $(exec_prefix)/libexec
61
+ sbindir = $(exec_prefix)/sbin
62
+ bindir = $(exec_prefix)/bin
63
+ archdir = $(rubyarchdir)
64
+
65
+
66
+ CC = x86_64-w64-mingw32-gcc
67
+ CXX = x86_64-w64-mingw32-g++
68
+ LIBRUBY = lib$(RUBY_SO_NAME).dll.a
69
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
70
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
71
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
72
+ empty =
73
+ OUTFLAG = -o $(empty)
74
+ COUTFLAG = -o $(empty)
75
+ CSRCFLAG = $(empty)
76
+
77
+ RUBY_EXTCONF_H =
78
+ cflags = $(optflags) $(debugflags) $(warnflags)
79
+ cxxflags = $(optflags) $(debugflags) $(warnflags)
80
+ optflags = -O3 -fno-omit-frame-pointer
81
+ debugflags = -ggdb3
82
+ warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict
83
+ CCDLFLAGS =
84
+ CFLAGS = $(CCDLFLAGS) -O3 -fno-fast-math -fno-omit-frame-pointer $(ARCH_FLAG)
85
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
86
+ DEFS = -D_FILE_OFFSET_BITS=64
87
+ CPPFLAGS = -DHAVE_STRNCPY_S -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT $(DEFS) $(cppflags)
88
+ CXXFLAGS = $(CCDLFLAGS) -march=x86-64 -mtune=generic -O2 -pipe $(ARCH_FLAG)
89
+ ldflags = -L. -pipe -s
90
+ dldflags = -pipe -s -Wl,--enable-auto-image-base,--enable-auto-import $(DEFFILE)
91
+ ARCH_FLAG =
92
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
93
+ LDSHARED = $(CC) -shared
94
+ LDSHAREDXX = $(CXX) -shared
95
+ AR = ar
96
+ EXEEXT = .exe
97
+
98
+ RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
99
+ RUBY_SO_NAME = x64-msvcrt-ruby250
100
+ RUBYW_INSTALL_NAME = $(RUBYW_BASE_NAME)
101
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
102
+ RUBYW_BASE_NAME = rubyw
103
+ RUBY_BASE_NAME = ruby
104
+
105
+ arch = x64-mingw32
106
+ sitearch = x64-msvcrt
107
+ ruby_version = 2.5.0
108
+ ruby = $(bindir)/$(RUBY_BASE_NAME)
109
+ RUBY = $(ruby)
110
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
111
+
112
+ RM = rm -f
113
+ RM_RF = $(RUBY) -run -e rm -- -rf
114
+ RMDIRS = rmdir --ignore-fail-on-non-empty -p
115
+ MAKEDIRS = /usr/bin/mkdir -p
116
+ INSTALL = /usr/bin/install -c
117
+ INSTALL_PROG = $(INSTALL) -m 0755
118
+ INSTALL_DATA = $(INSTALL) -m 644
119
+ COPY = cp
120
+ TOUCH = exit >
121
+
122
+ #### End of system configuration section. ####
123
+
124
+ preload =
125
+ libpath = . $(libdir)
126
+ LIBPATH = -L. -L$(libdir)
127
+ DEFFILE = $(TARGET)-$(arch).def
128
+
129
+ CLEANFILES = mkmf.log $(DEFFILE)
130
+ DISTCLEANFILES =
131
+ DISTCLEANDIRS =
132
+
133
+ extout =
134
+ extout_prefix =
135
+ target_prefix = /win32
136
+ LOCAL_LIBS =
137
+ LIBS = $(LIBRUBYARG_SHARED) -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi
138
+ ORIG_SRCS = api.c
139
+ SRCS = $(ORIG_SRCS)
140
+ OBJS = api.o
141
+ HDRS =
142
+ LOCAL_HDRS =
143
+ TARGET = api
144
+ TARGET_NAME = api
145
+ TARGET_ENTRY = Init_$(TARGET_NAME)
146
+ DLLIB = $(TARGET).so
147
+ EXTSTATIC =
148
+ STATIC_LIB =
149
+
150
+ TIMESTAMP_DIR = .
151
+ BINDIR = $(bindir)
152
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
153
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
154
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
155
+ HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
156
+ ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
157
+ TARGET_SO_DIR =
158
+ TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
159
+ CLEANLIBS = $(TARGET_SO)
160
+ CLEANOBJS = *.o *.bak
161
+
162
+ all: $(DLLIB)
163
+ static: $(STATIC_LIB)
164
+ .PHONY: all install static install-so install-rb
165
+ .PHONY: clean clean-so clean-static clean-rb
166
+
167
+ clean-static::
168
+ clean-rb-default::
169
+ clean-rb::
170
+ clean-so::
171
+ clean: clean-so clean-static clean-rb-default clean-rb
172
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
173
+
174
+ distclean-rb-default::
175
+ distclean-rb::
176
+ distclean-so::
177
+ distclean-static::
178
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
179
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
180
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
181
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
182
+
183
+ realclean: distclean
184
+ install: install-so install-rb
185
+
186
+ install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.-.win32.time
187
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
188
+ clean-static::
189
+ -$(Q)$(RM) $(STATIC_LIB)
190
+ install-rb: pre-install-rb do-install-rb install-rb-default
191
+ install-rb-default: pre-install-rb-default do-install-rb-default
192
+ pre-install-rb: Makefile
193
+ pre-install-rb-default: Makefile
194
+ do-install-rb:
195
+ do-install-rb-default:
196
+ pre-install-rb-default:
197
+ @$(NULLCMD)
198
+ $(TIMESTAMP_DIR)/.sitearchdir.-.win32.time:
199
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
200
+ $(Q) $(TOUCH) $@
201
+
202
+ site-install: site-install-so site-install-rb
203
+ site-install-so: install-so
204
+ site-install-rb: install-rb
205
+
206
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
207
+
208
+ .cc.o:
209
+ $(ECHO) compiling $(<)
210
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
211
+
212
+ .cc.S:
213
+ $(ECHO) translating $(<)
214
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
215
+
216
+ .mm.o:
217
+ $(ECHO) compiling $(<)
218
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
219
+
220
+ .mm.S:
221
+ $(ECHO) translating $(<)
222
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
223
+
224
+ .cxx.o:
225
+ $(ECHO) compiling $(<)
226
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
227
+
228
+ .cxx.S:
229
+ $(ECHO) translating $(<)
230
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
231
+
232
+ .cpp.o:
233
+ $(ECHO) compiling $(<)
234
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
235
+
236
+ .cpp.S:
237
+ $(ECHO) translating $(<)
238
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
239
+
240
+ .c.o:
241
+ $(ECHO) compiling $(<)
242
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
243
+
244
+ .c.S:
245
+ $(ECHO) translating $(<)
246
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
247
+
248
+ .m.o:
249
+ $(ECHO) compiling $(<)
250
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
251
+
252
+ .m.S:
253
+ $(ECHO) translating $(<)
254
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
255
+
256
+ $(TARGET_SO): $(DEFFILE) $(OBJS) Makefile
257
+ $(ECHO) linking shared-object win32/$(DLLIB)
258
+ -$(Q)$(RM) $(@)
259
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
260
+
261
+
262
+
263
+ $(DEFFILE):
264
+ $(ECHO) generating $(@)
265
+ $(Q) (echo EXPORTS && echo $(TARGET_ENTRY)) > $@
266
+
267
+ $(OBJS): $(HDRS) $(ruby_headers)
@@ -0,0 +1,2 @@
1
+ EXPORTS
2
+ Init_api
Binary file
Binary file
@@ -1,11 +1,15 @@
1
- ##########################################################################
2
- # extconf.rb
3
- #
4
- # The Windows::API binary should be built using the Rake task, i.e.
5
- # 'rake build' or 'rake install'.
6
- ##########################################################################
7
- require 'mkmf'
8
-
9
- have_func('strncpy_s')
10
-
11
- create_makefile('win32/api', 'win32')
1
+ ##########################################################################
2
+ # extconf.rb
3
+ #
4
+ # The Windows::API binary should be built using the Rake task, i.e.
5
+ # 'rake build' or 'rake install'.
6
+ ##########################################################################
7
+ require 'mkmf'
8
+
9
+ if RbConfig::CONFIG['host_os'] =~ /mingw/
10
+ $CFLAGS << ' -fno-omit-frame-pointer'
11
+ end
12
+
13
+ have_func('strncpy_s')
14
+
15
+ create_makefile('win32/api', 'win32')
@@ -0,0 +1,38 @@
1
+ have_func: checking for strncpy_s()... -------------------- yes
2
+
3
+ "x86_64-w64-mingw32-gcc -o conftest.exe -Ic:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -Ic:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -Ic:/Ruby25-x64/include/ruby-2.5.0 -I. -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -fno-omit-frame-pointer conftest.c -L. -Lc:/Ruby25-x64/lib -L. -pipe -s -lx64-msvcrt-ruby250 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
4
+ checked program was:
5
+ /* begin */
6
+ 1: #include "ruby.h"
7
+ 2:
8
+ 3: #include <winsock2.h>
9
+ 4: #include <windows.h>
10
+ 5: int main(int argc, char **argv)
11
+ 6: {
12
+ 7: return 0;
13
+ 8: }
14
+ /* end */
15
+
16
+ "x86_64-w64-mingw32-gcc -o conftest.exe -Ic:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -Ic:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -Ic:/Ruby25-x64/include/ruby-2.5.0 -I. -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -fno-omit-frame-pointer conftest.c -L. -Lc:/Ruby25-x64/lib -L. -pipe -s -lx64-msvcrt-ruby250 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
17
+ checked program was:
18
+ /* begin */
19
+ 1: #include "ruby.h"
20
+ 2:
21
+ 3: #include <winsock2.h>
22
+ 4: #include <windows.h>
23
+ 5:
24
+ 6: /*top*/
25
+ 7: extern int t(void);
26
+ 8: int main(int argc, char **argv)
27
+ 9: {
28
+ 10: if (argc > 1000000) {
29
+ 11: printf("%p", &t);
30
+ 12: }
31
+ 13:
32
+ 14: return 0;
33
+ 15: }
34
+ 16: int t(void) { void ((*volatile p)()); p = (void ((*)()))strncpy_s; return !p; }
35
+ /* end */
36
+
37
+ --------------------
38
+
@@ -1,949 +1,1102 @@
1
- #include <ruby.h>
2
- #include <windows.h>
3
-
4
- // Ruby 1.9.x
5
- #ifndef RSTRING_PTR
6
- #define RSTRING_PTR(s) (RSTRING(s)->ptr)
7
- #endif
8
- #ifndef RSTRING_LEN
9
- #define RSTRING_LEN(s) (RSTRING(s)->len)
10
- #endif
11
-
12
- #ifndef RARRAY_PTR
13
- #define RARRAY_PTR(a) (RARRAY(a)->ptr)
14
- #endif
15
- #ifndef RARRAY_LEN
16
- #define RARRAY_LEN(a) (RARRAY(a)->len)
17
- #endif
18
-
19
- #define MAX_BUF 1024
20
- #define WINDOWS_API_VERSION "1.4.8"
21
-
22
- #define _T_VOID 0
23
- #define _T_LONG 1
24
- #define _T_POINTER 2
25
- #define _T_INTEGER 3
26
- #define _T_CALLBACK 4
27
- #define _T_STRING 5
28
-
29
- VALUE cAPIError, cAPIProtoError, cAPILoadError;
30
- static VALUE ActiveCallback = Qnil;
31
-
32
- typedef struct {
33
- HANDLE library;
34
- FARPROC function;
35
- int return_type;
36
- int prototype[20];
37
- } Win32API;
38
-
39
- static void api_free(Win32API* ptr){
40
- if(ptr->library)
41
- FreeLibrary(ptr->library);
42
-
43
- if(ptr)
44
- free(ptr);
45
- }
46
-
47
- static VALUE api_allocate(VALUE klass){
48
- Win32API* ptr = malloc(sizeof(Win32API));
49
- return Data_Wrap_Struct(klass, 0, api_free, ptr);
50
- }
51
-
52
- /* Helper function that converts the error number returned by GetLastError()
53
- * into a human readable string. Note that we always use English for error
54
- * output because that's what Ruby itself does.
55
- *
56
- * Internal use only.
57
- */
58
- char* StringError(DWORD dwError){
59
- LPVOID lpMsgBuf;
60
- static char buf[MAX_PATH];
61
- DWORD dwLen, dwLastError;
62
-
63
- // Assume ASCII (English) error messages from the Windows API
64
- dwLen = FormatMessageA(
65
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
66
- FORMAT_MESSAGE_FROM_SYSTEM |
67
- FORMAT_MESSAGE_IGNORE_INSERTS,
68
- NULL,
69
- dwError,
70
- MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
71
- (LPSTR)&lpMsgBuf,
72
- 0,
73
- NULL
74
- );
75
-
76
- dwLastError = GetLastError();
77
-
78
- /* It appears that Windows doesn't necessarily ship with the DLL
79
- * required to always use English error messages. Check for error
80
- * ERROR_MUI_FILE_NOT_FOUND (15100) or ERROR_RESOURCE_LANG_NOT_FOUND (1815)
81
- * and try again if necessary.
82
- */
83
- if(!dwLen && (dwLastError == 15100 || dwLastError == 1815)){
84
- dwLen = FormatMessageA(
85
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
86
- FORMAT_MESSAGE_FROM_SYSTEM |
87
- FORMAT_MESSAGE_IGNORE_INSERTS,
88
- NULL,
89
- dwError,
90
- 0,
91
- (LPSTR)&lpMsgBuf,
92
- 0,
93
- NULL
94
- );
95
- }
96
-
97
- if(!dwLen){
98
- rb_raise(
99
- cAPIError,
100
- "Attempt to format message failed (error = '%d')",
101
- GetLastError()
102
- );
103
- }
104
-
105
- memset(buf, 0, MAX_PATH);
106
-
107
- // Remove \r\n at end of string.
108
- #ifdef HAVE_STRNCPY_S
109
- strncpy_s(buf, MAX_PATH, lpMsgBuf, dwLen - 2);
110
- #else
111
- strncpy(buf, lpMsgBuf, dwLen - 2);
112
- #endif
113
-
114
- LocalFree(lpMsgBuf);
115
-
116
- return buf;
117
- }
118
-
119
- /*
120
- * call-seq:
121
- * Win32::API::Callback.new(prototype, return='L'){ |proto| ... }
122
- *
123
- * Creates and returns a new Win32::API::Callback object. The prototype
124
- * arguments are yielded back to the block in the same order they were
125
- * declared.
126
- *
127
- * The +prototype+ is the function prototype for the callback function. This
128
- * is a string. The possible valid characters are 'I' (integer), 'L' (long),
129
- * 'V' (void), 'P' (pointer) or 'S' (string). Unlike API objects, API::Callback
130
- * objects do not have a default prototype.
131
- *
132
- * The +return+ argument is the return type for the callback function. The
133
- * valid characters are the same as for the +prototype+. The default is
134
- * 'L' (long).
135
- *
136
- * Example:
137
- * require 'win32/api'
138
- * include Win32
139
- *
140
- * EnumWindows = API.new('EnumWindows', 'KP', 'L', 'user32')
141
- * GetWindowText = API.new('GetWindowText', 'LPI', 'I', 'user32')
142
- *
143
- * EnumWindowsProc = API::Callback.new('LP', 'I'){ |handle, param|
144
- * buf = "\0" * 200
145
- * GetWindowText.call(handle, buf, 200);
146
- * puts buf.strip unless buf.strip.empty?
147
- * buf.index(param).nil? ? true : false
148
- * }
149
- *
150
- * EnumWindows.call(EnumWindowsProc, 'UEDIT32')
151
- */
152
- static VALUE callback_init(int argc, VALUE* argv, VALUE self)
153
- {
154
- void *find_callback(VALUE,int);
155
- VALUE v_proto, v_return, v_proc;
156
- int i;
157
-
158
- rb_scan_args(argc, argv, "11&", &v_proto, &v_return, &v_proc);
159
-
160
- /* Validate prototype characters */
161
- for(i = 0; i < RSTRING_LEN(v_proto); i++){
162
- switch(RSTRING_PTR(v_proto)[i]){
163
- case 'I': case 'L': case 'P': case 'V': case 'S':
164
- break;
165
- default:
166
- rb_raise(cAPIProtoError, "Illegal prototype '%c'",
167
- RSTRING_PTR(v_proto)[i]
168
- );
169
- }
170
- }
171
-
172
- if(NIL_P(v_return) || RARRAY_LEN(v_return) == 0){
173
- v_return = rb_str_new2("L");
174
- }
175
- else{
176
- switch(*(char*)RSTRING_PTR(v_return)){
177
- case 'I': case 'L': case 'P': case 'V': case 'S':
178
- break;
179
- default:
180
- rb_raise(cAPIProtoError, "Illegal return type '%s'",
181
- RSTRING_PTR(v_return)
182
- );
183
- }
184
- }
185
-
186
- rb_iv_set(self, "@function", v_proc);
187
- rb_iv_set(self, "@prototype", v_proto);
188
- rb_iv_set(self, "@return_type", v_return);
189
- rb_iv_set(self, "@address", ULONG2NUM((LPARAM)find_callback(self,RSTRING_LEN(v_proto))));
190
- ActiveCallback = self;
191
-
192
- return self;
193
- }
194
-
195
- /*
196
- * call-seq:
197
- * Win32::API.new(function, prototype='V', return='L', dll='kernel32')
198
- *
199
- * Creates and returns a new Win32::API object. The +function+ is the name
200
- * of the Windows function.
201
- *
202
- * The +prototype+ is the function prototype for +function+. This can be a
203
- * string or an array of characters. The possible valid characters are 'I'
204
- * (integer), 'L' (long), 'V' (void), 'P' (pointer), 'K' (callback) or 'S'
205
- * (string).
206
- *
207
- * The default is void ('V').
208
- *
209
- * Constant (const char*) strings should use 'S'. Pass by reference string
210
- * buffers should use 'P'. The former is faster, but cannot be modified.
211
- *
212
- * The +return+ argument is the return type for the function. The valid
213
- * characters are the same as for the +prototype+. The default is 'L' (long).
214
- *
215
- * The +dll+ is the name of the DLL file that the function is exported from.
216
- * The default is 'kernel32'.
217
- *
218
- * If the function cannot be found then an API::Error is raised (a subclass
219
- * of RuntimeError).
220
- *
221
- * Example:
222
- *
223
- * require 'win32/api'
224
- * include Win32
225
- *
226
- * buf = 0.chr * 260
227
- * len = [buf.length].pack('L')
228
- *
229
- * GetUserName = API.new('GetUserName', 'PP', 'I', 'advapi32')
230
- * GetUserName.call(buf, len)
231
- *
232
- * puts buf.strip
233
- */
234
- static VALUE api_init(int argc, VALUE* argv, VALUE self)
235
- {
236
- HMODULE hLibrary;
237
- FARPROC fProc;
238
- Win32API* ptr;
239
- int i;
240
- const char* first = "A";
241
- const char* second = "W";
242
- VALUE v_proc, v_proto, v_return, v_dll;
243
-
244
- rb_scan_args(argc, argv, "13", &v_proc, &v_proto, &v_return, &v_dll);
245
-
246
- Data_Get_Struct(self, Win32API, ptr);
247
-
248
- // Convert a string prototype to an array of characters
249
- if(rb_respond_to(v_proto, rb_intern("split")))
250
- v_proto = rb_str_split(v_proto, "");
251
-
252
- // Convert a nil or empty prototype to 'V' (void) automatically
253
- if(NIL_P(v_proto) || RARRAY_LEN(v_proto) == 0){
254
- v_proto = rb_ary_new();
255
- rb_ary_push(v_proto, rb_str_new2("V"));
256
- }
257
-
258
- // Set an arbitrary limit of 20 parameters
259
- if(20 < RARRAY_LEN(v_proto))
260
- rb_raise(rb_eArgError, "too many parameters: %d", RARRAY_LEN(v_proto));
261
-
262
- // Set the default dll to 'kernel32'
263
- if(NIL_P(v_dll))
264
- v_dll = rb_str_new2("kernel32");
265
-
266
- // Set the default return type to 'L' (DWORD)
267
- if(NIL_P(v_return))
268
- v_return = rb_str_new2("L");
269
-
270
- SafeStringValue(v_dll);
271
- SafeStringValue(v_proc);
272
-
273
- hLibrary = LoadLibrary(TEXT(RSTRING_PTR(v_dll)));
274
-
275
- // The most likely cause of failure is a bad DLL load path
276
- if(!hLibrary){
277
- rb_raise(cAPILoadError, "LoadLibrary() function failed for '%s': %s",
278
- RSTRING_PTR(v_dll),
279
- StringError(GetLastError())
280
- );
281
- }
282
-
283
- ptr->library = hLibrary;
284
-
285
- /* Attempt to get the function. If it fails, try again with an 'A'
286
- * appended. If that fails, try again with a 'W' appended. If that
287
- * still fails, raise an API::LoadLibraryError.
288
- */
289
-
290
- fProc = GetProcAddress(hLibrary, TEXT(RSTRING_PTR(v_proc)));
291
-
292
- // Skip the ANSI and Wide function checks for MSVCRT functions.
293
- if(!fProc){
294
- if(strstr(RSTRING_PTR(v_dll), "msvcr")){
295
- rb_raise(
296
- cAPILoadError,
297
- "Unable to load function '%s'",
298
- RSTRING_PTR(v_proc)
299
- );
300
- }
301
- else{
302
- VALUE v_ascii = rb_str_new3(v_proc);
303
- v_ascii = rb_str_cat(v_ascii, first, 1);
304
- fProc = GetProcAddress(hLibrary, TEXT(RSTRING_PTR(v_ascii)));
305
-
306
- if(!fProc){
307
- VALUE v_unicode = rb_str_new3(v_proc);
308
- v_unicode = rb_str_cat(v_unicode, second, 1);
309
- fProc = GetProcAddress(hLibrary, TEXT(RSTRING_PTR(v_unicode)));
310
-
311
- if(!fProc){
312
- rb_raise(
313
- cAPILoadError,
314
- "Unable to load function '%s', '%s', or '%s'",
315
- RSTRING_PTR(v_proc),
316
- RSTRING_PTR(v_ascii),
317
- RSTRING_PTR(v_unicode)
318
- );
319
- }
320
- else{
321
- rb_iv_set(self, "@effective_function_name", v_unicode);
322
- }
323
- }
324
- else{
325
- rb_iv_set(self, "@effective_function_name", v_ascii);
326
- }
327
- }
328
- }
329
- else{
330
- rb_iv_set(self, "@effective_function_name", v_proc);
331
- }
332
-
333
- ptr->function = fProc;
334
-
335
- // Push the numeric prototypes onto our int array for later use.
336
-
337
- for(i = 0; i < RARRAY_LEN(v_proto); i++){
338
- SafeStringValue(RARRAY_PTR(v_proto)[i]);
339
- switch(*(char*)StringValuePtr(RARRAY_PTR(v_proto)[i])){
340
- case 'L':
341
- ptr->prototype[i] = _T_LONG;
342
- break;
343
- case 'P':
344
- ptr->prototype[i] = _T_POINTER;
345
- break;
346
- case 'I': case 'B':
347
- ptr->prototype[i] = _T_INTEGER;
348
- break;
349
- case 'V':
350
- ptr->prototype[i] = _T_VOID;
351
- break;
352
- case 'K':
353
- ptr->prototype[i] = _T_CALLBACK;
354
- break;
355
- case 'S':
356
- ptr->prototype[i] = _T_STRING;
357
- break;
358
- default:
359
- rb_raise(cAPIProtoError, "Illegal prototype '%s'",
360
- StringValuePtr(RARRAY_PTR(v_proto)[i])
361
- );
362
- }
363
- }
364
-
365
- // Store the return type for later use.
366
-
367
- // Automatically convert empty strings or nil to type void.
368
- if(NIL_P(v_return) || RSTRING_LEN(v_return) == 0){
369
- v_return = rb_str_new2("V");
370
- ptr->return_type = _T_VOID;
371
- }
372
- else{
373
- SafeStringValue(v_return);
374
- switch(*RSTRING_PTR(v_return)){
375
- case 'L':
376
- ptr->return_type = _T_LONG;
377
- break;
378
- case 'P':
379
- ptr->return_type = _T_POINTER;
380
- break;
381
- case 'I': case 'B':
382
- ptr->return_type = _T_INTEGER;
383
- break;
384
- case 'V':
385
- ptr->return_type = _T_VOID;
386
- break;
387
- case 'S':
388
- ptr->return_type = _T_STRING;
389
- break;
390
- default:
391
- rb_raise(cAPIProtoError, "Illegal return type '%s'",
392
- RSTRING_PTR(v_return)
393
- );
394
- }
395
- }
396
-
397
- rb_iv_set(self, "@dll_name", v_dll);
398
- rb_iv_set(self, "@function_name", v_proc);
399
- rb_iv_set(self, "@prototype", v_proto);
400
- rb_iv_set(self, "@return_type", v_return);
401
-
402
- return self;
403
- }
404
-
405
- /*
406
- * call-seq:
407
- *
408
- * API::Function.new(address, prototype = 'V', return_type = 'L')
409
- *
410
- * Creates and returns an API::Function object. This object is similar to an
411
- * API object, except that instead of a character function name you pass a
412
- * function pointer address as the first argument, and there's no associated
413
- * DLL file.
414
- *
415
- * Once you have your API::Function object you can then call it the same way
416
- * you would an API object.
417
- *
418
- * Example:
419
- *
420
- * require 'win32/api'
421
- * include Win32
422
- *
423
- * LoadLibrary = API.new('LoadLibrary', 'P', 'L')
424
- * GetProcAddress = API.new('GetProcAddress', 'LP', 'L')
425
- *
426
- * # Play a system beep
427
- * hlib = LoadLibrary.call('user32')
428
- * addr = GetProcAddress.call(hlib, 'MessageBeep')
429
- * func = Win32::API::Function.new(addr, 'L', 'L')
430
- * func.call(0)
431
- */
432
- static VALUE func_init(int argc, VALUE* argv, VALUE self){
433
- Win32API* ptr;
434
- int i;
435
- VALUE v_address, v_proto, v_return;
436
-
437
- rb_scan_args(argc, argv, "12", &v_address, &v_proto, &v_return);
438
-
439
- Data_Get_Struct(self, Win32API, ptr);
440
-
441
- // Convert a string prototype to an array of characters
442
- if(rb_respond_to(v_proto, rb_intern("split")))
443
- v_proto = rb_str_split(v_proto, "");
444
-
445
- // Convert a nil or empty prototype to 'V' (void) automatically
446
- if(NIL_P(v_proto) || RARRAY_LEN(v_proto) == 0){
447
- v_proto = rb_ary_new();
448
- rb_ary_push(v_proto, rb_str_new2("V"));
449
- }
450
-
451
- // Set an arbitrary limit of 20 parameters
452
- if(20 < RARRAY_LEN(v_proto))
453
- rb_raise(rb_eArgError, "too many parameters: %d\n", RARRAY_LEN(v_proto));
454
-
455
- // Set the default return type to 'L' (DWORD)
456
- if(NIL_P(v_return))
457
- v_return = rb_str_new2("L");
458
-
459
- ptr->function = (FARPROC)NUM2LONG(v_address);
460
-
461
- // Push the numeric prototypes onto our int array for later use.
462
-
463
- for(i = 0; i < RARRAY_LEN(v_proto); i++){
464
- SafeStringValue(RARRAY_PTR(v_proto)[i]);
465
- switch(*(char*)StringValuePtr(RARRAY_PTR(v_proto)[i])){
466
- case 'L':
467
- ptr->prototype[i] = _T_LONG;
468
- break;
469
- case 'P':
470
- ptr->prototype[i] = _T_POINTER;
471
- break;
472
- case 'I': case 'B':
473
- ptr->prototype[i] = _T_INTEGER;
474
- break;
475
- case 'V':
476
- ptr->prototype[i] = _T_VOID;
477
- break;
478
- case 'K':
479
- ptr->prototype[i] = _T_CALLBACK;
480
- break;
481
- case 'S':
482
- ptr->prototype[i] = _T_STRING;
483
- break;
484
- default:
485
- rb_raise(cAPIProtoError, "Illegal prototype '%s'",
486
- StringValuePtr(RARRAY_PTR(v_proto)[i])
487
- );
488
- }
489
- }
490
-
491
- // Store the return type for later use.
492
-
493
- // Automatically convert empty strings or nil to type void.
494
- if(NIL_P(v_return) || RSTRING_LEN(v_return) == 0){
495
- v_return = rb_str_new2("V");
496
- ptr->return_type = _T_VOID;
497
- }
498
- else{
499
- SafeStringValue(v_return);
500
- switch(*RSTRING_PTR(v_return)){
501
- case 'L':
502
- ptr->return_type = _T_LONG;
503
- break;
504
- case 'P':
505
- ptr->return_type = _T_POINTER;
506
- break;
507
- case 'I': case 'B':
508
- ptr->return_type = _T_INTEGER;
509
- break;
510
- case 'V':
511
- ptr->return_type = _T_VOID;
512
- break;
513
- case 'S':
514
- ptr->return_type = _T_STRING;
515
- break;
516
- default:
517
- rb_raise(cAPIProtoError, "Illegal return type '%s'",
518
- RSTRING_PTR(v_return)
519
- );
520
- }
521
- }
522
-
523
- rb_iv_set(self, "@address", v_address);
524
- rb_iv_set(self, "@prototype", v_proto);
525
- rb_iv_set(self, "@return_type", v_return);
526
-
527
- return self;
528
- }
529
-
530
- typedef struct {
531
- DWORD params[20];
532
- } CALLPARAM;
533
-
534
-
535
- DWORD CallbackFunction(CALLPARAM param, VALUE callback)
536
- {
537
- VALUE v_proto, v_return, v_proc, v_retval;
538
- VALUE argv[20];
539
- int i, argc;
540
- char *a_proto;
541
- char *a_return;
542
-
543
- if(callback && !NIL_P(callback)){
544
- v_proto = rb_iv_get(callback, "@prototype");
545
- a_proto = RSTRING_PTR(v_proto);
546
-
547
- v_return = rb_iv_get(callback, "@return_type");
548
- a_return = RSTRING_PTR(v_return);
549
-
550
- v_proc = rb_iv_get(callback, "@function");
551
- argc = RSTRING_LEN(v_proto);
552
-
553
- for(i=0; i < RSTRING_LEN(v_proto); i++){
554
- argv[i] = Qnil;
555
- switch(a_proto[i]){
556
- case 'L':
557
- argv[i] = ULONG2NUM(param.params[i]);
558
- break;
559
- case 'P':
560
- if(param.params[i])
561
- argv[i] = rb_str_new2((char *)param.params[i]);
562
- break;
563
- case 'I':
564
- argv[i] = INT2NUM(param.params[i]);
565
- break;
566
- default:
567
- rb_raise(cAPIProtoError, "Illegal prototype '%s'", a_proto[i]);
568
- }
569
- }
570
-
571
- v_retval = rb_funcall2(v_proc, rb_intern("call"), argc, argv);
572
-
573
- /* Handle true and false explicitly, as some CALLBACK functions
574
- * require TRUE or FALSE to break out of loops, etc.
575
- */
576
- if(v_retval == Qtrue)
577
- return TRUE;
578
- else if(v_retval == Qfalse)
579
- return FALSE;
580
-
581
- switch (*a_return) {
582
- case 'I':
583
- return NUM2INT(v_retval);
584
- break;
585
- case 'L':
586
- return NUM2ULONG(v_retval);
587
- break;
588
- case 'S':
589
- return (unsigned long)RSTRING_PTR(v_retval);
590
- break;
591
- case 'P':
592
- if(NIL_P(v_retval)){
593
- return 0;
594
- }
595
- else if(FIXNUM_P(v_retval)){
596
- return NUM2ULONG(v_retval);
597
- }
598
- else{
599
- StringValue(v_retval);
600
- rb_str_modify(v_retval);
601
- return (unsigned long)StringValuePtr(v_retval);
602
- }
603
- break;
604
- }
605
- }
606
-
607
- return 0;
608
- }
609
-
610
- #define CALLBACK0(x) DWORD CALLBACK CallbackFunction0_##x() {\
611
- CALLPARAM param = {0};\
612
- param.params[0] = 0;\
613
- return CallbackFunction(param,FuncTable[0][x]);\
614
- }
615
-
616
- #define CALLBACK1(x) DWORD CALLBACK CallbackFunction1_##x(DWORD p1) {\
617
- CALLPARAM param = {p1};\
618
- return CallbackFunction(param,FuncTable[1][x]);\
619
- }
620
-
621
- #define CALLBACK2(x) DWORD CALLBACK CallbackFunction2_##x(\
622
- DWORD p1, DWORD p2){\
623
- CALLPARAM param = {p1,p2};\
624
- return CallbackFunction(param,FuncTable[2][x]);\
625
- }
626
-
627
- #define CALLBACK3(x) DWORD CALLBACK CallbackFunction3_##x(\
628
- DWORD p1, DWORD p2, DWORD p3){\
629
- CALLPARAM param = {p1,p2,p3};\
630
- return CallbackFunction(param,FuncTable[3][x]);\
631
- }
632
-
633
- #define CALLBACK4(x) DWORD CALLBACK CallbackFunction4_##x(\
634
- DWORD p1, DWORD p2, DWORD p3, DWORD p4){\
635
- CALLPARAM param = {p1,p2,p3,p4};\
636
- return CallbackFunction(param,FuncTable[4][x]);\
637
- }
638
-
639
- #define CALLBACK5(x) DWORD CALLBACK CallbackFunction5_##x(\
640
- DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5\
641
- ){\
642
- CALLPARAM param = {p1,p2,p3,p4,p5};\
643
- return CallbackFunction(param,FuncTable[5][x]);\
644
- }
645
-
646
- #define CALLBACK6(x) DWORD CALLBACK CallbackFunction6_##x(\
647
- DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5, DWORD p6\
648
- ){\
649
- CALLPARAM param = {p1,p2,p3,p4,p5,p6};\
650
- return CallbackFunction(param,FuncTable[6][x]);\
651
- }
652
-
653
- #define CALLBACK7(x) DWORD CALLBACK CallbackFunction7_##x(\
654
- DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5, DWORD p6, DWORD p7\
655
- ){\
656
- CALLPARAM param = {p1,p2,p3,p4,p5,p6,p7};\
657
- return CallbackFunction(param,FuncTable[7][x]);\
658
- }
659
-
660
- #define CALLBACK8(x) DWORD CALLBACK CallbackFunction8_##x(\
661
- DWORD p1, DWORD p2, DWORD p3, DWORD p4,\
662
- DWORD p5, DWORD p6, DWORD p7, DWORD p8\
663
- ){\
664
- CALLPARAM param = {p1,p2,p3,p4,p5,p6,p7,p8};\
665
- return CallbackFunction(param,FuncTable[8][x]);\
666
- }
667
-
668
- #define CALLBACK9(x) DWORD CALLBACK CallbackFunction9_##x(\
669
- DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5,\
670
- DWORD p6, DWORD p7, DWORD p8, DWORD p9\
671
- ){\
672
- CALLPARAM param = {p1,p2,p3,p4,p5,p6,p7,p8,p9};\
673
- return CallbackFunction(param,FuncTable[9][x]);\
674
- }
675
-
676
- #define DEFCALLBACK(x) CALLBACK##x(0)\
677
- CALLBACK##x(1)\
678
- CALLBACK##x(2)\
679
- CALLBACK##x(3)\
680
- CALLBACK##x(4)\
681
- CALLBACK##x(5)\
682
- CALLBACK##x(6)\
683
- CALLBACK##x(7)\
684
- CALLBACK##x(8)\
685
- CALLBACK##x(9)
686
-
687
- #define CF(x,y) CallbackFunction##x##_##y
688
-
689
- static VALUE FuncTable[10][10];
690
-
691
- DEFCALLBACK(0)
692
- DEFCALLBACK(1)
693
- DEFCALLBACK(2)
694
- DEFCALLBACK(3)
695
- DEFCALLBACK(4)
696
- DEFCALLBACK(5)
697
- DEFCALLBACK(6)
698
- DEFCALLBACK(7)
699
- DEFCALLBACK(8)
700
- DEFCALLBACK(9)
701
-
702
- void *CallbackTable[10][10] = {
703
- {CF(0,0),CF(0,1),CF(0,2),CF(0,3),CF(0,4),CF(0,5),CF(0,6),CF(0,7),CF(0,8),CF(0,9)},
704
- {CF(1,0),CF(1,1),CF(1,2),CF(1,3),CF(1,4),CF(1,5),CF(1,6),CF(1,7),CF(1,8),CF(1,9)},
705
- {CF(2,0),CF(2,1),CF(2,2),CF(2,3),CF(2,4),CF(2,5),CF(2,6),CF(2,7),CF(2,8),CF(2,9)},
706
- {CF(3,0),CF(3,1),CF(3,2),CF(3,3),CF(3,4),CF(3,5),CF(3,6),CF(3,7),CF(3,8),CF(3,9)},
707
- {CF(4,0),CF(4,1),CF(4,2),CF(4,3),CF(4,4),CF(4,5),CF(4,6),CF(4,7),CF(4,8),CF(4,9)},
708
- {CF(5,0),CF(5,1),CF(5,2),CF(5,3),CF(5,4),CF(5,5),CF(5,6),CF(5,7),CF(5,8),CF(5,9)},
709
- {CF(6,0),CF(6,1),CF(6,2),CF(6,3),CF(6,4),CF(6,5),CF(6,6),CF(6,7),CF(6,8),CF(6,9)},
710
- {CF(7,0),CF(7,1),CF(7,2),CF(7,3),CF(7,4),CF(7,5),CF(7,6),CF(7,7),CF(7,8),CF(7,9)},
711
- {CF(8,0),CF(8,1),CF(8,2),CF(8,3),CF(8,4),CF(8,5),CF(8,6),CF(8,7),CF(8,8),CF(8,9)},
712
- {CF(9,0),CF(9,1),CF(9,2),CF(9,3),CF(9,4),CF(9,5),CF(9,6),CF(9,7),CF(9,8),CF(9,9)}};
713
-
714
-
715
- void *find_callback(VALUE obj,int len)
716
- {
717
- int i;
718
- for(i=0;i<10;i++)
719
- {
720
- if(FuncTable[len][i]==0)
721
- break;
722
- }
723
- if(i>=10)
724
- rb_raise(cAPIError,"too many callbacks are defined.");
725
- FuncTable[len][i] = obj;
726
- return CallbackTable[len][i];
727
- }
728
-
729
- /*
730
- * call-seq:
731
- * Win32::API#call(arg1, arg2, ...)
732
- *
733
- * Calls the function pointer with the given arguments (if any). Note that,
734
- * while this method will catch some prototype mismatches (raising a TypeError
735
- * in the process), it is not fulproof. It is ultimately your job to make
736
- * sure the arguments match the +prototype+ specified in the constructor.
737
- *
738
- * For convenience, nil is converted to NULL, true is converted to TRUE (1)
739
- * and false is converted to FALSE (0).
740
- */
741
- static VALUE api_call(int argc, VALUE* argv, VALUE self){
742
- VALUE v_proto, v_args, v_arg, v_return;
743
- Win32API* ptr;
744
- unsigned long return_value;
745
- int i = 0;
746
- int len;
747
-
748
- struct{
749
- unsigned long params[20];
750
- } param;
751
-
752
- Data_Get_Struct(self, Win32API, ptr);
753
-
754
- rb_scan_args(argc, argv, "0*", &v_args);
755
-
756
- v_proto = rb_iv_get(self, "@prototype");
757
-
758
- // For void prototypes, allow either no args or an explicit nil
759
- if(RARRAY_LEN(v_proto) != RARRAY_LEN(v_args)){
760
- char* c = StringValuePtr(RARRAY_PTR(v_proto)[0]);
761
- if(!strcmp(c, "V")){
762
- rb_ary_push(v_args, Qnil);
763
- }
764
- else{
765
- rb_raise(rb_eArgError,
766
- "wrong number of parameters: expected %li, got %li",
767
- RARRAY_LEN(v_proto), RARRAY_LEN(v_args)
768
- );
769
- }
770
- }
771
-
772
- len = RARRAY_LEN(v_proto);
773
-
774
- for(i = 0; i < len; i++){
775
- v_arg = RARRAY_PTR(v_args)[i];
776
-
777
- // Convert nil to NULL. Otherwise convert as appropriate.
778
- if(NIL_P(v_arg))
779
- param.params[i] = (unsigned long)NULL;
780
- else if(v_arg == Qtrue)
781
- param.params[i] = TRUE;
782
- else if(v_arg == Qfalse)
783
- param.params[i] = FALSE;
784
- else
785
- switch(ptr->prototype[i]){
786
- case _T_LONG:
787
- param.params[i] = NUM2ULONG(v_arg);
788
- break;
789
- case _T_INTEGER:
790
- param.params[i] = NUM2INT(v_arg);
791
- break;
792
- case _T_POINTER:
793
- if(FIXNUM_P(v_arg)){
794
- param.params[i] = NUM2ULONG(v_arg);
795
- }
796
- else{
797
- StringValue(v_arg);
798
- rb_str_modify(v_arg);
799
- param.params[i] = (unsigned long)StringValuePtr(v_arg);
800
- }
801
- break;
802
- case _T_CALLBACK:
803
- ActiveCallback = v_arg;
804
- v_proto = rb_iv_get(ActiveCallback, "@prototype");
805
- param.params[i] = (LPARAM)NUM2ULONG(rb_iv_get(ActiveCallback, "@address"));;
806
- break;
807
- case _T_STRING:
808
- param.params[i] = (unsigned long)RSTRING_PTR(v_arg);
809
- break;
810
- default:
811
- param.params[i] = NUM2ULONG(v_arg);
812
- }
813
- }
814
-
815
- /* Call the function, get the return value */
816
- return_value = ptr->function(param);
817
-
818
-
819
- /* Return the appropriate type based on the return type specified
820
- * in the constructor.
821
- */
822
- switch(ptr->return_type){
823
- case _T_INTEGER:
824
- v_return = INT2NUM(return_value);
825
- break;
826
- case _T_LONG:
827
- v_return = ULONG2NUM(return_value);
828
- break;
829
- case _T_VOID:
830
- v_return = Qnil;
831
- break;
832
- case _T_POINTER:
833
- if(!return_value){
834
- v_return = Qnil;
835
- }
836
- else{
837
- VALUE v_efunc = rb_iv_get(self, "@effective_function_name");
838
- char* efunc = RSTRING_PTR(v_efunc);
839
- if(efunc[strlen(efunc)-1] == 'W'){
840
- v_return = rb_str_new(
841
- (TCHAR*)return_value,
842
- wcslen((wchar_t*)return_value)*2
843
- );
844
- }
845
- else{
846
- v_return = rb_str_new2((TCHAR*)return_value);
847
- }
848
- }
849
- break;
850
- case _T_STRING:
851
- {
852
- VALUE v_efunc = rb_iv_get(self, "@effective_function_name");
853
- char* efunc = RSTRING_PTR(v_efunc);
854
-
855
- if(efunc[strlen(efunc)-1] == 'W'){
856
- v_return = rb_str_new(
857
- (TCHAR*)return_value,
858
- wcslen((wchar_t*)return_value)*2
859
- );
860
- }
861
- else{
862
- v_return = rb_str_new2((TCHAR*)return_value);
863
- }
864
- }
865
- break;
866
- default:
867
- v_return = INT2NUM(0);
868
- }
869
-
870
- return v_return;
871
- }
872
-
873
- /*
874
- * Wraps the Windows API functions in a Ruby interface.
875
- */
876
- void Init_api(){
877
- VALUE mWin32, cAPI, cCallback, cFunction;
878
-
879
- /* Modules and Classes */
880
-
881
- /* The Win32 module serves as a namespace only */
882
- mWin32 = rb_define_module("Win32");
883
-
884
- /* The API class encapsulates a function pointer to Windows API function */
885
- cAPI = rb_define_class_under(mWin32, "API", rb_cObject);
886
-
887
- /* The API::Callback class encapsulates a Windows CALLBACK function */
888
- cCallback = rb_define_class_under(cAPI, "Callback", rb_cObject);
889
-
890
- /* The API::Function class encapsulates a raw function pointer */
891
- cFunction = rb_define_class_under(cAPI, "Function", cAPI);
892
-
893
- /* The API::Error class serves as a base class for other errors */
894
- cAPIError = rb_define_class_under(cAPI, "Error", rb_eRuntimeError);
895
-
896
- /* The LoadError class is raised if a function cannot be found or loaded */
897
- cAPILoadError = rb_define_class_under(cAPI, "LoadLibraryError", cAPIError);
898
-
899
- /* The PrototypeError class is raised if an invalid prototype is passed */
900
- cAPIProtoError = rb_define_class_under(cAPI, "PrototypeError", cAPIError);
901
-
902
- /* Miscellaneous */
903
- rb_define_alloc_func(cAPI, api_allocate);
904
-
905
- /* Win32::API Instance Methods */
906
- rb_define_method(cAPI, "initialize", api_init, -1);
907
- rb_define_method(cAPI, "call", api_call, -1);
908
-
909
- /* Win32::API::Callback Instance Methods */
910
- rb_define_method(cCallback, "initialize", callback_init, -1);
911
-
912
- /* Win32::API::Function Instance Methods */
913
- rb_define_method(cFunction, "initialize", func_init, -1);
914
-
915
- /* The name of the DLL that exports the API function */
916
- rb_define_attr(cAPI, "dll_name", 1, 0);
917
-
918
- /* The name of the function passed to the constructor */
919
- rb_define_attr(cAPI, "function_name", 1, 0);
920
-
921
- /* The name of the actual function that is returned by the constructor.
922
- * For example, if you passed 'GetUserName' to the constructor, then the
923
- * effective function name would be either 'GetUserNameA' or 'GetUserNameW'.
924
- */
925
- rb_define_attr(cAPI, "effective_function_name", 1, 0);
926
-
927
- /* The prototype, returned as an array of characters */
928
- rb_define_attr(cAPI, "prototype", 1, 0);
929
-
930
- /* The return type, returned as a single character, S, P, L, I, V or B */
931
- rb_define_attr(cAPI, "return_type", 1, 0);
932
-
933
- /* Win32::API::Callback Instance Methods */
934
-
935
- /* The prototype, returned as an array of characters */
936
- rb_define_attr(cCallback, "prototype", 1, 0);
937
-
938
- /* The return type, returned as a single character, S, P, L, I, V or B */
939
- rb_define_attr(cCallback, "return_type", 1, 0);
940
-
941
- /* The numeric address of the function pointer */
942
- rb_define_attr(cCallback, "address", 1, 0);
943
- rb_define_attr(cFunction, "address", 1, 0);
944
-
945
- /* Constants */
946
-
947
- /* 1.4.8: The version of the win32-api library */
948
- rb_define_const(cAPI, "VERSION", rb_str_new2(WINDOWS_API_VERSION));
949
- }
1
+ #include <ruby.h>
2
+ #include <windows.h>
3
+
4
+ // Ruby 1.9.x
5
+ #ifndef RSTRING_PTR
6
+ #define RSTRING_PTR(s) (RSTRING(s)->ptr)
7
+ #endif
8
+ #ifndef RSTRING_LEN
9
+ #define RSTRING_LEN(s) (RSTRING(s)->len)
10
+ #endif
11
+
12
+ #ifndef RARRAY_PTR
13
+ #define RARRAY_PTR(a) (RARRAY(a)->ptr)
14
+ #endif
15
+ #ifndef RARRAY_LEN
16
+ #define RARRAY_LEN(a) (RARRAY(a)->len)
17
+ #endif
18
+
19
+ #if defined(HAVE_LONG_LONG) && SIZEOF_SIZE_T > SIZEOF_LONG
20
+ # define NUM2SIZET(x) ((size_t)NUM2ULL(x))
21
+ # define NUM2SSIZET(x) ((ssize_t)NUM2LL(x))
22
+ #else
23
+ # define NUM2SIZET(x) NUM2ULONG(x)
24
+ # define NUM2SSIZET(x) NUM2LONG(x)
25
+ #endif
26
+
27
+ #if SIZEOF_SIZE_T > SIZEOF_LONG && defined(HAVE_LONG_LONG)
28
+ # define SIZET2NUM(v) ULL2NUM(v)
29
+ # define SSIZET2NUM(v) LL2NUM(v)
30
+ #elif SIZEOF_SIZE_T == SIZEOF_LONG
31
+ # define SIZET2NUM(v) ULONG2NUM(v)
32
+ # define SSIZET2NUM(v) LONG2NUM(v)
33
+ #else
34
+ # define SIZET2NUM(v) UINT2NUM(v)
35
+ # define SSIZET2NUM(v) INT2NUM(v)
36
+ #endif
37
+
38
+
39
+ #define MAX_BUF 1024
40
+ #define WINDOWS_API_VERSION "1.9.1"
41
+
42
+ #define _T_VOID 0
43
+ #define _T_LONG 1
44
+ #define _T_POINTER 2
45
+ #define _T_INTEGER 3
46
+ #define _T_CALLBACK 4
47
+ #define _T_STRING 5
48
+
49
+ VALUE cAPIError, cAPIProtoError, cAPILoadError;
50
+ static VALUE ActiveCallback = Qnil;
51
+
52
+ typedef struct {
53
+ HANDLE library;
54
+ FARPROC function;
55
+ int return_type;
56
+ int prototype[20];
57
+ } Win32API;
58
+
59
+ static void api_free(Win32API* ptr){
60
+ if(ptr->library)
61
+ FreeLibrary(ptr->library);
62
+
63
+ if(ptr)
64
+ free(ptr);
65
+ }
66
+
67
+ static VALUE api_allocate(VALUE klass){
68
+ Win32API* ptr = malloc(sizeof(Win32API));
69
+ memset(ptr, 0, sizeof(*ptr));
70
+ return Data_Wrap_Struct(klass, 0, api_free, ptr);
71
+ }
72
+
73
+ /* Helper function that converts the error number returned by GetLastError()
74
+ * into a human readable string. Note that we always use English for error
75
+ * output because that's what Ruby itself does.
76
+ *
77
+ * Internal use only.
78
+ */
79
+ char* StringError(DWORD dwError){
80
+ LPVOID lpMsgBuf;
81
+ static char buf[MAX_PATH];
82
+ DWORD dwLen, dwLastError;
83
+
84
+ // Assume ASCII (English) error messages from the Windows API
85
+ dwLen = FormatMessageA(
86
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
87
+ FORMAT_MESSAGE_FROM_SYSTEM |
88
+ FORMAT_MESSAGE_IGNORE_INSERTS,
89
+ NULL,
90
+ dwError,
91
+ MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
92
+ (LPSTR)&lpMsgBuf,
93
+ 0,
94
+ NULL
95
+ );
96
+
97
+ dwLastError = GetLastError();
98
+
99
+ /* It appears that Windows doesn't necessarily ship with the DLL
100
+ * required to always use English error messages. Check for error
101
+ * ERROR_MUI_FILE_NOT_FOUND (15100) or ERROR_RESOURCE_LANG_NOT_FOUND (1815)
102
+ * and try again if necessary.
103
+ */
104
+ if(!dwLen && (dwLastError == 15100 || dwLastError == 1815)){
105
+ dwLen = FormatMessageA(
106
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
107
+ FORMAT_MESSAGE_FROM_SYSTEM |
108
+ FORMAT_MESSAGE_IGNORE_INSERTS,
109
+ NULL,
110
+ dwError,
111
+ 0,
112
+ (LPSTR)&lpMsgBuf,
113
+ 0,
114
+ NULL
115
+ );
116
+ }
117
+
118
+ if(!dwLen){
119
+ rb_raise(
120
+ cAPIError,
121
+ "Attempt to format message failed (error = '%lu')",
122
+ GetLastError()
123
+ );
124
+ }
125
+
126
+ memset(buf, 0, MAX_PATH);
127
+
128
+ // Remove \r\n at end of string.
129
+ #ifdef HAVE_STRNCPY_S
130
+ strncpy_s(buf, MAX_PATH, lpMsgBuf, dwLen - 2);
131
+ #else
132
+ strncpy(buf, lpMsgBuf, dwLen - 2);
133
+ #endif
134
+
135
+ LocalFree(lpMsgBuf);
136
+
137
+ return buf;
138
+ }
139
+
140
+ /*
141
+ * call-seq:
142
+ * Win32::API::Callback.new(prototype, return='L'){ |proto| ... }
143
+ *
144
+ * Creates and returns a new Win32::API::Callback object. The prototype
145
+ * arguments are yielded back to the block in the same order they were
146
+ * declared.
147
+ *
148
+ * The +prototype+ is the function prototype for the callback function. This
149
+ * is a string. The possible valid characters are 'I' (integer), 'L' (long),
150
+ * 'V' (void), 'P' (pointer) or 'S' (string). Unlike API objects, API::Callback
151
+ * objects do not have a default prototype.
152
+ *
153
+ * The +return+ argument is the return type for the callback function. The
154
+ * valid characters are the same as for the +prototype+. The default is
155
+ * 'L' (long).
156
+ *
157
+ * Example:
158
+ * require 'win32/api'
159
+ * include Win32
160
+ *
161
+ * EnumWindows = API.new('EnumWindows', 'KP', 'L', 'user32')
162
+ * GetWindowText = API.new('GetWindowText', 'LPI', 'I', 'user32')
163
+ *
164
+ * EnumWindowsProc = API::Callback.new('LP', 'I'){ |handle, param|
165
+ * buf = "\0" * 200
166
+ * GetWindowText.call(handle, buf, 200);
167
+ * puts buf.strip unless buf.strip.empty?
168
+ * buf.index(param).nil? ? true : false
169
+ * }
170
+ *
171
+ * EnumWindows.call(EnumWindowsProc, 'UEDIT32')
172
+ */
173
+ static VALUE callback_init(int argc, VALUE* argv, VALUE self)
174
+ {
175
+ void *find_callback(VALUE,int);
176
+ VALUE v_proto, v_return, v_proc;
177
+ int i;
178
+
179
+ rb_scan_args(argc, argv, "11&", &v_proto, &v_return, &v_proc);
180
+
181
+ /* Validate prototype characters */
182
+ for(i = 0; i < RSTRING_LEN(v_proto); i++){
183
+ switch(RSTRING_PTR(v_proto)[i]){
184
+ case 'I': case 'L': case 'P': case 'V': case 'S':
185
+ break;
186
+ default:
187
+ rb_raise(cAPIProtoError, "Illegal prototype '%c'",
188
+ RSTRING_PTR(v_proto)[i]
189
+ );
190
+ }
191
+ }
192
+
193
+ if(NIL_P(v_return) || RARRAY_LEN(v_return) == 0){
194
+ v_return = rb_str_new2("L");
195
+ }
196
+ else{
197
+ switch(*(TCHAR*)RSTRING_PTR(v_return)){
198
+ case 'I': case 'L': case 'P': case 'V': case 'S':
199
+ break;
200
+ default:
201
+ rb_raise(cAPIProtoError, "Illegal return type '%s'",
202
+ RSTRING_PTR(v_return)
203
+ );
204
+ }
205
+ }
206
+
207
+ rb_iv_set(self, "@function", v_proc);
208
+ rb_iv_set(self, "@prototype", v_proto);
209
+ rb_iv_set(self, "@return_type", v_return);
210
+ rb_iv_set(self, "@address", SIZET2NUM((LPARAM)find_callback(self,RSTRING_LEN(v_proto))));
211
+ ActiveCallback = self;
212
+
213
+ return self;
214
+ }
215
+
216
+ /*
217
+ * call-seq:
218
+ * Win32::API.new(function, prototype='V', return='L', dll='kernel32')
219
+ *
220
+ * Creates and returns a new Win32::API object. The +function+ is the name
221
+ * of the Windows function.
222
+ *
223
+ * The +prototype+ is the function prototype for +function+. This can be a
224
+ * string or an array of characters. The possible valid characters are 'I'
225
+ * (integer), 'L' (long), 'V' (void), 'P' (pointer), 'K' (callback) or 'S'
226
+ * (string).
227
+ *
228
+ * The default is void ('V').
229
+ *
230
+ * Constant (const char*) strings should use 'S'. Pass by reference string
231
+ * buffers should use 'P'. The former is faster, but cannot be modified.
232
+ *
233
+ * The +return+ argument is the return type for the function. The valid
234
+ * characters are the same as for the +prototype+. The default is 'L' (long).
235
+ *
236
+ * The +dll+ is the name of the DLL file that the function is exported from.
237
+ * The default is 'kernel32'.
238
+ *
239
+ * If the function cannot be found then an API::Error is raised (a subclass
240
+ * of RuntimeError).
241
+ *
242
+ * Example:
243
+ *
244
+ * require 'win32/api'
245
+ * include Win32
246
+ *
247
+ * buf = 0.chr * 260
248
+ * len = [buf.length].pack('L')
249
+ *
250
+ * GetUserName = API.new('GetUserName', 'PP', 'I', 'advapi32')
251
+ * GetUserName.call(buf, len)
252
+ *
253
+ * puts buf.strip
254
+ */
255
+ static VALUE api_init(int argc, VALUE* argv, VALUE self)
256
+ {
257
+ HMODULE hLibrary;
258
+ FARPROC fProc;
259
+ Win32API* ptr;
260
+ int i;
261
+ const char* first = "A";
262
+ const char* second = "W";
263
+ VALUE v_proc, v_proto, v_return, v_dll;
264
+
265
+ rb_scan_args(argc, argv, "13", &v_proc, &v_proto, &v_return, &v_dll);
266
+
267
+ Data_Get_Struct(self, Win32API, ptr);
268
+
269
+ // Convert a string prototype to an array of characters
270
+ if(rb_respond_to(v_proto, rb_intern("split")))
271
+ v_proto = rb_str_split(v_proto, "");
272
+
273
+ // Convert a nil or empty prototype to 'V' (void) automatically
274
+ if(NIL_P(v_proto) || RARRAY_LEN(v_proto) == 0){
275
+ v_proto = rb_ary_new();
276
+ rb_ary_push(v_proto, rb_str_new2("V"));
277
+ }
278
+
279
+ // Set an arbitrary limit of 20 parameters
280
+ if(RARRAY_LEN(v_proto) > 20)
281
+ rb_raise(rb_eArgError, "too many parameters: %ld", RARRAY_LEN(v_proto));
282
+
283
+ // Set the default dll to 'kernel32'
284
+ if(NIL_P(v_dll))
285
+ v_dll = rb_str_new2("kernel32");
286
+
287
+ // Set the default return type to 'L' (DWORD)
288
+ if(NIL_P(v_return))
289
+ v_return = rb_str_new2("L");
290
+
291
+ #if defined TAINTING_SUPPORT
292
+ SafeStringValue(v_dll);
293
+ SafeStringValue(v_proc);
294
+ #endif
295
+
296
+ hLibrary = LoadLibrary(TEXT(RSTRING_PTR(v_dll)));
297
+
298
+ // The most likely cause of failure is a bad DLL load path
299
+ if(!hLibrary){
300
+ rb_raise(cAPILoadError, "LoadLibrary() function failed for '%s': %s",
301
+ RSTRING_PTR(v_dll),
302
+ StringError(GetLastError())
303
+ );
304
+ }
305
+
306
+ ptr->library = hLibrary;
307
+
308
+ /* Attempt to get the function. If it fails, try again with an 'A'
309
+ * appended. If that fails, try again with a 'W' appended. If that
310
+ * still fails, raise an API::LoadLibraryError.
311
+ */
312
+
313
+ fProc = GetProcAddress(hLibrary, TEXT(RSTRING_PTR(v_proc)));
314
+
315
+ // Skip the ANSI and Wide function checks for MSVCRT functions.
316
+ if(!fProc){
317
+ if(strstr(RSTRING_PTR(v_dll), "msvcr")){
318
+ rb_raise(
319
+ cAPILoadError,
320
+ "Unable to load function '%s'",
321
+ RSTRING_PTR(v_proc)
322
+ );
323
+ }
324
+ else{
325
+ VALUE v_ascii = rb_str_new3(v_proc);
326
+ v_ascii = rb_str_cat(v_ascii, first, 1);
327
+ fProc = GetProcAddress(hLibrary, TEXT(RSTRING_PTR(v_ascii)));
328
+
329
+ if(!fProc){
330
+ VALUE v_unicode = rb_str_new3(v_proc);
331
+ v_unicode = rb_str_cat(v_unicode, second, 1);
332
+ fProc = GetProcAddress(hLibrary, TEXT(RSTRING_PTR(v_unicode)));
333
+
334
+ if(!fProc){
335
+ rb_raise(
336
+ cAPILoadError,
337
+ "Unable to load function '%s', '%s', or '%s'",
338
+ RSTRING_PTR(v_proc),
339
+ RSTRING_PTR(v_ascii),
340
+ RSTRING_PTR(v_unicode)
341
+ );
342
+ }
343
+ else{
344
+ rb_iv_set(self, "@effective_function_name", v_unicode);
345
+ }
346
+ }
347
+ else{
348
+ rb_iv_set(self, "@effective_function_name", v_ascii);
349
+ }
350
+ }
351
+ }
352
+ else{
353
+ rb_iv_set(self, "@effective_function_name", v_proc);
354
+ }
355
+
356
+ ptr->function = fProc;
357
+
358
+ // Push the numeric prototypes onto our int array for later use.
359
+
360
+ for(i = 0; i < RARRAY_LEN(v_proto); i++){
361
+ #if defined TAINTING_SUPPORT
362
+ SafeStringValue(RARRAY_PTR(v_proto)[i]);
363
+ #endif
364
+ switch(*(TCHAR*)StringValuePtr(RARRAY_PTR(v_proto)[i])){
365
+ case 'L':
366
+ ptr->prototype[i] = _T_LONG;
367
+ break;
368
+ case 'P':
369
+ ptr->prototype[i] = _T_POINTER;
370
+ break;
371
+ case 'I': case 'B':
372
+ ptr->prototype[i] = _T_INTEGER;
373
+ break;
374
+ case 'V':
375
+ ptr->prototype[i] = _T_VOID;
376
+ break;
377
+ case 'K':
378
+ ptr->prototype[i] = _T_CALLBACK;
379
+ break;
380
+ case 'S':
381
+ ptr->prototype[i] = _T_STRING;
382
+ break;
383
+ default:
384
+ rb_raise(cAPIProtoError, "Illegal prototype '%s'",
385
+ StringValuePtr(RARRAY_PTR(v_proto)[i])
386
+ );
387
+ }
388
+ }
389
+
390
+ // Store the return type for later use.
391
+
392
+ // Automatically convert empty strings or nil to type void.
393
+ if(NIL_P(v_return) || RSTRING_LEN(v_return) == 0){
394
+ v_return = rb_str_new2("V");
395
+ ptr->return_type = _T_VOID;
396
+ }
397
+ else{
398
+ #if defined TAINTING_SUPPORT
399
+ SafeStringValue(v_return);
400
+ #endif
401
+ switch(*RSTRING_PTR(v_return)){
402
+ case 'L':
403
+ ptr->return_type = _T_LONG;
404
+ break;
405
+ case 'P':
406
+ ptr->return_type = _T_POINTER;
407
+ break;
408
+ case 'I': case 'B':
409
+ ptr->return_type = _T_INTEGER;
410
+ break;
411
+ case 'V':
412
+ ptr->return_type = _T_VOID;
413
+ break;
414
+ case 'S':
415
+ ptr->return_type = _T_STRING;
416
+ break;
417
+ default:
418
+ rb_raise(cAPIProtoError, "Illegal return type '%s'",
419
+ RSTRING_PTR(v_return)
420
+ );
421
+ }
422
+ }
423
+
424
+ rb_iv_set(self, "@dll_name", v_dll);
425
+ rb_iv_set(self, "@function_name", v_proc);
426
+ rb_iv_set(self, "@prototype", v_proto);
427
+ rb_iv_set(self, "@return_type", v_return);
428
+
429
+ return self;
430
+ }
431
+
432
+ /*
433
+ * call-seq:
434
+ *
435
+ * API::Function.new(address, prototype = 'V', return_type = 'L')
436
+ *
437
+ * Creates and returns an API::Function object. This object is similar to an
438
+ * API object, except that instead of a character function name you pass a
439
+ * function pointer address as the first argument, and there's no associated
440
+ * DLL file.
441
+ *
442
+ * Once you have your API::Function object you can then call it the same way
443
+ * you would an API object.
444
+ *
445
+ * Example:
446
+ *
447
+ * require 'win32/api'
448
+ * include Win32
449
+ *
450
+ * LoadLibrary = API.new('LoadLibrary', 'P', 'L')
451
+ * GetProcAddress = API.new('GetProcAddress', 'LP', 'L')
452
+ *
453
+ * # Play a system beep
454
+ * hlib = LoadLibrary.call('user32')
455
+ * addr = GetProcAddress.call(hlib, 'MessageBeep')
456
+ * func = Win32::API::Function.new(addr, 'L', 'L')
457
+ * func.call(0)
458
+ */
459
+ static VALUE func_init(int argc, VALUE* argv, VALUE self){
460
+ Win32API* ptr;
461
+ int i;
462
+ VALUE v_address, v_proto, v_return;
463
+
464
+ rb_scan_args(argc, argv, "12", &v_address, &v_proto, &v_return);
465
+
466
+ Data_Get_Struct(self, Win32API, ptr);
467
+
468
+ // Convert a string prototype to an array of characters
469
+ if(rb_respond_to(v_proto, rb_intern("split")))
470
+ v_proto = rb_str_split(v_proto, "");
471
+
472
+ // Convert a nil or empty prototype to 'V' (void) automatically
473
+ if(NIL_P(v_proto) || RARRAY_LEN(v_proto) == 0){
474
+ v_proto = rb_ary_new();
475
+ rb_ary_push(v_proto, rb_str_new2("V"));
476
+ }
477
+
478
+ // Set an arbitrary limit of 20 parameters
479
+ if(20 < RARRAY_LEN(v_proto))
480
+ rb_raise(rb_eArgError, "too many parameters: %li\n", RARRAY_LEN(v_proto));
481
+
482
+ // Set the default return type to 'L' (DWORD)
483
+ if(NIL_P(v_return))
484
+ v_return = rb_str_new2("L");
485
+
486
+ ptr->function = (FARPROC)NUM2SIZET(v_address);
487
+
488
+ // Push the numeric prototypes onto our int array for later use.
489
+
490
+ for(i = 0; i < RARRAY_LEN(v_proto); i++){
491
+ #if defined TAINTING_SUPPORT
492
+ SafeStringValue(RARRAY_PTR(v_proto)[i]);
493
+ #endif
494
+ switch(*(char*)StringValuePtr(RARRAY_PTR(v_proto)[i])){
495
+ case 'L':
496
+ ptr->prototype[i] = _T_LONG;
497
+ break;
498
+ case 'P':
499
+ ptr->prototype[i] = _T_POINTER;
500
+ break;
501
+ case 'I': case 'B':
502
+ ptr->prototype[i] = _T_INTEGER;
503
+ break;
504
+ case 'V':
505
+ ptr->prototype[i] = _T_VOID;
506
+ break;
507
+ case 'K':
508
+ ptr->prototype[i] = _T_CALLBACK;
509
+ break;
510
+ case 'S':
511
+ ptr->prototype[i] = _T_STRING;
512
+ break;
513
+ default:
514
+ rb_raise(cAPIProtoError, "Illegal prototype '%s'",
515
+ StringValuePtr(RARRAY_PTR(v_proto)[i])
516
+ );
517
+ }
518
+ }
519
+
520
+ // Store the return type for later use.
521
+
522
+ // Automatically convert empty strings or nil to type void.
523
+ if(NIL_P(v_return) || RSTRING_LEN(v_return) == 0){
524
+ v_return = rb_str_new2("V");
525
+ ptr->return_type = _T_VOID;
526
+ }
527
+ else{
528
+ #if defined TAINTING_SUPPORT
529
+ SafeStringValue(v_return);
530
+ #endif
531
+ switch(*RSTRING_PTR(v_return)){
532
+ case 'L':
533
+ ptr->return_type = _T_LONG;
534
+ break;
535
+ case 'P':
536
+ ptr->return_type = _T_POINTER;
537
+ break;
538
+ case 'I': case 'B':
539
+ ptr->return_type = _T_INTEGER;
540
+ break;
541
+ case 'V':
542
+ ptr->return_type = _T_VOID;
543
+ break;
544
+ case 'S':
545
+ ptr->return_type = _T_STRING;
546
+ break;
547
+ default:
548
+ rb_raise(cAPIProtoError, "Illegal return type '%s'",
549
+ RSTRING_PTR(v_return)
550
+ );
551
+ }
552
+ }
553
+
554
+ rb_iv_set(self, "@address", v_address);
555
+ rb_iv_set(self, "@prototype", v_proto);
556
+ rb_iv_set(self, "@return_type", v_return);
557
+
558
+ return self;
559
+ }
560
+
561
+ typedef struct {
562
+ uintptr_t params[20];
563
+ } CALLPARAM;
564
+
565
+
566
+ DWORD CallbackFunction(CALLPARAM param, VALUE callback)
567
+ {
568
+ VALUE v_proto, v_return, v_proc, v_retval;
569
+ VALUE argv[20];
570
+ int i, argc;
571
+ char *a_proto;
572
+ char *a_return;
573
+
574
+ if(callback && !NIL_P(callback)){
575
+ v_proto = rb_iv_get(callback, "@prototype");
576
+ a_proto = RSTRING_PTR(v_proto);
577
+
578
+ v_return = rb_iv_get(callback, "@return_type");
579
+ a_return = RSTRING_PTR(v_return);
580
+
581
+ v_proc = rb_iv_get(callback, "@function");
582
+ argc = RSTRING_LEN(v_proto);
583
+
584
+ for(i=0; i < RSTRING_LEN(v_proto); i++){
585
+ argv[i] = Qnil;
586
+ switch(a_proto[i]){
587
+ case 'L':
588
+ argv[i] = SIZET2NUM(param.params[i]);
589
+ break;
590
+ case 'P':
591
+ if(param.params[i])
592
+ argv[i] = rb_str_new2((char *)param.params[i]);
593
+ break;
594
+ case 'I':
595
+ argv[i] = INT2NUM(param.params[i]);
596
+ break;
597
+ default:
598
+ rb_raise(cAPIProtoError, "Illegal prototype '%c'", a_proto[i]);
599
+ }
600
+ }
601
+
602
+ v_retval = rb_funcall2(v_proc, rb_intern("call"), argc, argv);
603
+
604
+ /* Handle true and false explicitly, as some CALLBACK functions
605
+ * require TRUE or FALSE to break out of loops, etc.
606
+ */
607
+ if(v_retval == Qtrue)
608
+ return TRUE;
609
+ else if(v_retval == Qfalse)
610
+ return FALSE;
611
+
612
+ switch (*a_return) {
613
+ case 'I':
614
+ return NUM2INT(v_retval);
615
+ break;
616
+ case 'L':
617
+ return NUM2SIZET(v_retval);
618
+ break;
619
+ case 'S':
620
+ return (uintptr_t)RSTRING_PTR(v_retval);
621
+ break;
622
+ case 'P':
623
+ if(NIL_P(v_retval)){
624
+ return 0;
625
+ }
626
+ else if(FIXNUM_P(v_retval)){
627
+ return NUM2SIZET(v_retval);
628
+ }
629
+ else{
630
+ StringValue(v_retval);
631
+ rb_str_modify(v_retval);
632
+ return (uintptr_t)StringValuePtr(v_retval);
633
+ }
634
+ break;
635
+ }
636
+ }
637
+
638
+ return 0;
639
+ }
640
+
641
+ #define CALLBACK0(x) DWORD CALLBACK CallbackFunction0_##x() {\
642
+ CALLPARAM param = {{0}};\
643
+ param.params[0] = 0;\
644
+ return CallbackFunction(param,FuncTable[0][x]);\
645
+ }
646
+
647
+ #define CALLBACK1(x) DWORD CALLBACK CallbackFunction1_##x(DWORD p1) {\
648
+ CALLPARAM param = {{p1}};\
649
+ return CallbackFunction(param,FuncTable[1][x]);\
650
+ }
651
+
652
+ #define CALLBACK2(x) DWORD CALLBACK CallbackFunction2_##x(\
653
+ DWORD p1, DWORD p2){\
654
+ CALLPARAM param = {{p1,p2}};\
655
+ return CallbackFunction(param,FuncTable[2][x]);\
656
+ }
657
+
658
+ #define CALLBACK3(x) DWORD CALLBACK CallbackFunction3_##x(\
659
+ DWORD p1, DWORD p2, DWORD p3){\
660
+ CALLPARAM param = {{p1,p2,p3}};\
661
+ return CallbackFunction(param,FuncTable[3][x]);\
662
+ }
663
+
664
+ #define CALLBACK4(x) DWORD CALLBACK CallbackFunction4_##x(\
665
+ DWORD p1, DWORD p2, DWORD p3, DWORD p4){\
666
+ CALLPARAM param = {{p1,p2,p3,p4}};\
667
+ return CallbackFunction(param,FuncTable[4][x]);\
668
+ }
669
+
670
+ #define CALLBACK5(x) DWORD CALLBACK CallbackFunction5_##x(\
671
+ DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5\
672
+ ){\
673
+ CALLPARAM param = {{p1,p2,p3,p4,p5}};\
674
+ return CallbackFunction(param,FuncTable[5][x]);\
675
+ }
676
+
677
+ #define CALLBACK6(x) DWORD CALLBACK CallbackFunction6_##x(\
678
+ DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5, DWORD p6\
679
+ ){\
680
+ CALLPARAM param = {{p1,p2,p3,p4,p5,p6}};\
681
+ return CallbackFunction(param,FuncTable[6][x]);\
682
+ }
683
+
684
+ #define CALLBACK7(x) DWORD CALLBACK CallbackFunction7_##x(\
685
+ DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5, DWORD p6, DWORD p7\
686
+ ){\
687
+ CALLPARAM param = {{p1,p2,p3,p4,p5,p6,p7}};\
688
+ return CallbackFunction(param,FuncTable[7][x]);\
689
+ }
690
+
691
+ #define CALLBACK8(x) DWORD CALLBACK CallbackFunction8_##x(\
692
+ DWORD p1, DWORD p2, DWORD p3, DWORD p4,\
693
+ DWORD p5, DWORD p6, DWORD p7, DWORD p8\
694
+ ){\
695
+ CALLPARAM param = {{p1,p2,p3,p4,p5,p6,p7,p8}};\
696
+ return CallbackFunction(param,FuncTable[8][x]);\
697
+ }
698
+
699
+ #define CALLBACK9(x) DWORD CALLBACK CallbackFunction9_##x(\
700
+ DWORD p1, DWORD p2, DWORD p3, DWORD p4, DWORD p5,\
701
+ DWORD p6, DWORD p7, DWORD p8, DWORD p9\
702
+ ){\
703
+ CALLPARAM param = {{p1,p2,p3,p4,p5,p6,p7,p8,p9}};\
704
+ return CallbackFunction(param,FuncTable[9][x]);\
705
+ }
706
+
707
+ #define DEFCALLBACK(x) CALLBACK##x(0)\
708
+ CALLBACK##x(1)\
709
+ CALLBACK##x(2)\
710
+ CALLBACK##x(3)\
711
+ CALLBACK##x(4)\
712
+ CALLBACK##x(5)\
713
+ CALLBACK##x(6)\
714
+ CALLBACK##x(7)\
715
+ CALLBACK##x(8)\
716
+ CALLBACK##x(9)
717
+
718
+ #define CF(x,y) CallbackFunction##x##_##y
719
+
720
+ static VALUE FuncTable[10][10];
721
+
722
+ DEFCALLBACK(0)
723
+ DEFCALLBACK(1)
724
+ DEFCALLBACK(2)
725
+ DEFCALLBACK(3)
726
+ DEFCALLBACK(4)
727
+ DEFCALLBACK(5)
728
+ DEFCALLBACK(6)
729
+ DEFCALLBACK(7)
730
+ DEFCALLBACK(8)
731
+ DEFCALLBACK(9)
732
+
733
+ void *CallbackTable[10][10] = {
734
+ {CF(0,0),CF(0,1),CF(0,2),CF(0,3),CF(0,4),CF(0,5),CF(0,6),CF(0,7),CF(0,8),CF(0,9)},
735
+ {CF(1,0),CF(1,1),CF(1,2),CF(1,3),CF(1,4),CF(1,5),CF(1,6),CF(1,7),CF(1,8),CF(1,9)},
736
+ {CF(2,0),CF(2,1),CF(2,2),CF(2,3),CF(2,4),CF(2,5),CF(2,6),CF(2,7),CF(2,8),CF(2,9)},
737
+ {CF(3,0),CF(3,1),CF(3,2),CF(3,3),CF(3,4),CF(3,5),CF(3,6),CF(3,7),CF(3,8),CF(3,9)},
738
+ {CF(4,0),CF(4,1),CF(4,2),CF(4,3),CF(4,4),CF(4,5),CF(4,6),CF(4,7),CF(4,8),CF(4,9)},
739
+ {CF(5,0),CF(5,1),CF(5,2),CF(5,3),CF(5,4),CF(5,5),CF(5,6),CF(5,7),CF(5,8),CF(5,9)},
740
+ {CF(6,0),CF(6,1),CF(6,2),CF(6,3),CF(6,4),CF(6,5),CF(6,6),CF(6,7),CF(6,8),CF(6,9)},
741
+ {CF(7,0),CF(7,1),CF(7,2),CF(7,3),CF(7,4),CF(7,5),CF(7,6),CF(7,7),CF(7,8),CF(7,9)},
742
+ {CF(8,0),CF(8,1),CF(8,2),CF(8,3),CF(8,4),CF(8,5),CF(8,6),CF(8,7),CF(8,8),CF(8,9)},
743
+ {CF(9,0),CF(9,1),CF(9,2),CF(9,3),CF(9,4),CF(9,5),CF(9,6),CF(9,7),CF(9,8),CF(9,9)}};
744
+
745
+
746
+ void *find_callback(VALUE obj,int len)
747
+ {
748
+ int i;
749
+ for(i=0;i<10;i++)
750
+ {
751
+ if(FuncTable[len][i]==0)
752
+ break;
753
+ }
754
+ if(i>=10)
755
+ rb_raise(cAPIError,"too many callbacks are defined.");
756
+ FuncTable[len][i] = obj;
757
+ return CallbackTable[len][i];
758
+ }
759
+
760
+ /*
761
+ * call-seq:
762
+ * Win32::API#call(arg1, arg2, ...)
763
+ *
764
+ * Calls the function pointer with the given arguments (if any). Note that,
765
+ * while this method will catch some prototype mismatches (raising a TypeError
766
+ * in the process), it is not fulproof. It is ultimately your job to make
767
+ * sure the arguments match the +prototype+ specified in the constructor.
768
+ *
769
+ * For convenience, nil is converted to NULL, true is converted to TRUE (1)
770
+ * and false is converted to FALSE (0).
771
+ */
772
+ static VALUE api_call(int argc, VALUE* argv, VALUE self){
773
+ VALUE v_proto, v_args, v_arg, v_return;
774
+ Win32API* ptr;
775
+ uintptr_t return_value;
776
+ int i = 0;
777
+ int len;
778
+
779
+ struct{
780
+ uintptr_t params[20];
781
+ } param;
782
+
783
+ Data_Get_Struct(self, Win32API, ptr);
784
+
785
+ rb_scan_args(argc, argv, "0*", &v_args);
786
+
787
+ v_proto = rb_iv_get(self, "@prototype");
788
+
789
+ // For void prototypes, allow either no args or an explicit nil
790
+ if(RARRAY_LEN(v_proto) != RARRAY_LEN(v_args)){
791
+ char* c = StringValuePtr(RARRAY_PTR(v_proto)[0]);
792
+ if(!strcmp(c, "V")){
793
+ rb_ary_push(v_args, Qnil);
794
+ }
795
+ else{
796
+ rb_raise(rb_eArgError,
797
+ "wrong number of parameters: expected %ld, got %ld",
798
+ RARRAY_LEN(v_proto), RARRAY_LEN(v_args)
799
+ );
800
+ }
801
+ }
802
+
803
+ len = RARRAY_LEN(v_proto);
804
+
805
+ for(i = 0; i < len; i++){
806
+ v_arg = RARRAY_PTR(v_args)[i];
807
+
808
+ // Convert nil to NULL. Otherwise convert as appropriate.
809
+ if(NIL_P(v_arg))
810
+ param.params[i] = (uintptr_t)NULL;
811
+ else if(v_arg == Qtrue)
812
+ param.params[i] = TRUE;
813
+ else if(v_arg == Qfalse)
814
+ param.params[i] = FALSE;
815
+ else
816
+ switch(ptr->prototype[i]){
817
+ case _T_LONG:
818
+ param.params[i] = NUM2SIZET(v_arg);
819
+ break;
820
+ case _T_INTEGER:
821
+ param.params[i] = NUM2INT(v_arg);
822
+ break;
823
+ case _T_POINTER:
824
+ if(FIXNUM_P(v_arg)){
825
+ param.params[i] = NUM2SIZET(v_arg);
826
+ }
827
+ else{
828
+ StringValue(v_arg);
829
+ rb_str_modify(v_arg);
830
+ param.params[i] = (uintptr_t)StringValuePtr(v_arg);
831
+ }
832
+ break;
833
+ case _T_CALLBACK:
834
+ ActiveCallback = v_arg;
835
+ param.params[i] = (LPARAM)NUM2SIZET(rb_iv_get(ActiveCallback, "@address"));;
836
+ break;
837
+ case _T_STRING:
838
+ param.params[i] = (uintptr_t)RSTRING_PTR(v_arg);
839
+ break;
840
+ default:
841
+ param.params[i] = NUM2SIZET(v_arg);
842
+ }
843
+ }
844
+
845
+ /* Call the function, get the return value */
846
+ if(strcmp(StringValuePtr(RARRAY_PTR(v_proto)[0]), "V") == 0 && len == 1)
847
+ {
848
+ return_value = ptr->function();
849
+ }
850
+ else
851
+ {
852
+ switch(len)
853
+ {
854
+ case 0:
855
+ return_value = ptr->function();
856
+ break;
857
+ case 1:
858
+ return_value = ptr->function(param.params[0]);
859
+ break;
860
+ case 2:
861
+ return_value = ptr->function(param.params[0], param.params[1]);
862
+ break;
863
+ case 3:
864
+ return_value = ptr->function(param.params[0], param.params[1],
865
+ param.params[2]);
866
+ break;
867
+ case 4:
868
+ return_value = ptr->function(param.params[0], param.params[1],
869
+ param.params[2], param.params[3]);
870
+ break;
871
+ case 5:
872
+ return_value = ptr->function(param.params[0], param.params[1],
873
+ param.params[2], param.params[3], param.params[4]);
874
+ break;
875
+ case 6:
876
+ return_value = ptr->function(param.params[0], param.params[1],
877
+ param.params[2], param.params[3], param.params[4], param.params[5]);
878
+ break;
879
+ case 7:
880
+ return_value = ptr->function(param.params[0], param.params[1],
881
+ param.params[2], param.params[3], param.params[4], param.params[5],
882
+ param.params[6]);
883
+ break;
884
+ case 8:
885
+ return_value = ptr->function(param.params[0], param.params[1],
886
+ param.params[2], param.params[3], param.params[4], param.params[5],
887
+ param.params[6], param.params[7]);
888
+ break;
889
+ case 9:
890
+ return_value = ptr->function(param.params[0], param.params[1],
891
+ param.params[2], param.params[3], param.params[4], param.params[5],
892
+ param.params[6], param.params[7], param.params[8]);
893
+ break;
894
+ case 10:
895
+ return_value = ptr->function(param.params[0], param.params[1],
896
+ param.params[2], param.params[3], param.params[4], param.params[5],
897
+ param.params[6], param.params[7], param.params[8], param.params[9]);
898
+ break;
899
+ case 11:
900
+ return_value = ptr->function(param.params[0], param.params[1],
901
+ param.params[2], param.params[3], param.params[4], param.params[5],
902
+ param.params[6], param.params[7], param.params[8], param.params[9],
903
+ param.params[10]);
904
+ break;
905
+ case 12:
906
+ return_value = ptr->function(param.params[0], param.params[1],
907
+ param.params[2], param.params[3], param.params[4], param.params[5],
908
+ param.params[6], param.params[7], param.params[8], param.params[9],
909
+ param.params[10], param.params[11]);
910
+ break;
911
+ case 13:
912
+ return_value = ptr->function(param.params[0], param.params[1],
913
+ param.params[2], param.params[3], param.params[4], param.params[5],
914
+ param.params[6], param.params[7], param.params[8], param.params[9],
915
+ param.params[10], param.params[11], param.params[12]);
916
+ break;
917
+ case 14:
918
+ return_value = ptr->function(param.params[0], param.params[1],
919
+ param.params[2], param.params[3], param.params[4], param.params[5],
920
+ param.params[6], param.params[7], param.params[8], param.params[9],
921
+ param.params[10], param.params[11], param.params[12], param.params[13]);
922
+ break;
923
+ case 15:
924
+ return_value = ptr->function(param.params[0], param.params[1],
925
+ param.params[2], param.params[3], param.params[4], param.params[5],
926
+ param.params[6], param.params[7], param.params[8], param.params[9],
927
+ param.params[10], param.params[11], param.params[12], param.params[13],
928
+ param.params[14]);
929
+ break;
930
+ case 16:
931
+ return_value = ptr->function(param.params[0], param.params[1],
932
+ param.params[2], param.params[3], param.params[4], param.params[5],
933
+ param.params[6], param.params[7], param.params[8], param.params[9],
934
+ param.params[10], param.params[11], param.params[12], param.params[13],
935
+ param.params[14], param.params[15]);
936
+ break;
937
+ case 17:
938
+ return_value = ptr->function(param.params[0], param.params[1],
939
+ param.params[2], param.params[3], param.params[4], param.params[5],
940
+ param.params[6], param.params[7], param.params[8], param.params[9],
941
+ param.params[10], param.params[11], param.params[12], param.params[13],
942
+ param.params[14], param.params[15], param.params[16]);
943
+ break;
944
+ case 18:
945
+ return_value = ptr->function(param.params[0], param.params[1],
946
+ param.params[2], param.params[3], param.params[4], param.params[5],
947
+ param.params[6], param.params[7], param.params[8], param.params[9],
948
+ param.params[10], param.params[11], param.params[12], param.params[13],
949
+ param.params[14], param.params[15], param.params[16], param.params[17]);
950
+ break;
951
+ case 19:
952
+ return_value = ptr->function(param.params[0], param.params[1],
953
+ param.params[2], param.params[3], param.params[4], param.params[5],
954
+ param.params[6], param.params[7], param.params[8], param.params[9],
955
+ param.params[10], param.params[11], param.params[12], param.params[13],
956
+ param.params[14], param.params[15], param.params[16], param.params[17],
957
+ param.params[18]);
958
+ break;
959
+ case 20:
960
+ return_value = ptr->function(param.params[0], param.params[1],
961
+ param.params[2], param.params[3], param.params[4], param.params[5],
962
+ param.params[6], param.params[7], param.params[8], param.params[9],
963
+ param.params[10], param.params[11], param.params[12], param.params[13],
964
+ param.params[14], param.params[15], param.params[16], param.params[17],
965
+ param.params[18], param.params[19]);
966
+ break;
967
+ default:
968
+ rb_raise(rb_eArgError,"number of parameters exceed 20!");
969
+ }
970
+ }
971
+
972
+ /* Return the appropriate type based on the return type specified
973
+ * in the constructor.
974
+ */
975
+ switch(ptr->return_type){
976
+ case _T_INTEGER:
977
+ v_return = INT2NUM(return_value);
978
+ break;
979
+ case _T_LONG:
980
+ v_return = SIZET2NUM(return_value);
981
+ break;
982
+ case _T_VOID:
983
+ v_return = Qnil;
984
+ break;
985
+ case _T_POINTER:
986
+ if(!return_value){
987
+ v_return = Qnil;
988
+ }
989
+ else{
990
+ VALUE v_efunc = rb_iv_get(self, "@effective_function_name");
991
+ char* efunc = RSTRING_PTR(v_efunc);
992
+ if(efunc[strlen(efunc)-1] == 'W'){
993
+ v_return = rb_str_new(
994
+ (TCHAR*)return_value,
995
+ wcslen((wchar_t*)return_value)*2
996
+ );
997
+ }
998
+ else{
999
+ v_return = rb_str_new2((TCHAR*)return_value);
1000
+ }
1001
+ }
1002
+ break;
1003
+ case _T_STRING:
1004
+ {
1005
+ VALUE v_efunc = rb_iv_get(self, "@effective_function_name");
1006
+ char* efunc = RSTRING_PTR(v_efunc);
1007
+
1008
+ if(efunc[strlen(efunc)-1] == 'W'){
1009
+ v_return = rb_str_new(
1010
+ (TCHAR*)return_value,
1011
+ wcslen((wchar_t*)return_value)*2
1012
+ );
1013
+ }
1014
+ else{
1015
+ v_return = rb_str_new2((TCHAR*)return_value);
1016
+ }
1017
+ }
1018
+ break;
1019
+ default:
1020
+ v_return = INT2NUM(0);
1021
+ }
1022
+
1023
+ return v_return;
1024
+ }
1025
+
1026
+ /*
1027
+ * Wraps the Windows API functions in a Ruby interface.
1028
+ */
1029
+ void Init_api(){
1030
+ VALUE mWin32, cAPI, cCallback, cFunction;
1031
+
1032
+ /* Modules and Classes */
1033
+
1034
+ /* The Win32 module serves as a namespace only */
1035
+ mWin32 = rb_define_module("Win32");
1036
+
1037
+ /* The API class encapsulates a function pointer to Windows API function */
1038
+ cAPI = rb_define_class_under(mWin32, "API", rb_cObject);
1039
+
1040
+ /* The API::Callback class encapsulates a Windows CALLBACK function */
1041
+ cCallback = rb_define_class_under(cAPI, "Callback", rb_cObject);
1042
+
1043
+ /* The API::Function class encapsulates a raw function pointer */
1044
+ cFunction = rb_define_class_under(cAPI, "Function", cAPI);
1045
+
1046
+ /* The API::Error class serves as a base class for other errors */
1047
+ cAPIError = rb_define_class_under(cAPI, "Error", rb_eRuntimeError);
1048
+
1049
+ /* The LoadError class is raised if a function cannot be found or loaded */
1050
+ cAPILoadError = rb_define_class_under(cAPI, "LoadLibraryError", cAPIError);
1051
+
1052
+ /* The PrototypeError class is raised if an invalid prototype is passed */
1053
+ cAPIProtoError = rb_define_class_under(cAPI, "PrototypeError", cAPIError);
1054
+
1055
+ /* Miscellaneous */
1056
+ rb_define_alloc_func(cAPI, api_allocate);
1057
+
1058
+ /* Win32::API Instance Methods */
1059
+ rb_define_method(cAPI, "initialize", api_init, -1);
1060
+ rb_define_method(cAPI, "call", api_call, -1);
1061
+
1062
+ /* Win32::API::Callback Instance Methods */
1063
+ rb_define_method(cCallback, "initialize", callback_init, -1);
1064
+
1065
+ /* Win32::API::Function Instance Methods */
1066
+ rb_define_method(cFunction, "initialize", func_init, -1);
1067
+
1068
+ /* The name of the DLL that exports the API function */
1069
+ rb_define_attr(cAPI, "dll_name", 1, 0);
1070
+
1071
+ /* The name of the function passed to the constructor */
1072
+ rb_define_attr(cAPI, "function_name", 1, 0);
1073
+
1074
+ /* The name of the actual function that is returned by the constructor.
1075
+ * For example, if you passed 'GetUserName' to the constructor, then the
1076
+ * effective function name would be either 'GetUserNameA' or 'GetUserNameW'.
1077
+ */
1078
+ rb_define_attr(cAPI, "effective_function_name", 1, 0);
1079
+
1080
+ /* The prototype, returned as an array of characters */
1081
+ rb_define_attr(cAPI, "prototype", 1, 0);
1082
+
1083
+ /* The return type, returned as a single character, S, P, L, I, V or B */
1084
+ rb_define_attr(cAPI, "return_type", 1, 0);
1085
+
1086
+ /* Win32::API::Callback Instance Methods */
1087
+
1088
+ /* The prototype, returned as an array of characters */
1089
+ rb_define_attr(cCallback, "prototype", 1, 0);
1090
+
1091
+ /* The return type, returned as a single character, S, P, L, I, V or B */
1092
+ rb_define_attr(cCallback, "return_type", 1, 0);
1093
+
1094
+ /* The numeric address of the function pointer */
1095
+ rb_define_attr(cCallback, "address", 1, 0);
1096
+ rb_define_attr(cFunction, "address", 1, 0);
1097
+
1098
+ /* Constants */
1099
+
1100
+ /* 1.6.0: The version of the win32-api library */
1101
+ rb_define_const(cAPI, "VERSION", rb_str_new2(WINDOWS_API_VERSION));
1102
+ }