win32-api 1.9.2-universal-mingw32 → 1.10.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbda787ddee639f0586e7661d07814ec87374373feb4b0e0be0db1123dcce9cd
4
- data.tar.gz: 34c0c1da9f2d7d7ba24b53fdfbf6b07953769dc7e8d963e803debf0f39fa0d3c
3
+ metadata.gz: 0e094917b41770c3fc5a82f79b60638d3eb3dc7d5255e17e1aae7089a0070979
4
+ data.tar.gz: 2e548c70a32503b0b4f3353bde818a72a4ca75975d6a972d7a570cfc48a93348
5
5
  SHA512:
6
- metadata.gz: 982edadad844e9bfbe6f3012f959ca2df820a16bce05d70594c1e45901e54d445afae627613455706a719bc99274efc91c08d4fe11e9649ac136ad299c053e68
7
- data.tar.gz: 5f46486f077ddfda70c4ebebfd5fe2bc060b70fdc7d45a30357f2d4adf1d282eafef4b010967550ffa2dc9cf8dbe6ba23959253fde68302f9a7f5d343f7867aa
6
+ metadata.gz: 1fb21c7689902148c217af40a432791037c9492519f84d171ac3c70225258313af9a13aef7bb2c94b3c319488256dfa3092c123d742d401f46127b9d50168018
7
+ data.tar.gz: c3f81dfa40a40920cb44a9dda2e19164e8edb0c3ed41c18577b93186b8abd31cebd76b803c6a22ab82b8fe899cb2b403b8ccd1bbabb55c962552084ca816e70d
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ == 1.10.0 - 19-Apr-2021
2
+ * Add Ruby 3.1 snapshot support
3
+ * Add API.last_error
4
+
1
5
  == 1.9.2 - 13-Sep-2020
2
6
  * Handle Ruby 3.0 snapshot (formerly known as Ruby 2.8).
3
7
 
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM mcr.microsoft.com/windows/servercore:1903
1
+ FROM mcr.microsoft.com/windows/servercore:20H2
2
2
  LABEL maintainer "Hiroshi Hatake <cosmo0920.wp@gmail.com>"
3
3
  LABEL Description="win32-api building docker image"
4
4
 
@@ -80,6 +80,16 @@ RUN powershell \
80
80
  Invoke-WebRequest -OutFile C:\rubyinstaller-2.7.0-1-x64.exe https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-2.7.0-1/rubyinstaller-2.7.0-1-x64.exe
81
81
  RUN cmd /c "C:\rubyinstaller-2.7.0-1-x64.exe" /silent /dir=c:\ruby27-x64
82
82
 
83
+ # Ruby 3.0
84
+ RUN powershell \
85
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
86
+ Invoke-WebRequest -OutFile C:\rubyinstaller-3.0.0-1-x86.exe https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.0.0-1/rubyinstaller-3.0.0-1-x86.exe
87
+ RUN cmd /c "C:\rubyinstaller-3.0.0-1-x86.exe" /silent /dir=c:\ruby30
88
+ RUN powershell \
89
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
90
+ Invoke-WebRequest -OutFile C:\rubyinstaller-3.0.0-1-x64.exe https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.0.0-1/rubyinstaller-3.0.0-1-x64.exe
91
+ RUN cmd /c "C:\rubyinstaller-3.0.0-1-x64.exe" /silent /dir=c:\ruby30-x64
92
+
83
93
  # DevKit
84
94
  RUN powershell \
85
95
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
@@ -92,8 +102,12 @@ RUN cmd /c C:\DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe -o"c:\DevKit64" -y
92
102
 
93
103
  RUN choco install -y git \
94
104
  && choco install -y msys2 --params "'/NoPath /NoUpdate /InstallDir:C:\msys64'"
105
+ # pacman -Syu --noconfirm is needed for downloading ucrt64 repo.
106
+ # They should be removed after using Ruby 2.5.9, 2.6.7, and 2.7.3 installers.
95
107
  RUN refreshenv \
108
+ && C:\ruby27\bin\ridk exec pacman -Syu --noconfirm \
96
109
  && C:\ruby27\bin\ridk install 2 3 \
110
+ && C:\ruby27-x64\bin\ridk exec pacman -Syu --noconfirm \
97
111
  && C:\ruby27-x64\bin\ridk install 2 3
98
112
 
99
113
  ENTRYPOINT ["cmd"]
data/Dockerfile.trunk CHANGED
@@ -2,15 +2,15 @@ FROM cosmo0920/win32-api:latest
2
2
  LABEL maintainer "Hiroshi Hatake <cosmo0920.wp@gmail.com>"
3
3
  LABEL Description="win32-api building docker image"
4
4
 
5
- # Ruby 3.0
5
+ # Ruby 3.1
6
6
  RUN powershell \
7
7
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
8
- Invoke-WebRequest -OutFile C:\rubyinstaller-head-x86-20200911.exe https://ci.appveyor.com/api/buildjobs/trvw8cisuqismasc/artifacts/packages%2Fri%2Frecipes%2Finstaller-inno%2Frubyinstaller-head-x86.exe
9
- RUN cmd /c "C:\rubyinstaller-head-x86-20200911.exe" /silent /dir=c:\ruby30
8
+ Invoke-WebRequest -OutFile C:\rubyinstaller-head-x86-20210418.exe https://ci.appveyor.com/api/buildjobs/smfh4ojkobb4duif/artifacts/packages%2Fri%2Frecipes%2Finstaller-inno%2Frubyinstaller-head-x86.exe
9
+ RUN cmd /c "C:\rubyinstaller-head-x86-20210418.exe" /silent /dir=c:\ruby31
10
10
  RUN powershell \
11
11
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
12
- Invoke-WebRequest -OutFile C:\rubyinstaller-head-x64-20200911.exe https://ci.appveyor.com/api/buildjobs/ufndgf49pysdvpt9/artifacts/packages%2Fri%2Frecipes%2Finstaller-inno%2Frubyinstaller-head-x64.exe
13
- RUN cmd /c "C:\rubyinstaller-head-x64-20200911.exe" /silent /dir=c:\ruby30-x64
12
+ Invoke-WebRequest -OutFile C:\rubyinstaller-head-x64-20210418.exe https://ci.appveyor.com/api/buildjobs/hsgdg4xl5ny74k94/artifacts/packages%2Fri%2Frecipes%2Finstaller-inno%2Frubyinstaller-head-x64.exe
13
+ RUN cmd /c "C:\rubyinstaller-head-x64-20210418.exe" /silent /dir=c:\ruby31-x64
14
14
 
15
15
  RUN mkdir C:\pkg
16
16
  COPY build-gem.bat C:\\build-gem.bat
data/Rakefile CHANGED
@@ -59,7 +59,7 @@ namespace 'gem' do
59
59
  end
60
60
 
61
61
  desc 'Build a binary gem'
62
- task :binary, :ruby2_32, :ruby2_64, :ruby21, :ruby21_64, :ruby22, :ruby22_64, :ruby23_32, :ruby23_64, :ruby24_32, :ruby24_64, :ruby25_32, :ruby25_64, :ruby_26_32, :ruby26_64, :ruby27_32, :ruby27_64, :ruby30_32, :ruby30_64 do |task, args|
62
+ task :binary, :ruby2_32, :ruby2_64, :ruby21, :ruby21_64, :ruby22, :ruby22_64, :ruby23_32, :ruby23_64, :ruby24_32, :ruby24_64, :ruby25_32, :ruby25_64, :ruby_26_32, :ruby26_64, :ruby27_32, :ruby27_64, :ruby30_32, :ruby30_64, :ruby31_32, :ruby31_64 do |task, args|
63
63
  # These are just what's on my system at the moment. Adjust as needed.
64
64
  # ri refers to RubyInstaller, ruby 2.3 and prev were built with RubyInstaller (:ri),
65
65
  # 2.4 and later with RubyInstaller2 (:ri2)
@@ -100,6 +100,8 @@ namespace 'gem' do
100
100
  :ruby27_64 => {:path => "#{pre}/ruby27-x64/bin", :ri => :ri2_64, :omit => true},
101
101
  :ruby30_32 => {:path => "#{pre}/ruby30/bin", :ri => :ri2, :omit => true},
102
102
  :ruby30_64 => {:path => "#{pre}/ruby30-x64/bin", :ri => :ri2_64, :omit => true},
103
+ :ruby31_32 => {:path => "#{pre}/ruby31/bin", :ri => :ri2, :omit => true},
104
+ :ruby31_64 => {:path => "#{pre}/ruby31-x64/bin", :ri => :ri2_64, :omit => true},
103
105
  }
104
106
  )
105
107
 
data/appveyor.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  version: '{build}'
2
2
 
3
+ image: Visual Studio 2019
4
+
3
5
  init:
4
6
  # use a minimal path
5
7
  - 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
@@ -26,6 +28,10 @@ test_script:
26
28
  environment:
27
29
  matrix:
28
30
  - ruby_version: _trunk
31
+ - ruby_version: 30-x64
32
+ - ruby_version: 30
33
+ - ruby_version: 27-x64
34
+ - ruby_version: 27
29
35
  - ruby_version: 26-x64
30
36
  - ruby_version: 26
31
37
  - ruby_version: 25-x64
@@ -34,12 +40,6 @@ environment:
34
40
  - ruby_version: 24
35
41
  - ruby_version: 23-x64
36
42
  - 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
43
 
44
44
  matrix:
45
45
  allow_failures:
data/ext/win32/api.c CHANGED
@@ -43,7 +43,7 @@
43
43
 
44
44
 
45
45
  #define MAX_BUF 1024
46
- #define WINDOWS_API_VERSION "1.9.2"
46
+ #define WINDOWS_API_VERSION "1.10.0"
47
47
 
48
48
  #define _T_VOID 0
49
49
  #define _T_LONG 1
@@ -62,6 +62,35 @@ typedef struct {
62
62
  int prototype[20];
63
63
  } Win32API;
64
64
 
65
+ typedef struct ThreadData {
66
+ DWORD win32api_error;
67
+ } ThreadData;
68
+
69
+ static inline ThreadData* thread_data_get(void);
70
+ static ID id_thread_data;
71
+
72
+ static ThreadData* thread_data_init(void)
73
+ {
74
+ ThreadData* td;
75
+ VALUE obj;
76
+
77
+ obj = Data_Make_Struct(rb_cObject, ThreadData, NULL, -1, td);
78
+ rb_thread_local_aset(rb_thread_current(), id_thread_data, obj);
79
+
80
+ return td;
81
+ }
82
+
83
+ static inline ThreadData* thread_data_get()
84
+ {
85
+ VALUE obj = rb_thread_local_aref(rb_thread_current(), id_thread_data);
86
+
87
+ if(obj != Qnil && TYPE(obj) == T_DATA){
88
+ return (ThreadData*) DATA_PTR(obj);
89
+ }
90
+
91
+ return thread_data_init();
92
+ }
93
+
65
94
  static void api_free(Win32API* ptr){
66
95
  if(ptr->library)
67
96
  FreeLibrary(ptr->library);
@@ -781,6 +810,7 @@ static VALUE api_call(int argc, VALUE* argv, VALUE self){
781
810
  uintptr_t return_value;
782
811
  int i = 0;
783
812
  int len;
813
+ ThreadData* thread_data = thread_data_get();
784
814
 
785
815
  struct{
786
816
  uintptr_t params[20];
@@ -975,6 +1005,8 @@ static VALUE api_call(int argc, VALUE* argv, VALUE self){
975
1005
  }
976
1006
  }
977
1007
 
1008
+ thread_data->win32api_error = GetLastError();
1009
+
978
1010
  /* Return the appropriate type based on the return type specified
979
1011
  * in the constructor.
980
1012
  */
@@ -1029,6 +1061,21 @@ static VALUE api_call(int argc, VALUE* argv, VALUE self){
1029
1061
  return v_return;
1030
1062
  }
1031
1063
 
1064
+ /*
1065
+ * call-seq:
1066
+ * Win32::API.last_error
1067
+ *
1068
+ * Return the last Win32 error code of the current executing thread.
1069
+ *
1070
+ * The error code shouldn't be retrieved by calling GetLastError() manually
1071
+ * because Ruby's internal code may call other Win32 API and reset the error
1072
+ * code before it.
1073
+ */
1074
+ static VALUE get_last_error(VALUE self)
1075
+ {
1076
+ return INT2NUM(thread_data_get()->win32api_error);
1077
+ }
1078
+
1032
1079
  /*
1033
1080
  * Wraps the Windows API functions in a Ruby interface.
1034
1081
  */
@@ -1061,6 +1108,9 @@ void Init_api(){
1061
1108
  /* Miscellaneous */
1062
1109
  rb_define_alloc_func(cAPI, api_allocate);
1063
1110
 
1111
+ /* GetLastError alternative */
1112
+ rb_define_singleton_method(cAPI, "last_error", get_last_error, 0);
1113
+
1064
1114
  /* Win32::API Instance Methods */
1065
1115
  rb_define_method(cAPI, "initialize", api_init, -1);
1066
1116
  rb_define_method(cAPI, "call", api_call, -1);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -18,7 +18,7 @@ class TC_Win32_API < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_version
21
- assert_equal('1.9.2', API::VERSION)
21
+ assert_equal('1.10.0', API::VERSION)
22
22
  end
23
23
 
24
24
  def test_constructor_basic
@@ -43,6 +43,12 @@ class TC_Win32_API < Test::Unit::TestCase
43
43
  assert_equal(0xFFFFFFFF, @gfa.call('C:/foobarbazblah'))
44
44
  end
45
45
 
46
+ def test_last_error
47
+ @gfa.call('C:/foobarbazblah')
48
+ error_file_not_found = 2
49
+ assert_equal(error_file_not_found, API.last_error)
50
+ end
51
+
46
52
  def test_dll_name
47
53
  assert_respond_to(@gcd, :dll_name)
48
54
  assert_equal('kernel32', @gcd.dll_name)
data/win32-api.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'win32-api'
5
- spec.version = '1.9.2'
5
+ spec.version = '1.10.0'
6
6
  spec.authors = ['Daniel J. Berger', 'Park Heesob', 'Hiroshi Hatake']
7
7
  spec.license = 'Artistic-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.10.0
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-09-13 00:00:00.000000000 Z
13
+ date: 2021-04-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: test-unit
@@ -83,6 +83,8 @@ files:
83
83
  - lib/win32/ruby2_64/win32/api.so
84
84
  - lib/win32/ruby30_32/win32/api.so
85
85
  - lib/win32/ruby30_64/win32/api.so
86
+ - lib/win32/ruby31_32/win32/api.so
87
+ - lib/win32/ruby31_64/win32/api.so
86
88
  - test/test_win32_api.rb
87
89
  - test/test_win32_api_callback.rb
88
90
  - test/test_win32_api_function.rb
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  - !ruby/object:Gem::Version
107
109
  version: '0'
108
110
  requirements: []
109
- rubygems_version: 3.2.0.rc.1
111
+ rubygems_version: 3.3.0.dev
110
112
  signing_key:
111
113
  specification_version: 4
112
114
  summary: A superior replacement for Win32API