rb-scpt 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +497 -0
  3. data/doc/aem-manual/01_introduction.html +60 -0
  4. data/doc/aem-manual/02_apioverview.html +107 -0
  5. data/doc/aem-manual/03_packingandunpackingdata.html +135 -0
  6. data/doc/aem-manual/04_references.html +409 -0
  7. data/doc/aem-manual/05_targetingapplications.html +164 -0
  8. data/doc/aem-manual/06_buildingandsendingevents.html +229 -0
  9. data/doc/aem-manual/07_findapp.html +63 -0
  10. data/doc/aem-manual/08_examples.html +94 -0
  11. data/doc/aem-manual/aemreferenceinheritance.gif +0 -0
  12. data/doc/aem-manual/index.html +56 -0
  13. data/doc/appscript-manual/01_introduction.html +94 -0
  14. data/doc/appscript-manual/02_aboutappscripting.html +247 -0
  15. data/doc/appscript-manual/03_quicktutorial.html +167 -0
  16. data/doc/appscript-manual/04_gettinghelp.html +188 -0
  17. data/doc/appscript-manual/05_keywordconversion.html +106 -0
  18. data/doc/appscript-manual/06_classesandenums.html +192 -0
  19. data/doc/appscript-manual/07_applicationobjects.html +211 -0
  20. data/doc/appscript-manual/08_realvsgenericreferences.html +96 -0
  21. data/doc/appscript-manual/09_referenceforms.html +241 -0
  22. data/doc/appscript-manual/10_referenceexamples.html +154 -0
  23. data/doc/appscript-manual/11_applicationcommands.html +245 -0
  24. data/doc/appscript-manual/12_commandexamples.html +138 -0
  25. data/doc/appscript-manual/13_performanceissues.html +142 -0
  26. data/doc/appscript-manual/14_notes.html +80 -0
  27. data/doc/appscript-manual/application_architecture.gif +0 -0
  28. data/doc/appscript-manual/application_architecture2.gif +0 -0
  29. data/doc/appscript-manual/finder_to_textedit_event.gif +0 -0
  30. data/doc/appscript-manual/index.html +62 -0
  31. data/doc/appscript-manual/relationships_example.gif +0 -0
  32. data/doc/appscript-manual/ruby_to_itunes_event.gif +0 -0
  33. data/doc/full.css +106 -0
  34. data/doc/index.html +45 -0
  35. data/doc/mactypes-manual/01_introduction.html +54 -0
  36. data/doc/mactypes-manual/02_aliasclass.html +124 -0
  37. data/doc/mactypes-manual/03_fileurlclass.html +126 -0
  38. data/doc/mactypes-manual/04_unitsclass.html +100 -0
  39. data/doc/mactypes-manual/index.html +53 -0
  40. data/doc/osax-manual/01_introduction.html +67 -0
  41. data/doc/osax-manual/02_interface.html +147 -0
  42. data/doc/osax-manual/03_examples.html +73 -0
  43. data/doc/osax-manual/04_notes.html +61 -0
  44. data/doc/osax-manual/index.html +53 -0
  45. data/doc/rb-appscript-logo.png +0 -0
  46. data/extconf.rb +65 -0
  47. data/rb-scpt.gemspec +14 -0
  48. data/sample/AB_export_vcard.rb +31 -0
  49. data/sample/AB_list_people_with_emails.rb +13 -0
  50. data/sample/Add_iCal_event.rb +21 -0
  51. data/sample/Create_daily_iCal_todos.rb +75 -0
  52. data/sample/Export_Address_Book_phone_numbers.rb +59 -0
  53. data/sample/Hello_world.rb +21 -0
  54. data/sample/List_iTunes_playlist_names.rb +11 -0
  55. data/sample/Make_Mail_message.rb +33 -0
  56. data/sample/Open_file_in_TextEdit.rb +13 -0
  57. data/sample/Organize_Mail_messages.rb +61 -0
  58. data/sample/Print_folder_tree.rb +16 -0
  59. data/sample/Select_all_HTML_files.rb +14 -0
  60. data/sample/Set_iChat_status.rb +24 -0
  61. data/sample/Simple_Finder_GUI_Scripting.rb +18 -0
  62. data/sample/Stagger_Finder_windows.rb +25 -0
  63. data/sample/TextEdit_demo.rb +130 -0
  64. data/sample/iTunes_top40_to_html.rb +71 -0
  65. data/src/SendThreadSafe.c +380 -0
  66. data/src/SendThreadSafe.h +139 -0
  67. data/src/lib/_aem/aemreference.rb +1022 -0
  68. data/src/lib/_aem/codecs.rb +662 -0
  69. data/src/lib/_aem/connect.rb +205 -0
  70. data/src/lib/_aem/encodingsupport.rb +77 -0
  71. data/src/lib/_aem/findapp.rb +85 -0
  72. data/src/lib/_aem/mactypes.rb +251 -0
  73. data/src/lib/_aem/send.rb +279 -0
  74. data/src/lib/_aem/typewrappers.rb +59 -0
  75. data/src/lib/_appscript/defaultterminology.rb +277 -0
  76. data/src/lib/_appscript/referencerenderer.rb +245 -0
  77. data/src/lib/_appscript/reservedkeywords.rb +116 -0
  78. data/src/lib/_appscript/safeobject.rb +249 -0
  79. data/src/lib/_appscript/terminology.rb +471 -0
  80. data/src/lib/aem.rb +253 -0
  81. data/src/lib/appscript.rb +1075 -0
  82. data/src/lib/kae.rb +1489 -0
  83. data/src/lib/osax.rb +659 -0
  84. data/src/rbae.c +979 -0
  85. data/test/README +3 -0
  86. data/test/test_aemreference.rb +118 -0
  87. data/test/test_appscriptcommands.rb +152 -0
  88. data/test/test_appscriptreference.rb +106 -0
  89. data/test/test_codecs.rb +186 -0
  90. data/test/test_findapp.rb +26 -0
  91. data/test/test_mactypes.rb +79 -0
  92. data/test/test_osax.rb +54 -0
  93. data/test/testall.sh +10 -0
  94. metadata +145 -0
@@ -0,0 +1,279 @@
1
+ #
2
+ # rb-appscript
3
+ #
4
+ # send -- Event class represents a packed AppleEvent that's ready to send via AESendMessage
5
+ #
6
+
7
+ module Send
8
+
9
+ # Defines the Event class, which represents an Apple event that's packed and ready to send,
10
+ # and the EventError class, which contains error information for a failed event.
11
+
12
+ require "ae"
13
+ require "kae"
14
+ require "_aem/codecs"
15
+
16
+ class Event
17
+ # Represents an Apple event.
18
+
19
+ # Clients don't instantiate this class directly; instead, new instances are returned by AEM::Application#event.
20
+
21
+ attr_reader :AEM_event
22
+
23
+ def initialize(address, event_code, params={}, atts={}, transaction=KAE::KAnyTransactionID,
24
+ return_id= KAE::KAutoGenerateReturnID, codecs=DefaultCodecs)
25
+ # Create and pack a new Apple event ready for sending.
26
+ # address : AEAddressDesc -- the target application, identified by PSN, URL, etc.
27
+ # event_code : string -- 8-letter code indicating event's class and id, e.g. 'coregetd'
28
+ # params : hash -- a hash of form {AE_code=>anything,...} containing zero or more event parameters (message arguments)
29
+ # atts : hash -- a hash of form {AE_code=>anything,...} containing zero or more event attributes (event info)
30
+ # transaction : integer -- transaction number; AEM::Application takes care of this value
31
+ # return_id : integer -- reply event's ID
32
+ # codecs : Codecs -- clients can provide custom Codecs object for packing parameters and unpacking result of this event
33
+ @_event_code = event_code
34
+ @_codecs = codecs
35
+ @AEM_event = _create_apple_event(event_code[0, 4], event_code[-4, 4], address, return_id, transaction)
36
+ atts.each {|key, value| @AEM_event.put_attr(key, codecs.pack(value))}
37
+ params.each {|key, value| @AEM_event.put_param(key, codecs.pack(value))}
38
+ end
39
+
40
+ def _create_apple_event(event_class, event_id, target, return_id, transaction_id)
41
+ # Hook method; may be overridden to customise how AppleEvent descriptors are created.
42
+ return AE::AEDesc.new_apple_event(event_class, event_id, target, return_id, transaction_id)
43
+ end
44
+
45
+ def _send_apple_event(flags, timeout)
46
+ # Hook method; may be overridden to customise how events are sent.
47
+ return @AEM_event.send_thread_safe(flags, timeout)
48
+ end
49
+
50
+ def inspect
51
+ return "#<AEM::Event @code=#{@_event_code}>"
52
+ end
53
+
54
+ alias_method :to_s, :inspect
55
+
56
+ def send(timeout=KAE::KAEDefaultTimeout, flags=KAE::KAECanSwitchLayer + KAE::KAEWaitReply)
57
+ # Send this Apple event (may be called any number of times).
58
+ # timeout : int | KAEDefaultTimeout | KNoTimeOut -- number of ticks to wait for target process to reply before raising timeout error
59
+ # flags : integer -- bitwise flags [1] indicating how target process should handle event
60
+ # Result : anything -- value returned by application, if any
61
+ #
62
+ # [1] Should be the sum of zero or more of the following kae module constants:
63
+ #
64
+ # KAENoReply | KAEQueueReply | KAEWaitReply
65
+ # KAEDontReconnect
66
+ # KAEWantReceipt
67
+ # KAENeverInteract | KAECanInteract | KAEAlwaysInteract
68
+ # KAECanSwitchLayer
69
+
70
+ begin
71
+ reply_event = _send_apple_event(flags, timeout)
72
+ rescue AE::MacOSError => err # The Apple Event Manager raised an error.
73
+ if not(@_event_code == 'aevtquit' and err.to_i == -609) # Ignore invalid connection errors (-609) when quitting
74
+ raise EventError.new(err.to_i)
75
+ end
76
+ else # Decode application's reply, if any. May be a return value, error number (and optional message), or nothing.
77
+ if reply_event.type != KAE::TypeNull
78
+ event_result = {}
79
+ reply_event.length.times do |i|
80
+ key, value = reply_event.get_item(i + 1, KAE::TypeWildCard)
81
+ event_result[key] = value
82
+ end
83
+ if event_result.has_key?(KAE::KeyErrorNumber) # The application raised an error.
84
+ # Error info is unpacked using default codecs for reliability.
85
+ e_num = DefaultCodecs.unpack(event_result[KAE::KeyErrorNumber])
86
+ if e_num != 0 # Some apps (e.g. Finder) may return error code 0 to indicate a successful operation, so ignore this.
87
+ raise EventError.new(e_num, event_result)
88
+ end
89
+ end
90
+ if event_result.has_key?(KAE::KeyAEResult)
91
+ # Return values are unpacked using [optionally] client-supplied codecs.
92
+ # This allows aem clients such as appscript to customise how values are unpacked
93
+ # (e.g. to unpack object specifier descs as appscript references instead of aem references).
94
+ return @_codecs.unpack(event_result[KAE::KeyAEResult])
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+
102
+ class EventError < RuntimeError
103
+ # Represents an error raised by the Apple Event Manager or target application when a command fails.
104
+ #
105
+ # Methods:
106
+ # number : integer -- MacOS error number
107
+ # message : string -- application error message if any, or default error description if available
108
+
109
+ # Most applications don't provide error description strings, so define default descriptions for the common ones.
110
+ # Following default error descriptions are cribbed from the AppleScript Language Guide/MacErrors.h:
111
+
112
+ MacOSErrorDescriptions = {
113
+ # OS errors
114
+ -34 => "Disk is full.",
115
+ -35 => "Disk wasn't found.",
116
+ -37 => "Bad name for file.",
117
+ -38 => "File wasn't open.",
118
+ -39 => "End of file error.",
119
+ -42 => "Too many files open.",
120
+ -43 => "File wasn't found.",
121
+ -44 => "Disk is write protected.",
122
+ -45 => "File is locked.",
123
+ -46 => "Disk is locked.",
124
+ -47 => "File is busy.",
125
+ -48 => "Duplicate file name.",
126
+ -49 => "File is already open.",
127
+ -50 => "Parameter error.",
128
+ -51 => "File reference number error.",
129
+ -61 => "File not open with write permission.",
130
+ -108 => "Out of memory.",
131
+ -120 => "Folder wasn't found.",
132
+ -124 => "Disk is disconnected.",
133
+ -128 => "User canceled.",
134
+ -192 => "A resource wasn't found.",
135
+ -600 => "Application isn't running.",
136
+ -601 => "Not enough room to launch application with special requirements.",
137
+ -602 => "Application is not 32-bit clean.",
138
+ -605 => "More memory is needed than is specified in the size resource.",
139
+ -606 => "Application is background-only.",
140
+ -607 => "Buffer is too small.",
141
+ -608 => "No outstanding high-level event.",
142
+ -609 => "Connection is invalid.",
143
+ -904 => "Not enough system memory to connect to remote application.",
144
+ -905 => "Remote access is not allowed.",
145
+ -906 => "Application isn't running or program linking isn't enabled.",
146
+ -915 => "Can't find remote machine.",
147
+ -30720 => "Invalid date and time.",
148
+ # AE errors
149
+ -1700 => "Can't make some data into the expected type.",
150
+ -1701 => "Some parameter is missing for command.",
151
+ -1702 => "Some data could not be read.",
152
+ -1703 => "Some data was the wrong type.",
153
+ -1704 => "Some parameter was invalid.",
154
+ -1705 => "Operation involving a list item failed.",
155
+ -1706 => "Need a newer version of the Apple Event Manager.",
156
+ -1707 => "Event isn't an Apple event.",
157
+ -1708 => "Application could not handle this command.",
158
+ -1709 => "AEResetTimer was passed an invalid reply.",
159
+ -1710 => "Invalid sending mode was passed.",
160
+ -1711 => "User canceled out of wait loop for reply or receipt.",
161
+ -1712 => "Apple event timed out.",
162
+ -1713 => "No user interaction allowed.",
163
+ -1714 => "Wrong keyword for a special function.",
164
+ -1715 => "Some parameter wasn't understood.",
165
+ -1716 => "Unknown Apple event address type.",
166
+ -1717 => "The handler is not defined.",
167
+ -1718 => "Reply has not yet arrived.",
168
+ -1719 => "Can't get reference. Invalid index.",
169
+ -1720 => "Invalid range.",
170
+ -1721 => "Wrong number of parameters for command.",
171
+ -1723 => "Can't get reference. Access not allowed.",
172
+ -1725 => "Illegal logical operator called.",
173
+ -1726 => "Illegal comparison or logical.",
174
+ -1727 => "Expected a reference.",
175
+ -1728 => "Can't get reference.",
176
+ -1729 => "Object counting procedure returned a negative count.",
177
+ -1730 => "Container specified was an empty list.",
178
+ -1731 => "Unknown object type.",
179
+ -1739 => "Attempting to perform an invalid operation on a null descriptor.",
180
+ # Application scripting errors
181
+ -10000 => "Apple event handler failed.",
182
+ -10001 => "Type error.",
183
+ -10002 => "Invalid key form.",
184
+ -10003 => "Can't set reference to given value. Access not allowed.",
185
+ -10004 => "A privilege violation occurred.",
186
+ -10005 => "The read operation wasn't allowed.",
187
+ -10006 => "Can't set reference to given value.",
188
+ -10007 => "The index of the event is too large to be valid.",
189
+ -10008 => "The specified object is a property, not an element.",
190
+ -10009 => "Can't supply the requested descriptor type for the data.",
191
+ -10010 => "The Apple event handler can't handle objects of this class.",
192
+ -10011 => "Couldn't handle this command because it wasn't part of the current transaction.",
193
+ -10012 => "The transaction to which this command belonged isn't a valid transaction.",
194
+ -10013 => "There is no user selection.",
195
+ -10014 => "Handler only handles single objects.",
196
+ -10015 => "Can't undo the previous Apple event or user action.",
197
+ -10023 => "Enumerated value is not allowed for this property.",
198
+ -10024 => "Class can't be an element of container.",
199
+ -10025 => "Illegal combination of properties settings.",
200
+ }
201
+
202
+ # Following Cocoa Scripting error descriptions taken from:
203
+ # http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSScriptCommand.html
204
+ # http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSScriptObjectSpecifier.html
205
+
206
+ CocoaErrorDescriptions = [
207
+ ["NSReceiverEvaluationScriptError", "The object or objects specified by the direct parameter to a command could not be found."],
208
+ ["NSKeySpecifierEvaluationScriptError", "The object or objects specified by a key (for commands that support key specifiers) could not be found."],
209
+ ["NSArgumentEvaluationScriptError", "The object specified by an argument could not be found."],
210
+ ["NSReceiversCantHandleCommandScriptError", "The receivers don't support the command sent to them."],
211
+ ["NSRequiredArgumentsMissingScriptError", "An argument (or more than one argument) is missing."],
212
+ ["NSArgumentsWrongScriptError", "An argument (or more than one argument) is of the wrong type or is otherwise invalid."],
213
+ ["NSUnknownKeyScriptError", "An unidentified error occurred; indicates an error in the scripting support of the application."],
214
+ ["NSInternalScriptError", "An unidentified internal error occurred; indicates an error in the scripting support of the application."],
215
+ ["NSOperationNotSupportedForKeyScriptError", "The implementation of a scripting command signaled an error."],
216
+ ["NSCannotCreateScriptCommandError", "Could not create the script command; an invalid or unrecognized Apple event was received."],
217
+ ["NSNoSpecifierError", "No error encountered."],
218
+ ["NSNoTopLevelContainersSpecifierError", "Someone called evaluate with nil."],
219
+ ["NSContainerSpecifierError", "Error evaluating container specifier."],
220
+ ["NSUnknownKeySpecifierError", "Receivers do not understand the key."],
221
+ ["NSInvalidIndexSpecifierError", "Index out of bounds."],
222
+ ["NSInternalSpecifierError", "Other internal error."],
223
+ ["NSOperationNotSupportedForKeySpecifierError", "Attempt made to perform an unsupported operation on some key."]
224
+ ]
225
+
226
+ attr_reader :number, :raw
227
+ alias_method :to_i, :number
228
+
229
+ def initialize(number, reply_params={})
230
+ @number = number
231
+ @message = nil
232
+ @raw = reply_params
233
+ end
234
+
235
+ def message
236
+ if not @message
237
+ desc = @raw[KAE::KeyErrorString]
238
+ @message = DefaultCodecs.unpack(desc) if desc
239
+ if @message.is_a?(String) and @number > 0
240
+ # add clarification to default Cocoa Scripting error messages
241
+ CocoaErrorDescriptions.each do |name, description|
242
+ if @message[0, name.length] == name
243
+ @message += " (#{description})"
244
+ break
245
+ end
246
+ end
247
+ end
248
+ # if no message supplied or is a MacOSError, use default message if one is available
249
+ @message = MacOSErrorDescriptions.fetch(number, '') if @message == nil
250
+ end
251
+ return @message
252
+ end
253
+
254
+ def to_s
255
+ if message != ''
256
+ return "EventError\n\t\tOSERROR: #{number}\n\t\tMESSAGE: #{message}"
257
+ else
258
+ return "EventError\n\t\tOSERROR: #{number}"
259
+ end
260
+ end
261
+
262
+ # extended error info (some apps may return additional error info, though most don't)
263
+
264
+ def offending_object
265
+ desc = @raw[KAE::KOSAErrorOffendingObject]
266
+ return desc ? DefaultCodecs.unpack(desc) : nil
267
+ end
268
+
269
+ def expected_type
270
+ desc = @raw[KAE::KOSAErrorExpectedType]
271
+ return desc ? DefaultCodecs.unpack(desc) : nil
272
+ end
273
+
274
+ def partial_result
275
+ desc = @raw[KAE::KOSAErrorPartialResult]
276
+ return desc ? DefaultCodecs.unpack(desc) : nil
277
+ end
278
+ end
279
+ end
@@ -0,0 +1,59 @@
1
+ #
2
+ # rb-appscript
3
+ #
4
+ # typewrappers -- Ruby classes representing type, enumerator, property and keyword AEDescs
5
+ #
6
+
7
+ module TypeWrappers
8
+
9
+ class AETypeBase
10
+
11
+ attr_reader :code
12
+
13
+ def initialize(code)
14
+ if not(code.is_a?(String) and code.length == 4)
15
+ raise ArgumentError, "Code must be a four-character string: #{code.inspect}"
16
+ end
17
+ @code = code
18
+ end
19
+
20
+ def hash
21
+ return @code.hash
22
+ end
23
+
24
+ def ==(val)
25
+ return (self.equal?(val) or (val.class == self.class and val.code == @code))
26
+ end
27
+
28
+ alias_method :eql?, :==
29
+
30
+ def to_s
31
+ return "AEM::#{self.class::Name}.new(#{@code.inspect})"
32
+ end
33
+
34
+ def inspect
35
+ return to_s
36
+ end
37
+ end
38
+
39
+
40
+ class AEType < AETypeBase
41
+ Name = 'AEType'
42
+ end
43
+
44
+
45
+ class AEEnum < AETypeBase
46
+ Name = 'AEEnum'
47
+ end
48
+
49
+
50
+ class AEProp < AETypeBase
51
+ Name = 'AEProp'
52
+ end
53
+
54
+
55
+ class AEKey < AETypeBase
56
+ Name = 'AEKey'
57
+ end
58
+
59
+ end
@@ -0,0 +1,277 @@
1
+ #
2
+ # rb-appscript
3
+ #
4
+ # defaultterminology -- lookup tables for default type, enumerator and command definitions
5
+ #
6
+
7
+ module DefaultTerminology
8
+ # Defines built-in terminology available for any application. When constructing the terminology tables for a particular application, the Terminology module will duplicate these tables and then add application-specific terms to create the finished lookup tables.
9
+
10
+ require "aem"
11
+
12
+ Enums = {
13
+ 'yes ' => :yes,
14
+ 'no ' => :no,
15
+ 'ask ' => :ask,
16
+
17
+ 'case' => :case,
18
+ 'diac' => :diacriticals,
19
+ 'expa' => :expansion,
20
+ 'hyph' => :hyphens,
21
+ 'punc' => :punctuation,
22
+ 'whit' => :whitespace,
23
+ 'nume' => :numeric_strings,
24
+ 'rmte' => :application_responses,
25
+ }
26
+
27
+ Types = {
28
+ '****' => :anything,
29
+
30
+ 'bool' => :boolean,
31
+
32
+ 'shor' => :short_integer,
33
+ 'long' => :integer,
34
+ 'magn' => :unsigned_integer,
35
+ 'comp' => :double_integer,
36
+
37
+ 'fixd' => :fixed,
38
+ 'lfxd' => :long_fixed,
39
+ 'decm' => :decimal_struct,
40
+
41
+ 'sing' => :short_float,
42
+ 'doub' => :float,
43
+ 'exte' => :extended_float,
44
+ 'ldbl' => :float_128bit,
45
+
46
+ 'TEXT' => :string,
47
+ 'cstr' => :c_string,
48
+ 'pstr' => :pascal_string,
49
+ 'STXT' => :styled_text,
50
+ 'tsty' => :text_style_info,
51
+ 'styl' => :styled_clipboard_text,
52
+ 'encs' => :encoded_string,
53
+ 'psct' => :writing_code,
54
+ 'intl' => :international_writing_code,
55
+ 'itxt' => :international_text,
56
+ 'sutx' => :styled_unicode_text,
57
+ 'utxt' => :unicode_text,
58
+ 'utf8' => :utf8_text, # typeUTF8Text
59
+ 'ut16' => :utf16_text, # typeUTF16ExternalRepresentation
60
+
61
+ 'vers' => :version,
62
+ 'ldt ' => :date,
63
+ 'list' => :list,
64
+ 'reco' => :record,
65
+ 'tdta' => :data,
66
+ 'scpt' => :script,
67
+
68
+ 'insl' => :location_reference,
69
+ 'obj ' => :reference,
70
+
71
+ 'alis' => :alias,
72
+ 'fsrf' => :file_ref,
73
+ 'fss ' => :file_specification,
74
+ 'furl' => :file_url,
75
+
76
+ 'QDpt' => :point,
77
+ 'qdrt' => :bounding_rectangle,
78
+ 'fpnt' => :fixed_point,
79
+ 'frct' => :fixed_rectangle,
80
+ 'lpnt' => :long_point,
81
+ 'lrct' => :long_rectangle,
82
+ 'lfpt' => :long_fixed_point,
83
+ 'lfrc' => :long_fixed_rectangle,
84
+
85
+ 'EPS ' => :EPS_picture,
86
+ 'GIFf' => :GIF_picture,
87
+ 'JPEG' => :JPEG_picture,
88
+ 'PICT' => :PICT_picture,
89
+ 'TIFF' => :TIFF_picture,
90
+ 'cRGB' => :RGB_color,
91
+ 'tr16' => :RGB16_color,
92
+ 'tr96' => :RGB96_color,
93
+ 'cgtx' => :graphic_text,
94
+ 'clrt' => :color_table,
95
+ 'tpmm' => :pixel_map_record,
96
+
97
+ 'best' => :best,
98
+ 'type' => :type_class,
99
+ 'enum' => :enumerator,
100
+ 'prop' => :property,
101
+
102
+ # AEAddressDesc types
103
+
104
+ 'port' => :mach_port,
105
+ 'kpid' => :kernel_process_id,
106
+ 'bund' => :application_bundle_id,
107
+ 'psn ' => :process_serial_number,
108
+ 'sign' => :application_signature,
109
+ 'aprl' => :application_url,
110
+
111
+ # misc.
112
+
113
+ 'msng' => :missing_value,
114
+
115
+ 'cobj' => :item,
116
+
117
+ 'null' => :null,
118
+
119
+ 'mLoc' => :machine_location,
120
+ 'mach' => :machine,
121
+
122
+ 'tdas' => :dash_style,
123
+ 'trot' => :rotation,
124
+
125
+ 'suin' => :suite_info,
126
+ 'gcli' => :class_info,
127
+ 'pinf' => :property_info,
128
+ 'elin' => :element_info,
129
+ 'evin' => :event_info,
130
+ 'pmin' => :parameter_info,
131
+
132
+ # unit types
133
+
134
+ 'cmtr' => :centimeters,
135
+ 'metr' => :meters,
136
+ 'kmtr' => :kilometers,
137
+ 'inch' => :inches,
138
+ 'feet' => :feet,
139
+ 'yard' => :yards,
140
+ 'mile' => :miles,
141
+
142
+ 'sqrm' => :square_meters,
143
+ 'sqkm' => :square_kilometers,
144
+ 'sqft' => :square_feet,
145
+ 'sqyd' => :square_yards,
146
+ 'sqmi' => :square_miles,
147
+
148
+ 'ccmt' => :cubic_centimeters,
149
+ 'cmet' => :cubic_meters,
150
+ 'cuin' => :cubic_inches,
151
+ 'cfet' => :cubic_feet,
152
+ 'cyrd' => :cubic_yards,
153
+
154
+ 'litr' => :liters,
155
+ 'qrts' => :quarts,
156
+ 'galn' => :gallons,
157
+
158
+ 'gram' => :grams,
159
+ 'kgrm' => :kilograms,
160
+ 'ozs ' => :ounces,
161
+ 'lbs ' => :pounds,
162
+
163
+ 'degc' => :degrees_Celsius,
164
+ 'degf' => :degrees_Fahrenheit,
165
+ 'degk' => :degrees_Kelvin,
166
+
167
+ # month and weekday
168
+
169
+ 'jan ' => :January,
170
+ 'feb ' => :February,
171
+ 'mar ' => :March,
172
+ 'apr ' => :April,
173
+ 'may ' => :May,
174
+ 'jun ' => :June,
175
+ 'jul ' => :July,
176
+ 'aug ' => :August,
177
+ 'sep ' => :September,
178
+ 'oct ' => :October,
179
+ 'nov ' => :November,
180
+ 'dec ' => :December,
181
+
182
+ 'sun ' => :Sunday,
183
+ 'mon ' => :Monday,
184
+ 'tue ' => :Tuesday,
185
+ 'wed ' => :Wednesday,
186
+ 'thu ' => :Thursday,
187
+ 'fri ' => :Friday,
188
+ 'sat ' => :Saturday,
189
+ }
190
+
191
+ Properties = {
192
+ 'pcls' => :class_,
193
+ 'pALL' => :properties_,
194
+ 'ID ' => :id_,
195
+ }
196
+
197
+ Elements = {
198
+ 'cobj' => :items,
199
+ }
200
+
201
+ Commands = {
202
+ :quit => ['aevtquit', {
203
+ :saving => 'savo',
204
+ }],
205
+ :activate => ['miscactv', {
206
+ }],
207
+ :run => ['aevtoapp', {
208
+ }],
209
+ :launch => ['ascrnoop', {
210
+ }],
211
+ :open => ['aevtodoc', {
212
+ }],
213
+ :get => ['coregetd', {
214
+ }],
215
+ :print => ['aevtpdoc', {
216
+ }],
217
+ :set => ['coresetd', {
218
+ :to => 'data',
219
+ }],
220
+ :reopen => ['aevtrapp', {
221
+ }],
222
+ :open_location => ['GURLGURL', {
223
+ :window => 'WIND',
224
+ }],
225
+ }
226
+
227
+ #######
228
+ # TypeByCode and TypeByName tables are used to convert Ruby Symbols to and from AEDescs of typeType, typeEnum and typeProperty.
229
+
230
+ TypeByCode = {} # used to decode class (typeType) and enumerator (typeEnum) descriptors
231
+ TypeByName = {} # used to encode class and enumerator keywords
232
+ TypeCodeByName = {} # used to check for name collisions
233
+
234
+ Enums.each do |code, name|
235
+ TypeByCode[code] = name
236
+ TypeByName[name] = AEM::AEEnum.new(code)
237
+ TypeCodeByName[name.to_s] = code
238
+ end
239
+
240
+ [Types, Properties].each do |table|
241
+ table.each do |code, name|
242
+ TypeByCode[code] = name
243
+ TypeByName[name] = AEM::AEType.new(code)
244
+ TypeCodeByName[name.to_s] = code
245
+ end
246
+ end
247
+
248
+ #######
249
+ # ReferenceByCode and ReferenceByName tables are used to convert between appscript- and aem-style references
250
+
251
+ ReferenceByCode = {} # used by ReferenceRenderer module to convert property and element four-char codes to human readable names
252
+ ReferenceByName = {} # used to convert appscript-style references and commands to their aem equivalents
253
+
254
+ Properties.each do |code, name|
255
+ ReferenceByCode['p' + code] = name.to_s
256
+ ReferenceByName[name] = [:property, code]
257
+ end
258
+
259
+ Elements.each do |code, name|
260
+ ReferenceByCode['e' + code] = name.to_s
261
+ ReferenceByName[name] = [:element, code]
262
+ end
263
+
264
+ Commands.each do |name, info|
265
+ ReferenceByName[name] = [:command, info]
266
+ end
267
+
268
+ #######
269
+ # CommandCodeByName; used by Terminology._make_reference_table to check for any collisions between standard and application-defined commands where the command names are the same but the codes are different
270
+
271
+ CommandCodeByName = {} # {'quit' => 'aevtquit', 'activate' => 'miscactv',...}
272
+ ReferenceByName.each do |name, info|
273
+ if info[0] == :command
274
+ CommandCodeByName[name.to_s] = info[1][0]
275
+ end
276
+ end
277
+ end