Texas Instruments TI-89 Developer's Manual page 1260

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

1218
OO_SuperFrame
/* The C compiler complains about 0 length array for empty FRAMEs
FRAME(C, &B, 0, 0, 0)
ENDFRAME
*/
const OO_Hdr C = /* hand-coded empty FRAME C */
{
(pFrame)&B, 0, OO_RO | OO_SEQ, 0, 0
};
void A_foo(pFrame self)
{
/* implementation of A::foo */
}
void B_foo(pFrame self)
{
/* implementation of B::foo */
Access_AMS_Global_Variables;
pFrame super = OO_SuperFrame;
/* Call inherited foo method */
foo(super);
}
void main(void)
{
foo((pFrame)&C);
}
Main calls method foo of frame C. Frame C has no implementation of foo, so inherited method
foo from frame B (routine B_foo) actually gets called.
B_foo wants to call the inherited foo method of frame self. If it calls the parent foo method of
frame self, it will, in fact, be calling itself recursively — remember self points to frame C, the
parent of which is frame B.
OO_SuperFrame conveniently contains a pointer to the parent frame of the frame where the
latest method address was retrieved. Method foo was retrieved from frame B, so
OO_SuperFrame contains a pointer to frame A. Now a call to foo(super) in B_foo calls the foo
method of frame A (routine A_foo).
Note:
OO_SuperFrame is a system-wide global variable. If you intend to use it in one of your method
implementations, make an immediate copy into a local variable because subsequent method calls or
attribute accesses will change its value.
TI-89 / TI-92 Plus Developer Guide
Appendix B: Global Variables — Apps
(continued)
Not for Distribution
Beta Version January 26, 2001

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-92 plus

Table of Contents