rb-appscript 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/CHANGES +59 -0
  2. data/LICENSE +65 -0
  3. data/README +1 -1
  4. data/TODO +13 -13
  5. data/doc/aem-manual/04_references.html +13 -13
  6. data/doc/aem-manual/05_targettingapplications.html +7 -5
  7. data/doc/aem-manual/06_buildingandsendingevents.html +1 -1
  8. data/doc/aem-manual/08_examples.html +6 -6
  9. data/doc/aem-manual/index.html +3 -4
  10. data/doc/appscript-manual/02_aboutappscripting.html +2 -10
  11. data/doc/appscript-manual/04_gettinghelp.html +32 -18
  12. data/doc/appscript-manual/05_keywordconversion.html +7 -7
  13. data/doc/appscript-manual/06_classesandenums.html +2 -21
  14. data/doc/appscript-manual/07_applicationobjects.html +11 -2
  15. data/doc/appscript-manual/08_realvsgenericreferences.html +1 -1
  16. data/doc/appscript-manual/09_referenceforms.html +13 -13
  17. data/doc/appscript-manual/10_referenceexamples.html +7 -7
  18. data/doc/appscript-manual/11_applicationcommands.html +30 -28
  19. data/doc/appscript-manual/13_performanceissues.html +3 -3
  20. data/doc/appscript-manual/{15_notes.html → 14_notes.html} +18 -13
  21. data/doc/appscript-manual/full.css +1 -2
  22. data/doc/appscript-manual/index.html +3 -4
  23. data/doc/index.html +2 -1
  24. data/doc/mactypes-manual/index.html +23 -13
  25. data/doc/osax-manual/index.html +27 -5
  26. data/rb-appscript.gemspec +1 -1
  27. data/sample/AB_list_people_with_emails.rb +2 -1
  28. data/sample/Add_iCal_event.rb +18 -0
  29. data/sample/Export_Address_Book_phone_numbers.rb +56 -0
  30. data/sample/Hello_world.rb +9 -1
  31. data/sample/Select_all_HTML_files.rb +4 -2
  32. data/sample/iTunes_top40_to_html.rb +7 -4
  33. data/src/lib/_aem/aemreference.rb +50 -51
  34. data/src/lib/_aem/codecs.rb +148 -178
  35. data/src/lib/_aem/connect.rb +0 -2
  36. data/src/lib/_aem/findapp.rb +1 -1
  37. data/src/lib/_aem/mactypes.rb +2 -9
  38. data/src/lib/_aem/send.rb +2 -2
  39. data/src/lib/_appscript/defaultterminology.rb +2 -2
  40. data/src/lib/_appscript/referencerenderer.rb +119 -14
  41. data/src/lib/_appscript/reservedkeywords.rb +5 -0
  42. data/src/lib/_appscript/safeobject.rb +190 -0
  43. data/src/lib/_appscript/terminology.rb +195 -90
  44. data/src/lib/aem.rb +8 -9
  45. data/src/lib/appscript.rb +175 -159
  46. data/src/lib/osax.rb +65 -29
  47. data/src/rbae.c +42 -2
  48. data/test/test_aemreference.rb +3 -3
  49. data/test/test_appscriptcommands.rb +135 -0
  50. data/test/test_appscriptreference.rb +10 -8
  51. data/test/test_mactypes.rb +7 -1
  52. data/test/test_osax.rb +57 -0
  53. data/test/testall.sh +2 -1
  54. metadata +10 -9
  55. data/doc/aem-manual/09_notes.html +0 -41
  56. data/doc/appscript-manual/14_problemapps.html +0 -192
  57. data/misc/adobeunittypes.rb +0 -14
  58. data/misc/dump.rb +0 -72
  59. data/rb-appscript-0.2.0.gem +0 -0
@@ -56,7 +56,7 @@ class UnitTypeCodecs
56
56
  [:degrees_Kelvin, KAE::TypeDegreesK],
57
57
  ]
58
58
 
59
- DefaultPacker = proc { |value, code| AE::AEDesc.new(code, [value].pack('d')) }
59
+ DefaultPacker = proc { |units, code| AE::AEDesc.new(code, [units.value].pack('d')) }
60
60
  DefaultUnpacker = proc { |desc, name| MacTypes::Units.new(desc.data.unpack('d')[0], name) }
61
61
 
62
62
  def initialize
@@ -69,7 +69,7 @@ class UnitTypeCodecs
69
69
  # type_defs is a list of lists, where each sublist is of form:
70
70
  # [typename, typecode, packproc, unpackproc]
71
71
  # or:
72
- # [typename, typecode, packproc, unpackproc]
72
+ # [typename, typecode]
73
73
  # If optional packproc and unpackproc are omitted, default pack/unpack procs
74
74
  # are used instead; these pack/unpack AEDesc data as a double precision float.
75
75
  type_defs.each do |name, code, packer, unpacker|
@@ -81,7 +81,7 @@ class UnitTypeCodecs
81
81
  def pack(val)
82
82
  if val.is_a?(MacTypes::Units)
83
83
  code, packer = @type_by_name.fetch(val.type) { |val| raise IndexError, "Unknown unit type: #{val.inspect}" }
84
- return [true, packer.call(val.value, code)]
84
+ return [true, packer.call(val, code)]
85
85
  else
86
86
  return [false, val]
87
87
  end
@@ -166,19 +166,9 @@ class Codecs
166
166
  def pack(val) # clients may override this to replace existing packers
167
167
  case val
168
168
  when AEMReference::Base then val.AEM_pack_self(self)
169
- when NilClass then NullDesc
170
- when TrueClass then TrueDesc
171
- when FalseClass then FalseDesc
169
+
172
170
  when Fixnum then AE::AEDesc.new(KAE::TypeSInt32, [val].pack('l'))
173
- when Bignum
174
- if SInt32Bounds === val
175
- AE::AEDesc.new(KAE::TypeSInt32, [val].pack('l'))
176
- elsif SInt64Bounds === val
177
- AE::AEDesc.new(KAE::TypeSInt64, [val].pack('q'))
178
- else
179
- AE::AEDesc.new(KAE::TypeFloat, [val.to_f].pack('d'))
180
- end
181
- when Float then AE::AEDesc.new(KAE::TypeFloat, [val].pack('d'))
171
+
182
172
  when String then
183
173
  begin
184
174
  # Note: while typeUnicodeText is deprecated (see AEDataModel.h), it's still the
@@ -197,12 +187,21 @@ class Codecs
197
187
  raise
198
188
  end
199
189
  end
190
+
191
+ when TrueClass then TrueDesc
192
+ when FalseClass then FalseDesc
193
+
194
+ when Float then AE::AEDesc.new(KAE::TypeFloat, [val].pack('d'))
195
+
200
196
  when Time
201
197
  AE::AEDesc.new(KAE::TypeLongDateTime,
202
198
  [AE.convert_unix_seconds_to_long_date_time(val.to_i)].pack('q'))
199
+
203
200
  when Array then pack_array(val)
204
201
  when Hash then pack_hash(val)
202
+
205
203
  when MacTypes::FileBase then val.desc
204
+
206
205
  when TypeWrappers::AEType then
207
206
  AE::AEDesc.new(KAE::TypeType, Codecs.four_char_code(val.code))
208
207
  when TypeWrappers::AEEnum then
@@ -211,7 +210,19 @@ class Codecs
211
210
  AE::AEDesc.new(KAE::TypeProperty, Codecs.four_char_code(val.code))
212
211
  when TypeWrappers::AEKey then
213
212
  AE::AEDesc.new(KAE::TypeKeyword, Codecs.four_char_code(val.code))
213
+
214
214
  when AE::AEDesc then val
215
+
216
+ when Bignum
217
+ if SInt32Bounds === val
218
+ AE::AEDesc.new(KAE::TypeSInt32, [val].pack('l'))
219
+ elsif SInt64Bounds === val
220
+ AE::AEDesc.new(KAE::TypeSInt64, [val].pack('q'))
221
+ else
222
+ AE::AEDesc.new(KAE::TypeFloat, [val.to_f].pack('d'))
223
+ end
224
+
225
+ when NilClass then NullDesc
215
226
  else
216
227
  did_pack, desc = @unit_type_codecs.pack(val)
217
228
  if did_pack
@@ -237,7 +248,7 @@ class Codecs
237
248
  usrf = nil
238
249
  val.each do | key, value |
239
250
  if key.is_a?(TypeWrappers::AETypeBase)
240
- if key.code == 'pcls' # AS packs records that contain a 'class' property by coercing the packed record to that type at the end
251
+ if key.code == KAE::PClass # AS packs records that contain a 'class' property by coercing the packed record to that type at the end
241
252
  begin
242
253
  record = record.coerce(value.code)
243
254
  rescue
@@ -255,7 +266,7 @@ class Codecs
255
266
  end
256
267
  end
257
268
  if usrf
258
- record.put_param('usrf', usrf)
269
+ record.put_param(KAE::KeyASUserRecordFields, usrf)
259
270
  end
260
271
  return record
261
272
  end
@@ -266,7 +277,7 @@ class Codecs
266
277
  def unpack_unknown(desc) # clients may override this to provide additional unpackers
267
278
  if desc.is_record? # if it's a record-like structure with an unknown/unsupported type then unpack it as a hash, including the original type info as a 'class' property
268
279
  rec = desc.coerce(KAE::TypeAERecord)
269
- rec.put_param('pcls', pack(TypeWrappers::AEType.new(desc.type)))
280
+ rec.put_param(KAE::PClass, pack(TypeWrappers::AEType.new(desc.type)))
270
281
  unpack(rec)
271
282
  else # else return unchanged
272
283
  desc
@@ -277,37 +288,24 @@ class Codecs
277
288
  def unpack(desc) # clients may override this to replace existing unpackers
278
289
  return case desc.type
279
290
 
280
- when KAE::TypeNull then nil
281
- when KAE::TypeBoolean then desc.data != "\000"
282
- when KAE::TypeFalse then false
283
- when KAE::TypeTrue then true
291
+ when KAE::TypeObjectSpecifier then unpack_object_specifier(desc)
284
292
 
285
- when KAE::TypeSInt16 then desc.data.unpack('s')[0]
286
293
  when KAE::TypeSInt32 then desc.data.unpack('l')[0]
287
- when KAE::TypeUInt32 then desc.data.unpack('L')[0]
288
- when KAE::TypeSInt64 then desc.data.unpack('q')[0]
289
- when KAE::TypeIEEE32BitFloatingPoint then desc.data.unpack('f')[0]
290
294
  when KAE::TypeIEEE64BitFloatingPoint then desc.data.unpack('d')[0]
291
- when KAE::Type128BitFloatingPoint then
292
- desc.coerce(KAE::TypeIEEE64BitFloatingPoint).data.unpack('d')[0]
293
295
 
294
- when KAE::TypeUTF8Text then desc.data
295
296
  when
296
297
  KAE::TypeUnicodeText,
297
298
  KAE::TypeChar,
298
299
  KAE::TypeIntlText,
299
300
  KAE::TypeUTF16ExternalRepresentation,
300
- KAE::TypeStyledText,
301
- KAE::TypeStyledUnicodeText
301
+ KAE::TypeStyledText
302
302
  desc.coerce(KAE::TypeUTF8Text).data
303
+
304
+ when KAE::TypeFalse then false
305
+ when KAE::TypeTrue then true
303
306
 
304
307
  when KAE::TypeLongDateTime then
305
308
  Time.at(AE.convert_long_date_time_to_unix_seconds(desc.data.unpack('q')[0]))
306
-
307
- when KAE::TypeVersion
308
- vers, lo = desc.data.unpack('CC')
309
- subvers, patch = lo.divmod(16)
310
- "#{vers}.#{subvers}.#{patch}"
311
309
 
312
310
  when KAE::TypeAEList then unpack_aelist(desc)
313
311
  when KAE::TypeAERecord then unpack_aerecord(desc)
@@ -319,26 +317,41 @@ class Codecs
319
317
  KAE::TypeFSS
320
318
  MacTypes::FileURL.desc(desc)
321
319
 
322
- when KAE::TypeQDPoint then desc.data.unpack('ss').reverse
323
- when KAE::TypeQDRectangle then
324
- x1, y1, x2, y2 = desc.data.unpack('ssss')
325
- [y1, x1, y2, x2]
326
- when KAE::TypeRGBColor then desc.data.unpack('SSS')
327
-
328
320
  when KAE::TypeType then unpack_type(desc)
329
321
  when KAE::TypeEnumerated then unpack_enumerated(desc)
330
322
  when KAE::TypeProperty then unpack_property(desc)
331
323
  when KAE::TypeKeyword then unpack_keyword(desc)
332
324
 
325
+ when KAE::TypeSInt16 then desc.data.unpack('s')[0]
326
+ when KAE::TypeUInt32 then desc.data.unpack('L')[0]
327
+ when KAE::TypeSInt64 then desc.data.unpack('q')[0]
328
+
329
+ when KAE::TypeNull then nil
330
+
331
+ when KAE::TypeUTF8Text then desc.data
332
+
333
333
  when KAE::TypeInsertionLoc then unpack_insertion_loc(desc)
334
- when KAE::TypeObjectSpecifier then unpack_object_specifier(desc)
335
- when KAE::TypeAbsoluteOrdinal then unpack_absolute_ordinal(desc)
336
334
  when KAE::TypeCurrentContainer then unpack_current_container(desc)
337
335
  when KAE::TypeObjectBeingExamined then unpack_object_being_examined(desc)
338
336
  when KAE::TypeCompDescriptor then unpack_comp_descriptor(desc)
339
337
  when KAE::TypeLogicalDescriptor then unpack_logical_descriptor(desc)
340
- when KAE::TypeRangeDescriptor then unpack_range_descriptor(desc)
341
338
 
339
+ when KAE::TypeIEEE32BitFloatingPoint then desc.data.unpack('f')[0]
340
+ when KAE::Type128BitFloatingPoint then
341
+ desc.coerce(KAE::TypeIEEE64BitFloatingPoint).data.unpack('d')[0]
342
+
343
+ when KAE::TypeQDPoint then desc.data.unpack('ss').reverse
344
+ when KAE::TypeQDRectangle then
345
+ x1, y1, x2, y2 = desc.data.unpack('ssss')
346
+ [y1, x1, y2, x2]
347
+ when KAE::TypeRGBColor then desc.data.unpack('SSS')
348
+
349
+ when KAE::TypeVersion
350
+ vers, lo = desc.data.unpack('CC')
351
+ subvers, patch = lo.divmod(16)
352
+ "#{vers}.#{subvers}.#{patch}"
353
+
354
+ when KAE::TypeBoolean then desc.data != "\000"
342
355
  else
343
356
  did_unpack, val = @unit_type_codecs.unpack(desc)
344
357
  if did_unpack
@@ -354,7 +367,7 @@ class Codecs
354
367
  def unpack_aelist(desc)
355
368
  lst = []
356
369
  desc.length().times do |i|
357
- lst.push(unpack(desc.get(i + 1, KAE::TypeWildCard)[1]))
370
+ lst.push(unpack(desc.get_item(i + 1, KAE::TypeWildCard)[1]))
358
371
  end
359
372
  return lst
360
373
  end
@@ -362,8 +375,8 @@ class Codecs
362
375
  def unpack_aerecord(desc)
363
376
  dct = {}
364
377
  desc.length().times do |i|
365
- key, value = desc.get(i + 1, KAE::TypeWildCard)
366
- if key == 'usrf'
378
+ key, value = desc.get_item(i + 1, KAE::TypeWildCard)
379
+ if key == KAE::KeyASUserRecordFields
367
380
  lst = unpack_aelist(value)
368
381
  (lst.length / 2).times do |i|
369
382
  dct[lst[i * 2]] = lst[i * 2 + 1]
@@ -394,51 +407,22 @@ class Codecs
394
407
  end
395
408
 
396
409
  #######
397
-
398
- class Range
399
- attr_reader :range
400
-
401
- def initialize(range)
402
- @range = range
403
- end
404
- end
405
-
406
- class Ordinal
407
- attr_reader :code
408
-
409
- def initialize(code)
410
- @code = code
411
- end
412
- end
413
-
414
- def _desc_to_hash(desc)
415
- desc = desc.coerce(KAE::TypeAERecord)
416
- h = {}
417
- desc.length.times do |i|
418
- k, v = desc.get(i + 1, KAE::TypeWildCard)
419
- h[k] = v
420
- end
421
- return h
422
- end
423
-
424
- #######
425
-
426
- FullUnpackOrdinals = {
427
- KAE::KAEFirst => 'first',
428
- KAE::KAELast => 'last',
429
- KAE::KAEMiddle => 'middle',
430
- KAE::KAEAny => 'any',
410
+ # Lookup tables for converting enumerator, ordinal codes to aem reference method names.
411
+ # Used by unpack_object_specifier, fully_unpack_object_specifier to construct aem references.
412
+
413
+ AbsoluteOrdinals = {
414
+ Codecs.four_char_code(KAE::KAEFirst) => 'first',
415
+ Codecs.four_char_code(KAE::KAELast) => 'last',
416
+ Codecs.four_char_code(KAE::KAEMiddle) => 'middle',
417
+ Codecs.four_char_code(KAE::KAEAny) => 'any',
431
418
  }
432
419
 
433
- DeferredUnpackOrdinals = {
434
- KAE::KAEFirst => ['first', AEMReference::MultipleElements::First],
435
- KAE::KAELast => ['last', AEMReference::MultipleElements::Last],
436
- KAE::KAEMiddle => ['middle', AEMReference::MultipleElements::Middle],
437
- KAE::KAEAny => ['any', AEMReference::MultipleElements::Any],
438
- }
420
+ AllAbsoluteOrdinal = Codecs.four_char_code(KAE::KAEAll)
439
421
 
440
- # InsertionLoc keys and comparison and logic comparison operators aren't unpacked before use,
441
- # so need to call four_char_codes to swap bytes here.
422
+ RelativePositionEnums = {
423
+ Codecs.four_char_code(KAE::KAEPrevious) => 'previous',
424
+ Codecs.four_char_code(KAE::KAENext) => 'next',
425
+ }
442
426
 
443
427
  InsertionLocEnums = {
444
428
  Codecs.four_char_code(KAE::KAEBefore) => 'before',
@@ -466,105 +450,98 @@ class Codecs
466
450
 
467
451
  #######
468
452
 
469
- def fully_unpack_object_specifier(desc)
470
- # Codecs.unpack_object_specifier and DeferredSpecifier._real_ref will call this when needed
453
+ def fully_unpack_object_specifier(desc)
454
+ # Recursively unpack an object specifier and all of its container descs.
455
+ # (Note: Codecs#unpack_object_specifier and AEMReference::DeferredSpecifier#_real_ref will call this when needed.)
471
456
  case desc.type
457
+ when KAE::TypeObjectSpecifier
458
+ want = Codecs.four_char_code(desc.get_param(KAE::KeyAEDesiredClass, KAE::TypeType).data)
459
+ key_form = Codecs.four_char_code(desc.get_param(KAE::KeyAEKeyForm, KAE::TypeEnumeration).data)
460
+ key = desc.get_param(KAE::KeyAEKeyData, KAE::TypeWildCard)
461
+ ref = fully_unpack_object_specifier(desc.get_param(KAE::KeyAEContainer, KAE::TypeWildCard))
462
+ case key_form
463
+ when KAE::FormPropertyID
464
+ return ref.property(Codecs.four_char_code(key.data))
465
+ when KAE::FormUserPropertyID
466
+ return ref.userproperty(unpack(key))
467
+ when KAE::FormRelativePosition
468
+ return ref.send(RelativePositionEnums[key.data], want)
469
+ else
470
+ ref = ref.elements(want)
471
+ case key_form
472
+ when KAE::FormAbsolutePosition
473
+ if key.type == KAE::TypeAbsoluteOrdinal
474
+ if key.data == AllAbsoluteOrdinal
475
+ return ref
476
+ else
477
+ return ref.send(AbsoluteOrdinals[key.data])
478
+ end
479
+ else
480
+ return ref.by_index(unpack(key))
481
+ end
482
+ when KAE::FormName
483
+ return ref.by_name(unpack(key))
484
+ when KAE::FormUniqueID
485
+ return ref.by_id(unpack(key))
486
+ when KAE::FormRange
487
+ return ref.by_range(
488
+ unpack(key.get_param(KAE::KeyAERangeStart, KAE::TypeWildCard)),
489
+ unpack(key.get_param(KAE::KeyAERangeStop, KAE::TypeWildCard)))
490
+ when KAE::FormTest
491
+ return ref.by_filter(unpack(key))
492
+ end
493
+ end
494
+ raise TypeError
472
495
  when KAE::TypeNull then return self.class::App
473
496
  when KAE::TypeCurrentContainer then return self.class::Con
474
497
  when KAE::TypeObjectBeingExamined then return self.class::Its
475
- end
476
- rec = _desc_to_hash(desc)
477
- want = unpack(rec[KAE::KeyAEDesiredClass]).code
478
- key_form = unpack(rec[KAE::KeyAEKeyForm]).code
479
- key = unpack(rec[KAE::KeyAEKeyData])
480
- ref = unpack(rec[KAE::KeyAEContainer])
481
- if ref == nil
482
- ref = self.class::App
483
- end
484
- if key_form == KAE::FormPropertyID
485
- return ref.property(key.code)
486
- elsif key_form == 'usrp'
487
- return ref.userproperty(key)
488
- elsif key_form == KAE::FormRelativePosition
489
- if key.code == KAE::KAEPrevious
490
- return ref.previous(want)
491
- elsif key.code == KAE::KAENext
492
- return ref.next(want)
493
- else
494
- raise RuntimeError, "Bad relative position selector: #{key}"
495
- end
496
498
  else
497
- ref = ref.elements(want)
498
- if key_form == KAE::FormName
499
- return ref.by_name(key)
500
- elsif key_form == KAE::FormAbsolutePosition
501
- if key.is_a?(Ordinal)
502
- if key.code == KAE::KAEAll
503
- return ref
504
- else
505
- return ref.send(FullUnpackOrdinals[key.code])
506
- end
507
- else
508
- return ref.by_index(key)
509
- end
510
- elsif key_form == KAE::FormUniqueID
511
- return ref.by_id(key)
512
- elsif key_form == KAE::FormRange
513
- return ref.by_range(*key.range)
514
- elsif key_form == KAE::FormTest
515
- return ref.by_filter(key)
516
- end
499
+ return unpack(desc)
517
500
  end
518
- raise TypeError
519
501
  end
520
502
 
521
503
  ##
522
504
 
523
- def unpack_object_specifier(desc)
524
- # defers full unpacking of [most] object specifiers for efficiency
525
- rec = _desc_to_hash(desc)
526
- key_form = unpack(rec[KAE::KeyAEKeyForm]).code
505
+ def unpack_object_specifier(desc)
506
+ # Shallow-unpack an object specifier, retaining the container AEDesc as-is.
507
+ # (i.e. Defers full unpacking of [most] object specifiers for efficiency.)
508
+ key_form = Codecs.four_char_code(desc.get_param(KAE::KeyAEKeyForm, KAE::TypeEnumeration).data)
527
509
  if [KAE::FormPropertyID, KAE::FormAbsolutePosition, KAE::FormName, KAE::FormUniqueID].include?(key_form)
528
- want = unpack(rec[KAE::KeyAEDesiredClass]).code
529
- key = unpack(rec[KAE::KeyAEKeyData])
530
- container = AEMReference::DeferredSpecifier.new(rec[KAE::KeyAEContainer], self)
531
- if key_form == KAE::FormPropertyID
532
- ref = AEMReference::Property.new(want, container, key.code)
533
- elsif key_form == KAE::FormAbsolutePosition
534
- if key.is_a?(Ordinal)
535
- if key.code == KAE::KAEAll
536
- ref = AEMReference::AllElements.new(want, container)
510
+ want = Codecs.four_char_code(desc.get_param(KAE::KeyAEDesiredClass, KAE::TypeType).data)
511
+ key = desc.get_param(KAE::KeyAEKeyData, KAE::TypeWildCard)
512
+ container = AEMReference::DeferredSpecifier.new(desc.get_param(KAE::KeyAEContainer, KAE::TypeWildCard), self)
513
+ case key_form
514
+ when KAE::FormPropertyID
515
+ ref = AEMReference::Property.new(want, container, Codecs.four_char_code(key.data))
516
+ when KAE::FormAbsolutePosition
517
+ if key.type == KAE::TypeAbsoluteOrdinal
518
+ if key.data == AllAbsoluteOrdinal
519
+ ref = AEMReference::AllElements.new(want, container)
520
+ else
521
+ ref = fully_unpack_object_specifier(desc) # do a full unpack of rarely returned reference forms
522
+ end
537
523
  else
538
- keyname, key = DeferredUnpackOrdinals[key.code]
539
- ref = AEMReference::ElementByOrdinal.new(want, AEMReference::UnkeyedElements.new(want, container), key, keyname)
524
+ ref = AEMReference::ElementByIndex.new(want, AEMReference::UnkeyedElements.new(want, container), unpack(key))
540
525
  end
541
- else
542
- ref = AEMReference::ElementByIndex.new(want, AEMReference::UnkeyedElements.new(want, container), key)
543
- end
544
- elsif key_form == KAE::FormName
545
- ref = AEMReference::ElementByName.new(want, AEMReference::UnkeyedElements.new(want, container), key)
546
- elsif key_form == KAE::FormUniqueID
547
- ref = AEMReference::ElementByID.new(want, AEMReference::UnkeyedElements.new(want, container), key)
526
+ when KAE::FormName
527
+ ref = AEMReference::ElementByName.new(want, AEMReference::UnkeyedElements.new(want, container), unpack(key))
528
+ when KAE::FormUniqueID
529
+ ref = AEMReference::ElementByID.new(want, AEMReference::UnkeyedElements.new(want, container), unpack(key))
548
530
  end
549
- ref.AEM_set_desc(desc) # retain existing AEDesc for efficiency
550
- return ref
551
- else # do full unpack of more complex, rarely returned reference forms
552
- return fully_unpack_object_specifier(desc)
531
+ else
532
+ ref = fully_unpack_object_specifier(desc) # do a full unpack of more complex, rarely returned reference forms
553
533
  end
534
+ ref.AEM_set_desc(desc) # retain existing AEDesc for efficiency
535
+ return ref
554
536
  end
555
537
 
556
538
 
557
539
  def unpack_insertion_loc(desc)
558
- rec = _desc_to_hash(desc)
559
- return unpack_object_specifier(rec[KAE::KeyAEObject]).send(InsertionLocEnums[rec[KAE::KeyAEPosition].data])
540
+ return unpack_object_specifier(desc.get_param(KAE::KeyAEObject, KAE::TypeWildCard)).send(InsertionLocEnums[desc.get_param(KAE::KeyAEPosition, KAE::TypeEnumeration).data])
560
541
  end
561
542
 
562
543
  ##
563
544
 
564
- def unpack_absolute_ordinal(desc)
565
- return Ordinal.new(Codecs.four_char_code(desc.data))
566
- end
567
-
568
545
  def unpack_current_container(desc)
569
546
  return Con
570
547
  end
@@ -588,10 +565,9 @@ class Codecs
588
565
  end
589
566
 
590
567
  def unpack_comp_descriptor(desc)
591
- rec = _desc_to_hash(desc)
592
- operator = ComparisonEnums[rec[KAE::KeyAECompOperator].data]
593
- op1 = unpack(rec[KAE::KeyAEObject1])
594
- op2 = unpack(rec[KAE::KeyAEObject2])
568
+ operator = ComparisonEnums[desc.get_param(KAE::KeyAECompOperator, KAE::TypeEnumeration).data]
569
+ op1 = unpack(desc.get_param(KAE::KeyAEObject1, KAE::TypeWildCard))
570
+ op2 = unpack(desc.get_param(KAE::KeyAEObject2, KAE::TypeWildCard))
595
571
  if operator == 'contains'
596
572
  return unpack_contains_comp_descriptor(op1, op2)
597
573
  else
@@ -600,17 +576,11 @@ class Codecs
600
576
  end
601
577
 
602
578
  def unpack_logical_descriptor(desc)
603
- rec = _desc_to_hash(desc)
604
- operator = LogicalEnums[rec[KAE::KeyAELogicalOperator].data]
605
- operands = unpack(rec[KAE::KeyAELogicalTerms])
579
+ operator = LogicalEnums[desc.get_param(KAE::KeyAELogicalOperator, KAE::TypeEnumeration).data]
580
+ operands = unpack(desc.get_param(KAE::KeyAELogicalTerms, KAE::TypeAEList))
606
581
  return operands[0].send(operator, *operands[1, operands.length])
607
582
  end
608
583
 
609
- def unpack_range_descriptor(desc)
610
- rec = _desc_to_hash(desc)
611
- return Range.new([unpack(rec[KAE::KeyAERangeStart]), unpack(rec[KAE::KeyAERangeStop])])
612
- end
613
-
614
584
  end
615
585
 
616
586
  DefaultCodecs = Codecs.new