Carbon


OSLCountProcPtr

Header: AEObjects.h Carbon status: Supported

Defines a pointer to an object counting callback function. Your object counting function counts the number of Apple event objects of a specified class in a specified container object.

typedef OSErr(* OSLCountProcPtr) (
    DescType desiredType, 
    DescType containerClass, 
    const AEDesc *container, 
    SInt32 *result
);

You would declare your function like this if you were to name it MyOSLCountCallback:

OSErr MyOSLCountCallback (
    DescType desiredType, 
    DescType containerClass, 
    const AEDesc *container, 
    SInt32 *result
);
Parameter descriptions
desiredType

The object class of the Apple event objects to be counted.

containerClass

The object class of the container for the Apple event objects to be counted.

container

A pointer to a token that identifies the container for the Apple event objects to be counted. (Token is defined in AEDisposeToken.)

result

A pointer to a variable where your object-counting function stores the number of Apple objects of the specified class in the specified container.

function result

A result code. Your object counting function should return noErr if it successfully counted the objects and errAEEventNotHandled if it can’t count the objects. When the Apple Event Manager receives the result code errAEEventNotHandled after calling an object counting function, it attempts to use other methods of counting the specified objects, such as calling an equivalent system object counting function.

DISCUSSION

If you want the Apple Event Manager to help your application resolve object specifier records 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 comparison function, as described in OSLCompareProcPtr, and an object-counting function.

The Apple Event Manager calls your object-counting function when, in the course of resolving an object specifier record, the manager requires a count of the number of Apple event objects of a given class in a given container.

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

OSLCountObjectsUPP MyCountObjectsUPP;

MyCountObjectsUPP = NewOSLCountObjectsUPP (&MyCountObjectsCallback);

You can then pass the UPP MyCountObjectsUPP as a parameter to the AESetObjectCallbacks function or the AEInstallSpecialHandler function.

If you wish to call your object counting callback function directly, you can use the InvokeOSLCountUPP function.

After you are finished with your object counting callback function, you can dispose of the UPP with the DisposeOSLCountUPP function. However, if you will use the same object counting 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.

VERSION NOTES

Revisit, based on system object accessor dispatch table write-up.

Use of the system object accessor dispatch table is not recommended for Carbon applications—see “Installing Object Accessors” (to be supplied later) for more information.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)