@@ -25,14 +25,16 @@ def redirect(filename, func, *args):
2525 if f : f .close ()
2626
2727def realmain ():
28+ #list('C:System Folder:Extensions:AppleScript\252')
2829 #list('C:Tao AppleScript:Finder Liaison:Finder Liaison 1.0')
30+ #list('C:Tao AppleScript:Scriptable Text Editor')
2931 #list('C:Internet:Eudora 1.4.2:Eudora1.4.2')
30- list ('E:Excel 4.0:Microsoft Excel' )
32+ # list('E:Excel 4.0:Microsoft Excel')
3133 #list('C:Internet:Netscape 1.0N:Netscape 1.0N')
3234 #find('C:')
33- # find('D:')
34- # find('E:')
35- # find('F:')
35+ find ('D:' )
36+ find ('E:' )
37+ find ('F:' )
3638
3739def find (dir , maxlevel = 5 ):
3840 hits = []
@@ -52,7 +54,7 @@ def find(dir, maxlevel = 5):
5254 hits = hits + find (fullname , maxlevel - 1 )
5355 else :
5456 ctor , type = MacOS .GetCreatorAndType (fullname )
55- if type == 'APPL' :
57+ if type in ( 'APPL' , 'FNDR' , 'zsys' , 'INIT' , 'scri' , 'cdev' ) :
5658 sys .stderr .write (" %s\n " % `fullname` )
5759 try :
5860 rf = OpenRFPerm (fullname , 0 , '\1 ' )
@@ -82,13 +84,14 @@ def list(fullname):
8284 for i in range (Count1Resources ('aeut' )):
8385 res = Get1IndResource ('aeut' , 1 + i )
8486 resources .append (res )
85- print "\n LISTING aete+aeut RESOURCE IN" , `fullname`
87+ print "\n LISTING aete+aeut RESOURCES IN" , `fullname`
8688 for res in resources :
87- print res .GetResInfo ()
89+ print "decoding" , res .GetResInfo (), "..."
8890 data = res .data
8991 try :
9092 aete = decode (data )
9193 showaete (aete )
94+ print "Checking putaete..."
9295 f = StringIO .StringIO ()
9396 putaete (f , aete )
9497 newdata = f .getvalue ()
@@ -139,6 +142,12 @@ def simplify(item):
139142# It is presented bottom-up instead of top-down because there are direct
140143# references to the lower-level part-decoders from the high-level part-decoders.
141144
145+ def getbyte (f , * args ):
146+ c = f .read (1 )
147+ if not c :
148+ raise EOFError , 'in getbyte' + str (args )
149+ return ord (c )
150+
142151def getword (f , * args ):
143152 getalign (f )
144153 s = f .read (2 )
@@ -181,8 +190,8 @@ def getlist(f, description, getitem):
181190 count = getword (f )
182191 list = []
183192 for i in range (count ):
184- getalign (f )
185193 list .append (generic (getitem , f ))
194+ getalign (f )
186195 return list
187196
188197def alt_generic (what , f , * args ):
@@ -202,49 +211,100 @@ def generic(what, f, *args):
202211 return record
203212 return "BAD GENERIC ARGS: %s" % `what`
204213
205- getdata = [(getostype , "type" ), (getpstr , "description" ), (getword , "flags" )]
206- getoptarg = [(getpstr , "name" ), (getostype , "keyword" ), (getdata , "what" )]
207- getcommand = [(getpstr , "name" ), (getpstr , "description" ),
208- (getostype , "suite code" ), (getostype , "command code" ),
214+ getdata = [
215+ (getostype , "type" ),
216+ (getpstr , "description" ),
217+ (getword , "flags" )
218+ ]
219+ getargument = [
220+ (getpstr , "name" ),
221+ (getostype , "keyword" ),
222+ (getdata , "what" )
223+ ]
224+ getevent = [
225+ (getpstr , "name" ),
226+ (getpstr , "description" ),
227+ (getostype , "suite code" ),
228+ (getostype , "event code" ),
209229 (getdata , "returns" ),
210230 (getdata , "accepts" ),
211- (getlist , "optional arguments" , getoptarg )]
212- getprop = [(getpstr , "name" ), (getostype , "code" ), (getdata , "what" )]
213- getelem = [(getostype , "type" ), (getlist , "accessibility" , getostype )]
214- getclass = [(getpstr , "name" ), (getostype , "class code" ), (getpstr , "description" ),
215- (getlist , "properties" , getprop ), (getlist , "elements" , getelem )]
216- getenumitem = [(getpstr , "name" ), (getostype , "value" ), (getpstr , "description" )]
217- getenum = [(getostype , "enumtype" ), (getlist , "enumitem" , getenumitem )]
218- getsuite = [(getpstr , "name" ), (getpstr , "description" ), (getostype , "code" ),
219- (getword , "flags1" ), (getword , "flags2" ),
220- (getlist , "commands" , getcommand ),
231+ (getlist , "optional arguments" , getargument )
232+ ]
233+ getproperty = [
234+ (getpstr , "name" ),
235+ (getostype , "code" ),
236+ (getdata , "what" )
237+ ]
238+ getelement = [
239+ (getostype , "type" ),
240+ (getlist , "keyform" , getostype )
241+ ]
242+ getclass = [
243+ (getpstr , "name" ),
244+ (getostype , "class code" ),
245+ (getpstr , "description" ),
246+ (getlist , "properties" , getproperty ),
247+ (getlist , "elements" , getelement )
248+ ]
249+ getcomparison = [
250+ (getpstr , "operator name" ),
251+ (getostype , "operator ID" ),
252+ (getpstr , "operator comment" ),
253+ ]
254+ getenumerator = [
255+ (getpstr , "enumerator name" ),
256+ (getostype , "enumerator ID" ),
257+ (getpstr , "enumerator comment" )
258+ ]
259+ getenumeration = [
260+ (getostype , "enumeration ID" ),
261+ (getlist , "enumerator" , getenumerator )
262+ ]
263+ getsuite = [
264+ (getpstr , "suite name" ),
265+ (getpstr , "suite description" ),
266+ (getostype , "suite ID" ),
267+ (getword , "suite level" ),
268+ (getword , "suite version" ),
269+ (getlist , "events" , getevent ),
221270 (getlist , "classes" , getclass ),
222- (getword , "count???" ), (getlist , "enums" , getenum )]
223- getaete = [(getword , "skip1" ), (getword , "skip2" ), (getword , "skip3" ),
224- (getlist , "suites" , getsuite )]
271+ (getlist , "comparisons" , getcomparison ),
272+ (getlist , "enumerations" , getenumeration )
273+ ]
274+ getaete = [
275+ (getword , "major/minor version in BCD" ),
276+ (getword , "language code" ),
277+ (getword , "script code" ),
278+ (getlist , "suites" , getsuite )
279+ ]
225280
226281
227282# Display 'aete' resources in a friendly manner.
228283# This one's done top-down again...
229284
230285def showaete (aete ):
231- [flags1 , flags2 , flags3 , suites ] = aete
232- print "\n Global flags: x%x, x%x, x%x\n " % (flags1 , flags2 , flags3 )
286+ [version , language , script , suites ] = aete
287+ major , minor = divmod (version , 256 )
288+ print "\n Version %d/%d, language %d, script %d" % \
289+ (major , minor , language , script )
233290 for suite in suites :
234291 showsuite (suite )
235292
236293def showsuite (suite ):
237- [name , desc , code , flags1 , flags2 , commands , classes , skip1 , enums ] = suite
294+ [name , desc , code , level , version , events , classes , comps , enums ] = suite
238295 print "\n Suite %s -- %s (%s)" % (`name` , `desc` , `code` )
239- for command in commands :
240- showcommand (command )
241- for classe in classes :
242- showclass (classe )
296+ print "Level %d, version %d" % (level , version )
297+ for event in events :
298+ showevent (event )
299+ for cls in classes :
300+ showclass (cls )
301+ for comp in comps :
302+ showcomparison (comp )
243303 for enum in enums :
244- showenum (enum )
304+ showenumeration (enum )
245305
246- def showcommand ( command ):
247- [name , desc , code , subcode , returns , accepts , arguments ] = command
306+ def showevent ( event ):
307+ [name , desc , code , subcode , returns , accepts , arguments ] = event
248308 print "\n Command %s -- %s (%s, %s)" % (`name` , `desc` , `code` , `subcode` )
249309 print " returns" , showdata (returns )
250310 print " accepts" , showdata (accepts )
@@ -255,8 +315,8 @@ def showargument(arg):
255315 [name , keyword , what ] = arg
256316 print " %s (%s)" % (name , `keyword` ), showdata (what )
257317
258- def showclass (classe ):
259- [name , code , desc , properties , elements ] = classe
318+ def showclass (cls ):
319+ [name , code , desc , properties , elements ] = cls
260320 print "\n Class %s (%s) -- %s" % (`name` , `code` , `desc` )
261321 for prop in properties :
262322 showproperty (prop )
@@ -265,27 +325,31 @@ def showclass(classe):
265325
266326def showproperty (prop ):
267327 [name , code , what ] = prop
268- print " property %s (%s)" % (name , code ), showdata (what )
328+ print " property %s (%s)" % (` name` , ` code` ), showdata (what )
269329
270330def showelement (elem ):
271- [code , accessibility ] = elem
272- print " element %s" % `code` , "as" , accessibility
331+ [code , keyform ] = elem
332+ print " element %s" % `code` , "as" , keyform
333+
334+ def showcomparison (comp ):
335+ [name , code , comment ] = comp
336+ print " comparison %s (%s) -- %s" % (`name` , `code` , comment )
273337
274- def showenum (enum ):
338+ def showenumeration (enum ):
275339 [code , items ] = enum
276340 print "\n Enum %s" % `code`
277341 for item in items :
278- showitem (item )
342+ showenumerator (item )
279343
280- def showitem (item ):
344+ def showenumerator (item ):
281345 [name , code , desc ] = item
282346 print " %s (%s) -- %s" % (`name` , `code` , `desc` )
283347
284348def showdata (data ):
285349 [type , description , flags ] = data
286350 return "%s -- %s %s" % (`type` , `description` , showdataflags (flags ))
287351
288- dataflagdict = {15 : "optional" , 14 : "list" , 13 : "enum" , 12 : "writable " }
352+ dataflagdict = {15 : "optional" , 14 : "list" , 13 : "enum" , 12 : "mutable " }
289353def showdataflags (flags ):
290354 bits = []
291355 for i in range (16 ):
@@ -301,30 +365,30 @@ def showdataflags(flags):
301365# Closedly modelled after showaete()...
302366
303367def putaete (f , aete ):
304- [flags1 , flags2 , flags3 , suites ] = aete
305- putword (f , flags1 )
306- putword (f , flags2 )
307- putword (f , flags3 )
368+ [version , language , script , suites ] = aete
369+ putword (f , version )
370+ putword (f , language )
371+ putword (f , script )
308372 putlist (f , suites , putsuite )
309373
310374def putsuite (f , suite ):
311- [name , desc , code , flags1 , flags2 , commands , classes , skip1 , enums ] = suite
375+ [name , desc , code , level , version , events , classes , comps , enums ] = suite
312376 putpstr (f , name )
313377 putpstr (f , desc )
314378 putostype (f , code )
315- putword (f , flags1 )
316- putword (f , flags2 )
317- putlist (f , commands , putcommand )
379+ putword (f , level )
380+ putword (f , version )
381+ putlist (f , events , putevent )
318382 putlist (f , classes , putclass )
319- putword (f , skip1 )
320- putlist (f , enums , putenum )
383+ putlist (f , comps , putcomparison )
384+ putlist (f , enums , putenumeration )
321385
322- def putcommand (f , command ):
323- [name , desc , code , subcode , returns , accepts , arguments ] = command
386+ def putevent (f , event ):
387+ [name , desc , eventclass , eventid , returns , accepts , arguments ] = event
324388 putpstr (f , name )
325389 putpstr (f , desc )
326- putostype (f , code )
327- putostype (f , subcode )
390+ putostype (f , eventclass )
391+ putostype (f , eventid )
328392 putdata (f , returns )
329393 putdata (f , accepts )
330394 putlist (f , arguments , putargument )
@@ -335,8 +399,8 @@ def putargument(f, arg):
335399 putostype (f , keyword )
336400 putdata (f , what )
337401
338- def putclass (f , classe ):
339- [name , code , desc , properties , elements ] = classe
402+ def putclass (f , cls ):
403+ [name , code , desc , properties , elements ] = cls
340404 putpstr (f , name )
341405 putostype (f , code )
342406 putpstr (f , desc )
@@ -350,12 +414,18 @@ def putelement(f, elem):
350414 putostype (f , code )
351415 putlist (f , parts , putostype )
352416
353- def putenum (f , enum ):
417+ def putcomparison (f , comp ):
418+ [name , id , comment ] = comp
419+ putpstr (f , name )
420+ putostype (f , id )
421+ putpstr (f , comment )
422+
423+ def putenumeration (f , enum ):
354424 [code , items ] = enum
355425 putostype (f , code )
356- putlist (f , items , putitem )
426+ putlist (f , items , putenumerator )
357427
358- def putitem (f , item ):
428+ def putenumerator (f , item ):
359429 [name , code , desc ] = item
360430 putpstr (f , name )
361431 putostype (f , code )
@@ -370,13 +440,16 @@ def putdata(f, data):
370440def putlist (f , list , putitem ):
371441 putword (f , len (list ))
372442 for item in list :
373- putalign (f )
374443 putitem (f , item )
444+ putalign (f )
375445
376446def putalign (f ):
377447 if f .tell () & 1 :
378448 f .write ('\0 ' )
379449
450+ def putbyte (f , value ):
451+ f .write (chr (value ))
452+
380453def putword (f , value ):
381454 putalign (f )
382455 f .write (chr ((value >> 8 )& 0xff ))
0 commit comments