Guide to the HP Structure Definition Language


Previous Contents Index


        StructMember1 LONGWORD SIGNED ALIGN; 
This ensures that the member is aligned, even if it is within an aggregate that is not aligned.


        StructMember1 LONGWORD SIGNED NOALIGN; 
No action will be taken to ensure that this member will be aligned.


        StructMember1 LONGWORD SIGNED BASEALIGN (4); 
Here, StructMember1 will have an offset that is a multiple of 16 ( 24 ).

basealign-option can either be an expression in parentheses or the name of a data type.

See also Section 3.2.2.3.

[DIMENSION [lbound:]hbound]

Specifies that the member is an array. If a single value is specified, that value indicates the number of elements in the array. Otherwise, lbound and hbound represent lower and upper bounds of the array, respectively (see Section 3.2.2.7).

[PREFIX prefix-string]

Specifies the prefix used to form the member name. For subaggregates, the prefix is used to form the names of subaggregate members. It may be any valid HP SDL name with 0 to 32 characters, may or may not be enclosed in quotation marks (" "), and may be null (see Section 3.2.2.2).

[TAG tag-string]

Specifies the tag used to form the member name. The tag is appended to the prefix, if a prefix was specified. It can have 0 to 32 alphabetic or numeric characters; the tag must be enclosed in quotation marks (" ") if it begins with a numeric character (see Section 3.2.2.2).

[FILL]

Indicates that the specified member or aggregate occurs only as a fill to force byte alignment on the following member or aggregate, respectively. In some languages, filler member and aggregate declarations do not appear in the output file.

aggregate-body

Is one or more of the following:

END [ aggregate-name ]

Marks the end of the AGGREGATE or subaggregate declaration. The aggregate-name, if specified, must match the name on the most recently specified AGGREGATE or subaggregate declaration.

CONSTANT Declaration

The following sections describe the function and format of a CONSTANT declaration.

4.7 CONSTANT Description

A CONSTANT declaration generates a list of one or more named constants in the output file. You may specify a valid constant name or names and the constant values to be assigned to them. For example:


CONSTANT block_node_size EQUALS 24; 
 
CONSTANT Strcon EQUALS STRING "This is a string constant" PREFIX Jg$ 

The first declaration creates the named constant block_node_size and assigns it the value 24. The second declaration creates the named string constant Strcon and assigns it the specified value.

The values of both declared constants (except string constants) and local symbols may be used in HP SDL expressions. However, there is an important difference between declared constants and local symbols: declared constants are translated directly to the output file, whereas local symbols are not passed directly to the output file. For example, you can define the local symbol #block_size as follows:


#block_size = 24; 

A subsequent CONSTANT declaration may refer to #block_size and use the value 24, as follows:


CONSTANT block_node_size EQUALS #block_size; 

CONSTANT declarations (except string constants) can also be specified in a comma-delimited list, as follows:


CONSTANT 
 xyz EQUALS 10, 
 alpha EQUALS 0, 
 noname EQUALS 63; 

To specify related constants with the same or incremental values, use a CONSTANT declaration with the INCREMENT option. In this form, the EQUALS expression gives the value to be assigned to the first named constant; values for subsequent constants are derived by incrementing the first value by the specified increment and assigning the result to the next name in the list. For example:


CONSTANT ( 
        bits, 
        bytes, 
        words, 
        longs, 
        quads, 
        octas 
        ) EQUALS 0 INCREMENT 1 PREFIX ctx$; 

When HP SDL assigns incremental values, it loops until values are assigned to all the names in a list. If there is no INCREMENT clause, the increment value is 0; thus, the same initial value is assigned to all the names. If names are omitted from a comma-delimited list, HP SDL reserves the numbers that would be assigned to names in those positions. This lets you reserve numeric values for later assignment of names. For example:


CONSTANT 
 (bad_block,bad_data,,,, 
  overlay,rewrite) EQUALS 0 INCREMENT 4; 

In the previous example, HP SDL assigns the values 0 and 4 to the names bad_block and bad_data, reserves the values 8, 12, and 16, and assigns the values 20 and 24 to the names overlay and rewrite.

The COUNTER option saves the last assigned value in a specified local symbol for subsequent use. For example:


CONSTANT (pli,c,bliss,macro) 
  EQUALS 4 INCREMENT 4 PREFIX lang$ 
  COUNTER #lang; 
 
CONSTANT (basic,pascal,fortran) 
   EQUALS #lang + 4 INCREMENT 4 PREFIX lang$; 

The following table shows the constant names produced by these two declarations.
Constant Name Value
lang$k_pli 4
lang$k_c 8
lang$k_bliss 12
lang$k_macro 16
lang$k_basic 20
lang$k_pascal 24
lang$k_fortran 28

You can comment individual declarations in a CONSTANT declaration list. For example:


CONSTANT( 
        pli,    /* PL/I 
        c,      /* C 
        macro   /* MACRO-32 
        ) EQUALS 4 INCREMENT 4 PREFIX lang$; 

Defining Global Constants in HP MACRO

HP SDL does not directly generate definitions for global symbols (constants), but instead generates local constant definitions. The HP MACRO back end, however, generates all declarations within macros so that they can be invoked with arguments that will produce global definitions.

HP SDL also produces HP MACRO output declarations that can generate global definitions when an invocation of the macro is assembled. In the following example, the HP SDL module $IODEF contains the following constant declarations:


CONSTANT ( 
 nop, 
 unload, 
 loadmcode, 
 seek, 
 spacefile, 
 startmproc, 
 recal, 
 stop, 
 drvclr, 
 initialize) EQUALS 0 INCREMENT 1 PREFIX "io$"; 

The HP MACRO output generated by this declaration is a macro definition that must be invoked as follows in order to result in global rather than local constant definitions:


$IODEF <= => 

This argument results in global constant definitions rather than local constant definitions. To request that the locations of data fields be defined globally, add the argument <::> following <= =>.

4.8 CONSTANT Format

A CONSTANT declaration has the following syntax:


CONSTANT constant-name constant-class 
 
    constant-class = { EQUALS expression numeric-options } 
                     { EQUALS STRING string string-options } 
 
    numeric-options = [ PREFIX prefix-string ] 
 
                      [ TAG tag-string ] 
 
                      [ COUNTER #local-name ] 
 
                      [ TYPENAME type-name ] ; 
 
    string-options = [ PREFIX prefix-string ] 
 
                     [ TAG tag-string ] ; 
 
CONSTANT (constant-name,...) EQUALS expression 
 
                 [ INCREMENT expression ] 
 
                 [ PREFIX prefix-string ] 
 
                 [ TAG tag-string ] 
 
                 [ COUNTER #local-name ] 
 
                 [ TYPENAME type-name ]; 
 
CONSTANT  (constant-name,...) EQUALS expression, 
                   . 
                   . 
                   . 
   ; 

CONSTANT constant-name

Specifies any valid HP SDL name used to identify the constant.

When more than one name is specified, separate the names with commas and enclose the list in parentheses.

EQUALS expression

EQUALS STRING string

Specifies the value to be assigned to the constant.

[PREFIX prefix-string]

Specifies the prefix used to form the constant name. It may be any valid HP SDL name with 0 to 32 characters, may or may not be enclosed in quotation marks (" "), and may be null (see Section 3.2.2.2).

[TAG tag-string]

Specifies the tag used to form the constant name. The tag is appended to the prefix, if a prefix was specified. It can have 0 to 32 alphabetic or numeric characters; the tag must be enclosed in quotation marks (" ") if it begins with a numeric character (see Section 3.2.2.2).

[COUNTER #local-name]

Specifies the local symbol assigned to the last value that is assigned to a constant in the list.

[TYPENAME type-name]

Specifies a named data type that is not a HP SDL data type.

(constant-name,...)

Is a list of valid names.

A constant-name in this list can be null, though the list itself cannot be null. If a member of the list is null, the corresponding value is reserved.

If INCREMENT is not specified, all names are assigned the value specified in the EQUALS expression.

[INCREMENT expression]

Specifies the value to be added to the EQUALS expression for each iteration of HP SDL's generation of named CONSTANT declarations. It must be a valid HP SDL integer expression. HP SDL assigns the value of the EQUALS expression to the first constant name; the value of the INCREMENT expression is added to the EQUALS expression and assigned to the next constant name.

ENTRY Declaration

The following sections describe the function and format of the ENTRY declaration.

4.9 ENTRY Description

An ENTRY declaration produces an external procedure or function declaration in the output file. You must specify a valid entry name on the ENTRY declaration. You may also specify any or all of the ENTRY declaration options described in Table 3-2 in Section 3.2.2 and shown within the context of an ENTRY declaration in Section 4.10.

The following example shows the ENTRY declaration for the VMS system service SYS$GETJPI:


ENTRY SYS$GETJPI ALIAS $GETJPI PARAMETER ( 
   LONGWORD UNSIGNED VALUE NAMED EFN DEFAULT 0 TYPENAME EFNUM, 
   LONGWORD UNSIGNED NAMED PIDADR IN OUT DEFAULT 0 TYPENAME PROCID, 
   CHARACTER DESCRIPTOR NAMED PRCNAM IN DEFAULT 0 TYPENAME PROCNAME, 
   ANY NAMED ITMLST IN TYPENAME ITEMLIST, 
   QUADWORD UNSIGNED NAMED IOSB OUT DEFAULT 0 TYPENAME IOSB, 
   ADDRESS(ENTRY) NAMED ASTADR DEFAULT 0 TYPENAME ASTADR, 
   LONGWORD UNSIGNED VALUE NAMED ASTPRM DEFAULT 0 TYPENAME USERPARM 
   ) RETURNS LONGWORD TYPENAME CONDVALU; 

4.10 ENTRY Format

An ENTRY declaration has the following syntax:


ENTRY entry-name [ ALIAS internal-name ] 
 
                 [ PARAMETER (param-desc,...) ] 
 
                 [ LINKAGE link-name ]; 
 
                 [ VARIABLE ] 
 
                 [ RETURNS return-data-type   [ NAMED param-name ] ] 
 
                 [ TYPENAME type-name ]; 

ENTRY entry-name

Specifies any valid HP SDL name used to name the external entry point.

[ALIAS internal-name]

Specifies an alternate internal name used to designate the entry point.

[PARAMETER (param-desc,...)]

Describes the parameters of the external entry, if any. Param-desc must be specified as follows:


{ data-type      }   [ DESCRIPTOR   ]       [ IN  ] 
{ aggregate-name }   [ RTL_STR_DESC ] 
                     [ VALUE        ]       [ OUT ] 
                     [ REFERENCE    ] 
                                            [ NAMED param-name ] 
 
                                            [ DIMENSION expression ] 
 
                                            [ DEFAULT constant-value ] 
 
                                            [ TYPENAME type-name ] 
 
                                            [ OPTIONAL ] 
 
                                            [ LIST ] 

{data-type}

Is any valid HP SDL data type.

{aggregate-name}

Is the name of a previously declared aggregate that describes the data type of the parameter.

[DESCRIPTOR]

Indicates that the parameter is passed by descriptor.

[RTL_STR_DESC]

Indicates that the parameter can be passed by any of the classes of string descriptors. The data type must be CHARACTER. For example:


ENTRY xyz PARAMETER ( CHARACTER RTL_STR_DESC ); 

[VALUE]

Indicates that the parameter is passed by immediate value.

[REFERENCE]

Indicates that the parameter is passed by reference. REFERENCE is the default.

[IN]

Indicates an input parameter. IN is the default.

[OUT]

Indicates an output parameter.

[NAMED param-name]

Specifies the parameter name.

[DIMENSION expression]

Is the number of elements of an array parameter.

If expression is an asterisk (*), the number of dimensions depends on the dimensions of the actual parameter.

[DEFAULT constant-value]

Specifies a default value for a parameter. In languages supporting this option, the omission of an actual parameter is allowed.

[TYPENAME type-name]

Specifies a named data type that is not a HP SDL data type.

[OPTIONAL]

Specifies that the parameter may or may not appear in the sequence of (keyword) parameters for a call using the entry point name. This is supported only in HP Ada, HP BASIC, HP BLISS, HP MACRO, and Kednos PL/I output.

[LIST]

Indicates that the routine may be called with one or more parameters of the type being described. LIST may be specified only for the last parameter.

Note

All the PARAMETER options, if specified, must follow the data type or aggregate-name in the declaration.

[LINKAGE link-name]

Specifies (for HP MACRO only) that a special call macro (spelled "link-name") will be used in the expansion of the entry macro.

[VARIABLE]

Indicates that not all parameters are described; that is, the entry point has a variable number of parameters and not all corresponding arguments need be present in the argument list when the entry point is invoked. See also the description of the LIST parameter option.

[RETURNS return-data-type [NAMED param-name]]

Specifies the data type and, optionally, the name of the parameter returned by the external entry, if it is a function.

The VOID keyword cannot be used in a PARAMETER clause.

The syntax is:


    return-data-type = { data-type } 
                       { user-type sizeopt } 
                       { VOID } 
 

The argument user-type sizeopt specifies a user-defined type declared using the DECLARE statement's SIZEOF clause, shown and described in Section 3.10.

The return type VOID indicates that the procedure returns no value.

[TYPENAME type-name]

Specifies a named data type for the return value that is not a HP SDL data type.


Previous Next Contents Index