Technotes


MPW Object Pascal Without MacApp



Technote PT 06January 1987



Revised by: March 1988
Written by: Rick Blair January 1987



Object Pascal must have a CODE segment named %_MethTables in order to access object methods. In MacApp this is taken care of "behind the scenes" so you don't have to worry about it . However, if you are doing a straight Object Pascal program, you must make sure that %_MethTables is around when you need it. If it's unloaded when you call a method, your Macintosh will begin executing wild noncode and die a gruesome and horrible death.

The MPW Pascal compiler must see some declaration of an object in order to produce a reference to the magic segment. You can achieve this cheaply by simply including ObjIntf.p in your Uses declaration. This must be in the main program, by the way. The compiler will produce a call to %_InitObj which is in %_MethTables.

If you're a more adventurous soul, you can call %_InitObj explicitly from the initialization section of your main program (you must use the {$%+} compiler directive to allow the use of "%" in identifiers). This will load the %_MethTables segment. See Technical Note #93 for ideas about locking down segments that are needed forever without fragmenting the heap.

Further Reference:




Technotes
Previous Technote | Contents | Next Technote