accessibility_core 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,19 +4,14 @@ $CFLAGS << ' -std=c99 -Wall -Werror -pedantic -ObjC'
4
4
  $LIBS << ' -framework CoreFoundation -framework ApplicationServices -framework Cocoa'
5
5
  $LIBS << ' -framework CoreGraphics' unless `sw_vers -productVersion`.to_f == 10.7
6
6
 
7
- if RUBY_ENGINE == 'macruby'
8
- $CFLAGS << ' -fobjc-gc'
9
- else
10
- unless RbConfig::CONFIG["CC"].match /clang/
11
- clang = `which clang`.chomp
12
- if clang.empty?
13
- raise "Clang not installed. Cannot build C extension"
14
- else
15
- RbConfig::MAKEFILE_CONFIG["CC"] = clang
16
- RbConfig::MAKEFILE_CONFIG["CXX"] = clang
17
- end
7
+ unless RbConfig::CONFIG["CC"].match(/clang/)
8
+ clang = `which clang`.chomp
9
+ if clang.empty?
10
+ raise "Clang not installed. Cannot build C extension"
11
+ else
12
+ RbConfig::MAKEFILE_CONFIG["CC"] = clang
13
+ RbConfig::MAKEFILE_CONFIG["CXX"] = clang
18
14
  end
19
- $CFLAGS << ' -DNOT_MACRUBY'
20
15
  end
21
16
 
22
17
  create_makefile 'accessibility/core/core'
@@ -3,20 +3,14 @@ require 'mkmf'
3
3
  $CFLAGS << ' -std=c99 -Wall -Werror -pedantic -ObjC'
4
4
  $LIBS << ' -framework CoreFoundation -framework Cocoa -framework IOKit'
5
5
 
6
- if RUBY_ENGINE == 'macruby'
7
- $CFLAGS << ' -fobjc-gc'
8
- $CFLAGS.sub! /-Werror/, '' # :(
9
- else
10
- unless RbConfig::CONFIG["CC"].match /clang/
11
- clang = `which clang`.chomp
12
- if clang.empty?
13
- raise "Clang not installed. Cannot build C extension"
14
- else
15
- RbConfig::MAKEFILE_CONFIG["CC"] = clang
16
- RbConfig::MAKEFILE_CONFIG["CXX"] = clang
17
- end
6
+ unless RbConfig::CONFIG["CC"].match(/clang/)
7
+ clang = `which clang`.chomp
8
+ if clang.empty?
9
+ raise "Clang not installed. Cannot build C extension"
10
+ else
11
+ RbConfig::MAKEFILE_CONFIG["CC"] = clang
12
+ RbConfig::MAKEFILE_CONFIG["CXX"] = clang
18
13
  end
19
- $CFLAGS << ' -DNOT_MACRUBY'
20
14
  end
21
15
 
22
16
  create_makefile 'accessibility/extras/extras'
@@ -7,11 +7,9 @@
7
7
  #import <IOKit/ps/IOPSKeys.h>
8
8
  #import <IOKit/pwr_mgt/IOPMLib.h>
9
9
  #import <IOKit/hidsystem/IOHIDShared.h>
10
+ #import <Cocoa/Cocoa.h>
10
11
 
11
12
  static VALUE rb_mBattery;
12
- #ifndef NOT_MACRUBY
13
- static VALUE rb_cScreen;
14
- #endif
15
13
 
16
14
  static VALUE battery_not_installed;
17
15
  static VALUE battery_charged;
@@ -20,11 +18,6 @@ static VALUE battery_discharging;
20
18
 
21
19
  static io_connect_t screen_connection = MACH_PORT_NULL;
22
20
 
23
-
24
- #ifdef NOT_MACRUBY
25
-
26
- #import <Cocoa/Cocoa.h>
27
-
28
21
  static VALUE rb_cRunningApp;
29
22
  static VALUE rb_cWorkspace;
30
23
  static VALUE rb_cProcInfo;
@@ -38,9 +31,9 @@ static VALUE key_opts;
38
31
 
39
32
  static
40
33
  VALUE
41
- wrap_app(NSRunningApplication* app)
34
+ wrap_app(NSRunningApplication* const app)
42
35
  {
43
- return Data_Wrap_Struct(rb_cRunningApp, NULL, objc_finalizer, (void*)app);
36
+ return Data_Wrap_Struct(rb_cRunningApp, NULL, objc_finalizer, (void*)app);
44
37
  }
45
38
 
46
39
  static
@@ -52,22 +45,23 @@ unwrap_app(VALUE app)
52
45
  return running_app;
53
46
  }
54
47
 
55
- static VALUE wrap_array_apps(NSArray* ary)
48
+ static VALUE wrap_array_apps(NSArray* const ary)
56
49
  {
57
- CFArrayRef array = (CFArrayRef)ary;
50
+ CFArrayRef const array = (CFArrayRef const)ary;
58
51
  WRAP_ARRAY(wrap_app);
59
52
  }
60
53
 
61
54
 
62
55
  static
63
56
  VALUE
64
- rb_running_app_with_pid(VALUE self, VALUE pid)
57
+ rb_running_app_with_pid(VALUE self, VALUE num_pid)
65
58
  {
66
- NSRunningApplication* app = [NSRunningApplication
67
- runningApplicationWithProcessIdentifier:NUM2PIDT(pid)];
68
- if (app)
69
- return wrap_app(app);
70
- return Qnil; // ruby behaviour would be to raise, but we want "drop-in" compat
59
+ const pid_t pid = NUM2PIDT(num_pid);
60
+ NSRunningApplication* const app =
61
+ [NSRunningApplication runningApplicationWithProcessIdentifier:pid];
62
+
63
+ if (app) return wrap_app(app);
64
+ return Qnil; // ruby behaviour would be to raise, but we want "drop-in" compat
71
65
  }
72
66
 
73
67
  static
@@ -82,10 +76,9 @@ static
82
76
  VALUE
83
77
  rb_running_app_current_app(VALUE self)
84
78
  {
85
- NSRunningApplication* app = [NSRunningApplication currentApplication];
86
- if (app)
87
- return wrap_app(app);
88
- return Qnil;
79
+ NSRunningApplication* const app = [NSRunningApplication currentApplication];
80
+ if (app) return wrap_app(app);
81
+ return Qnil;
89
82
  }
90
83
 
91
84
  static
@@ -482,26 +475,19 @@ static
482
475
  VALUE
483
476
  rb_screen_screens(VALUE self)
484
477
  {
485
- return wrap_array_screens((CFArrayRef)[NSScreen screens]);
478
+ return wrap_array_screens((CFArrayRef)[NSScreen screens]);
486
479
  }
487
480
 
488
481
  static
489
482
  VALUE
490
483
  rb_screen_frame(VALUE self)
491
484
  {
492
- return wrap_rect([unwrap_screen(self) frame]);
485
+ return wrap_rect(NSRectToCGRect([unwrap_screen(self) frame]));
493
486
  }
494
487
 
495
- #endif
496
-
497
-
498
488
  static
499
489
  VALUE
500
- #ifdef NOT_MACRUBY
501
490
  rb_screen_wake(VALUE self)
502
- #else
503
- rb_screen_wake(VALUE self, SEL sel)
504
- #endif
505
491
  {
506
492
  // don't bother if we are awake
507
493
  if (!CGDisplayIsAsleep(CGMainDisplayID()))
@@ -518,7 +504,7 @@ rb_screen_wake(VALUE self, SEL sel)
518
504
  }
519
505
  }
520
506
 
521
- CGPoint mouse = [NSEvent mouseLocation];
507
+ CGPoint mouse = NSPointToCGPoint([NSEvent mouseLocation]);
522
508
  IOGPoint point = { mouse.x, mouse.y };
523
509
  unsigned int flags = (unsigned int)[NSEvent modifierFlags];
524
510
  NXEventData data;
@@ -720,8 +706,6 @@ Init_extras()
720
706
  // force Ruby to be registered as an app with the system
721
707
  [NSApplication sharedApplication];
722
708
 
723
- #ifdef NOT_MACRUBY
724
-
725
709
  /*
726
710
  * Document-class: NSRunningApplication
727
711
  *
@@ -861,9 +845,7 @@ Init_extras()
861
845
  rb_define_method(rb_cBundle, "infoDictionary", rb_bundle_info_dict, 0);
862
846
  rb_define_method(rb_cBundle, "objectForInfoDictionaryKey", rb_bundle_object_for_info_dict_key, 1);
863
847
 
864
-
865
848
  rb_define_method(rb_cObject, "load_plist", rb_load_plist, 1);
866
- #endif
867
849
 
868
850
 
869
851
  /*
@@ -877,15 +859,10 @@ Init_extras()
877
859
  */
878
860
  rb_cScreen = rb_define_class("NSScreen", rb_cObject);
879
861
 
880
- #ifdef NOT_MACRUBY
881
862
  rb_define_singleton_method(rb_cScreen, "mainScreen", rb_screen_main, 0);
882
863
  rb_define_singleton_method(rb_cScreen, "screens", rb_screen_screens, 0);
883
864
  rb_define_singleton_method(rb_cScreen, "wakeup", rb_screen_wake, 0); // our custom method
884
865
  rb_define_method( rb_cScreen, "frame", rb_screen_frame, 0);
885
- #else
886
- rb_objc_define_method(*(VALUE*)rb_cScreen, "wakeup", rb_screen_wake, 0);
887
- #endif
888
-
889
866
 
890
867
  /*
891
868
  * Document-module: Battery
@@ -4,20 +4,14 @@ $CFLAGS << ' -std=c99 -Wall -Werror -pedantic -ObjC'
4
4
  $LIBS << ' -framework CoreFoundation -framework ApplicationServices -framework Cocoa'
5
5
  $LIBS << ' -framework CoreGraphics' unless `sw_vers -productVersion`.to_f == 10.7
6
6
 
7
- if RUBY_ENGINE == 'macruby'
8
- $CFLAGS << ' -fobjc-gc'
9
- $CFLAGS.sub! /-Werror/, ''
10
- else
11
- unless RbConfig::CONFIG["CC"].match /clang/
12
- clang = `which clang`.chomp
13
- if clang.empty?
14
- raise "Clang not installed. Cannot build C extension"
15
- else
16
- RbConfig::MAKEFILE_CONFIG["CC"] = clang
17
- RbConfig::MAKEFILE_CONFIG["CXX"] = clang
18
- end
7
+ unless RbConfig::CONFIG["CC"].match(/clang/)
8
+ clang = `which clang`.chomp
9
+ if clang.empty?
10
+ raise "Clang not installed. Cannot build C extension"
11
+ else
12
+ RbConfig::MAKEFILE_CONFIG["CC"] = clang
13
+ RbConfig::MAKEFILE_CONFIG["CXX"] = clang
19
14
  end
20
- $CFLAGS << ' -DNOT_MACRUBY'
21
15
  end
22
16
 
23
17
  create_makefile 'accessibility/highlighter/highlighter'
@@ -4,8 +4,6 @@
4
4
  #include "../extras/extras.h"
5
5
 
6
6
 
7
- #ifdef NOT_MACRUBY
8
-
9
7
  static VALUE rb_cHighlighter;
10
8
  static VALUE rb_cColor;
11
9
 
@@ -53,9 +51,9 @@ static
53
51
  CGRect
54
52
  flip(CGRect rect)
55
53
  {
56
- double screen_height = NSMaxY([[NSScreen mainScreen] frame]);
57
- rect.origin.y = screen_height - NSMaxY(rect);
58
- return rect;
54
+ const double screen_height = NSMaxY([[NSScreen mainScreen] frame]);
55
+ rect.origin.y = screen_height - NSMaxY(NSRectFromCGRect(rect));
56
+ return rect;
59
57
  }
60
58
 
61
59
  static
@@ -65,14 +63,12 @@ rb_highlighter_new(int argc, VALUE* argv, VALUE self)
65
63
  if (!argc)
66
64
  rb_raise(rb_eArgError, "wrong number of arguments (0 for 1+)");
67
65
 
68
- CGRect bounds = unwrap_rect(coerce_to_rect(argv[0]));
69
- bounds = flip(bounds); // we assume the rect is in the other co-ordinate system
70
-
71
- NSWindow* window =
72
- [[NSWindow alloc] initWithContentRect:bounds
73
- styleMask:NSBorderlessWindowMask
74
- backing:NSBackingStoreBuffered
75
- defer:true];
66
+ const CGRect bounds = flip(unwrap_rect(coerce_to_rect(argv[0])));
67
+ NSWindow* const window =
68
+ [[NSWindow alloc] initWithContentRect:NSRectFromCGRect(bounds)
69
+ styleMask:NSBorderlessWindowMask
70
+ backing:NSBackingStoreBuffered
71
+ defer:true];
76
72
 
77
73
  NSColor* color = [NSColor magentaColor];
78
74
 
@@ -89,7 +85,7 @@ rb_highlighter_new(int argc, VALUE* argv, VALUE self)
89
85
  [window setLevel:NSStatusWindowLevel];
90
86
  [window setBackgroundColor:color];
91
87
  [window setIgnoresMouseEvents:true];
92
- [window setFrame:bounds display:false];
88
+ [window setFrame:NSRectFromCGRect(bounds) display:false];
93
89
  [window makeKeyAndOrderFront:NSApp];
94
90
  [window setReleasedWhenClosed:false];
95
91
 
@@ -132,7 +128,7 @@ static
132
128
  VALUE
133
129
  rb_highlighter_frame(VALUE self)
134
130
  {
135
- return wrap_rect([unwrap_window(self) frame]);
131
+ return wrap_rect(NSRectToCGRect([unwrap_window(self) frame]));
136
132
  }
137
133
 
138
134
  static
@@ -225,7 +221,6 @@ rb_color_equality(VALUE self, VALUE other)
225
221
  return Qfalse;
226
222
  }
227
223
 
228
- #endif
229
224
 
230
225
 
231
226
  void
@@ -234,8 +229,6 @@ Init_highlighter()
234
229
  Init_bridge();
235
230
  Init_extras();
236
231
 
237
- #ifdef NOT_MACRUBY
238
-
239
232
  // force initialization or NSWindow won't work
240
233
  [NSApplication sharedApplication];
241
234
 
@@ -292,6 +285,4 @@ Init_highlighter()
292
285
  //rb_define_singleton_method(rb_cColor, "colorWithSRGBRed", rb_color_rgb, 2);
293
286
 
294
287
  rb_define_method(rb_cColor, "==", rb_color_equality, 1);
295
-
296
- #endif
297
288
  }
@@ -1,33 +1,3 @@
1
1
  require 'accessibility/core/version'
2
+ require 'accessibility/bridge/mri'
2
3
 
3
-
4
- if defined? MACRUBY_REVISION
5
-
6
- ##
7
- # Whether or not we are running on MacRuby
8
- def on_macruby?
9
- true
10
- end
11
-
12
- framework 'Cocoa'
13
-
14
- # A workaround that guarantees that `CGPoint` is defined
15
- unless defined? MOUNTAIN_LION_APPKIT_VERSION
16
- MOUNTAIN_LION_APPKIT_VERSION = 1187
17
- end
18
-
19
- if NSAppKitVersionNumber >= MOUNTAIN_LION_APPKIT_VERSION
20
- framework '/System/Library/Frameworks/CoreGraphics.framework'
21
- end
22
-
23
- require 'accessibility/bridge/macruby'
24
-
25
- else
26
-
27
- def on_macruby?
28
- false
29
- end
30
-
31
- require 'accessibility/bridge/mri'
32
-
33
- end
@@ -3,10 +3,5 @@ require 'accessibility/bridge'
3
3
 
4
4
  # internal deps
5
5
  require 'accessibility/core/version'
6
-
7
- if on_macruby?
8
- require 'accessibility/core/macruby'
9
- else
10
- require 'accessibility/core/core.bundle'
11
- end
6
+ require 'accessibility/core/core.bundle'
12
7
 
@@ -6,6 +6,6 @@ module Accessibility
6
6
  # Namespace for `accessibility_core` specific classes
7
7
  module Core
8
8
  # return [String]
9
- VERSION = '0.4.3'
9
+ VERSION = '0.5.0'
10
10
  end
11
11
  end
@@ -1,5 +1,3 @@
1
1
  require 'accessibility/bridge'
2
-
3
2
  require 'accessibility/extras/common'
4
- framework 'Cocoa' if on_macruby?
5
3
  require 'accessibility/extras/extras.bundle'
@@ -1,8 +1,3 @@
1
1
  require 'accessibility/bridge'
2
-
3
- if on_macruby?
4
- require 'accessibility/highlighter/macruby'
5
- else
6
- require 'accessibility/highlighter/highlighter.bundle'
7
- end
2
+ require 'accessibility/highlighter/highlighter.bundle'
8
3
 
@@ -3,16 +3,6 @@ $LOAD_PATH << 'lib'
3
3
  require 'minitest/autorun'
4
4
  require 'minitest/pride'
5
5
 
6
- if defined? MACRUBY_REVISION
7
- def on_macruby?
8
- true
9
- end
10
- else
11
- def on_macruby?
12
- false
13
- end
14
- end
15
-
16
6
  if `uname -r`.to_i >= 13
17
7
  def on_sea_lion?
18
8
  true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accessibility_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-05 00:00:00.000000000 Z
11
+ date: 2015-01-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
14
  accessibility_core is a wrapper around the OS X Accessibility framework.
@@ -28,15 +28,12 @@ extensions:
28
28
  extra_rdoc_files: []
29
29
  files:
30
30
  - lib/accessibility/bridge/common.rb
31
- - lib/accessibility/bridge/macruby.rb
32
31
  - lib/accessibility/bridge/mri.rb
33
32
  - lib/accessibility/bridge.rb
34
- - lib/accessibility/core/macruby.rb
35
33
  - lib/accessibility/core/version.rb
36
34
  - lib/accessibility/core.rb
37
35
  - lib/accessibility/extras/common.rb
38
36
  - lib/accessibility/extras.rb
39
- - lib/accessibility/highlighter/macruby.rb
40
37
  - lib/accessibility/highlighter.rb
41
38
  - ext/accessibility/bridge/bridge.c
42
39
  - ext/accessibility/core/core.c
@@ -52,9 +49,8 @@ files:
52
49
  - README.markdown
53
50
  - History.markdown
54
51
  - .yardopts
55
- - test/test_core.rb
56
52
  - test/helper.rb
57
- homepage: http://github.com/AXElements/accessibility_core
53
+ homepage: https://github.com/AXElements/accessibility_core
58
54
  licenses:
59
55
  - BSD 3-clause
60
56
  metadata: {}
@@ -74,10 +70,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
70
  version: '0'
75
71
  requirements: []
76
72
  rubyforge_project:
77
- rubygems_version: 2.0.3
73
+ rubygems_version: 2.0.14
78
74
  signing_key:
79
75
  specification_version: 4
80
76
  summary: A library for building automation tools on OS X
81
77
  test_files:
82
- - test/test_core.rb
83
78
  - test/helper.rb