Arrays
The functions of this set let you represent data as arrays. TempLuator supports two types of arrays: inline arrays and "normal" arrays. All elements of an inline array are shown in a single output line. Each element of a "normal" array is printed on its own line. The simplest way to define an inline array is to pass a non-nil value of NumberOfItems parameter to a basic type definition.
inlinearray(Type, Name, Comment, NumberOfItems, ViewerFn, BytesPerElement) MaxInlineElements array(Type, Name, Fn, NumberOfItems, Comment)
inlinearray(Type, Name, Comment, NumberOfItems, ViewerFn, BytesPerElement)
This function is used to print inline arrays. Here Type is the type of the array, Name - name of the variable, Comment - an optional commentary, NumberOfItems - total number of items in the array, ViewerFn - a function that prints the elements of the array, BytesPerElement - number of bytes to read from the input file for each element of the array. All parameters (except for Comment) are mandatory. NumberOfItems and BytesPerElement must evaluate to a number. Type, Name and Comment must be strings. ViewerFn should expect one parameter, which is the ordinary ReaderData table.
This global variable defines the maximum number of visible elements in inline arrays. By default it is set to 64. If an inline array contains more than MaxInlineElements, then only the first MaxInlineElements items are printed and the rest is represented with an ellipsis. For example, when MaxInlineElements is set to 3 the output looks like this:
int Multipliers[2] = { 1, 2 }; int Scalers[128] = { 1, 2, 3, ... };An important note: the smaller is the MaxInlineElements value, the faster TempLuator works.
array(Type, Name, Fn, NumberOfItems, Comment)
This function lets you print arrays in a neat way by handling folding and indentation internally. Here Type is the type of each array element, Name - name of the array, Fn - function that processes array elements, Comment - an optional commentary. All parameters except for the Comment are mandatory. The Fn function is passed one parameter which is a string equal to the name of the array with appended zero-based index of the current element placed in square brackets.
Here is an example from the actual JPEG template (here ScanPars is a struct() defined function) and its output for the case when the number of image components in scan is 3:
local Ns = PeekUI8() BYTE("Ns", "Number of image components in scan") CrLf() array("struct ScanPars", "ScanPars", ScanPars, Ns)BYTE Ns = 3; // Number of image components in scan struct ScanPars ScanPars[3] = { struct ScanPars ScanPars[0] = { BYTE Cs = 1; // Scan component selector BYTE Td:4 = 0; // DC entropy coding table destination selector BYTE Ta:4 = 0; // AC entropy coding table destination selector }; struct ScanPars ScanPars[1] = { BYTE Cs = 2; // Scan component selector BYTE Td:4 = 1; // DC entropy coding table destination selector BYTE Ta:4 = 1; // AC entropy coding table destination selector }; struct ScanPars ScanPars[2] = { BYTE Cs = 3; // Scan component selector BYTE Td:4 = 1; // DC entropy coding table destination selector BYTE Ta:4 = 1; // AC entropy coding table destination selector }; };