rb-appscript 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/CHANGES +243 -0
  2. data/LICENSE +1 -0
  3. data/README +42 -0
  4. data/TODO +31 -0
  5. data/doc/aem-manual/01_introduction.html +48 -0
  6. data/doc/aem-manual/02_apioverview.html +89 -0
  7. data/doc/aem-manual/03_packingandunpackingdata.html +98 -0
  8. data/doc/aem-manual/04_references.html +401 -0
  9. data/doc/aem-manual/05_targettingapplications.html +133 -0
  10. data/doc/aem-manual/06_buildingandsendingevents.html +175 -0
  11. data/doc/aem-manual/07_findapp.html +54 -0
  12. data/doc/aem-manual/08_examples.html +85 -0
  13. data/doc/aem-manual/09_notes.html +41 -0
  14. data/doc/aem-manual/aemreferenceinheritance.gif +0 -0
  15. data/doc/aem-manual/full.css +21 -0
  16. data/doc/aem-manual/index.html +43 -0
  17. data/doc/appscript-manual/01_introduction.html +82 -0
  18. data/doc/appscript-manual/02_aboutappscripting.html +244 -0
  19. data/doc/appscript-manual/03_quicktutorial.html +154 -0
  20. data/doc/appscript-manual/04_gettinghelp.html +101 -0
  21. data/doc/appscript-manual/05_keywordconversion.html +91 -0
  22. data/doc/appscript-manual/06_classesandenums.html +174 -0
  23. data/doc/appscript-manual/07_applicationobjects.html +181 -0
  24. data/doc/appscript-manual/08_realvsgenericreferences.html +86 -0
  25. data/doc/appscript-manual/09_referenceforms.html +232 -0
  26. data/doc/appscript-manual/10_referenceexamples.html +142 -0
  27. data/doc/appscript-manual/11_applicationcommands.html +204 -0
  28. data/doc/appscript-manual/12_commandexamples.html +129 -0
  29. data/doc/appscript-manual/13_performanceissues.html +115 -0
  30. data/doc/appscript-manual/14_problemapps.html +193 -0
  31. data/doc/appscript-manual/15_notes.html +84 -0
  32. data/doc/appscript-manual/application_architecture.gif +0 -0
  33. data/doc/appscript-manual/application_architecture2.gif +0 -0
  34. data/doc/appscript-manual/finder_to_textedit_event.gif +0 -0
  35. data/doc/appscript-manual/full.css +21 -0
  36. data/doc/appscript-manual/index.html +49 -0
  37. data/doc/appscript-manual/relationships_example.gif +0 -0
  38. data/doc/appscript-manual/ruby_to_itunes_event.gif +0 -0
  39. data/doc/index.html +30 -0
  40. data/doc/mactypes-manual/index.html +216 -0
  41. data/doc/osax-manual/index.html +169 -0
  42. data/extconf.rb +54 -0
  43. data/misc/adobeunittypes.rb +14 -0
  44. data/misc/dump.rb +72 -0
  45. data/rb-appscript.gemspec +20 -0
  46. data/sample/AB_list_people_with_emails.rb +8 -0
  47. data/sample/Create_daily_iCal_todos.rb +72 -0
  48. data/sample/Hello_world.rb +9 -0
  49. data/sample/List_iTunes_playlist_names.rb +7 -0
  50. data/sample/Make_Mail_message.rb +29 -0
  51. data/sample/Open_file_in_TextEdit.rb +9 -0
  52. data/sample/Organize_Mail_messages.rb +57 -0
  53. data/sample/Print_folder_tree.rb +12 -0
  54. data/sample/Select_all_HTML_files.rb +8 -0
  55. data/sample/Set_iChat_status.rb +20 -0
  56. data/sample/Simple_Finder_GUI_Scripting.rb +14 -0
  57. data/sample/Stagger_Finder_windows.rb +21 -0
  58. data/sample/TextEdit_demo.rb +126 -0
  59. data/sample/iTunes_top40_to_html.rb +64 -0
  60. data/src/lib/_aem/aemreference.rb +1006 -0
  61. data/src/lib/_aem/codecs.rb +617 -0
  62. data/src/lib/_aem/connect.rb +100 -0
  63. data/src/lib/_aem/findapp.rb +83 -0
  64. data/src/lib/_aem/mactypes.rb +228 -0
  65. data/src/lib/_aem/send.rb +257 -0
  66. data/src/lib/_aem/typewrappers.rb +57 -0
  67. data/src/lib/_appscript/defaultterminology.rb +245 -0
  68. data/src/lib/_appscript/referencerenderer.rb +132 -0
  69. data/src/lib/_appscript/reservedkeywords.rb +107 -0
  70. data/src/lib/_appscript/terminology.rb +314 -0
  71. data/src/lib/aem.rb +216 -0
  72. data/src/lib/appscript.rb +830 -0
  73. data/src/lib/kae.rb +1484 -0
  74. data/src/lib/osax.rb +171 -0
  75. data/src/rbae.c +766 -0
  76. data/test/README +1 -0
  77. data/test/test_aemreference.rb +112 -0
  78. data/test/test_appscriptreference.rb +102 -0
  79. data/test/test_codecs.rb +159 -0
  80. data/test/test_findapp.rb +24 -0
  81. data/test/test_mactypes.rb +67 -0
  82. data/test/testall.sh +9 -0
  83. metadata +143 -0
data/CHANGES ADDED
@@ -0,0 +1,243 @@
1
+ 2006-11-20 -- 0.2.0
2
+
3
+ - removed path expansion in FindApp#byName, MacFile::Alias#at, MacFile::FileURL#at
4
+
5
+ - changed default send flags to KAE::KAECanSwitchLayer + KAE::KAEWaitReply (same as AppleScript)
6
+
7
+ - aliased AE::MacOSError#number to #to_i; added #to_s and #inspect methods
8
+
9
+ - added #to_s and #inspect methods to AE::AEDesc
10
+
11
+ - fixed undefined variable bug in FindApp#byName when raising an ApplicationNotFoundError
12
+
13
+ - added osax module and documentation
14
+
15
+ - added event handling code to rbae.c (not yet fully tested)
16
+
17
+ - added gemspec for source-based gem
18
+
19
+ - made Reference class's AS_appdata and AS_aemreference instance variables writeable as well as readable - this'll make it easier to inject workarounds (e.g. modified pack/unpack routines) for occasional application flaws
20
+
21
+ - added sample scripts: Organize_Mail_messages.rb, Create_daily_iCal_todos.rb, Simple_Finder_GUI_Scripting.rb, Set_iChat_status.rb
22
+
23
+ - now always packs a subject attribute (KAE::TypeSubjectAttr); this is normally a null descriptor. (Note: AS includes a subject attribute for commands whose direct parameter isn't a reference, e.g. make. Photoshop CS2's make command requires either an 'at' parameter or subject attribute and throws an error if it doesn't get one. Including a subject attribute by default should hopefully prevent any complaints.) [BB]
24
+
25
+ - removed built-in :telltarget argument to simplify the API a bit. Now, if a command is called on a reference and already has a direct parameter, the reference is packed as the subject attribute instead. Also, 'telltarget' is no longer a reserved word.
26
+
27
+ - true and false are now packed as AEDescs of typeTrue and typeFalse (same as AppleScript), not typeBoolean [BB]
28
+
29
+ - when hashes containing a :class or AEType.new('pcls') key whose value is a Symbol or AEBaseType instance are packed, the resulting AEDesc is now coerced to that type (previously the class property was packed as just another key-value pair, and the result was an AEDesc of typeAERecord) [BB]
30
+
31
+ - codecs module now unpacks a record-like AEDesc with an unknown type as a hash containing an additional 'class' property that indicates the original type (i.e. same as AppleScript)
32
+
33
+ - aliased AEM::CommandError#number to #to_i
34
+
35
+ - where property and element names are the same (e.g. file, text in BBEdit), appscript now packs this as a property specifier, unless the name is 'text', in which case it's packed as an elements specifier (i.e. [hopefully] same as AppleScript)
36
+
37
+ - renamed macfile.rb/MacFile module to mactypes.rb/MacTypes
38
+
39
+ - renamed MacTypes::Alias, MacTypes::MacFileURL methods:
40
+
41
+ Alias.at -> Alias.path
42
+ FileURL.at -> FileURL.path
43
+ Alias.newDesc -> Alias.desc
44
+ FileURL.newDesc -> FileURL.desc
45
+
46
+ - renamed AS.app methods:
47
+
48
+ app#byName -> app#by_name
49
+ app#byCreator -> app#by_creator
50
+ app#byID -> app#by_id
51
+ app#byPID -> app#by_pid
52
+ app#byURL -> app#by_url
53
+
54
+ - renamed appscript reference methods:
55
+
56
+ startswith -> starts_with
57
+ endswith -> ends_with
58
+ isin -> is_in
59
+ doesnotstartwith -> does_not_start_with
60
+ doesnotendwith -> does_not_end_with
61
+ doesnotcontain -> does_not_contain
62
+ isnotin -> is_not_in
63
+
64
+ - renamed built-in appscript command parameters:
65
+
66
+ :waitreply -> :wait_reply
67
+ :resulttype -> :result_type
68
+
69
+ - renamed AEM::Application methods:
70
+
71
+ Application.newPath -> Application.by_path
72
+ Application.newURL -> Application.by_url
73
+ Application.newPID -> Application.by_pid
74
+ Application.newAEDesc -> Application.by_desc
75
+
76
+ - renamed aem reference methods:
77
+
78
+ byindex -> by_index
79
+ byname -> by_name
80
+ byid -> by_id
81
+ byrange -> by_range
82
+ byfilter -> by_filter
83
+ startswith -> starts_with
84
+ endswith -> ends_with
85
+ isin -> is_in
86
+
87
+ - renamed FindApp methods:
88
+
89
+ FindApp.byName -> FindApp.by_name
90
+ FindApp.byCreator -> FindApp.by_creator
91
+ FindApp.byID -> FindApp.by_id
92
+
93
+ - changed type names in defaultterminology.rb to be more AppleScript-like, e.g. :String -> :string, :MissingValue -> :missing_value (note that there are still a few deliberate differences, e.g. :float instead of :real)
94
+
95
+ - added month and weekday name-code definitions to defaultterminology.rb
96
+
97
+ - changed internal variable and method names to follow Ruby style guidelines
98
+
99
+ - added MacTypes::Units class
100
+
101
+ - added add_unit_types method to Codecs class, allowing additional unit type definitions to be added
102
+
103
+ - fixed appscript reference rendering bug where property/element names could get muddled (e.g. 'document' property would appear as 'documents')
104
+
105
+ - fixed wierd rendering bug where rendered references would be invisible if client script contained an 'app' method of its own (Ruby was invoking this instead of ReferenceRenderer#method_missing)
106
+
107
+ - moved findapp.rb and mactypes.rb to _aem/ (they're already re-exported by aem.rb, appscript.rb, etc. so clients don't need to require them directly)
108
+
109
+ - 'help' is now a reserved word (though is not currently implemented)
110
+
111
+ - Attempting to pack invalid UTF8 strings now raises TypeError instead of AEM::NotUTF8TextError
112
+
113
+ - changed AEM::Application#running? to AEM::Application.is_running?(path)
114
+
115
+ - added aem manual
116
+
117
+ - replaced big if...elsif... block in Codecs#pack with case block
118
+
119
+ - removed AEM::AEEventName (the 'evnt' type, cEventIdentifier, is used by OSAGetHandlerNames)
120
+
121
+ - updated kae.rb; now contains constants scraped from the following OS X 10.4u SDK frameworks:
122
+ AE.framework (all headers)
123
+ Carbon.framework (AEInteraction.h only)
124
+ OpenScripting.framework (all headers except FinderRegistry.h)
125
+
126
+ - Connect.local_app_by_pid now returns an AEDesc of typeKernelProcessID
127
+
128
+ - added basic support for equality tests and hashing to MacFile::Alias and MacFile::URL. Note that it only tests for exact data equality; two objects that identify the same filesystem object/location by different means, using paths of different case, etc. will test as false.
129
+
130
+ - adjusted packing of 'make' command so that if target reference is typeObjectSpecifier then it's packed as the subject attribute but if it's typeInsertionLoc it's packed as an 'at' parameter (this avoids a bug in Cocoa Scripting where packing an insertion location as the subject attribute results in an error when CS tries to coerce it to an object specifier)
131
+
132
+ - fixed various bugs in aem's transaction-handling code
133
+
134
+ - added #abort_transaction and added optional 'session' argument to #start_transaction in AEM::Application and AS::Application
135
+
136
+
137
+ 2006-10-23 -- 0.1.6
138
+
139
+ - improved test_aemreference.rb
140
+
141
+ - fixed bug in aemreference.rb where comparing two non-equivalent aem references could return true
142
+
143
+ - simplified four-char-code conversion routines in codecs.rb
144
+
145
+ - AS::Reference#methods now returns names of application-defined properties, elements and commands in addition to names of built-in methods [MN]
146
+
147
+ - AS::Reference#respond_to? now returns true for names of application-defined properties, elements and commands in addition to names of built-in methods [MN]
148
+
149
+ - removed rbosadict; use ASDictionary.app instead (available from <http://appscript.sourceforge.net>)
150
+
151
+ - removed AS::Application#useterminology; added optional 'terms' argument to Application constructors instead
152
+
153
+ - in Terminology module, changed timeout for ascrgdte event from 120 to 30 sec
154
+
155
+ - added dump tool + documentation
156
+
157
+ - added info to manual on scripting non-stay-open applications
158
+
159
+ - removed MacFile::Alias#newPath and MacFile::FileURL#newPath constructors (use #at instead)
160
+
161
+ - changed MacFile::Alias#to_s and MacFile::FileURL#to_s to return plain path string instead of object representation (use #inspect for that)
162
+
163
+ - removed MacFile::Alias#path and MacFile::FileURL#path (use #to_s instead)
164
+
165
+ - added macfile manual
166
+
167
+ - Connect.launch_app no longer waits for reply/error when sending a launch event to an already running application
168
+
169
+
170
+ 2006-10-18 -- 0.1.5
171
+
172
+ - renamed MacFile::Alias#newPath, MacFile::FileURL#newPath to Alias#at and FileURL#at for conciseness; e.g.: FileURL.at("/some/path"). Note: newPath methods will be removed in 0.2.0.
173
+
174
+ - appscript module now packs UInt32 csig attributes correctly [DH]
175
+
176
+ - fixed little-endian bugs when packing and unpacking typeSInt64 and typeLongDateTime
177
+
178
+ - packing and unpacking typeLongDateTime AEDescs is now about as accurate as can be expected, given the inherent problems of LongDateTime (i.e. UCConvertLongDateTimeToCFAbsoluteTime and UCConvertCFAbsoluteTimeToLongDateTime have off-by-an-hour [or whatever the local difference is] inaccuracies at ST/DST/ST boundaries)
179
+
180
+ - improved error reporting in MacFile module: creating a MacFile::Alias object with a path to a non-existent filesystem object, getting path for MacFile::Alias object that no longer identifies a valid filesystem object, etc. now raises MacFile::FileNotFoundError instead of various MacOSErrors
181
+
182
+ - comparison methods' arguments now display correctly when to_s/inspect is called on its-based references
183
+
184
+ - its-based aem references now correctly unpack KAEContains comparison descriptors as 'reference.isin(value)', rather than trying to unpack them incorrectly as 'value.contains(reference)'
185
+
186
+ - first/middle/last/any references now compare correctly with identical references that have been previously packed and unpacked. Previously the codecs module was unpacking them with different _key attributes, so equality tests would always return false even when the two references were identical.
187
+
188
+ - Attempting to pack invalid UTF8 strings now raises AEM::NotUTF8TextError rather than AE::MacOSError -1700.
189
+
190
+ - fixed launch method (was calling non-existent Connect.launch, not Connect.launchApp)
191
+
192
+ - attempting to retrieve aete resource from an application that doesn't have any terminology no longer raises 'resource not found' (-192) error
193
+
194
+ - AEM module now re-exports AE::MacOSError class for convenience
195
+
196
+ - Apple Event Manager-raised errors that occur when sending events are now reported correctly (was giving 'uninitialized constant Send::Event::None' errors)
197
+
198
+ - appscript referencerenderer module now renders class names in next and previous references correctly
199
+
200
+ - GenericReference#to_s now includes 'AS.' prefix when rendering string representations of generic references
201
+
202
+ - fixed ==() methods in appscript Reference and aem Application classes
203
+
204
+ - implemented eql? methods so aem types, aem references and appscript references should now work correctly as hash keys
205
+
206
+ - fixed endian bugs in Codecs when unpacking insertion location selectors and comparison and logic operators
207
+
208
+
209
+ 2006-10-15 -- 0.1.4
210
+
211
+ - fixed error message when reporting an unknown parameter (was showing command name, not parameter name)
212
+
213
+ - fixed bug in TextEdit_demo.rb script (count command's parameter should be :each, not :each_)
214
+
215
+ - fixed bug where typeBoolean AEDescs would always unpack as true
216
+
217
+ - fixed bugs when packing and unpacking AEDescs of typeSInt64
218
+
219
+ - integers between 2*31 and 2**63-1 now pack as typeSInt64, not typeFloat
220
+
221
+ - [mostly] fixed timezone and winter/summer time bugs; there's probably still problems at the points where DST begins and ends (some of which may be Ruby's fault; this is still to be determined)
222
+
223
+
224
+ 2006-10-13 -- 0.1.3
225
+
226
+ - fixed a bug in appscript where the first argument in a command call would be ignored if it was false or nil [MN]
227
+
228
+ - changed priority order for determining what an ambiguous keyword (e.g. :workbook in Excel) that may be either a type or enumerator name should be packed as; previously typeEnumerated was the default, now it's typeType [MN]
229
+
230
+
231
+ 2006-10-12 -- 0.1.2
232
+
233
+ - fixed a bug where appscript was unpacking typeEnumerated AEDescs as AEM::AEEnums instead of Symbols [MN]
234
+
235
+
236
+ 2006-10-10 -- 0.1.1
237
+
238
+ - made several corrections and improvements to appscript manual [MN]
239
+
240
+
241
+ 2006-10-09 -- 0.1.0
242
+
243
+ - first release
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Copyright (C) 2006 HAS
data/README ADDED
@@ -0,0 +1,42 @@
1
+ Appscript Read Me
2
+
3
+ ======================================================================
4
+ ABOUT
5
+
6
+ Ruby appscript (rb-appscript) is a high-level Apple event bridge for the Ruby scripting language. rb-appscript is closely based on the Python appscript (py-appscript) bridge.
7
+
8
+ See the doc folder for more information.
9
+
10
+ ======================================================================
11
+ REQUIREMENTS
12
+
13
+ - Mac OS X 10.3+
14
+ - Ruby 1.8+
15
+
16
+ ======================================================================
17
+ INSTALLATION
18
+
19
+ $ ruby extconf.rb
20
+ $ make
21
+ $ sudo make install
22
+
23
+ -------
24
+
25
+ Please note that the version of Ruby included with Mac OS X 10.4 is missing the header files needed to build appscript on PPC-based Macs. You can avoid this issue by installing the latest version of Ruby from <http://www.ruby-lang.org/en/downloads/> and updating your shell login profiles to suit.
26
+
27
+ ======================================================================
28
+ NOTES
29
+
30
+ - rb-appscript 0.2.0 contains a number of API changes from rb-appscript 0.1.x; see the CHANGES file and documentation for details
31
+
32
+ ======================================================================
33
+ AUTHOR
34
+
35
+ - HAS -- hhas -at- users - sourceforge - net <http://rb-appscript.rubyforge.org> <http://appscript.sourceforge.net>
36
+
37
+ ======================================================================
38
+ COPYRIGHT
39
+
40
+ Copyright (C) 2006 HAS
41
+
42
+ Appscript is released under the MIT License. See the LICENSE file for more information.
data/TODO ADDED
@@ -0,0 +1,31 @@
1
+ TO DO
2
+
3
+ - pack/unpack support for application types (note: packing would be a bit tricky, since app('foo') could also indicate a reference, in which case it should be packed as a null desc; unpacking might be a bit clumsy, and would (at least in theory) require a by_desc/by_aem_application method to be added to AS::Application to handle typeMachPort, other types could be converted to paths/creator codes/urls/etc. ok though)
4
+
5
+ - remove rbAE_pidToPsn from rbae.c? (no longer used by connect.rb)
6
+
7
+ - allow users to extract a generic ref from a real ref (to_generic) for comparison purposes. Or vice-versa?
8
+
9
+ - implement built-in help system by bridging to py-appscript
10
+
11
+ - see if it's possible to work better with irb's autocomplete (autocomplete support is currently limited to start of a reference)
12
+
13
+ - ae/aem/appscript-defined exception classes aren't quite idiomatic Ruby
14
+
15
+ - finish commenting source code
16
+
17
+ - would be nice if MacFile::FileNotFoundError always showed the failed path (this'd need a bit of Alias Manager glue added to the ae extension)
18
+
19
+ - include an example project (or source for) that uses ruby2exe to build a standalone 'applet'
20
+
21
+ - profiling
22
+
23
+ - finish writing tests
24
+
25
+ - improve and polish documentation
26
+
27
+ - finish problem apps chapter (see comments in HTML file)
28
+
29
+ - see also TO DO items in source files
30
+
31
+ - see also py-appscript's todo.txt file
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+
5
+ <title>aem | 1. Introduction</title>
6
+
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <style type="text/css" media="all"><!--@import url(full.css);--></style>
9
+
10
+ </head>
11
+ <body>
12
+
13
+ <h1>1. Introduction</h1>
14
+
15
+ <!-- top navigation -->
16
+ <div class="navbar">
17
+ <a href="index.html">Previous</a> | <a href="index.html">Up</a> | <a href="02_apioverview.html">Next</a>
18
+ </div>
19
+
20
+ <!-- content -->
21
+ <div id="content">
22
+
23
+ <h2>What is aem?</h2>
24
+
25
+ <p>The aem package provides a mid-level object-oriented wrapper around the low-level ae extension. It provides the following services:</p>
26
+
27
+ <ul>
28
+ <li>an object-oriented API for constructing Apple Event Object Model queries ("references")</li>
29
+ <li>data conversion between common Ruby and AEM types</li>
30
+ <li>AEAddressDesc creation</li>
31
+ <li>Apple event construction and dispatch.</li>
32
+ </ul>
33
+
34
+ <p>The aem package provides a direct foundation for the high-level appscript package. It can also be used directly by developers and end-users for controlling scriptable applications in situations where appscript is unavailable or unsuitable.</p>
35
+
36
+ <p class="hilitebox">Note that this documentation is an API reference, not a full user guide. Some familiarity with Apple events and the Apple Event Manager is required in order to understand and use aem.</p>
37
+
38
+ </div>
39
+
40
+ <!-- bottom navigation -->
41
+ <div class="navbar">
42
+ <a href="index.html">Previous</a> | <a href="index.html">Up</a> | <a href="02_apioverview.html">Next</a>
43
+ </div>
44
+
45
+ <!--footer-->
46
+ <p class="footer">&copy; 2006 HAS</p>
47
+ </body>
48
+ </html>
@@ -0,0 +1,89 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+
5
+ <title>aem | 2. API overview</title>
6
+
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <style type="text/css" media="all"><!--@import url(full.css);--></style>
9
+
10
+ </head>
11
+ <body>
12
+
13
+ <h1>2. API overview</h1>
14
+
15
+ <!-- top navigation -->
16
+ <div class="navbar">
17
+ <a href="01_introduction.html">Previous</a> | <a href="index.html">Up</a> | <a href="03_packingandunpackingdata.html">Next</a>
18
+ </div>
19
+
20
+ <!-- content -->
21
+ <div id="content">
22
+
23
+ <h2>Classes</h2>
24
+
25
+ <p>The main aem classes are as follows:</p>
26
+
27
+ <dl>
28
+ <dt>Application</dt>
29
+ <dd>Represents a scriptable application, and provides an <code>event</code> method for constructing Apple events.</dd>
30
+
31
+ <dt>Event</dt>
32
+ <dd>Represents a ready-to-send Apple event, and provides a <code>send</code> method for sending it. Returned by the <code>Application</code> class's <code>event</code> method.</dd>
33
+
34
+ <dt>CommandError</dt>
35
+ <dd>Exception raised to indicate an application or Apple Event Manager error.</dd>
36
+
37
+ <dt>Codecs</dt>
38
+ <dd>Provides <code>pack</code> and <code>unpack</code> methods for converting Ruby values to AE types, and vice-versa. Clients usually don't need to access this class directly.</dd>
39
+
40
+ <dt>AEType, AEEnum</dt>
41
+ <dd>Represent Apple event type and enumerator values.</dd>
42
+
43
+ </dl>
44
+
45
+ <p>In addition, there are a number of classes used to represent application references, although the user does not instantiate these directly.</p>
46
+
47
+
48
+ <h2>Attributes</h2>
49
+
50
+ <p>The AEM module exports three top-level methods for use in constructing application references:</p>
51
+
52
+ <dl>
53
+ <dt>app</dt>
54
+ <dd>Returns the base object used to construct absolute references.</dd>
55
+
56
+ <dt>con</dt>
57
+ <dd>Returns the base object used to construct relative reference to container object (used in by-range specifiers).</dd>
58
+
59
+ <dt>its</dt>
60
+ <dd>Returns the base object used to construct relative reference to object being tested (used in by-filter specifiers).</dd>
61
+ </dl>
62
+
63
+
64
+ <p>References are constructed from these base objects using chained property/method calls.</p>
65
+
66
+
67
+ <h2>Modules</h2>
68
+
69
+ <p>The aem package also exports the following support module:</p>
70
+
71
+ <dl>
72
+ <dt>FindApp</dt>
73
+ <dd>Provides functions for locating applications by name, bundle id or creator code.</dd>
74
+
75
+ </dl>
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <!-- bottom navigation -->
82
+ <div class="navbar">
83
+ <a href="01_introduction.html">Previous</a> | <a href="index.html">Up</a> | <a href="03_packingandunpackingdata.html">Next</a>
84
+ </div>
85
+
86
+ <!--footer-->
87
+ <p class="footer">&copy; 2006 HAS</p>
88
+ </body>
89
+ </html>
@@ -0,0 +1,98 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+
5
+ <title>aem | 3. Packing and unpacking data</title>
6
+
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8
+ <style type="text/css" media="all"><!--@import url(full.css);--></style>
9
+
10
+ </head>
11
+ <body>
12
+
13
+ <h1>3. Packing and unpacking data</h1>
14
+
15
+ <!-- top navigation -->
16
+ <div class="navbar">
17
+ <a href="02_apioverview.html">Previous</a> | <a href="index.html">Up</a> | <a href="04_references.html">Next</a>
18
+ </div>
19
+
20
+ <!-- content -->
21
+ <div id="content">
22
+
23
+
24
+ <h2>Codecs</h2>
25
+
26
+ <p>The <code>AEM::Codecs</code> class provides methods for converting Python data to <code>AE::AEDesc</code> objects, and vice-versa.</p>
27
+
28
+ <pre><code>Codecs
29
+
30
+ Constructor:
31
+ new
32
+
33
+ Methods:
34
+
35
+ pack(data) -- convert Ruby data to an AEDesc; will raise
36
+ a TypeError if data's type/class is unsupported
37
+ data : anything
38
+ Result : AEDesc
39
+
40
+ unpack(desc) -- convert an AEDesc to Ruby data; will return
41
+ the AEDesc unchanged if it's an unsupported type
42
+ desc : AEDesc
43
+ Result : anything
44
+
45
+ add_unit_types(types) -- register custom unit type definitions
46
+ types : list -- a list of lists, where each sublist is of form
47
+ [name, code] or [name, code, pack_proc, unpack_proc]</code></pre>
48
+
49
+
50
+
51
+
52
+ <!-- <h3>Notes</h3>
53
+
54
+ TO DO: customisation options: subclassing and extending pack/unpack, overriding individual encoder/decoder methods and packUnknown/unpackUnknown; when to instantiate/when to modify; notes on appscript integration; notes on differences to py-appscript Codecs? notes on add_unit_types
55
+
56
+ -->
57
+
58
+
59
+
60
+ <h2>AE types</h2>
61
+
62
+ <p>The Apple Event Manager defines several types for representing type/class names, enumerator names, etc. that have no direct equivalent in Python. Accordingly, aem defines several classes to represent these types on the Python side. All share a common abstract base class, <code>AETypeBase</code>:</p>
63
+
64
+ <pre><code>AETypeBase -- Abstract base class
65
+
66
+ Constructor:
67
+ new(code)
68
+ code : str -- a four-character Apple event code
69
+
70
+ Methods:
71
+ code
72
+ Result : str -- the four-character code
73
+
74
+
75
+ AEType &lt; AETypeBase -- represents an AE object of typeType
76
+
77
+
78
+ AEEnum &lt; AETypeBase -- represents an AE object of typeEnumeration
79
+
80
+
81
+ AEProp &lt; AETypeBase -- represents an AE object of typeProperty
82
+
83
+
84
+ AEKey &lt; AETypeBase -- represents an AE object of typeKeyword</code></pre>
85
+
86
+
87
+
88
+ </div>
89
+
90
+ <!-- bottom navigation -->
91
+ <div class="navbar">
92
+ <a href="02_apioverview.html">Previous</a> | <a href="index.html">Up</a> | <a href="04_references.html">Next</a>
93
+ </div>
94
+
95
+ <!--footer-->
96
+ <p class="footer">&copy; 2006 HAS</p>
97
+ </body>
98
+ </html>