win32api 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3d2bc66684e2b50554cb5b0696078f0517decc37155030a81a3a474585a86b15
4
+ data.tar.gz: 91933703303ac4f1775282c9b9099c1222c4cb8b05500f4565cdd4dfb90bf3c3
5
+ SHA512:
6
+ metadata.gz: 5e88ed4cbbf6e791c2a5e7c1604a86e1766a8dc14a9eb4cc1942a988b31f1cec01caa505fcbb4ad5583dbb9827fef8e9fa44e52db1c0b923f971ce39e56d273c
7
+ data.tar.gz: d37b1432578eecf61074c56df4eb4f404ab09bdd434fc1bfd60ebf2be01221f8ccf791e74980628f670e5c134047841a07fbb354b7b8bfaa1763cf8401db0371
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: windows-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7.2
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.1.4
17
+ bundle install
18
+ bundle exec rake test
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in win32api.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
@@ -0,0 +1,36 @@
1
+ # Win32api
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/win32api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'win32api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install win32api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/win32api.
36
+
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "win32api"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,47 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ # for backward compatibility
5
+ warn "Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead", uplevel: 2
6
+
7
+ require 'fiddle/import'
8
+
9
+ class Win32API
10
+ DLL = {}
11
+ TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG}
12
+ POINTER_TYPE = Fiddle::SIZEOF_VOIDP == Fiddle::SIZEOF_LONG_LONG ? 'q*' : 'l!*'
13
+
14
+ WIN32_TYPES = "VPpNnLlIi"
15
+ DL_TYPES = "0SSI"
16
+
17
+ def initialize(dllname, func, import, export = "0", calltype = :stdcall)
18
+ @proto = [import].join.tr(WIN32_TYPES, DL_TYPES).sub(/^(.)0*$/, '\1')
19
+ import = @proto.chars.map {|win_type| TYPEMAP[win_type.tr(WIN32_TYPES, DL_TYPES)]}
20
+ export = TYPEMAP[export.tr(WIN32_TYPES, DL_TYPES)]
21
+ calltype = Fiddle::Importer.const_get(:CALL_TYPE_TO_ABI)[calltype]
22
+
23
+ handle = DLL[dllname] ||=
24
+ begin
25
+ Fiddle.dlopen(dllname)
26
+ rescue Fiddle::DLError
27
+ raise unless File.extname(dllname).empty?
28
+ Fiddle.dlopen(dllname + ".dll")
29
+ end
30
+
31
+ @func = Fiddle::Function.new(handle[func], import, export, calltype)
32
+ rescue Fiddle::DLError => e
33
+ raise LoadError, e.message, e.backtrace
34
+ end
35
+
36
+ def call(*args)
37
+ import = @proto.split("")
38
+ args.each_with_index do |x, i|
39
+ args[i], = [x == 0 ? nil : x].pack("p").unpack(POINTER_TYPE) if import[i] == "S"
40
+ args[i], = [x].pack("I").unpack("i") if import[i] == "I"
41
+ end
42
+ ret, = @func.call(*args)
43
+ return ret || 0
44
+ end
45
+
46
+ alias Call call
47
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: false
2
+ require 'fiddle/import'
3
+
4
+ module Win32
5
+ end
6
+
7
+ Win32.module_eval do
8
+ Importer = Fiddle::Importer
9
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "win32api"
5
+ spec.version = "0.1.0"
6
+ spec.authors = ["Hiroshi SHIBATA"]
7
+ spec.email = ["hsbt@ruby-lang.org"]
8
+
9
+ spec.summary = "The wrapper library for win32 API"
10
+ spec.description = spec.summary
11
+ spec.homepage = "https://github.com/ruby/win32api"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = spec.homepage
16
+
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: win32api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroshi SHIBATA
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-12-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: The wrapper library for win32 API
14
+ email:
15
+ - hsbt@ruby-lang.org
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".github/workflows/main.yml"
21
+ - ".gitignore"
22
+ - Gemfile
23
+ - README.md
24
+ - Rakefile
25
+ - bin/console
26
+ - bin/setup
27
+ - lib/Win32API.rb
28
+ - lib/win32/importer.rb
29
+ - win32api.gemspec
30
+ homepage: https://github.com/ruby/win32api
31
+ licenses: []
32
+ metadata:
33
+ homepage_uri: https://github.com/ruby/win32api
34
+ source_code_uri: https://github.com/ruby/win32api
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.3.0
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubygems_version: 3.2.0.rc.2
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: The wrapper library for win32 API
54
+ test_files: []