Contents

OSLCompareProcPtr

Defines a pointer to an object comparison callback function. Your object comparison function compares one Apple event object to another or to the data for a descriptor.

Declaration

typealias OSLCompareProcPtr = (DescType, UnsafePointer<AEDesc>?, UnsafePointer<AEDesc>?, UnsafeMutablePointer<DarwinBoolean>?) -> OSErr

Parameters

  • oper:

    A comparison operator that specifies the type of comparison to perform. The available comparison operators are described in Comparison_operator_constants. For related information, see the function 1449155 Createcompdescriptor. See Desctype.

  • obj1:

    A pointer to a token describing the first Apple event object to compare. (Token is defined in 1446783 Aedisposetoken. See Aedesc.

  • obj2:

    A pointer to a token or some other descriptor that specifies either an Apple event object or a value to compare to the Apple event object specified by the obj1 parameter. See Aedesc.

  • result:

    A pointer to a Boolean value where your object comparison function stores a value indicating the result of the comparison operation. You store TRUE if the values of the obj1 and obj2 parameters have the relationship specified by the comparisonOperator parameter; otherwise, you store FALSE.

Return Value

A result code. See Result Codes. Your object comparison function should return noErr if it successfully compared the objects and errAEEventNotHandled if it can’t compare the objects. When the Apple Event Manager gets an error result of errAEEventNotHandled, it attempts to use other methods of comparing the specified objects, such as calling an equivalent system object comparison function.

Discussion

The Apple Event Manager calls your object comparison function when, in the course of resolving an object specifier, the manager needs to compare an Apple event object with another object or with a value in a descriptor.

If you want the Apple Event Manager to help your application resolve object specifiers of key form formTest (and if your application doesn’t specify kAEIDoWhose as described in Callback Constants for the AEResolve Function), you should provide an object-counting function, as described in OSLCountProcPtr, and an object comparison function.

It is up to your application to interpret the comparison operators it receives. The meaning of comparison operators differs according to the Apple event objects being compared, and not all comparison operators apply to all object classes. The available comparison operators are described in Comparison Operator Constants.

To provide a pointer to your object comparison callback function, you create a universal procedure pointer (UPP) of type OSLCompareUPP, using the function NewOSLCompareUPP(_:). You can do so with code like the following:

OSLCompareObjectsUPP MyCompareObjectsUPP;
MyCompareObjectsUPP = NewOSLCompareObjectsUPP(&MyCompareObjectsCallback)

You can then pass the UPP MyCompareObjectsUPP as a parameter to the AESetObjectCallbacks(_:_:_:_:_:_:_:) function or the AEInstallSpecialHandler(_:_:_:) function.

If you wish to call your object comparison callback function directly, you can use the InvokeOSLCompareUPP(_:_:_:_:_:) function.

After you are finished with your object comparison callback function, you can dispose of the UPP with the DisposeOSLCompareUPP(_:) function. However, if you will use the same object comparison function in subsequent calls to the function AESetObjectCallbacks or the function AEInstallSpecialHandler, you can reuse the same UPP, rather than dispose of it and later create a new UPP.

See Also

Callbacks