Permalink
Browse files

JRUBY-6595 fixes last part of running win32 registry in 1.9 mode

  • Loading branch information...
1 parent 3172fee commit b8528c843009137b3442e6d5a6e25e81ceda188f @enebo enebo committed May 17, 2012
Showing with 16 additions and 23 deletions.
  1. +16 −23 lib/ruby/1.9/win32/registry.rb
@@ -1,4 +1,4 @@
-require 'dl/import'
+require 'Win32API'
module Win32
=begin rdoc
@@ -160,11 +160,7 @@ module Constants
# Error
#
class Error < ::StandardError
- module Kernel32
- extend DL::Importer
- dlload "kernel32.dll"
- end
- FormatMessageA = Kernel32.extern "int FormatMessageA(int, void *, int, int, void *, int, void *)", :stdcall
+ FormatMessageA = Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
def initialize(code)
@code = code
msg = "\0".force_encoding(Encoding::ASCII_8BIT) * 1024
@@ -195,34 +191,31 @@ def close
def class
Registry
end
-
+3
# Make all
Constants.constants.grep(/^HKEY_/) do |c|
- Registry.const_set c, new(Constants.const_get(c), c.to_s)
+ Registry.const_set c, new(Constants.const_get(c), c)
end
end
#
# Win32 APIs
#
module API
- extend DL::Importer
- dlload "advapi32.dll"
[
- "long RegOpenKeyExA(void *, void *, long, long, void *)",
- "long RegCreateKeyExA(void *, void *, long, long, long, long, void *, void *, void *)",
- "long RegEnumValueA(void *, long, void *, void *, void *, void *, void *, void *)",
- "long RegEnumKeyExA(void *, long, void *, void *, void *, void *, void *, void *)",
- "long RegQueryValueExA(void *, void *, void *, void *, void *, void *)",
- "long RegSetValueExA(void *, void *, long, long, void *, long)",
- "long RegDeleteValue(void *, void *)",
- "long RegDeleteKey(void *, void *)",
- "long RegFlushKey(void *)",
- "long RegCloseKey(void *)",
- "long RegQueryInfoKey(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *)",
+ %w/RegOpenKeyExA LPLLP L/,
+ %w/RegCreateKeyExA LPLLLLPPP L/,
+ %w/RegEnumValueA LLPPPPPP L/,
+ %w/RegEnumKeyExA LLPPLLLP L/,
+ %w/RegQueryValueExA LPLPPP L/,
+ %w/RegSetValueExA LPLLPL L/,
+ %w/RegDeleteValue LP L/,
+ %w/RegDeleteKey LP L/,
+ %w/RegFlushKey L L/,
+ %w/RegCloseKey L L/,
+ %w/RegQueryInfoKey LPPPPPPPPPPP L/,
].each do |fn|
- cfunc = extern fn, :stdcall
- const_set cfunc.name.intern, cfunc
+ const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
end
module_function

0 comments on commit b8528c8

Please sign in to comment.