background image
Compile-Time Results
A-1
A P P E N D I X
The Inside Story on Declare
A
This appendix describes the technical details of the declare mechanism. Knowing
these technical details is not necessary to understanding what declaring a view
means; they are provided primarily for completeness and to help you when you are
debugging. You shouldn't write code that depends on these details.
For a basic discussion of the declare mechanism, see the section "View Instantiation"
beginning on page 3-26. You should be familiar with that material before reading
this appendix.
To serve as an example here, imagine a calculator application whose base view is
named "Calculator." It has (among others) a child view named "Display." The
Display view is declared in the Calculator view. See Figure A-1 for an illustration
of this example.
In the following sections, we'll explain what happens at compile time and at run
time as a result of the declare operation. A number of slots are created, which
you may see in the Newton Toolkit (NTK) Inspector if you are examining the
view templates.
Compile-Time Results
26
As a result of the declare operation, at compile time, NTK creates a slot in the place
where the view is declared--that is, in the Calculator template. The name of the slot
is the name of the declared view,
Display
. This slot's value is initially set to
nil
.
Another slot, called
stepAllocateContext
, is also created in the Calculator
template. This slot holds an array of values (two for each view declared there). The
first value in each pair is a symbol used by the system at run time to identify the
name of the slot in the Calculator view that holds a reference to the declared view.
This symbol is simply the name of the declared view,
Display
.
The second value in each pair is a reference to the template for the declared view.
At run time, the system will preallocate a view memory object for the declared
view from this template.
Figure 27-0
Table 27-0
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна