win32-api 1.5.0-universal-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43f49890c4c1c03565dcebe7e0b9a1633e299d7c
4
+ data.tar.gz: 1fb103cb311aca0cca09355fa689b9343b1a44ce
5
+ SHA512:
6
+ metadata.gz: 6d185f01c4f9f1e553acbace429ebe58e610c1209d90d8db1f6c92e4471f821ca05ce5652f6767210968edee583d84f67865d3402ea6c048f3591b35178fae67
7
+ data.tar.gz: 4de7942471cd2360ce77eeb925830d8aa7e274b46bae4efc5166bac8dabdc542da61acde4e7dd60f42ba69256471cfb160120ded5131b8f200b5ea1cda74825e
data/CHANGES ADDED
@@ -0,0 +1,154 @@
1
+ == 1.5.0 - 22-Aug-2013
2
+ * Fixes for Ruby x64.
3
+ * There are now separate 32 and 64 bit binaries packaged for Ruby 2.x.
4
+ * Updates to the Rakefile for the gem:binary task.
5
+ * Some README updates, including Future Plans.
6
+
7
+ == 1.4.9 - 14-Jul-2013
8
+ * Added a binary for Ruby 2.0.
9
+ * Add devkit to Rakefile for the gem:binary task.
10
+
11
+ == 1.4.8 - 16-Jan-2011
12
+ * A binary for both 1.8.x and 1.9.x is now shipped as part of the binary
13
+ build. A stub file is used to dynamically require the correct binary based
14
+ on your current version of Ruby.
15
+ * Some updates to the Rakefile to help build multiple binaries.
16
+
17
+ == 1.4.7 - 4-Dec-2010
18
+ * An internal error formatting function now resorts to the default
19
+ LANGID on error 1815 (ERROR_RESOURCE_LANG_NOT_FOUND). Thanks go to
20
+ Little Snake for the spot.
21
+ * Added a default Rake task and refactored the clean task.
22
+
23
+ == 1.4.6 - 9-Feb-2010
24
+ * Fixed a warning that showed up with MinGW/gcc caused by an unnecessary
25
+ pointer dereference.
26
+ * Some updates to the Rakefile and gemspec. Gem building is now handled via
27
+ Rake tasks.
28
+ * Minor updates to the test suite.
29
+
30
+ == 1.4.5 - 24-Aug-2009
31
+ * Reverted the change in 1.4.4. We need unsigned longs in a few cases.
32
+ Consequently, you should upgrade windows-pr to 1.0.8 or later because
33
+ some return values were set to -1 instead of 0xFFFFFFFF as they are now.
34
+ * Updated one test to validate return value from failed function.
35
+
36
+ == 1.4.4 - 18-Aug-2009
37
+ * Fixed a bug where functions that returned a long return type were unsigned
38
+ instead of signed.
39
+ * The Rakefile has been refactored somewhat, including the removal of FFI
40
+ related tasks. Those are now in a separate branch in the repository.
41
+ * The test-unit library is now a development dependency instead of a runtime
42
+ dependency.
43
+
44
+ == 1.4.3 - 23-Jun-2009
45
+ * Bug fix for mingw.
46
+ * License now set to Artistic 2.0.
47
+
48
+ == 1.4.2 - 31-May-2009
49
+ * Updated the internal StringError() function to better handle the possibility
50
+ of the English .mui file not being found. Thanks go to Michel Demazure for
51
+ the spot.
52
+
53
+ == 1.4.1 - 29-May-2009
54
+ * Callback handling improvements.
55
+ * Updated the gemspec description.
56
+
57
+ == 1.4.0 - 19-Feb-2009
58
+ * Now compatible with Ruby 1.9.x.
59
+ * In what will go down as, "It seemed like a good idea at the time", I have
60
+ removed the feature where W (wide) character functions were used first if
61
+ your $KCODE environment variable was set to "UTF8". It caused too many
62
+ headaches in practice, especially amongst Rails users. You must now always
63
+ explicitly specify 'W' in the constructor if that's what you want.
64
+ * Fixed RF bug #23944 - bad error message for MSVCRT functions that failed
65
+ to load properly.
66
+
67
+ == 1.3.0 - 1-Jan-2009
68
+ * Fixed RubyForge bug #23395, which was caused by inadvertently modifying
69
+ a variable within a loop. This caused callbacks to fail in certain
70
+ situations.
71
+ * Added the Win32::API::LoadLibraryError and Win32::API::PrototypeError classes
72
+ to provide more fine grained handling of possible error conditions in the
73
+ constructor. These are both subclasses of Win32::API::Error.
74
+ * Removed the Win32::API::CallbackError class.
75
+ * Changed the upper limit on prototypes from 16 to 20. It turns out that
76
+ there are actually Windows functions with more than 16 prototypes.
77
+ * Refactored a high iteration test so that it counts as only one test
78
+ instead of 1000.
79
+
80
+ == 1.2.2 - 27-Nov-2008
81
+ * Fixed bug in the error message for illegal prototypes and illegal return
82
+ types where the character in question would come out as empty or garbage.
83
+ * Passing a bad return type to Win32::API::Callback now raises an error.
84
+ * Updated the error message for illegal return types to say, "Illegal return
85
+ type" instead of "Illegal prototype" as it did previously.
86
+ * The error message for a bad function name passed to Win32::API.new now
87
+ matches JRuby's FFI error message.
88
+ * Improved the handling of msvcrt functions with regards to skipping 'A'
89
+ and 'W' checks. Previously it was checking against the literal string
90
+ 'msvcrt'. Now it checks against any string that starts with 'msvcr'.
91
+ * Added test-unit 2.x as a prerequisite.
92
+ * Added tests for the Win32::API::Callback#address method.
93
+ * Added tests to all Win32::API classes that explicitly check error messages.
94
+
95
+ == 1.2.1 - 14-Nov-2008
96
+ * Fixed and updated callback handling.
97
+ * Fixed wide string return handling for pointers and strings.
98
+ * Added the Win32::API::Callback#address instance method.
99
+ * All errors are now in English instead of your native language, because
100
+ that's what Ruby itself does.
101
+
102
+ == 1.2.0 - 22-Jul-2008
103
+ * Added support for the 'S' (string) prototype and return type. It can be
104
+ used instead of 'P' (pointer) for const char*.
105
+ * Some internal refactoring. The attempts to load ANSI and/or Wide character
106
+ versions of functions are skipped for MSVCRT functions, since they do not
107
+ exist. This eliminates some unnecessary LoadLibrary() calls.
108
+ * Added a couple of gem building Rake tasks.
109
+ * Added a few more tests.
110
+
111
+ == 1.1.0 - 12-Jun-2008
112
+ * Added the Windows::API::Function class. This is a subclass of Win32::API
113
+ meant only for use with raw function pointers.
114
+ * Some documentation updates in the source and README files.
115
+
116
+ == 1.0.6 - 18-Apr-2008
117
+ * Added the effective_function_name method. This allows you to see what the
118
+ actual function name is that was defined, e.g. GetUserNameA vs GetUserNameW.
119
+ * Replaced an instance of _tcscmp with strcmp. The case in question was always
120
+ going to be ASCII.
121
+ * Cleaned up some -W3 warnings.
122
+ * Added the build_manifest task to the Rakefile, which is automatically run if
123
+ you're using a version of Ruby built with VC++ 8 or later. This builds a
124
+ ruby.exe.manifest file (if it doesn't already exist).
125
+
126
+ == 1.0.5 - 20-Nov-2007
127
+ * The API.new method now defaults to "W" (wide character functions) before "A"
128
+ (ANSI functions) if the $KCODE global variable is set to 'u' (UTF8).
129
+ * Minor improvements to the Rakefile.
130
+
131
+ == 1.0.4 - 26-Oct-2007
132
+ * Fixed a bug where methods that returned pointers ('P') could choke if the
133
+ resulting pointer was 0 or NULL. In this case, nil is now returned instead.
134
+ * Tweak to the extconf.rb file that helps the gem build it from source
135
+ properly.
136
+
137
+ == 1.0.3 - 28-Sep-2007
138
+ * Fixed a subtle but dangerous copy-on-write bug in the API#call method.
139
+
140
+ == 1.0.2 - 28-Sep-2007
141
+ * Fixed a bug in an internal struct member that was causing segfaults. Thanks
142
+ go to Lars Olsson for the spot.
143
+ * Fixed the 'install' task in the Rakefile. This only affected native builds,
144
+ not the prebuilt binary.
145
+ * Added a few more tests.
146
+
147
+ == 1.0.1 - 27-Sep-2007
148
+ * Functions declared with a void prototype no longer require an explicit nil
149
+ argument to fulfill the arity requirement. You can still call them with an
150
+ explicit nil if you wish, however.
151
+ * Fixed the gemspec for the native build.
152
+
153
+ == 1.0.0 - 14-Sep-2007
154
+ * Initial release
data/MANIFEST ADDED
@@ -0,0 +1,10 @@
1
+ * CHANGES
2
+ * MANIFEST
3
+ * README
4
+ * Rakefile
5
+ * win32-api.gemspec
6
+ * ext/extconf.rb
7
+ * ext/win32/api.c
8
+ * test/test_win32_api.rb
9
+ * test/test_win32_api_callback.rb
10
+ * test/test_win32_api_function.rb
data/README ADDED
@@ -0,0 +1,121 @@
1
+ = Description
2
+ This is a drop-in replacement for the Win32API library currently part of
3
+ Ruby's standard library.
4
+
5
+ = Synopsis
6
+ require 'win32/api'
7
+ include Win32
8
+
9
+ # Typical example - Get user name
10
+ buf = 0.chr * 260
11
+ len = [buf.length].pack('L')
12
+
13
+ GetUserName = API.new('GetUserName', 'PP', 'I', 'advapi32')
14
+ GetUserName.call(buf, len)
15
+
16
+ puts buf.strip
17
+
18
+ # Callback example - Enumerate windows
19
+ EnumWindows = API.new('EnumWindows', 'KP', 'L', 'user32')
20
+ GetWindowText = API.new('GetWindowText', 'LPI', 'I', 'user32')
21
+ EnumWindowsProc = API::Callback.new('LP', 'I'){ |handle, param|
22
+ buf = "\0" * 200
23
+ GetWindowText.call(handle, buf, 200);
24
+ puts buf.strip unless buf.strip.empty?
25
+ buf.index(param).nil? ? true : false
26
+ }
27
+
28
+ EnumWindows.call(EnumWindowsProc, 'UEDIT32')
29
+
30
+ # Raw function pointer example - System beep
31
+ LoadLibrary = API.new('LoadLibrary', 'P', 'L')
32
+ GetProcAddress = API.new('GetProcAddress', 'LP', 'L')
33
+
34
+ hlib = LoadLibrary.call('user32')
35
+ addr = GetProcAddress.call(hlib, 'MessageBeep')
36
+ func = Win32::API::Function.new(addr, 'L', 'L')
37
+ func.call(0)
38
+
39
+ = Differences between win32-api and Win32API
40
+ * This library has callback support
41
+ * This library supports raw function pointers.
42
+ * This library supports a separate string type for const char* (S).
43
+ * Argument order change. The DLL name is now last, not first.
44
+ * Removed the 'N' and 'n' prototypes. Always use 'L' for longs now.
45
+ * Sensible default arguments for the prototype, return type and DLL name.
46
+ * Reader methods for the function name, effective function name, prototype,
47
+ return type and DLL.
48
+ * Removed the support for lower case prototype and return types. Always
49
+ use capital letters.
50
+
51
+ = Developer's Notes
52
+ The current Win32API library that ships with the standard library has been
53
+ slated for removal from Ruby 2.0 and it will not receive any updates in the
54
+ Ruby 1.8.x branch. I have far too many libraries invested in it to let it
55
+ die at this point.
56
+
57
+ In addition, the current Win32API library was written in the bad old Ruby
58
+ 1.6.x days, which means it doesn't use the newer allocation framework.
59
+ There were several other refactorings that I felt it needed to more closely
60
+ match how it was actually being used in practice.
61
+
62
+ The first order of business was changing the order of the arguments. By
63
+ moving the DLL name from first to last, I was able to provide reasonable
64
+ default arguments for the prototype, return type and the DLL. Only the
65
+ function name is required now.
66
+
67
+ There was a laundry list of other refactorings that were needed: sensical
68
+ instance variable names with proper accessors, removing support for lower
69
+ case prototype and return value characters that no one used in practice,
70
+ better naming conventions, the addition of RDoc ready comments and,
71
+ especially, callback and raw function pointer support.
72
+
73
+ Most importantly, we can now add, modify and fix any features that we feel
74
+ best benefit our end users.
75
+
76
+ = Multiple Binaries
77
+ As of win32-api 1.4.8 a binary gem is shipped that contains binaries for
78
+ both Ruby 1.8, Ruby 1.9, and 2.x. For Ruby 2.x, both 32 and 64 bit binaries
79
+ are included as of release 1.5.0.
80
+
81
+ The file under lib/win32 dynamically requires the correct binary based on
82
+ your version of Ruby.
83
+
84
+ = Documentation
85
+ The source file contains inline RDoc documentation. If you installed
86
+ this file as a gem, then you have the docs. Run "gem server" and point
87
+ your browser at http://localhost:8808 to see them.
88
+
89
+ = Warranty
90
+ This package is provided "as is" and without any express or
91
+ implied warranties, including, without limitation, the implied
92
+ warranties of merchantability and fitness for a particular purpose.
93
+
94
+ = Known Issues
95
+ Possible callback issues when dealing with multi-threaded applications.
96
+
97
+ Please submit any bug reports to the project page at
98
+ https://github.com/djberg96/win32-api
99
+
100
+ == Contributions
101
+ Although this library is free, please consider having your company
102
+ setup a gittip if used by your company professionally.
103
+
104
+ http://www.gittip.com/djberg96/
105
+
106
+ = Future Plans
107
+ I really don't have future plans for this library since I believe FFI to
108
+ be the preferred C interface going forward. This library will still be
109
+ maintained, at least until all of the win32utils libraries have been
110
+ converted to use either FFI or an OLE approach.
111
+
112
+ = Copyright
113
+ (C) 2003-2013 Daniel J. Berger
114
+ All Rights Reserved
115
+
116
+ = License
117
+ Artistic 2.0
118
+
119
+ = Authors
120
+ Daniel J. Berger
121
+ Park Heesob
data/Rakefile ADDED
@@ -0,0 +1,168 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+ include RbConfig
6
+
7
+ CLEAN.include(
8
+ '**/*.gem', # Gem files
9
+ '**/*.rbc', # Rubinius
10
+ '**/*.o', # C object file
11
+ '**/*.log', # Ruby extension build log
12
+ '**/Makefile', # C Makefile
13
+ '**/*.def', # Definition files
14
+ '**/*.exp',
15
+ '**/*.lib',
16
+ '**/*.pdb',
17
+ '**/*.obj',
18
+ '**/*.stackdump', # Junk that can happen on Windows
19
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
20
+ )
21
+
22
+ CLOBBER.include('lib') # Generated when building binaries
23
+
24
+ make = CONFIG['host_os'] =~ /mingw|cygwin/i ? 'make' : 'nmake'
25
+
26
+ desc 'Build the ruby.exe.manifest if it does not already exist'
27
+ task :build_manifest do
28
+ version = CONFIG['host_os'].split('_')[1]
29
+
30
+ if version && version.to_i >= 80
31
+ unless File.exist?(File.join(CONFIG['bindir'], 'ruby.exe.manifest'))
32
+ Dir.chdir(CONFIG['bindir']) do
33
+ sh "mt -inputresource:ruby.exe;2 -out:ruby.exe.manifest"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ desc "Build the win32-api library"
40
+ task :build => [:clean, :build_manifest] do
41
+ require 'devkit'
42
+ Dir.chdir('ext') do
43
+ ruby "extconf.rb"
44
+ sh make
45
+ cp 'api.so', 'win32' # For testing
46
+ end
47
+ end
48
+
49
+ namespace 'gem' do
50
+ require 'rubygems/package'
51
+
52
+ desc 'Build the win32-api gem'
53
+ task :create => [:clean] do
54
+ spec = eval(IO.read('win32-api.gemspec'))
55
+ if Gem::VERSION.to_f < 2.0
56
+ Gem::Builder.new(spec).build
57
+ else
58
+ Gem::Package.build(spec)
59
+ end
60
+ end
61
+
62
+ desc 'Build a binary gem'
63
+ task :binary, :ruby18, :ruby19, :ruby2_32, :ruby2_64 do |task, args|
64
+ require 'devkit'
65
+
66
+ # These are just what's on my system at the moment. Adjust as needed.
67
+ args.with_defaults(
68
+ :ruby18 => "c:/ruby187/bin/ruby",
69
+ :ruby19 => "c:/ruby/bin/ruby",
70
+ :ruby2_32 => "c:/ruby2/bin/ruby",
71
+ :ruby2_64 => "c:/ruby200-x64/bin/ruby"
72
+ )
73
+
74
+ Rake::Task[:clobber].invoke
75
+
76
+ mkdir_p 'lib/win32/ruby18/win32'
77
+ mkdir_p 'lib/win32/ruby19/win32'
78
+ mkdir_p 'lib/win32/ruby2_32/win32'
79
+ mkdir_p 'lib/win32/ruby2_64/win32'
80
+
81
+ args.each{ |key, rubyx|
82
+ # Adjust devkit paths as needed.
83
+ if `"#{rubyx}" -v` =~ /x64/i
84
+ ENV['PATH'] = "C:/Devkit64/bin;C:/Devkit64/mingw/bin;" + ENV['PATH']
85
+ else
86
+ ENV['PATH'] = "C:/Devkit/bin;C:/Devkit/mingw/bin;" + ENV['PATH']
87
+ end
88
+
89
+ Dir.chdir('ext') do
90
+ sh "make distclean" rescue nil
91
+ sh "#{rubyx} extconf.rb"
92
+ sh "make"
93
+
94
+ if key.to_s == 'ruby18'
95
+ cp 'api.so', '../lib/win32/ruby18/win32/api.so'
96
+ elsif key.to_s == 'ruby19'
97
+ cp 'api.so', '../lib/win32/ruby19/win32/api.so'
98
+ else
99
+ if `"#{rubyx}" -v` =~ /x64/i
100
+ cp 'api.so', '../lib/win32/ruby2_64/win32/api.so'
101
+ else
102
+ cp 'api.so', '../lib/win32/ruby2_32/win32/api.so'
103
+ end
104
+ end
105
+ end
106
+ }
107
+
108
+ # Create a stub file that automatically require's the correct binary
109
+ File.open('lib/win32/api.rb', 'w'){ |fh|
110
+ fh.puts "if RUBY_VERSION.to_f < 1.9"
111
+ fh.puts " require File.join(File.dirname(__FILE__), 'ruby18/win32/api')"
112
+ fh.puts "elsif RUBY_VERSION.to_f < 2.0"
113
+ fh.puts " require File.join(File.dirname(__FILE__), 'ruby19/win32/api')"
114
+ fh.puts "else"
115
+ fh.puts " require 'rbconfig'"
116
+ fh.puts " if RbConfig::CONFIG['arch'] =~ /x64/i"
117
+ fh.puts " require File.join(File.dirname(__FILE__), 'ruby2_64/win32/api')"
118
+ fh.puts " else"
119
+ fh.puts " require File.join(File.dirname(__FILE__), 'ruby2_32/win32/api')"
120
+ fh.puts " end"
121
+ fh.puts "end"
122
+ }
123
+
124
+ spec = eval(IO.read('win32-api.gemspec'))
125
+ spec.platform = Gem::Platform.new(['universal', 'mingw32'])
126
+ spec.extensions = nil
127
+ spec.files = spec.files.reject{ |f| f.include?('ext') }
128
+
129
+ if Gem::VERSION.to_f < 2.0
130
+ Gem::Builder.new(spec).build
131
+ else
132
+ Gem::Package.build(spec)
133
+ end
134
+ end
135
+
136
+ desc 'Install the gem'
137
+ task :install => [:create] do
138
+ file = Dir["*.gem"].first
139
+ sh "gem install #{file}"
140
+ end
141
+ end
142
+
143
+ namespace 'test' do
144
+ Rake::TestTask.new(:all) do |test|
145
+ task :all => [:build]
146
+ test.libs << 'ext'
147
+ test.warning = true
148
+ test.verbose = true
149
+ end
150
+
151
+ Rake::TestTask.new(:callback) do |test|
152
+ task :callback => [:build]
153
+ test.test_files = FileList['test/test_win32_api_callback.rb']
154
+ test.libs << 'ext'
155
+ test.warning = true
156
+ test.verbose = true
157
+ end
158
+
159
+ Rake::TestTask.new(:function) do |test|
160
+ task :function => [:build]
161
+ test.test_files = FileList['test/test_win32_api_function.rb']
162
+ test.libs << 'ext'
163
+ test.warning = true
164
+ test.verbose = true
165
+ end
166
+ end
167
+
168
+ task :default => 'test:all'