|
From: creedon <icr...@us...> - 2005-09-16 02:48:05
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/suites/DuckTape In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21890 Modified Files: Tag: commercial_suite_project-branch parseAete Log Message: factored table initialization code to DuckTape.initializeNewTerminologyTable Index: parseAete =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/suites/DuckTape/Attic/parseAete,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** parseAete 18 Aug 2005 16:28:58 -0000 1.1.2.1 --- parseAete 16 Sep 2005 02:47:56 -0000 1.1.2.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:suites.DuckTape.parseAete ! on parseAete (appPath, adrTable) { Çparse the app's aete resource and build a verb table ÇChanges Ç8/17/05; 9:38:09 PM by TAC Çin parseParams handler, added id as local so ids defined lower in calling chain don't get hammered Çadded call to init Çadded support for user.DuckTape.appIdStyle Çadded support for user.DuckTape.flUseEventInformationTable Ç8/14/05; 10:12:30 PM by TAC Çreworked assignUnique a bit, was still putting items in top level table even though eventInformationEntry was true Ç8/8/05; 1:37:13 PM by TAC Çdisabled FileMaker eventInfo event workaround, eventInfo table has been renamed eventInformation, we now scriptError so that a user can let us know that another collision occured Çminor tweaks to formatting of script and function Çtried to gather up some of the changes into the Changes bundle, i'm sure I missed a few so move 'em or make copies in the Changes bundle if you want Ç12/10/02; 3:36:02 PM by SE Ç Workaround for FMP having an eventInfo event! Ç1999 Ç10/14/99 by SE Çseveral changes related to fat headlines and line lengths Ç99/08/20 by DAB Çchanges related to various get functions such as getShort and getString Çcreated assignUnique Ç12/11/95 dmb Çdon't map entire Misc Standards suite of specific event are present Çthanks to Mike Alexander <mt...@um...> Ç1994 Ç11/2/94 dmb Çremove openApplication, extra quitApplication verbs Ç5/27/94 dml/dmb Çhandle long lines in events Ç1993 Ç9/15/93 dmb Çfixed bug in 'c@#^' handling and post processing Ç9/02/93 dmb Çhandle 'c@#^' psuedo property Ç8/10/93 dmb Çdon't create items with names that match objectModel scripts Ç7/30/93 dmb Çadd " = nil" to optional parameter definitions Ç7/09/93 dmb Çcoerce parameter types. avoid language reserved word collisions Ç2/11/93 dmb Çupdated for latest aete changes. handle special class properties. Ç9/24/92 dmb Çfirst cut parsing the application aete resource directly DuckTape.init (); local (aeteAdr, ix = 1); on placeLine (s) { // place a script line that my be too long for one line // Thu, Oct 14, 1999 at 5:18:25 PM by SE, simplified for fat headlines local (maxLen = 200); // don't use all 255 characters; that's too long for reading local (pos = op.getCursor ()); local (dir = right); local (comment = ""); Çif string.length (s) > maxLen // won't fit on one line, Thu, Oct 14, 1999 at 5:16:01 PM by SE, no longer needed--we have fat headlines now Çif s contains 'Ç' Çcomment = string.nthField (s, 'Ç', 2) Çs = string.nthField (s, 'Ç', 1) Çwhile string.length (s) > maxLen // still won't fit on one line Çlocal (i) Çfor i = maxLen - 1 downto 1 Çif s [i] == " " Çop.setLineText (string.mid (s, 1, i) + "\\") Çs = string.delete (s, 1, i) Çop.insert ("", dir) Çdir = down // for next time Çbreak op.setLineText (s); Çif comment != "" // Thu, Oct 14, 1999 at 5:16:49 PM by SE, no longer needed--we have fat headlines now Çop.insert (comment, dir) Çscript.makeComment () op.setCursor (pos)}; on getShort () { local (n); rollBeachBall (); n = number (binary (string.mid (aeteAdr^, ix, 2))); // 99/08/20, 16:46:59 by DAB ix = ix + 2; return (n)}; on getString () { local (n, s); rollBeachBall (); n = number (string.nthChar (aeteAdr^, ix)); // 99/08/20, 16:47:17 by DAB s = string.mid (aeteAdr^, ix + 1, n); // 99/08/20, 17:02:19 by DAB ix = ix + n + 1; return (s)}; on getString4 () { local (x); rollBeachBall (); x = string4 (string.mid (aeteAdr^, ix, 4)); // 99/08/20, 16:47:29 by DAB ix = ix + 4; return (x)}; on getName () { local (ixSpace, x); x = string.lower (getString ()); while string.countWords (x) > 1 { // make it an innerCase identifier ixSpace = string.patternMatch (' ', x); ch = string.upper (string.nthChar (x, ixSpace + 1)); x= string.firstWord (x) + ch + string.mid (x, ixSpace + 2, infinity)}; msg ("DuckTape: " + x); return (x)}; on skipString () { getString ()}; on skipBytes (n) { ix = ix + n}; on align () { if ix % 2 == 0 { // remember, we're in a 1-based world, so this is an odd byte ++ix}}; on assignUnique (name, adrValue, eventInformationEntry = false) { // 8/14/05; 8:02:31 PM by TAC - reworked a bit, was still putting items in top level table even though eventInformationEntry was true Çon assignUnique (name, adrValue, eventInformationEntry = false) // old code Çon sameValue (adr1, adr2) Çif typeOf (adr1^) != typeOf (adr2^) Çreturn (false) Çreturn (adr1^ == adr2^) Çlocal (adr, ct = 1) Çadr = @objectModel.[name] Çif defined (adr^) Çif sameValue (adr, adrValue) Çreturn (false) Çif typeOf (adr^) == scriptType Çreturn (false) Çif not eventInformationEntry and typeOf (adrValue^) == string4Type ÇscriptError ("Got one") Çif eventInformationEntry Çadr = @adrTable^.eventInformation.[name] Çelse Çadr = @adrTable^.[name] Çwhile defined (adr^) Çif sameValue (adr, adrValue) Çreturn (false) Çadr = @adrTable^.[name + ct++] Çtable.assign (adr, adrValue^) Çreturn (true) on sameValue (adr1, adr2) { if typeOf (adr1^) != typeOf (adr2^) { return (false)}; return (adr1^ == adr2^)}; local (adr, ct = 1); adr = @objectModel.[name]; if defined (adr^) { if sameValue (adr, adrValue) { return (false)}; if typeOf (adr^) == scriptType { return (false)}}; if eventInformationEntry { adr = @adrTable^.eventInformation} else { adr = adrTable}; local (s = name); while defined (adr^.[s]) { if sameValue (@adr^.[s], adrValue) { return (false)}; s = name + ct++}; table.assign (@adr^.[s], adrValue^); return (true)}; on parseEvents () { local (ixEvent, ctEvents, eventPrefix); on makeScript (onStatement, returnStatement, adr) { new (scriptType, adr); target.set (adr); placeLine (onStatement); // handles line overflow op.insertAtEndOfList (""); // Make a place for the return statement placeLine (returnStatement); Çop.setLineText (onStatement) Çop.insert (returnStatement, right) op.go (left, 1); window.zoom (adr); close (adr); return (true)}; on makeName (type) { Çbased on the direct parameter's type, come up with a name for it case type { objspecType { return ("obj")}; stringType { return ("s")}; intType; longType { return ("n")}; booleanType { return ("flag")}; aliasType; filespecType { return ("file")}} else { return ("x")}}; on makeParam (name, type) { local (coerceR); case type { objspecType { coerceR = "objspec"}; filespecType { coerceR = "filespec"}; aliasType { coerceR = "alias"}; 'itxt'; stringType { coerceR = "string"}; intType { coerceR = "short"}; longType { coerceR = "long"}; 'savo'; enumeratorType { coerceR = "enum"}; string4Type { coerceR = "string4"}; booleanType { coerceR = "boolean"}; singleType { coerceR = "single"}; doubleType { coerceR = "double"}; pointType { coerceR = "point"}; rectType { coerceR = "rect"}; rgbType { coerceR = "rgb"}} else { return (name)}; return (coerceR + " (" + name + ')')}; on mapSuite (code, adr) { case code { 'reqd' { adr^ = @system.macintosh.required}; 'core' { adr^ = @system.macintosh.core}; 'misc' { adr^ = @system.macintosh.misc}} else { return (false)}; return (true)}; on mapEvent (adrScript, adrTable) { local (hdr, rtn); local (verb = nameOf (adrScript^), appName = nameOf (adrTable^)); local (suiteName = string.nthField (adrScript, '.', string.countFields (adrScript, '.') - 1)); local (adr = @adrTable^.[verb]); rollBeachBall (); target.set (adrScript); msg ("DuckTape: " + nameOf (adrScript^)); op.firstSummit (); hdr = op.getLineText () - "appID"; hdr = hdr - ", "; rtn = string.commentDelete (hdr - ("on " + verb + " (")); rtn = string.popTrailing (rtn, ' '); rtn = string.replaceAll (rtn, " = nil", ""); rtn = string.replaceAll (rtn, " = 'no '", ""); if string.length (rtn) > 1 { // has at least one param rtn = ", " + rtn}; rtn = suiteName + '.' + verb + " (" + DuckTape.appIdStyle (appName, user.DuckTape.appIdStyle) + rtn; rtn = "return (" + rtn + ')'; return (makeScript (hdr, rtn, adr))}; on parseParams (isFirst) { local (id, ixParam, flags); for ixParam = 1 to getShort () { paramName = getName (); if defined (system.compiler.language.keywords.[paramName]) { local (ch = string.upper (string.nthChar (paramName, 1))); paramName = eventName + ch + string.delete (paramName, 1, 1)}; align (); id = getString4 (); paramType = getString4 (); skipString (); align (); ÇskipBytes (2) // param flags flags = getShort (); // param flags if not isFirst { hdr = hdr + ", "}; hdr = hdr + paramName; if flags < 0 { // high bit set -> optional parameter hdr = hdr + " = nil"}; rtn = rtn + ", '" + id + "', " + makeParam (paramName, paramType); isFirst = false}}; ctEvents = getShort (); if mapSuite (suiteCode, @adrSuite) and (suiteCode 'misc' or ctEvents == 0) { // map all events of suite for i = 1 to sizeOf (adrSuite^) { mapEvent (@adrSuite^ [i], adrTable)}}; bundle { // event prefix eventPrefix = "return (appleEvent ("; eventPrefix = eventPrefix + DuckTape.appIdStyle (nameOf (adrTable^), user.DuckTape.appIdStyle) + ", '"}; for ixEvent = 1 to ctEvents { // add / overwrite event provided local (eventName, comment, class, paramName, paramType, id, hdr, rtn, adr); eventName = getName (); comment = getString (); align (); class = getString4 (); id = getString4 (); Çif (eventName == "eventInfo") // Tue, Dec 10, 2002 at 3:36:02 PM by SE Workaround for FMP having an eventInfo event! ÇeventName = eventName + "1" if (eventName == "eventInformation") { // name space collision scriptError ("DuckTape Suite: parseAete name collision error. Please report this error to <http://sourceforge.net/tracker/?group_id=120666&atid=687798>.")}; adr = @adrTable^.[eventName]; hdr = "on " + eventName + " ("; rtn = eventPrefix + class + "', '" + id + "'"; skipBytes (4); // reply type skipString (); // reply description align (); skipBytes (2); // flags paramType = getString4 (); // direct param type skipString (); // direct param description align (); skipBytes (2); // reply flags if paramType != 'null' { // has a direct param local (paramName = makeName (paramType)); hdr = hdr + paramName; rtn = rtn + ", '----', " + makeParam (paramName, paramType); parseParams (false)} else { parseParams (true)}; hdr = hdr + ") // " + comment; rtn = rtn + "))"; if defined (user.DuckTape.skipOnParse.[class].[id]) { continue}; makeScript (hdr, rtn, adr)}}; on parseClasses () { local (ixClass, x, description); on parseProperties () { local (ixProperty); for ixProperty = 1 to getShort () { local (s); name = getName (); align (); value = getString4 (); if value == 'c@#!' { // kAESpecialClassProperties skipSpecialClass = true}; if value == 'c@#^' { // same props & elements as class sameAsClass = getString4 (); description = "all properties of " + sameAsClass + '*'} // append asterix for postprocessing f & r else { skipBytes (4); // property class description = name}; s = getString (); // what is it? if string.length (s) > 0 { description = description + " -- " + s}; align (); skipBytes (2); if not skipSpecialClass { if value != 'c@#^' { assignUnique (name, @value, user.DuckTape.flUseEventInformationTable)}; op.insert (description, dir); dir = down}}}; on parseElements () { local (ixElement, ixKeyForm); if sameAsClass != 0 { op.insert ("all elements of " + sameAsClass + '*', dir); dir = down}; for ixElement = 1 to getShort () { ÇskipBytes (4) // element class value = getString4 (); if not skipSpecialClass { op.insert (string (value) + '*', dir); // append asterix for postprocessing f & r dir = down}; for ixKeyForm = 1 to getShort () { skipBytes (4)}}}; // ignore it target.set (@adrTable^.objectHierarchy); editMenu.setFontSize (9); dir == noDirection; for ixClass = 1 to getShort () { local (className, classID, skipSpecialClass = false, sameAsClass = 0); className = getName (); align (); classID = getString4 (); description = className + " -- " + getString (); // the class description if dir == noDirection { op.setLineText (description)} else { op.insert (description, down)}; dir = right; op.insert ("Properties:", dir); align (); parseProperties (); if dir == right { // nothing added op.deleteLine ()} else { op.go (left, 1)}; if not skipSpecialClass { assignUnique (className, @classID, user.DuckTape.flUseEventInformationTable); op.insert ("Elements:", dir); dir = right} else { op.go (left, infinity); op.deleteLine (); dir = down}; parseElements (); if dir == right { // nothing added op.deleteLine ()}; op.go (left, infinity)}; op.firstSummit (); target.clear ()}; on parseComparisonOps () { local (ixComparison); for ixComparison = 1 to getShort () { skipString (); align (); skipBytes (4); skipString (); align ()}}; on parseEnumerations () { local (ixEnumeration); on parseEnumerators () { local (ixenumerator); for ixEnumerator = 1 to getShort () { local (name, value, adr); name = getName (); align (); value = enum (getString4 ()); assignUnique (name, @value, user.DuckTape.flUseEventInformationTable); Çadr = @adrTable^.[name] Çif defined (adr^) // name already used Çif (typeOf (adr^) != binaryType) or (adr^ != value) // not a duplicate, use unique name Çtable.assign (table.uniqueName (name, adrTable), value) Çelse Çadr^ = value skipString (); align ()}}; for ixEnumeration = 1 to getShort () { skipBytes (4); parseEnumerators ()}}; on parseSuites () { local (ixSuite, suiteCode, dir); for ixSuite = 1 to getShort () { getString (); // name of the suite skipString (); // description align (); suiteCode = getString4 (); skipBytes (4); // skip up to event array parseEvents (); parseClasses (); parseComparisonOps (); parseEnumerations ()}}; bundle { // make sure the table exists if not defined (adrTable^) { new (tableType, adrTable)}}; bundle { // make sure the eventInformation subtable exists 99/08/20, 13:29:44 by DAB if not defined (adrTable^.eventInformation) { new (tableType, @adrTable^.eventInformation)}}; bundle { // set up the class hierarchy outline new (outlineType, @adrTable^.objectHierarchy)}; bundle { // parse the resource Çlocal (name) Çif !rez.getNthResource (appPath, 'aete', 1, @name, @aete) ÇscriptError ("Couldn't find the resource.") Ç99/08/18, 20:42:00 by DAB move aete read to own script ÇDynamic aete, are returned as lists of aete on parseOneAETE () { ix = 1; string.setWordChar (' '); // make sure it's normal skipBytes (6); // skip up to suite array parseSuites ()}; local (aeteList); DuckTape.getAETE (appPath, @aeteList); if typeof (aeteList) == tableType { // dynamic case local (iy); for iy =1 to sizeof (aeteList) { aeteAdr = @aeteList[iy]; parseOneAete ()}} else { aeteAdr = @aeteList; parseOneAETE ()}}; bundle { // post-process the class hierarchy outline local (savedParams); table.assign (@savedParams, user.prefs.search); // save off user.prefs.search.wholewords = true; user.prefs.search.wraparound = true; on translateClasses (adrTable) { local (i, adr); for i = 1 to sizeof (adrTable^) { adr = @adrTable ^[i]; msg ("DuckTape: " + nameOf (adr^)); if typeOf (adr^) == string4type { user.prefs.search.searchfor = string (adr^) + '*'; user.prefs.search.replacewith = nameOf (adr^); search.reset (); search.replaceall ()}}}; target.set (@adrTable^.objectHierarchy); translateClasses (adrTable); translateClasses (@objectModel); wp.setTextMode (false); op.firstSummit (); op.sort (); target.clear (); table.assign (@user.prefs.search, savedParams)}; // restore originals bundle { // remove unneeded verbs if defined (adrTable^.quit) and defined (adrTable^.quitApplication) { delete (@adrTable^.quitApplication)}; if defined (adrTable^.openApplication) { delete (@adrTable^.openApplication)}}; msg (""); window.open (adrTable); return (true)}; Çbundle // testing ÇparseAete (system.verbs.[temp.DuckTape.appsTableItemName].appInfo.path, @system.verbs.[temp.DuckTape.appsTableItemName]) \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:suites.DuckTape.parseAete ! on parseAete (appPath, adrTable) { Çparse the app's aete resource and build a verb table ÇChanges Ç9/5/05; 6:01:53 PM by TAC Çsave root of adrTable near end of script Çadded support for user.DuckTape.callbacks.afterParseAete Çremoved support for skipping class/id when parsing events Çadded support for user.DuckTape.eventInformationTableName Ç8/18/05; 10:24:05 AM by TAC Çadded support for skipping class/id when parsing events Çin parseParams handler, added id as local so ids defined higher in calling chain don't get hammered Çadded call to init Çadded support for user.DuckTape.appIdStyle Çadded support for user.DuckTape.flUseEventInformationTable Ç8/14/05; 10:12:30 PM by TAC Çreworked assignUnique a bit, was still putting items in top level table even though eventInformationEntry was true Ç8/8/05; 1:37:13 PM by TAC Çdisabled FileMaker eventInfo event workaround, eventInfo table has been renamed eventInformation, we now scriptError so that a user can let us know that another collision occured Çminor tweaks to formatting of script and function Çtried to gather up some of the changes into the Changes bundle, i'm sure I missed a few so move 'em or make copies in the Changes bundle if you want Ç12/10/02; 3:36:02 PM by SE Ç Workaround for FMP having an eventInfo event! Ç1999 Ç10/14/99 by SE Çseveral changes related to fat headlines and line lengths Ç99/08/20 by DAB Çchanges related to various get functions such as getShort and getString Çcreated assignUnique Ç12/11/95 dmb Çdon't map entire Misc Standards suite of specific event are present Çthanks to Mike Alexander <mt...@um...> Ç1994 Ç11/2/94 dmb Çremove openApplication, extra quitApplication verbs Ç5/27/94 dml/dmb Çhandle long lines in events Ç1993 Ç9/15/93 dmb Çfixed bug in 'c@#^' handling and post processing Ç9/02/93 dmb Çhandle 'c@#^' psuedo property Ç8/10/93 dmb Çdon't create items with names that match objectModel scripts Ç7/30/93 dmb Çadd " = nil" to optional parameter definitions Ç7/09/93 dmb Çcoerce parameter types. avoid language reserved word collisions Ç2/11/93 dmb Çupdated for latest aete changes. handle special class properties. Ç9/24/92 dmb Çfirst cut parsing the application aete resource directly local (aeteAdr, ix = 1); on placeLine (s) { // place a script line that my be too long for one line // Thu, Oct 14, 1999 at 5:18:25 PM by SE, simplified for fat headlines local (maxLen = 200); // don't use all 255 characters; that's too long for reading local (pos = op.getCursor ()); local (dir = right); local (comment = ""); Çif string.length (s) > maxLen // won't fit on one line, Thu, Oct 14, 1999 at 5:16:01 PM by SE, no longer needed--we have fat headlines now Çif s contains 'Ç' Çcomment = string.nthField (s, 'Ç', 2) Çs = string.nthField (s, 'Ç', 1) Çwhile string.length (s) > maxLen // still won't fit on one line Çlocal (i) Çfor i = maxLen - 1 downto 1 Çif s [i] == " " Çop.setLineText (string.mid (s, 1, i) + "\\") Çs = string.delete (s, 1, i) Çop.insert ("", dir) Çdir = down // for next time Çbreak op.setLineText (s); Çif comment != "" // Thu, Oct 14, 1999 at 5:16:49 PM by SE, no longer needed--we have fat headlines now Çop.insert (comment, dir) Çscript.makeComment () op.setCursor (pos)}; on getShort () { local (n); rollBeachBall (); n = number (binary (string.mid (aeteAdr^, ix, 2))); // 99/08/20, 16:46:59 by DAB ix = ix + 2; return (n)}; on getString () { local (n, s); rollBeachBall (); n = number (string.nthChar (aeteAdr^, ix)); // 99/08/20, 16:47:17 by DAB s = string.mid (aeteAdr^, ix + 1, n); // 99/08/20, 17:02:19 by DAB ix = ix + n + 1; return (s)}; on getString4 () { local (x); rollBeachBall (); x = string4 (string.mid (aeteAdr^, ix, 4)); // 99/08/20, 16:47:29 by DAB ix = ix + 4; return (x)}; on getName () { local (ixSpace, x); x = string.lower (getString ()); while string.countWords (x) > 1 { // make it an innerCase identifier ixSpace = string.patternMatch (' ', x); ch = string.upper (string.nthChar (x, ixSpace + 1)); x= string.firstWord (x) + ch + string.mid (x, ixSpace + 2, infinity)}; msg ("DuckTape: " + x); return (x)}; on skipString () { getString ()}; on skipBytes (n) { ix = ix + n}; on align () { if ix % 2 == 0 { // remember, we're in a 1-based world, so this is an odd byte ++ix}}; on assignUnique (name, adrValue, eventInformationEntry = false) { // 8/14/05; 8:02:31 PM by TAC - reworked a bit, was still putting items in top level table even though eventInformationEntry was true on sameValue (adr1, adr2) { if typeOf (adr1^) != typeOf (adr2^) { return (false)}; return (adr1^ == adr2^)}; local (adr, ct = 1); adr = @objectModel.[name]; if defined (adr^) { if sameValue (adr, adrValue) { return (false)}; if typeOf (adr^) == scriptType { return (false)}}; if eventInformationEntry { adr = @adrTable^.[user.DuckTape.eventInformationTableName]} else { adr = adrTable}; local (s = name); while defined (adr^.[s]) { if sameValue (@adr^.[s], adrValue) { return (false)}; s = name + ct++}; table.assign (@adr^.[s], adrValue^); return (true)}; on parseEvents () { local (ixEvent, ctEvents, eventPrefix); on makeScript (onStatement, returnStatement, adr) { new (scriptType, adr); target.set (adr); placeLine (onStatement); // handles line overflow op.insertAtEndOfList (""); // Make a place for the return statement placeLine (returnStatement); Çop.setLineText (onStatement) Çop.insert (returnStatement, right) op.go (left, 1); window.zoom (adr); close (adr); return (true)}; on makeName (type) { Çbased on the direct parameter's type, come up with a name for it case type { objspecType { return ("obj")}; stringType { return ("s")}; intType; longType { return ("n")}; booleanType { return ("flag")}; aliasType; filespecType { return ("file")}} else { return ("x")}}; on makeParam (name, type) { local (coerceR); case type { objspecType { coerceR = "objspec"}; filespecType { coerceR = "filespec"}; aliasType { coerceR = "alias"}; 'itxt'; stringType { coerceR = "string"}; intType { coerceR = "short"}; longType { coerceR = "long"}; 'savo'; enumeratorType { coerceR = "enum"}; string4Type { coerceR = "string4"}; booleanType { coerceR = "boolean"}; singleType { coerceR = "single"}; doubleType { coerceR = "double"}; pointType { coerceR = "point"}; rectType { coerceR = "rect"}; rgbType { coerceR = "rgb"}} else { return (name)}; return (coerceR + " (" + name + ')')}; on mapSuite (code, adr) { case code { 'reqd' { adr^ = @system.macintosh.required}; 'core' { adr^ = @system.macintosh.core}; 'misc' { adr^ = @system.macintosh.misc}} else { return (false)}; return (true)}; on mapEvent (adrScript, adrTable) { local (hdr, rtn); local (verb = nameOf (adrScript^), appName = nameOf (adrTable^)); local (suiteName = string.nthField (adrScript, '.', string.countFields (adrScript, '.') - 1)); local (adr = @adrTable^.[verb]); rollBeachBall (); target.set (adrScript); msg ("DuckTape: " + nameOf (adrScript^)); op.firstSummit (); hdr = op.getLineText () - "appID"; hdr = hdr - ", "; rtn = string.commentDelete (hdr - ("on " + verb + " (")); rtn = string.popTrailing (rtn, ' '); rtn = string.replaceAll (rtn, " = nil", ""); rtn = string.replaceAll (rtn, " = 'no '", ""); if string.length (rtn) > 1 { // has at least one param rtn = ", " + rtn}; rtn = suiteName + '.' + verb + " (" + DuckTape.appIdStyle (appName, user.DuckTape.appIdStyle) + rtn; rtn = "return (" + rtn + ')'; return (makeScript (hdr, rtn, adr))}; on parseParams (isFirst) { local (id, ixParam, flags); for ixParam = 1 to getShort () { paramName = getName (); if defined (system.compiler.language.keywords.[paramName]) { local (ch = string.upper (string.nthChar (paramName, 1))); paramName = eventName + ch + string.delete (paramName, 1, 1)}; align (); id = getString4 (); paramType = getString4 (); skipString (); align (); ÇskipBytes (2) // param flags flags = getShort (); // param flags if not isFirst { hdr = hdr + ", "}; hdr = hdr + paramName; if flags < 0 { // high bit set -> optional parameter hdr = hdr + " = nil"}; rtn = rtn + ", '" + id + "', " + makeParam (paramName, paramType); isFirst = false}}; ctEvents = getShort (); if mapSuite (suiteCode, @adrSuite) and (suiteCode 'misc' or ctEvents == 0) { // map all events of suite for i = 1 to sizeOf (adrSuite^) { mapEvent (@adrSuite^ [i], adrTable)}}; bundle { // event prefix eventPrefix = "return (appleEvent ("; eventPrefix = eventPrefix + DuckTape.appIdStyle (nameOf (adrTable^), user.DuckTape.appIdStyle) + ", '"}; for ixEvent = 1 to ctEvents { // add / overwrite event provided local (eventName, comment, class, paramName, paramType, id, hdr, rtn, adr); eventName = getName (); comment = getString (); align (); class = getString4 (); id = getString4 (); Çif (eventName == "eventInfo") // Tue, Dec 10, 2002 at 3:36:02 PM by SE Workaround for FMP having an eventInfo event! ÇeventName = eventName + "1" if user.DuckTape.flUseEventInformationTable { if (eventName == user.DuckTape.eventInformationTableName) { // name space collision scriptError ("DuckTape Suite: parseAete name collision error. Please report this error to <http://sourceforge.net/tracker/?group_id=120666&atid=687798>.")}}; adr = @adrTable^.[eventName]; hdr = "on " + eventName + " ("; rtn = eventPrefix + class + "', '" + id + "'"; skipBytes (4); // reply type skipString (); // reply description align (); skipBytes (2); // flags paramType = getString4 (); // direct param type skipString (); // direct param description align (); skipBytes (2); // reply flags if paramType != 'null' { // has a direct param local (paramName = makeName (paramType)); hdr = hdr + paramName; rtn = rtn + ", '----', " + makeParam (paramName, paramType); parseParams (false)} else { parseParams (true)}; hdr = hdr + ") // " + comment; rtn = rtn + "))"; makeScript (hdr, rtn, adr)}}; on parseClasses () { local (ixClass, x, description); on parseProperties () { local (ixProperty); for ixProperty = 1 to getShort () { local (s); name = getName (); align (); value = getString4 (); if value == 'c@#!' { // kAESpecialClassProperties skipSpecialClass = true}; if value == 'c@#^' { // same props & elements as class sameAsClass = getString4 (); description = "all properties of " + sameAsClass + '*'} // append asterix for postprocessing f & r else { skipBytes (4); // property class description = name}; s = getString (); // what is it? if string.length (s) > 0 { description = description + " -- " + s}; align (); skipBytes (2); if not skipSpecialClass { if value != 'c@#^' { assignUnique (name, @value, user.DuckTape.flUseEventInformationTable)}; op.insert (description, dir); dir = down}}}; on parseElements () { local (ixElement, ixKeyForm); if sameAsClass != 0 { op.insert ("all elements of " + sameAsClass + '*', dir); dir = down}; for ixElement = 1 to getShort () { ÇskipBytes (4) // element class value = getString4 (); if not skipSpecialClass { op.insert (string (value) + '*', dir); // append asterix for postprocessing f & r dir = down}; for ixKeyForm = 1 to getShort () { skipBytes (4)}}}; // ignore it target.set (@adrTable^.objectHierarchy); editMenu.setFontSize (9); dir == noDirection; for ixClass = 1 to getShort () { local (className, classID, skipSpecialClass = false, sameAsClass = 0); className = getName (); align (); classID = getString4 (); description = className + " -- " + getString (); // the class description if dir == noDirection { op.setLineText (description)} else { op.insert (description, down)}; dir = right; op.insert ("Properties:", dir); align (); parseProperties (); if dir == right { // nothing added op.deleteLine ()} else { op.go (left, 1)}; if not skipSpecialClass { assignUnique (className, @classID, user.DuckTape.flUseEventInformationTable); op.insert ("Elements:", dir); dir = right} else { op.go (left, infinity); op.deleteLine (); dir = down}; parseElements (); if dir == right { // nothing added op.deleteLine ()}; op.go (left, infinity)}; op.firstSummit (); target.clear ()}; on parseComparisonOps () { local (ixComparison); for ixComparison = 1 to getShort () { skipString (); align (); skipBytes (4); skipString (); align ()}}; on parseEnumerations () { local (ixEnumeration); on parseEnumerators () { local (ixenumerator); for ixEnumerator = 1 to getShort () { local (name, value, adr); name = getName (); align (); value = enum (getString4 ()); assignUnique (name, @value, user.DuckTape.flUseEventInformationTable); Çadr = @adrTable^.[name] Çif defined (adr^) // name already used Çif (typeOf (adr^) != binaryType) or (adr^ != value) // not a duplicate, use unique name Çtable.assign (table.uniqueName (name, adrTable), value) Çelse Çadr^ = value skipString (); align ()}}; for ixEnumeration = 1 to getShort () { skipBytes (4); parseEnumerators ()}}; on parseSuites () { local (ixSuite, suiteCode, dir); for ixSuite = 1 to getShort () { getString (); // name of the suite skipString (); // description align (); suiteCode = getString4 (); skipBytes (4); // skip up to event array parseEvents (); parseClasses (); parseComparisonOps (); parseEnumerations ()}}; Çbundle // 8/24/05; 6:16:55 PM by TAC - old code? are these really needed? Çbundle // make sure the table exists Çif not defined (adrTable^) Çnew (tableType, adrTable) Çbundle // make sure the eventInformation subtable exists 99/08/20, 13:29:44 by DAB Çif not defined (adrTable^.eventInformation) Çnew (tableType, @adrTable^.eventInformation) bundle { // set up the class hierarchy outline new (outlineType, @adrTable^.objectHierarchy)}; bundle { // parse the resource Çlocal (name) Çif !rez.getNthResource (appPath, 'aete', 1, @name, @aete) ÇscriptError ("Couldn't find the resource.") Ç99/08/18, 20:42:00 by DAB move aete read to own script ÇDynamic aete, are returned as lists of aete on parseOneAETE () { ix = 1; string.setWordChar (' '); // make sure it's normal skipBytes (6); // skip up to suite array parseSuites ()}; local (aeteList); DuckTape.getAETE (appPath, @aeteList); if typeof (aeteList) == tableType { // dynamic case local (iy); for iy =1 to sizeof (aeteList) { aeteAdr = @aeteList[iy]; parseOneAete ()}} else { aeteAdr = @aeteList; parseOneAETE ()}}; bundle { // post-process the class hierarchy outline local (savedParams); table.assign (@savedParams, user.prefs.search); // save off user.prefs.search.wholewords = true; user.prefs.search.wraparound = true; on translateClasses (adrTable) { local (i, adr); for i = 1 to sizeof (adrTable^) { adr = @adrTable ^[i]; msg ("DuckTape: " + nameOf (adr^)); if typeOf (adr^) == string4type { user.prefs.search.searchfor = string (adr^) + '*'; user.prefs.search.replacewith = nameOf (adr^); search.reset (); search.replaceall ()}}}; target.set (@adrTable^.objectHierarchy); translateClasses (adrTable); translateClasses (@objectModel); wp.setTextMode (false); op.firstSummit (); op.sort (); target.clear (); table.assign (@user.prefs.search, savedParams)}; // restore originals bundle { // remove unneeded verbs if defined (adrTable^.quit) and defined (adrTable^.quitApplication) { delete (@adrTable^.quitApplication)}; if defined (adrTable^.openApplication) { delete (@adrTable^.openApplication)}}; DuckTape.callbackLoop (@user.DuckTape.callbacks.afterParseAete, adrTable); fileMenu.saveMyRoot (adrTable); msg (""); window.open (adrTable); return (true)}; Çbundle // testing ÇparseAete (system.verbs.[temp.DuckTape.appsTableItemName].appInfo.path, @system.verbs.[temp.DuckTape.appsTableItemName]) \ No newline at end of file |