home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Messaging / OSL / OSLPriv.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  11.6 KB  |  398 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OSLPriv.h (Orignal name: OSLPrivate.h)
  3.  
  4.     Contains:    
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1992 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <7>     8/29/95    jpa        DescPtr --> AEDesc* for Univ Hdrs 2.1.
  13.                                     [1279173]
  14.          <6>     6/27/95    NP        1262792: new version of OSLObjectInit
  15.          <5>     6/23/95    NP        1195474: Make Resolve reentrant.
  16.          <4>      5/3/95    NP        1211084: Remove 5$
  17.          <3>     4/24/95    eeh        1212343: include HshTbTyp.h; remove dups
  18.          <2>     8/19/94    NP        1181622: Ownership fix.
  19.         <12>      5/2/94    eeh        bug #1160654: various PPC native changes
  20.         <11>      2/9/94    NP        Tiger Team cleanup.
  21.         <10>      2/7/94    NP        Tiger Team doings.
  22.          <9>    10/22/93    NP        Removed obsolete context parameter from
  23.                                     some functions.
  24.          <8>    10/18/93    NP        Added/changed functional interfaces to
  25.                                     correspond with code.
  26.          <7>    10/11/93    NP        Internal interface changes and additions.
  27.          <6>     9/20/93    NP        Removed GetCurrentContext and
  28.                                     SetCurrentContext from here. Put them in
  29.                                     CntxtOSL.h.
  30.          <5>     8/18/93    NP        Mods for new context scheme.
  31.          <4>     8/16/93    NP        Adjusted for latest OSL proposal.
  32.          <3>     7/28/93    NP        Mods for new token type, OSLToken.
  33.          <2>     7/21/93    NP        Fixed #includes.
  34.          <1>     7/21/93    NP        first checked in
  35.  
  36.     To Do:
  37.  
  38. */
  39.  
  40. #ifndef _OSLPRIV_
  41. #define _OSLPRIV_
  42.  
  43. #ifndef __APPLEEVENTS__
  44. #include <AppleEvents.h>
  45. #endif
  46. #ifndef __AEOBJECTS__
  47. #include <AEObjects.h>
  48. #endif
  49. #ifndef __MIXEDMODE__
  50. #include <MixedMode.h>
  51. #endif
  52.  
  53. #ifndef __OSLTempdefs__
  54. #include "OSLTmpdf.h"
  55. #endif
  56. #ifndef _CNTXTOSL_
  57. #include "CntxtOSL.h"
  58. #endif
  59.  
  60. #ifndef _HSHTBTYP_
  61. #include "HshTbTyp.h"
  62. #endif
  63.  
  64. #define     kInitialHashTableSize 16
  65. #define     typeWhoseRangeInternal 'ind*'
  66.  
  67. #define     typeWhoseRangeInternal 'ind*'
  68.  
  69. #define     kAEAppDoesNothing    kAEIDoMinimum 
  70. #define     kAEAppDoesWhose        kAEIDoWhose 
  71. #define     kAEAppDoesAnyForms    kAEIDoWhose
  72.  
  73.  
  74. #define     kInitialHashTableSize    16 
  75.  
  76. #define     keyAEGetErrDescProc        'indc'
  77.  
  78. #define FailErr( res, err, lable )                                        \
  79.         if ( (err = (res)) != noErr )                                    \
  80.         {                                                                \
  81.             goto lable ;                                                \
  82.         }
  83.  
  84. #define    FAIL_ERR_PROC(err,lable)                                        \
  85.     return err ;                                                        \
  86. lable:                                                                    \
  87.     {
  88.  
  89. #define END_FAIL_ERR_PROC(err)                                            \
  90.     return err ;                                                        \
  91.     }
  92.  
  93. #define SizeOf sizeof
  94.  
  95. struct _TestTermRecord ;
  96. struct _ClassAndID ;
  97. struct _CompareEvtRecord ;
  98. struct _CompareRecord ;
  99. struct _LogicalRecord ;
  100. struct _IndexRecord ;
  101. struct _WhoseRecord ;
  102.  
  103.  
  104. struct _HashInfo {
  105.  long                     usedEntries ;
  106.  long                     collidedEntries ;
  107.  long                     totalEntries ;
  108.  long                     tableSize ;
  109. } ;
  110. typedef struct _HashInfo structHashInfo ;
  111.                 
  112. struct _ObjectAccessorKey {
  113.     DescType         firstKey ;
  114.     DescType         secondKey ;
  115. } ;
  116. typedef struct _ObjectAccessorKey ObjectAccessorKey ;
  117.  
  118. struct _ObjectAccessorValue {
  119.             OSLAccessorUPP         handler ;
  120.             long         handlerRefcon ;
  121. } ;
  122. typedef struct _ObjectAccessorValue ObjectAccessorValue ;
  123.         
  124.     
  125.     /* <eeh> Change to ObjRecord to accomodate new model: in certain cases that would
  126.       ordinarily call for two object records, one the container of the other, it is 
  127.       possible to combine them.  For instance, if an object's form is index and that
  128.       of its container is test and both are of the same class, then the two may be
  129.       combined into a single object.  We need a doubly-linked list for this type
  130.         of optimization. */
  131.  
  132. typedef struct _ObjRecord {
  133.     DescType         objClass ;                /*the desired class*/
  134.     struct _ObjRecord **objContainer ;                /*the container*/
  135.     struct _ObjRecord **objContained ;                /* makes it a doubly-linked list */
  136.     AEDesc         objSelectionData ;                    /*data to use in lookup*/
  137.     struct WhoseRecord **objTheWhose ;                    /*if it was a whose, this is the query structure
  138.                                             used only for nested whose clauses */
  139.     OSLToken         objValue ;                    /* result token */
  140.     Boolean         valIsExmn ;                /* is same as another token; don't dispose */
  141.     Boolean         objRedo ;                /* must be recalculated each time? */
  142.     AEDesc          theObjInput ;
  143.     union {
  144.         DescType objForm ;                /*how to get it*/
  145.         DescType    tokenClass;            /* could be union with objForm; we'll never use both */
  146.     } u ;
  147. } ObjRecord, *ObjRecordPtr, **Object ;
  148.  
  149. typedef enum testType {kCompare, kCompareEvt, kLogical} testType;
  150.     
  151. struct _TestTermRecord {
  152.     struct _TestTermRecord **next ;
  153.     Boolean         value ;
  154.     Boolean         redo ;
  155.     AEDesc          theTermInput ;
  156.     testType        ttype ; 
  157.     union {    
  158.         struct _LogicalRecord **log ;
  159.         struct _CompareEvtRecord **cEvt ;
  160.         struct _CompareRecord **compar;            // changed from "comp" because
  161.                                                 // compiler didn't like "comp"
  162.     } u ;
  163. } ;
  164. typedef struct _TestTermRecord TestTermRecord, *TestTermPtr, **Term ;
  165.  
  166. struct _ClassAndID {
  167.     DescType eventClass ;
  168.     DescType eventID ;
  169.     } ;
  170.  
  171. // <eeh> added 3/15
  172. struct _CompareEvtRecord {
  173.     AppleEvent        eventWParams ;
  174.     Boolean         value ;            /*result*/
  175.     Boolean         redo ;            /*must be recalculated each time?*/
  176.     AEDesc          theCompEvtInput ;
  177. } ;
  178. typedef struct _CompareEvtRecord CompareEvtRecord, *CompareEvtPtr, **CompareEvent ;
  179.  
  180. struct _CompareRecord {
  181.     Object            obj1 ;            /*left hand operand*/
  182.     Object            obj2 ;            /*right hand operand*/
  183.     DescType         oper  ;            /*> < <= etc.*/
  184.     
  185.     Boolean         value ;            /*result*/
  186.     Boolean         redo ;            /*must be recalculated each time?*/
  187.     AEDesc          theCompInput ;
  188. } ;
  189. typedef struct _CompareRecord CompareRecord, *ComparePtr, **Comparison ;
  190.  
  191. struct _LogicalRecord {
  192.     DescType         logicalOp ;            // AND, OR, NAND
  193.     Term            firstTerm ;            // start of linked list of terms
  194.     Boolean         value ;                // result
  195.     Boolean         redo ;                // must be recalculated each time?
  196.     AEDesc          theLogicalInput ;
  197. } ;
  198. typedef struct _LogicalRecord LogicalRecord, *LogicalPtr, **Logical ;
  199.     
  200.     
  201. struct _IndexRecord {
  202.  DescType         startCase ;        // for relative values instead of integers
  203.  long             startValue ;
  204.  DescType         stopCase ;        // for relative values instead of integers
  205.  long         stopValue ;
  206. } ;
  207. typedef struct _IndexRecord IndexRecord, *indexRecordPtr ;
  208.             
  209.  
  210. struct _WhoseRecord {
  211.  IndexRecord         index ;                // which matching objects desired
  212.  Term         theTerm ;                    // test to match against
  213.  OSLToken         whoseValue ;            // result token
  214.  AEDesc          theWhoseInput ;
  215. } ;
  216. typedef struct _WhoseRecord WhoseRecord, *WhoseRecordPtr, **Whose ;
  217.  
  218. typedef DescType *DescTypePtr, **DescTypeHandle ;
  219. typedef long *LongPtr, **LongHandle ;
  220.  
  221. struct _aeh {
  222.     ProcPtr                     DerefProc ;
  223.     ProcPtr                     NewProc ;
  224.     ProcPtr                     GrowProc ;
  225.     ProcPtr                     DisposeProc ;
  226.     } ;
  227. typedef struct _MemProcBlock MemProcBlock ;
  228. //typedef MemProcBlock* OSLMemProcs ;
  229.  
  230. struct _GlobalRec {
  231.     HHand                 aeHashTable ;
  232.     HHand                 coercionHashTable ;
  233.     HHand                 accessorHashTable ;
  234.     ProcPtr             phacProcPtr ;
  235.     ProcPtr             selhProcPtr ;
  236.     ProcPtr             blockingPtr ;
  237.     ProcPtr             unblockingPtr ;
  238.     OSLDisposeTokenUPP     diposeTokenProcPtr ;
  239.     OSLCompareUPP        compareProcPtr ;
  240.     OSLCountUPP            countProcPtr ;
  241.     OSLGetMarkTokenUPP     getMarkIDProcPtr ;
  242.     OSLMarkUPP             MarkProcPtr ;
  243.     OSLAdjustMarksUPP     AdjustMarksProcPtr ;
  244.     ProcPtr             AENonAevtHandler ;
  245.     OSLGetErrDescUPP     TypeAsIndexProc ;
  246. } ;
  247. typedef struct _GlobalRec GlobalRec, *GlobalRecPointer, **GlobalRecHandle ;
  248.  
  249. extern pascal OSErr SelectorDispatch(void) ;
  250.  
  251.  
  252. //pascal GlobalRecHandle GetGlobalRef(void) =
  253. //    { 0x2078, 0x02B6, 0x2EA8, 0x0154} ; 
  254. // movea.l expandMem,a0; move.l $154(a0),(a7) 
  255.     
  256. //pascal GlobalRecHandle GetSysGlobal(void) = 
  257. //    { 0x2078, 0x02B6, 0x2EA8, 0x017C } ;
  258. //movea.l expandMem,a0; move.l $17C(a0),(a7) }
  259.  
  260. //0x2B6 is the old ExpandMem (not defined in the system headers anymore!)
  261. #define GetGlobalRef() (GlobalRecHandle)(*((long *)((*((char **)0x2B6)) + 0x154)))
  262. #define GetSysGlobal() (GlobalRecHandle)(*((long *)((*((char **)0x2B6)) + 0x17C)))
  263.  
  264. #define IgnoreOSErr(x) x
  265.  
  266.  
  267. // a version for C OSErr functions: just drop it altogether.
  268. #define CIgnoreOSErr(call)             call
  269.  
  270. //==============================================================================
  271. // Functions
  272. //==============================================================================
  273.  
  274. // Implemented in glue that calls through to Apple Event Mgr undocumented calls.
  275.  
  276. extern OSErr CreateObject( const AEDesc *input, Object containedObj,
  277.         Boolean expandWhoseData, Object *theObject ) ;
  278.  
  279. extern OSErr CreateWhose( AEDesc input, Whose *theWhose ) ;
  280.  
  281. extern OSErr CreateTerm( AEDesc *input, Term *theTerm ) ;
  282.  
  283. extern OSErr CreateCompare( AEDesc  input , Comparison *theComparison ) ;
  284.  
  285. extern OSErr CreateLogical( const AEDesc *input , Logical *theLogical ) ;
  286.  
  287. extern void DisposeObj( Object o ) ;
  288.  
  289. extern void DisposeWhose( Whose w ) ;
  290.  
  291. extern void DisposeTerm( Term t ) ;
  292.  
  293. extern void DisposeLogical( Logical l ) ;
  294.  
  295. extern void DisposeCompare( Comparison c ) ;
  296.  
  297. extern void MakeNull(AEDesc *theDesc ) ;
  298. extern void MakeNullToken(OSLToken *theToken ) ;
  299. extern OSErr EvalObj( Object o , DescType exmnClass , OSLToken *objectBeingExmn,
  300.     short appDoesFlags) ;
  301.  
  302. extern OSErr CallCompareProc(  DescType oper, OSLToken obj1 ,
  303.     OSLToken obj2, Boolean *result ) ;
  304. OSErr NewCallCompareProc(DescType            oper,
  305.                             OSLToken        obj1,
  306.                             OSLToken        obj2,
  307.                             Boolean*        result);
  308. extern OSErr CallAdjustMarks( long newStart, long newStop,
  309.         OSLToken markToken ) ;
  310. OSErr NewCallAdjustMarks( long newStart, long newStop,
  311.         OSLToken markToken ) ;
  312. extern OSErr CallMark( OSLToken dToken, OSLToken  markToken, long n ) ;
  313. OSErr NewCallMark( OSLToken dToken, OSLToken  markToken, long n ) ;
  314. extern OSErr CallGetMarkToken( OSLToken dContainerToken,
  315.         DescType containerClass, OSLToken *result ) ;
  316. OSErr NewCallGetMarkToken( OSLToken dContainerToken,
  317.         DescType containerClass, OSLToken *result ) ;
  318. extern OSErr
  319. CallCountProc( DescType desiredType, DescType containerClass,
  320.         OSLToken container, long *result ) ;
  321. OSErr NewCallCountProc(DescType        desiredType,
  322.                         DescType    containerClass,
  323.                         OSLToken    container,
  324.                         long*        result);
  325. extern pascal OSErr
  326. iCallAccessor( DescType  wantType , OSLToken  container ,
  327.         DescType  containerClass , DescType form,
  328.          AEDesc selectionData , OSLToken *value ) ;
  329. extern OSErr CallGetErrDesc( AEDesc* *appDescPtr ) ;
  330. OSErr NewCallGetErrDesc( AEDesc* *appDescPtr ) ;
  331.  
  332. extern pascal OSErr
  333. iAEDisposeToken( OSLToken *theDesc ) ;    
  334. OSErr NewCallDisposeToken(OSLToken* theToken);
  335.  
  336. extern pascal OSErr
  337. iAEObjectInit(OSLContext* context);
  338.  
  339. static void
  340. zero( char *s, long bytes ) ;
  341.  
  342. extern OSErr            // EvalObj needs this guy
  343. InternalResolve    (    Object         thisObj ,    
  344.                      DescType    exmnClass ,
  345.                     OSLToken    *dObjExamined ,
  346.                     Boolean        *contIsExmn ,
  347.                     OSLToken    *value ,
  348.                     Boolean        *redo ) ;
  349.  
  350. OSErr GetExmn( OSLToken *result ) ; // what effect does this have?
  351. OSErr SetExmn( OSLToken *newDesc ) ;
  352. // I'm not sure the OSL needs this next guy
  353. OSErr SwapExmn( AEDesc *oldAndNewDesc ) ;
  354.  
  355. OSErr AddContextToTopOfStack(OSLContext* context);
  356. OSErr RemoveTopOfContextStack();
  357.  
  358. Boolean SetErrDesc( AEDesc failedDesc );
  359. OSErr
  360. EvalWhose( Whose whoz , DescType  wantClass , DescType  containerClass ,
  361.         OSLToken  container , short appDoesFlags );
  362.  
  363. pascal OSErr
  364. iAEGetObjectAccessor(    DescType        desiredClass,
  365.                         DescType        containerType,
  366.                         OSLAccessorUPP    *handler,
  367.                         long             *handlerRefcon,
  368.                         Boolean            isSysHandler);
  369.                         
  370. pascal OSErr
  371. iAEInstallObjectAccessor(DescType            desiredClass ,
  372.                         DescType            containerType ,
  373.                         OSLAccessorUPP        handler ,
  374.                         long                handlerRefcon ,
  375.                         Boolean                isSysHandler);
  376.  
  377. pascal OSErr
  378. InternalDisposeToken( OSLToken* token );
  379.  
  380. pascal OSErr
  381. iAEDisposeToken( OSLToken *theDesc );
  382.  
  383. pascal OSErr
  384. iAEResolve(    AEDesc dObjectSpecifier, OSLToken *dTheToken, OSLContext* startingContext);
  385.  
  386. OSErr GetAppDoesFlags(OSLContext* token, short* appDoesFlags);
  387.  
  388. OSErr MakeExternalWhose( const AEDesc* desc, AEDesc *result ) ;
  389.  
  390. // ISSUES
  391. // 1. Need to search all files for uses of IgnoreOSErr, and make sure it is
  392. // only used on functions of type pascal.  A different one needs to be written
  393. // (for consistency's sake only, since C lets me ignore returned values)
  394. // for C functions.
  395.  
  396. #endif // _OSLPRIV_
  397.  
  398.