accessibility_core 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.markdown +7 -0
- data/README.markdown +1 -0
- data/ext/accessibility/bridge/bridge.c +16 -40
- data/lib/accessibility/bridge/mri.rb +38 -0
- data/lib/accessibility/core/version.rb +1 -1
- metadata +4 -4
data/History.markdown
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.3.5 - Add some missing bits for MRI
|
2
|
+
|
3
|
+
* Add `Range#relative_to` to convert ranges to positive indicies
|
4
|
+
* Wrap all strings from Cocoa as UTF8
|
5
|
+
* Unwrap all ruby strings to Cocoa as UTF8
|
6
|
+
|
7
|
+
|
1
8
|
# 0.3.4 - More adjustments for AXElements
|
2
9
|
|
3
10
|
* Add `NSContainsRect()` for MRI
|
data/README.markdown
CHANGED
@@ -255,56 +255,32 @@ VALUE wrap_array_refs(CFArrayRef array) { WRAP_ARRAY(wrap_ref) }
|
|
255
255
|
VALUE
|
256
256
|
wrap_string(CFStringRef string)
|
257
257
|
{
|
258
|
-
|
259
|
-
// but probably will one day when I'm not looking
|
260
|
-
VALUE ruby_string;
|
261
|
-
CFIndex length = CFStringGetLength(string);
|
262
|
-
char* name = (char*)CFStringGetCStringPtr(string, kCFStringEncodingMacRoman);
|
263
|
-
|
264
|
-
if (name) {
|
265
|
-
ruby_string = rb_usascii_str_new(name, length);
|
266
|
-
}
|
267
|
-
else {
|
268
|
-
// currently we will always assume UTF-8
|
269
|
-
// perhaps we could use CFStringGetSystemEncoding in the future?
|
270
|
-
name = malloc(length+1);
|
271
|
-
CFStringGetCString(
|
272
|
-
string,
|
273
|
-
name,
|
274
|
-
length+1,
|
275
|
-
kCFStringEncodingUTF8
|
276
|
-
);
|
277
|
-
ruby_string = rb_enc_str_new(name, length, rb_utf8_encoding());
|
278
|
-
free(name);
|
279
|
-
}
|
280
|
-
|
281
|
-
return ruby_string;
|
258
|
+
return wrap_nsstring((NSString*)string);
|
282
259
|
}
|
283
260
|
|
284
261
|
VALUE
|
285
262
|
wrap_nsstring(NSString* string)
|
286
263
|
{
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
264
|
+
// TODO: find a larger scope to apply this autoreleasepool
|
265
|
+
@autoreleasepool{
|
266
|
+
return rb_enc_str_new(
|
267
|
+
[string UTF8String],
|
268
|
+
[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
|
269
|
+
rb_utf8_encoding()
|
270
|
+
);
|
271
|
+
}
|
292
272
|
}
|
293
273
|
|
294
274
|
CFStringRef
|
295
275
|
unwrap_string(VALUE string)
|
296
276
|
{
|
297
|
-
return
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
/* NULL, */
|
305
|
-
/* StringValuePtr(string), */
|
306
|
-
/* kCFStringEncodingUTF8 */
|
307
|
-
/* ); */
|
277
|
+
return CFStringCreateWithBytes(
|
278
|
+
NULL,
|
279
|
+
(UInt8*)StringValueCStr(string),
|
280
|
+
RSTRING_LEN(string),
|
281
|
+
kCFStringEncodingUTF8,
|
282
|
+
false
|
283
|
+
);
|
308
284
|
}
|
309
285
|
|
310
286
|
NSString*
|
@@ -149,5 +149,43 @@ class Array
|
|
149
149
|
end
|
150
150
|
|
151
151
|
|
152
|
+
##
|
153
|
+
# `accessibility-core` extensions to the `Range` class
|
154
|
+
class Range
|
155
|
+
|
156
|
+
##
|
157
|
+
# Returns a new Range instance which has negative values in
|
158
|
+
# the receiver expanded relative to `max`
|
159
|
+
#
|
160
|
+
# @example
|
161
|
+
#
|
162
|
+
# (1..10).relative_to(10) # => (1..10)
|
163
|
+
# (-3..-1).relative_to(10) # => (7..9)
|
164
|
+
#
|
165
|
+
# @param max [Fixnum]
|
166
|
+
# @return [Range]
|
167
|
+
def relative_to max
|
168
|
+
beg = adjust_index self.begin, max
|
169
|
+
len = adjust_index self.end, max
|
170
|
+
len -= 1 if exclude_end?
|
171
|
+
beg..len
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
private
|
176
|
+
|
177
|
+
def adjust_index val, max
|
178
|
+
if val >= max
|
179
|
+
exclude_end? ? max : max - 1
|
180
|
+
elsif val < 0
|
181
|
+
max + val
|
182
|
+
else
|
183
|
+
val
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
|
152
190
|
require 'accessibility/bridge/common'
|
153
191
|
require 'accessibility/bridge/bridge.bundle'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accessibility_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yard
|
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
segments:
|
109
109
|
- 0
|
110
|
-
hash:
|
110
|
+
hash: 865923332438012461
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
none: false
|
113
113
|
requirements:
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
segments:
|
118
118
|
- 0
|
119
|
-
hash:
|
119
|
+
hash: 865923332438012461
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
122
|
rubygems_version: 1.8.24
|