Run-time results 26 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 906

Advertising
background image

A P P E N D I X

A-2

Run-Time Results

Note

Protos built into the system use an analogous slot called

allocateContext

, that holds the same thing as

stepAllocateContext

. The

allocateContext

slot is for

declared children from the

viewChildren

array and the

stepAllocateContext

slot is for declared children from the

stepChildren

array.

Also, as a result of the declare operation, NTK creates a slot in the Display template
called

preallocatedContext

. This slot holds a symbol that is the name of the

template, in this case

'Display

. This symbol will be used by the system when the

view is instantiated to find the preallocated view memory object for the Display view.

Run-Time Results

26

When the Calculator view is opened (even before its

ViewSetupFormScript

method is executed), a view memory object is preallocated for each view declared
in Calculator. (The information required to do this is obtained from the

allocateContext

and

stepAllocateContext

slots.) In our example, a view

memory object is created for the Display view.

The

Display

slot in the Calculator view is updated so that it points to the newly

allocated Display view object.

Later in the instantiation process for the Calculator view, its child views are created
and shown, including the Display view. At this time, the view system looks at the
template for the Display view, sees the

preallocatedContext

slot, and knows

that a view memory object has been preallocated for this view. Using this slot, the
system can find the preallocated view.

The value of the

preallocatedContext

slot is the name of another slot in the

Calculator view. The system locates this slot in the Calculator view, and finds there
a reference to the preallocated view object. Instead of creating a new view object
for the Display view, the system uses the preallocated view.

Advertising