Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Mac OS Runtime Architectures /
Chapter 3 - Programming for the CFM-Based Runtime Architecture


Multiple Names for the Same Fragment

The CFM-based architecture allows you to assign multiple names to a single fragment. For example, if you have a fragment that implements multiple SOM classes, you can assign a separate name for each class, all of which point to the same fragment.

You store multiple names as multiple 'cfrg'0 entries. As mentioned earlier, the 'cfrg'0 resource is actually an array, so you can store as many fragment descriptions as you like.

For example, the 'cfrg'0 resource in Figure 3-1 contains two fragment entries, mooFrag and cowFrag, which both point to the same fragment (that is, their 'cfrg'0 resource entries map to the same location). If the Code Fragment Manager is called to prepare mooFrag and then called sometime later to prepare cowFrag, it knows that they are the same fragment and treats them as such. For example, if the preparation request for cowFrag came from the same process, it increments the reference count for mooFrag and creates a closure using the existing connection. In this manner it is possible to create "aliases" for fragment names.

Figure 3-1 Two names for a single fragment

You can use aliasing to update older libraries without having to change the client fragments that import from them. For example, say you build a library cowFrag and create several applications that use it. Sometime later you build another library mooFrag that contains all the functionality of cowFrag as well as some new features. If the 'cfrg'0 entry for mooFrag contains an entry for both mooFrag and cowFrag, then the following are possible:


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997