winwindow 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/winwindow.rb +6 -61
  2. metadata +20 -4
@@ -47,7 +47,6 @@ class WinWindow
47
47
  module AttachLib # :nodoc: all
48
48
  IsWin64=nil # TODO/FIX: detect this!
49
49
 
50
- #=begin
51
50
  # here begins the FFI version. this one needs to hack improperly into FFI's internals, bypassing its
52
51
  # broken API for #callback which doesn't set the calling convention, causing segfaults.
53
52
  begin
@@ -103,14 +102,15 @@ class WinWindow
103
102
 
104
103
  cb = FFI::CallbackInfo.new(find_type(types[return_type]), arg_types.map{|e| find_type(types[e]) }, options)
105
104
 
105
+ # the below is for ffi < 1.0; @ffi_callbacks goes away in the future. it's ignored by
106
+ # newer versions of ffi. so no harm in continuing to set it here.
106
107
  @ffi_callbacks = Hash.new unless defined?(@ffi_callbacks)
107
108
  @ffi_callbacks[callback_type_name] = cb
109
+ # and the below is for newer versions of ffi (1.0.*). of course, @ffi_module.callback
110
+ # works in newer. at some point I'll drop support for older broken versions and just
111
+ # use ffi's #callback.
112
+ typedef cb, callback_type_name
108
113
  end
109
- #options[:convention] = @ffi_module.instance_variable_defined?('@ffi_convention') ? @ffi_module.instance_variable_get('@ffi_convention') : :default
110
- #options[:enums] = @ffi_module.instance_variable_get('@ffi_enums') if @ffi_module.instance_variable_defined?('@ffi_enums')
111
- #unless @ffi_module.instance_variable_defined?('@ffi_callbacks')
112
- # @ffi_module.instance_variable_set('@ffi_callbacks', cb)
113
- #end
114
114
 
115
115
  # perform some hideous class_eval'ing to dynamically define the callback method such that it will take a block
116
116
  metaclass=class << self;self;end
@@ -129,61 +129,6 @@ class WinWindow
129
129
  #end
130
130
  nil
131
131
  end
132
- #=end
133
- =begin
134
- # here begins the Win32::API version. this one doesn't work because of a hard-coded limit on
135
- # callbacks in win32/api.c combined with a lack of any capacity to remove any callbacks.
136
- require 'win32/api'
137
-
138
- # basic types that Win32::API recognizes
139
- Types={ :char => 'I', # no 8-bit type in Win32::API?
140
- :uchar => 'I', # no unsigned types in Win32::API?
141
- :int => 'I',
142
- :uint => 'I',
143
- :long => 'L',
144
- :ulong => 'L',
145
- :void => 'V',
146
- :pointer => 'P',
147
- :callback => 'K',
148
- :string => 'P', # 'S' works here on mingw32, but not on mswin32
149
- }
150
-
151
- def use_lib(lib)
152
- @lib=lib
153
- end
154
- # this takes arguments in the order that they're given in c/c++ so that signatures look kind of like the source
155
- def attach(return_type, function_name, *arg_types)
156
- the_function=Win32::API.new(function_name.to_s, arg_types.map{|arg_type| Types[arg_type] }.join(''), Types[return_type], @lib)
157
- metaclass=class << self;self;end
158
- metaclass.send(:define_method, function_name) do |*args|
159
- the_function.call(*args)
160
- end
161
- nil
162
- end
163
- # this takes arguments like #attach, but with a name for the callback's type on the front.
164
- def callback(callback_type_name, return_type, callback_method_name, *arg_types)
165
- Types[callback_type_name]=Types[:callback]
166
-
167
- # perform some hideous class_eval'ing to dynamically define the callback method such that it will take a block
168
- metaclass=class << self;self;end
169
- metaclass.class_eval("def #{callback_method_name}(&block)
170
- #{callback_method_name}_with_arg_stuff_in_scope(block)
171
- end")
172
- types=Types
173
- metaclass.send(:define_method, callback_method_name.to_s+"_with_arg_stuff_in_scope") do |block|
174
- return Win32::API::Callback.new(arg_types.map{|t| types[t]}.join(''), types[return_type], &block)
175
- end
176
- def remove_#{callback_method_name}(callback_method)
177
- # Win32::API has no support for removing callbacks?
178
- nil
179
- end")
180
- # don't use define_method as this will be called from an ensure block which segfaults ruby 1.9.1. see http://redmine.ruby-lang.org/issues/show/2728
181
- #metaclass.send(:define_method, "remove_"+callback_method_name.to_s) do |callback_method|
182
- # nil
183
- #end
184
- nil
185
- end
186
- =end
187
132
  def self.add_type(hash)
188
133
  hash.each_pair do |key, value|
189
134
  unless Types.key?(value)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winwindow
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 13
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 4
8
- - 0
9
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ethan
@@ -14,21 +15,31 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-09-01 00:00:00 -04:00
18
+ date: 2011-02-05 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: ffi
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  - 5
30
33
  - 4
31
34
  version: 0.5.4
35
+ - - <
36
+ - !ruby/object:Gem::Version
37
+ hash: 19
38
+ segments:
39
+ - 1
40
+ - 1
41
+ - 0
42
+ version: 1.1.0
32
43
  type: :runtime
33
44
  version_requirements: *id001
34
45
  description: A Ruby library to wrap windows API calls relating to hWnd window handles.
@@ -42,6 +53,7 @@ extra_rdoc_files: []
42
53
  files:
43
54
  - lib/winwindow.rb
44
55
  - lib/winwindow/ext.rb
56
+ - test/winwindow_test.rb
45
57
  has_rdoc: true
46
58
  homepage: http://winwindow.vapir.org/
47
59
  licenses: []
@@ -62,23 +74,27 @@ rdoc_options:
62
74
  require_paths:
63
75
  - lib
64
76
  required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
65
78
  requirements:
66
79
  - - ">="
67
80
  - !ruby/object:Gem::Version
81
+ hash: 3
68
82
  segments:
69
83
  - 0
70
84
  version: "0"
71
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
72
87
  requirements:
73
88
  - - ">="
74
89
  - !ruby/object:Gem::Version
90
+ hash: 3
75
91
  segments:
76
92
  - 0
77
93
  version: "0"
78
94
  requirements:
79
95
  - Microsoft Windows, probably with some sort of NT kernel
80
96
  rubyforge_project:
81
- rubygems_version: 1.3.6
97
+ rubygems_version: 1.3.7
82
98
  signing_key:
83
99
  specification_version: 3
84
100
  summary: A Ruby library to wrap windows API calls relating to hWnd window handles.