TEchnical Cites

  • 05:54:25 am on January 23, 2009 | 0
    Tags: , ,

    universal procedure pointer (UPP) is a pointer to a routine descriptor, which is a structure that occupies memory ( and hence must be allocated and disposed of). On Carbon, the UPP data type is opaque and might or might not require memory allocation. So we need to use a new creation and deletion function for each specific type of UPP we want to use.

    In a sense, universal procedure pointers are a piece of historical baggage dragged into Carbon by Mac OS8/9. They was first introduced with the so-called Universal Headers which, in turn, were introduced withthe Power Macintosh. They had to with the ability of the Power Macintosh to run applications that use theinstruction set of the Motorola 680×0 microprocessor (used in 680×0-based Macintoshes) as well asapplications that use the native instruction set of the Power Macintosh’s PowerPC microprocessor.

    In the Chapter 7 demonstration programs, the system software function which takes a universal procedurepointer is TrackControl . This function is called by your application when a mouse-down event occurs in acontrol, such as a scroll bar. Prior to the introduction of the Power Macintosh and the associatedintroduction of the Universal Headers, the TrackControl prototype looked like this:

    Sint16 TrackControl(TrackControl(ControlHandle theControl,Point localPoint,ProcPtr actionProc);

    The actionProc a parameter is simply the address of an application-defined function, called a callbackprocedure (or, in C terminology, a callback function) that is called repeatedly while the mouse buttonremains down. In other words, the TrackControl function used to take a procedure pointer (or, in Cterminology, a function pointer) in its actionProc parameter.The Universal Headers, which, amongst other things, allow you to write Classic API source code capableof being compiled as either 680×0 code or native PowerPC code, changed the prototype for TrackControl to:

    ControlPartCode TrackControl(ControlHandle theControl,Point startPoint,ControlActionUPP actionProc);

    Notice that the third parameter is now of type ControlActionUPP . This means that the actionProc parameternow takes a universal procedure pointer. This prototype has been carried through to Carbon, hence thenecessity to gain a basic understanding of universal procedure pointers.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: