Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Relevant replacement documents include:
MoreOSL/MoreOSLTokens.c
/* |
File: MoreOSLTokens.c |
Contains: Token definition for MoreOSL. |
Written by: Quinn |
Copyright: Copyright © 2000 by Apple Computer, Inc., all rights reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
Change History (most recent first): |
<2> 20/3/00 Quinn Added InitPropertyMOSLTokenFromOtherProperty. Fixed unitialised |
"err" in CompareMOSLTokens. |
<1> 6/3/00 Quinn First checked in. |
*/ |
///////////////////////////////////////////////////////////////// |
// MoreIsBetter Setup |
#include "MoreSetup.h" |
// Mac OS Interfaces |
#include <AppleEvents.h> |
#include <AERegistry.h> |
// MIB Prototypes |
#include "MoreAppleEvents.h" |
#include "MoreBBLog.h" |
#include "MoreOSL.h" // for error codes |
// Our Prototypes |
#include "MoreOSLTokens.h" |
///////////////////////////////////////////////////////////////// |
#if MORE_DEBUG |
extern pascal void BBLogMOSLToken(ConstStr255Param tag, const MOSLToken *tok) |
// See comment in header file. |
{ |
OSStatus err; |
AEDesc tmpDesc; |
MoreAssertQ(tag != nil); |
MoreAssertQ(tok != nil); |
err = AECreateDesc(tok->tokType, tok, sizeof(*tok), &tmpDesc); |
if (err == noErr) { |
BBLogDesc(tag, &tmpDesc); |
MoreAEDisposeDesc(&tmpDesc); |
} |
MoreAssertQ(err == noErr); |
} |
#endif |
extern pascal void InitObjectMOSLToken(MOSLToken *tok, DescType tokType, void *tokData) |
// See comment in header file. |
{ |
MoreAssertQ(tok != nil); |
tok->tokType = tokType; |
tok->tokObjType = tokType; |
tok->tokPropName = (OSType) 0; |
tok->tokData = tokData; |
} |
extern pascal void InitPropertyMOSLToken(MOSLToken *tok, DescType tokObjType, DescType tokPropName, void *tokData) |
// See comment in header file. |
{ |
MoreAssertQ(tok != nil); |
tok->tokType = typeProperty; |
tok->tokObjType = tokObjType; |
tok->tokPropName = tokPropName; |
tok->tokData = tokData; |
} |
extern pascal void InitPropertyMOSLTokenFromContainer(MOSLToken *tok, const MOSLToken *containerTok, DescType tokPropName) |
// See comment in header file. |
{ |
MoreAssertQ(tok != nil); |
MoreAssertQ(containerTok != nil); |
MoreAssertQ(containerTok->tokType != typeProperty); |
*tok = *containerTok; |
tok->tokType = typeProperty; |
tok->tokPropName = tokPropName; |
} |
extern pascal void InitPropertyMOSLTokenFromOtherProperty(MOSLToken *tok, const MOSLToken *propertyTok, DescType tokPropName) |
// See comment in header file. |
{ |
MoreAssertQ(tok != nil); |
MoreAssertQ(propertyTok != nil); |
MoreAssertQ(propertyTok->tokType == typeProperty); |
*tok = *propertyTok; |
tok->tokType = typeProperty; |
tok->tokPropName = tokPropName; |
} |
extern pascal OSStatus MOSLTokenToDesc(const MOSLToken *tok, AEDesc *desc) |
// See comment in header file. |
{ |
OSStatus err; |
MoreAssertQ(tok != nil); |
MoreAssertQ(desc != nil); |
MoreAENullDesc(desc); |
err = AECreateDesc(tok->tokType, tok, sizeof(*tok), desc); |
return err; |
} |
extern pascal void DescToMOSLToken(const AEDesc *tokDesc, MOSLToken *tok) |
// See comment in header file. |
{ |
OSStatus junk; |
MoreAssertQ(tok != nil); |
MoreAssertQ(tokDesc != nil); |
if (tokDesc->descriptorType == typeNull) { |
InitObjectMOSLToken(tok, cApplication, nil); |
} else { |
MoreAssertQ(AEGetDescDataSize(tokDesc) == sizeof(*tok)); |
junk = AEGetDescData(tokDesc, tok, sizeof(*tok)); |
MoreAssertQ(junk == noErr); |
MoreAssertQ(tokDesc->descriptorType == tok->tokType); |
} |
} |
extern pascal OSStatus CompareMOSLTokens(DescType oper, const MOSLToken *tok1, const MOSLToken *tok2, Boolean *result) |
// See comment in header file. |
{ |
OSStatus err; |
MoreAssertQ(tok1 != nil); |
MoreAssertQ(tok2 != nil); |
MoreAssertQ(result != nil); |
err = noErr; |
switch (oper) { |
case kAEEquals: |
*result = (tok1->tokObjType == tok2->tokObjType ) |
&& (tok1->tokPropName == tok2->tokPropName) |
&& (tok1->tokData == tok2->tokData ); |
break; |
case kAEGreaterThanEquals: |
case kAEGreaterThan: |
case kAELessThanEquals: |
case kAELessThan: |
err = kMOSLCantRelateObjectsErr; |
break; |
default: |
MoreAssertQ(false); |
err = kMOSLUnrecognisedOperatorErr; |
break; |
} |
return err; |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14