home *** CD-ROM | disk | FTP | other *** search
- /*
- File: OSLToken.c
-
- Contains: Routines for manipulating OSLTokens
-
- Owned by: Nick Pilch
-
- Copyright: © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <6> 5/21/95 NP 1248898: GetUserToken, ODDescToAEDesc, etc.
- recipe change.
- <5> 5/3/95 NP 1211084: Remove 5$
- <4> 2/8/95 NP 1218550: Don't allocate OSLContexts
- dynamically.
- <3> 11/15/94 NP 1196322,1199847-made functions non-pascal,
- changed implementation for new tokens.
- <2> 8/19/94 NP 1181622: Ownership fix.
- <5> 9/24/93 JA Minor syntactic tweaks for THINK C++.
- <4> 8/25/93 NP Fixed bugs: routines returning garbage.
- <3> 8/19/93 NP Changed name of error code.
- <2> 8/16/93 NP Adjusted for latest OSL proposal.
- <1> 8/11/93 NP first checked in
-
- To Do:
- */
-
- #pragma segment OSLToken
-
- #ifndef _OSLTOKEN_
- #include "OSLToken.h"
- #endif
-
- void StuffContextIntoToken(OSLToken* token, OSLContext context);
- OSLContext GetContextFromToken(const OSLToken* token);
-
- #pragma lib_export on
-
- #if 0
- OSErr OSLGetAppTokenDesc(OSLToken* token, AEDesc* appDesc)
- {
- appDesc->descriptorType = token->descriptorType;
- appDesc->dataHandle = token->dataHandle;
- return noErr;
- }
-
- OSErr OSLPutAppTokenDesc(OSLToken* token, AEDesc* appDesc)
- {
- token->descriptorType = appDesc->descriptorType;
- token->dataHandle = appDesc->dataHandle;
- return noErr;
- }
- #endif
- DescType OSLGetTokenDescType(const OSLToken* token)
- {
- return token->descriptorType;
- }
-
- void OSLSetTokenDescType(OSLToken* token, DescType appDescType)
- {
- token->descriptorType = appDescType;
- }
-
- Handle OSLGetTokenDataHandle(const OSLToken* token)
- {
- return token->dataHandle;
- }
-
- void OSLSetTokenDataHandle(OSLToken* token, Handle appHandle)
- {
- token->dataHandle = appHandle;
- }
-
- //$$$$$ These next two routines should put the context data at the beginning
- // of the token. Make necessary changes in NamRslvr as well.
-
- //------------------------------------------------------------------------------
- // StuffContextIntoToken
- //------------------------------------------------------------------------------
-
- void StuffContextIntoToken(OSLToken* token, OSLContext context)
- {
- *(OSLContext*)(((char*)(*(token->dataHandle))) + sizeof(long)) = context;
- }
-
- //------------------------------------------------------------------------------
- // GetContextFromToken
- //------------------------------------------------------------------------------
-
- OSLContext GetContextFromToken(const OSLToken* token)
- {
- return *(OSLContext*)(((char*)(*(token->dataHandle))) + sizeof(long));
- }
-
- //------------------------------------------------------------------------------
- // OSLGetTokenContext
- //------------------------------------------------------------------------------
-
- OSErr OSLGetTokenContext(const OSLToken* token, OSLContext* context)
- {
- if (!token->dataHandle)
- return errNotAValidToken;
- *context = GetContextFromToken(token);
- return noErr;
- }
-
- //------------------------------------------------------------------------------
- // OSLSetTokenContext
- //------------------------------------------------------------------------------
-
- OSErr OSLSetTokenContext(OSLToken* token, OSLContext* context)
- {
- if (!token->dataHandle)
- return errNotAValidToken;
- StuffContextIntoToken(token, *context);
- return noErr;
- }
-
-
-
- GetCallbackCallerProc OSLGetContextProc(const OSLContext* context)
- {
- return context->getCallerProc;
- }
-
- long OSLGetContextRefCon(const OSLContext* context)
- {
- return context->refCon;
- }
-
- void OSLSetContextProc(OSLContext* context,
- GetCallbackCallerProc proc)
- {
- context->getCallerProc = proc;
- }
-
- void OSLSetContextRefCon(OSLContext* context, long refCon)
- {
- context->refCon = refCon;
- }
-
-