(ddd-themes.info)Building Boxes from Data
1.2 Building Boxes from Data
============================
To visualize data structures, each atomic type and each type constructor
from the programming language is assigned a VSL display function.
Atomic values like numbers, characters, enumerations, or character
strings are displayed using string boxes holding their value; the VSL
function to display them leaves them unchanged:
// Atomic Values
simple_value(value) = value;
Composite values require more attention. An array, for instance, may
be displayed using a horizontal alignment:
// Array
array(...) = frame(halign(...));
When GDB sends DDD the value of an array, the VSL function `array()'
is invoked with array elements as values. A GDB array expression `{1,
2, 3}' is thus evaluated in VSL as
array(simple_value("1"), simple_value("2"), simple_value("3"))
which equals
"1" & "2" & "3"
a composite box holding a horizontal alignment of three string boxes.
The actual VSL function used in DDD also puts delimiters between the
elements and comes in a vertical variant as well.
Nested structures like multi-dimensional arrays are displayed by
applying the `array()' function in a bottom-up fashion. First,
`array()' is applied to the innermost structures; the resulting boxes
are then passed as arguments to another `array()' invocation. The GDB
output
{{"A", "B", "C"}, {"D", "E", "F"}}
representing a 2 * 3 array of character strings, is evaluated in VSL as
array(array("A", "B", "C"), array("A", "B", "C"))
resulting in a horizontal alignment of two more alignments representing
the inner arrays.
Record structures are built in a similar manner, using a display
function `struct\_member' rendering the record members. Names and
values are separated by an equality sign:
// Member of a record structure
struct_member (name, value) =
name & " = " & value;
The display function `struct' renders the record itself, using the
`valign()' function.(1)
// Record structure
struct(...) = frame(valign(...));
This is a simple example; the actual VSL function used in DDD takes
additional effort to align the equality signs; also, it ensures that
language-specific delimiters are used, that collapsed structs are
rendered properly, and so on.
---------- Footnotes ----------
(1) `valign()' is similar to `halign()', but builds a vertical
alignment.
automatically generated by info2www version 1.2.2.9