CHAP3
CHAP3
This chapter describes OMG Interface Definition Language (IDL) semantics and gives
the syntax for OMG IDL grammatical constructs.
Contents
This chapter contains the following sections.
“Overview” 3-2
“Lexical Conventions” 3-3
“Preprocessing” 3-9
“OMG IDL Grammar” 3-10
“OMG IDL Specification” 3-14
“Inheritance” 3-16
“Constant Declaration” 3-18
“Type Declaration” 3-22
“Exception Declaration” 3-30
“Operation Declaration” 3-31
“Attribute Declaration” 3-33
“CORBA Module” 3-34
“CORBA Module” 3-34
“Differences from C++” 3-37
“Standard Exceptions” 3-37
3.1 Overview
The OMG Interface Definition Language (IDL) is the language used to describe the
interfaces that client objects call and object implementations provide. An interface
definition written in OMG IDL completely defines the interface and fully specifies
each operation’s parameters. An OMG IDL interface provides the information needed
to develop clients that use the interface’s operations.
Clients are not written in OMG IDL, which is purely a descriptive language, but in
languages for which mappings from OMG IDL concepts have been defined. The
mapping of an OMG IDL concept to a client language construct will depend on the
facilities available in the client language. For example, an OMG IDL exception might
be mapped to a structure in a language that has no notion of exception, or to an
exception in a language that does. The binding of OMG IDL concepts to several
programming languages is described in this manual.
OMG IDL obeys the same lexical rules as C++ 1, although new keywords are
introduced to support distribution concepts. It also provides full support for standard
C++ preprocessing features. The OMG IDL specification is expected to track relevant
changes to C++ introduced by the ANSI standardization effort.
The OMG IDL grammar is a subset of the proposed ANSI C++ standard, with
additional constructs to support the operation invocation mechanism. OMG IDL is a
declarative language. It supports C++ syntax for constant, type, and operation
declarations; it does not include any algorithmic structures or variables. The grammar
is presented in “OMG IDL Grammar” on page 3-10.
OMG IDL-specific pragmas (those not defined for C++) may appear anywhere in a
specification; the textual location of these pragmas may be semantically constrained by
a particular implementation.
A source file containing interface specifications written in OMG IDL must have an
“.idl” extension. The file orb.idl contains OMG IDL type definitions and is available on
every ORB implementation.
1. Ellis, Margaret A. and Bjarne Stroustrup, The Annotated C++ Reference Manual, Add-
ison-Wesley Publishing Company, Reading, Massachusetts, 1990, ISBN 0-201-51459-1
The description of OMG IDL grammar uses a syntax notation that is similar to
Extended Backus-Naur Format (EBNF). Table 3-1 lists the symbols used in this format
and their meaning.
The first phase is preprocessing, which performs file inclusion and macro substitution.
Preprocessing is controlled by directives introduced by lines having # as the first
character other than white space. The result of preprocessing is a sequence of tokens.
Such a sequence of tokens, that is, a file after preprocessing, is called a translation unit.
OMG IDL uses the ISO Latin-1 (8859.1) character set. This character set is divided
into alphabetic characters (letters), digits, graphic characters, the space (blank)
character and formatting characters. Table 3-2 shows the OMG IDL alphabetic
characters; upper- and lower-case equivalencies are paired.
3.2.1 Tokens
There are five kinds of tokens: identifiers, keywords, literals, operators, and other
separators. Blanks, horizontal and vertical tabs, newlines, formfeeds, and comments
(collective, “white space”), as described below, are ignored except as they serve to
separate tokens. Some white space is required to separate otherwise adjacent
identifiers, keywords, and constants.
If the input stream has been parsed into tokens up to a given character, the next token
is taken to be the longest string of characters that could possibly constitute a token.
3.2.2 Comments
The characters /* start a comment, which terminates with the characters */. These
comments do not nest. The characters // start a comment, which terminates at the end
of the line on which they occur. The comment characters //, /*, and */ have no special
meaning within a // comment and are treated just like other characters. Similarly, the
comment characters // and /* have no special meaning within a /* comment. Comments
may contain alphabetic, digit, graphic, space, horizontal tab, vertical tab, form feed,
and newline characters.
3.2.3 Identifiers
An identifier is an arbitrarily long sequence of alphabetic, digit, and underscore (“_”)
characters. The first character must be an alphabetic character. All characters are
significant.
Identifiers that differ only in case collide and yield a compilation error. An identifier
for a definition must be spelled consistently (with respect to case) throughout a
specification.
There is only one namespace for OMG IDL identifiers. Using the same identifier for a
constant and an interface, for example, produces a compilation error.
3.2.4 Keywords
The identifiers listed in Table 3-6 are reserved for use as keywords and may not be
used otherwise.
Keywords obey the rules for identifiers (see“Identifiers” on page 3-6) and must be
written exactly as shown in the above list. For example, “boolean” is correct;
“Boolean” produces a compilation error. The keyword “Object” can be used as a
type specifier.
OMG IDL specifications use the characters shown in Table 3-7 as punctuation.
In addition, the tokens listed in Table 3-8 are used by the preprocessor.
3.2.5 Literals
This section describes the following literals:
• Integer
• Character
• Floating-point
• String
• Fixed-point
Integer Literals
An integer literal consisting of a sequence of digits is taken to be decimal (base ten)
unless it begins with 0 (digit zero). A sequence of digits starting with 0 is taken to be
an octal integer (base eight). The digits 8 and 9 are not octal digits. A sequence of
Character Literals
A character literal is one or more characters enclosed in single quotes, as in ’x’.
Character literals have type char.
A character is an 8-bit quantity with a numerical value between 0 and 255 (decimal).
The value of a space, alphabetic, digit, or graphic character literal is the numerical
value of the character as defined in the ISO Latin-1 (8859.1) character set standard
(See Table 3-2 on page 3-3, Table 3-3 on page 3-4, and Table 3-4 on page 3-4). The
value of a null is 0. The value of a formatting character literal is the numerical value of
the character as defined in the ISO 646 standard (See Table 3-5 on page 3-5). The
meaning of all other characters is implementation-dependent.
If the character following a backslash is not one of those specified, the behavior is
undefined. An escape sequence specifies a single character.
The escape \ooo consists of the backslash followed by one, two, or three octal digits
that are taken to specify the value of the desired character. The escape \xhh consists of
the backslash followed by x followed by one or two hexadecimal digits that are taken
to specify the value of the desired character. A sequence of octal or hexadecimal digits
is terminated by the first character that is not an octal digit or a hexadecimal digit,
respectively. The value of a character constant is implementation dependent if it
exceeds that of the largest char.
Wide character and wide string literals are specified exactly like character and string
literals. All character and string literals, both wide and non-wide, may only be
specified (portably) using the characters found in the ISO 8859-1 character set, that is
interface names, operation names, type names, etc., will continue to be limited to the
ISO 8859-1 character set.
Floating-point Literals
A floating-point literal consists of an integer part, a decimal point, a fraction part, an e
or E, and an optionally signed integer exponent. The integer and fraction parts both
consist of a sequence of decimal (base ten) digits. Either the integer part or the fraction
part (but not both) may be missing; either the decimal point or the letter e (or E) and
the exponent (but not both) may be missing.
String Literals
A string literal is a sequence of characters (as defined in “Character Literals” on page
3-8) surrounded by double quotes, as in "...".
Adjacent string literals are concatenated. Characters in concatenated strings are kept
distinct. For example,
"\xA" "B"
contains the two characters '\xA' and 'B' after concatenation (and not the single
hexadecimal character '\xAB').
The size of a string literal is the number of character literals enclosed by the quotes,
after concatenation. The size of the literal is associated with the literal. Within a string,
the double quote character " must be preceded by a \.
Fixed-Point Literals
A fixed-point decimal literal consists of an integer part, a decimal point, a fraction part
and a d or D. The integer and fraction parts both consist of a sequence of decimal (base
10) digits. Either the integer part or the fraction part (but not both) may be missing; the
decimal point (but not the letter d (or D)) may be missing.
3.3 Preprocessing
OMG IDL preprocessing, which is based on ANSI C++ preprocessing, provides macro
substitution, conditional compilation, and source file inclusion. In addition, directives
are provided to control line numbering in diagnostics and for symbolic debugging, to
Lines beginning with # (also called “directives”) communicate with this preprocessor.
White space may appear before the #. These lines have syntax independent of the rest
of OMG IDL; they may appear anywhere and have effects that last (independent of the
OMG IDL scoping rules) until the end of the translation unit. The textual location of
OMG IDL-specific pragmas may be semantically constrained.
A preprocessing directive (or any line) may be continued on the next line in a source
file by placing a backslash character (“\”), immediately before the newline at the end
of the line to be continued. The preprocessor effects the continuation by deleting the
backslash and the newline before the input sequence is divided into tokens. A
backslash character may not be the last character in a source file.
A preprocessing token is an OMG IDL token (see “Tokens” on page 3-6), a file name
as in a #include directive, or any single character other than white space that does not
match another preprocessing token.
The primary use of the preprocessing facilities is to include definitions from other
OMG IDL specifications. Text in files included with a #include directive is treated as
if it appeared in the including file. A complete description of the preprocessing
facilities may be found in The Annotated C++ Reference Manual. The #pragma
directive that is used to include RepositoryIds is described in Section 8.6,
“RepositoryIds,” on page 8-32.
| <unsigned_longlong_int>
(45) <unsigned_short_int> ::= “unsigned” “short”
(46) <unsigned_long_int> ::= “unsigned” “long”
(47) <unsigned_longlong_int> ::= “unsigned” “long” “long”
(48) <char_type> ::= “char”
(49) <wide_char_type> ::= “wchar”
(50) <boolean_type> ::= “boolean”
(51) <octet_type> ::= “octet”
(52) <any_type> ::= “any”
(53) <object_type> ::= “Object”
(54) <struct_type> ::= “struct” <identifier> “{” <member_list> “}”
(55) <member_list> ::= <member>+
(56) <member> ::= <type_spec> <declarators> “;”
(57) <union_type> ::= “union” <identifier> “switch” “(”
<switch_type_spec> “)” “{” <switch_body>
“}”
(58) <switch_type_spec> ::= <integer_type>
| <char_type>
| <boolean_type>
| <enum_type>
| <scoped_name>
(59) <switch_body> ::= <case>+
(60) <case> ::= <case_label>+ <element_spec> “;”
(61) <case_label> ::= “case” <const_exp> “:”
| “default” “:”
(62) <element_spec> ::= <type_spec> <declarator>
(63) <enum_type> ::= “enum” <identifier> “{” <enumerator> { “,”
<enumerator> }∗ “}”
(64) <enumerator> ::= <identifier>
(65) <sequence_type> ::= “sequence” “<” <simple_type_spec> “,”
<positive_int_const> “>”
| “sequence” “<” <simple_type_spec> “>”
(66) <string_type> ::= “string” “<” <positive_int_const> “>”
| “string”
(67) <wide_string_type> ::= “wstring” “<” <positive_int_const> “>”
| “wstring”
(68) <array_declarator> ::= <identifier> <fixed_array_size>+
(69) <fixed_array_size> ::= “[” <positive_int_const> “]”
(70) <attr_dcl> ::= [ “readonly” ] “attribute”
<param_type_spec> <simple_declarator> {
“,” <simple_declarator> }*
(71) <except_dcl> ::= “exception” <identifier> “{“ <member>* “}”
(72) <op_dcl> ::= [ <op_attribute> ] <op_type_spec> <identi-
fier> <parameter_dcls> [ <raises_expr> ] [
<context_expr> ]
(73) <op_attribute> ::= “oneway”
<specification>::=<definition>+
<definition>::=<type_dcl> “;”
| <const_dcl> “;”
| <except_dcl> “;”
| <interface> “;”
| <module> “;”
See “Constant Declaration” on page 3-18, “Type Declaration” on page 3-22, and
“Exception Declaration” on page 3-30, respectively, for specifications of
<const_dcl>, <type_dcl>, and <except_dcl>.
The module construct is used to scope OMG IDL identifiers; see “CORBA Module” on
page 3-34 for details.
Interface Header
The interface header consists of two elements:
• The interface name. The name must be preceded by the keyword interface, and
consists of an identifier that names the interface.
• An optional inheritance specification. The inheritance specification is described in
the next section.
The <identifier> that names an interface defines a legal type name. Such a type name
may be used anywhere an <identifier> is legal in the grammar, subject to semantic
constraints as described in the following sections. Since one can only hold references
to an object, the meaning of a parameter or structure member which is an interface
type is as a reference to an object supporting that interface. Each language binding
describes how the programmer must represent such interface references.
Inheritance Specification
The syntax for inheritance is as follows:
Interface Body
The interface body contains the following kinds of declarations:
• Constant declarations, which specify the constants that the interface exports;
constant declaration syntax is described in “Constant Declaration” on page 3-18.
• Type declarations, which specify the type definitions that the interface exports;
type declaration syntax is described in “Type Declaration” on page 3-22.
• Exception declarations, which specify the exception structures that the interface
exports; exception declaration syntax is described in “Exception Declaration” on
page 3-30.
• Attribute declarations, which specify the associated attributes exported by the
interface; attribute declaration syntax is described in “Attribute Declaration” on
page 3-33.
• Operation declarations, which specify the operations that the interface exports and
the format of each, including operation name, the type of data returned, the types
of all parameters of an operation, legal exceptions which may be returned as a
result of an invocation, and contextual information which may affect method
dispatch; operation declaration syntax is described in “Operation Declaration” on
page 3-31.
Forward Declaration
A forward declaration declares the name of an interface without defining it. This
permits the definition of interfaces that refer to each other. The syntax consists simply
of the keyword interface followed by an <identifier> that names the interface. The
actual definition must follow later in the specification.
3.6 Inheritance
An interface can be derived from another interface, which is then called a base
interface of the derived interface. A derived interface, like all interfaces, may declare
new elements (constants, types, attributes, exceptions, and operations). In addition,
unless redefined in the derived interface, the elements of a base interface can be
referred to as if they were elements of the derived interface. The name resolution
operator (“::”) may be used to refer to a base element explicitly; this permits reference
to a name that has been redefined in the derived interface.
A derived interface may redefine any of the type, constant, and exception names which
have been inherited; the scope rules for such names are described in “CORBA
Module” on page 3-34.
An interface may be derived from any number of base interfaces. Such use of more
than one direct base interface is often called multiple inheritance. The order of
derivation is not significant.
An interface may not be specified as a direct base interface of a derived interface more
than once; it may be an indirect base interface more than once. Consider the following
example:
interface A { ... }
interface B: A { ... }
interface C: A { ... }
interface D: B, C { ... }
The relationships between these interfaces is shown in Figure on page 3-17. This
“diamond” shape is legal.
B C
const long L = 3;
interface A {
typedef float coord[L]):
void f (in coord s); // s has three floats
};
interface B {
const long L = 4;
};
The early binding of constants, types, and exceptions at interface definition guarantees
that the signature of operation f in interface C is
Interface inheritance causes all identifiers in the closure of the inheritance tree to be
imported into the current naming scope. A type name, constant name, enumeration
value name, or exception name from an enclosing scope can be redefined in the current
scope. An attempt to use an ambiguous name without qualification is a compilation
error.
Operation names are used at run-time by both the stub and dynamic interfaces. As a
result, all operations that might apply to a particular object must have unique names.
This requirement prohibits redefining an operation name in a derived interface, as well
as inheriting two operations with the same name.
3.7.1 Syntax
The syntax for a constant declaration is:
| <string_type>
| <scoped_name>
<const_exp> ::= <or_expr>
<or_expr> ::= <xor_expr>
| <or_expr> “|” <xor_expr>
<xor_expr> ::= <and_expr>
| <xor_expr> “^” <and_expr>
<and_expr> ::= <shift_expr>
| <and_expr> “&” <shift_expr>
<shift_expr> ::= <add_expr>
| <shift_expr> “>>” <add_expr>
| <shift_expr> “<<” <add_expr>
<add_expr> ::= <mult_expr>
| <add_expr> “+” <mult_expr>
| <add_expr> “-” <mult_expr>
<mult_expr> ::= <unary_expr>
| <mult_expr> “*” <unary_expr>
| <mult_expr> “/” <unary_expr>
| <mult_expr> “%” <unary_expr>
<unary_expr> ::= <unary_operator> <primary_expr>
| <primary_expr>
<unary_operator> ::= “-”
| “+”
| “~”
<primary_expr> ::= <scoped_name>
| <literal>
| “(” <const_exp> “)”
<literal> ::= <integer_literal>
| <string_literal>
| <character_literal>
| <floating_pt_literal>
| <boolean_literal>
<boolean_literal> ::= “TRUE”
| “FALSE”
<positive_int_const> ::= <const_exp>
3.7.2 Semantics
The <scoped_name> in the <const_type> production must be a previously defined
name of an <integer_type>, <char_type>, <wide_ char_type>,
<boolean_type>, <floating_pt_type>, <fixed_pt_const_type>, <string_type>,
or <wide_string_type> constant.
An infix operator can combine two integers, floats or fixeds, but not mixtures of these.
Infix operators are applicable only to integer, float and fixed types.
If the type of an integer constant is long or unsigned long, then each subexpression
of the associated constant expression is treated as an unsigned long by default, or a
signed long for negated literals or negative integer constants. It is an error if any
subexpression values exceed the precision of the assigned type (long or unsigned
long), or if a final expression value (of type unsigned long) exceeds the precision of
the target type (long).
If the type of an integer constant is long long or unsigned long long, then each
subexpression of the associated constant expression is treated as an unsigned long
long by default, or a signed long long for negated literals or negative integer
constants. It is an error if any subexpression values exceed the precision of the
assigned type (long long or unsigned long long), or if a final expression value (of
type unsigned long long) exceeds the precision of the target type (long long).
If the type of a floating-point constant is long double, then each subexpression of the
associated constant expression is treated as a long double. It is an error if any
subexpression value exceeds the precision of long double.
Op Result: fixed<d,s>
+ fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1, max(s1,s2)>
- fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1, max(s1,s2)>
* fixed<d1+d2, s1+s2>
/ fixed<(d1-s1+s2) + sinf , sinf>
A quotient may have an arbitrary number of decimal places, denoted by a scale of s inf.
The computation proceeds pairwise, with the usual rules for left-to-right association,
operator precedence, and parentheses. If an individual computation between a pair of
fixed-point literals actually generates more than 31 significant digits, then a 31-digit
result is retained as follows:
Leading and trailing zeros are not considered significant. The omitted digits are
discarded; rounding is not performed. The result of the individual computation then
proceeds as one literal operand of the next pair of fixed-point literals to be computed.
The “~” unary operator indicates that the bit-complement of the expression to which it
is applied should be generated. For the purposes of such expressions, the values are 2’s
complement numbers. As such, the complement can be generated as follows:
The “%” binary operator yields the remainder from the division of the first expression
by the second. If the second operand of “%” is 0, the result is undefined; otherwise
(a/b)*b + a%b
is equal to a. If both operands are nonnegative, then the remainder is nonnegative; if
not, the sign of the remainder is implementation dependent.
The “<<”binary operator indicates that the value of the left operand should be shifted
left the number of bits specified by the right operand, with 0 fill for the vacated bits.
The right operand must be in the range 0 <= right operand < 64.
The “>>” binary operator indicates that the value of the left operand should be shifted
right the number of bits specified by the right operand, with 0 fill for the vacated bits.
The right operand must be in the range 0 <= right operand < 64.
The “&” binary operator indicates that the logical, bitwise AND of the left and right
operands should be generated.
The “|” binary operator indicates that the logical, bitwise OR of the left and right
operands should be generated.
The “^” binary operator indicates that the logical, bitwise EXCLUSIVE-OR of the left
and right operands should be generated.
For type declarations, OMG IDL defines a set of type specifiers to represent typed
values. The syntax is as follows:
<type_spec> ::= <simple_type_spec>
| <constr_type_spec>
<simple_type_spec> ::= <base_type_spec>
| <template_type_spec>
| <scoped_name>
<base_type_spec> ::= <floating_pt_type>
| <integer_type>
| <char_type>
| <wide_char_type>
| <boolean_type>
| <octet_type>
| <any_type>
<template_type_spec>::=<sequence_type>
| <string_type>
| <wide_string_type>
| <fixed_pt_type>
<constr_type_spec> ::= <struct_type>
| <union_type>
| <enum_type>
<declarators>::=<declarator> { “,” <declarator> }∗
<declarator> ::= <simple_declarator>
| <complex_declarator>
<simple_declarator> ::= <identifier>
<complex_declarator> ::= <array_declarator>
As seen above, OMG IDL type specifiers consist of scalar data types and type
constructors. OMG IDL type specifiers can be used in operation declarations to assign
data types to operation parameters. The next sections describe basic and constructed
type specifiers.
Each OMG IDL data type is mapped to a native data type via the appropriate language
mapping. Conversion errors between OMG IDL data types and the native types to
which they are mapped can occur during the performance of an operation invocation.
The invocation mechanism (client stub, dynamic invocation engine, and skeletons) may
signal an exception condition to the client if an attempt is made to convert an illegal
value. The standard exceptions which are to be signalled in such situations are defined
in “Standard Exceptions” on page 3-37.
Integer Types
OMG IDL integer types are short, unsigned short, long, unsigned long, long
long and unsigned long long, representing integer values in the range indicated
below in Table 3-10.
Floating-Point Types
OMG IDL floating-point types are float, double and long double. The float type
represents IEEE single-precision floating point numbers; the double type represents
IEEE double-precision floating point numbers.The long double data type represents
an IEEE double-extended floating-point number, which has an exponent of at least 15
bits in length and a signed fraction of at least 64 bits. See IEEE Standard for Binary
Floating-Point Arithmetic, ANSI/IEEE Standard 754-1985, for a detailed specification.
Char Type
OMG IDL defines a char data type that is an 8-bit quantity which (1) encodes a
single-byte character from any byte-oriented code set, or (2) when used in an array,
encodes a multi-byte character from a multi-byte code set. In other words, an
implementation is free to use any code set internally for encoding character data,
though conversion to another form may be required for transmission.
The ISO 8859-1 (Latin1) character set standard defines the meaning and representation
of all possible graphic characters used in OMG IDL (i.e., the space, alphabetic, digit
and graphic characters defined in Table 3-2 on page 3-3, Table 3-3 on page 3-4, and
Table 3-4 on page 3-4). The meaning and representation of the null and formatting
characters (see Table 3-5 on page 3-5) is the numerical value of the character as
defined in the ASCII (ISO 646) standard. The meaning of all other characters is
implementation-dependent.
Boolean Type
The boolean data type is used to denote a data item that can only take one of the
values TRUE and FALSE.
Octet Type
The octet type is an 8-bit quantity that is guaranteed not to undergo any conversion
when transmitted by the communication system.
Any Type
The any type permits the specification of values that can express any OMG IDL type.
Although the IDL syntax allows the generation of recursive constructed type
specifications, the only recursion permitted for constructed types is through the use of
the sequence template type. For example, the following is legal:
struct foo {
long value;
sequence<foo> chain;
}
See “Sequences” on page 3-27 for details of the sequence template type.
Structures
The structure syntax is:
<struct_type> ::= “struct” <identifier> “{” <member_list> “}”
<member_list> ::= <member>+
<member> ::= <type_spec> <declarators> “;”
The <identifier> in <struct_type> defines a new legal type. Structure types may
also be named using a typedef declaration.
Name scoping rules require that the member declarators in a particular structure be
unique. The value of a struct is the value of all of its members.
Discriminated Unions
The discriminated union syntax is:
<union_type> ::= “union” <identifier> “switch” “(”
<switch_type_spec> “)”
“{” <switch_body> “}”
<switch_type_spec> ::= <integer_type>
| <char_type>
| <boolean_type>
| <enum_type>
| <scoped_name>
<switch_body> ::= <case>+
<case> ::= <case_label>+ <element_spec> “;”
<case_label> ::= “case” <const_exp> “:”
| “default” “:”
<element_spec> ::= <type_spec> <declarator>
OMG IDL unions are a cross between the C union and switch statements. IDL
unions must be discriminated; that is, the union header must specify a typed tag field
that determines which union member to use for the current instance of a call. The
<identifier> following the union keyword defines a new legal type. Union types may
also be named using a typedef declaration. The <const_exp> in a <case_label>
must be consistent with the <switch_type_spec>. A default case can appear at most
once. The <scoped_name> in the <switch_type_spec> production must be a
previously defined integer, char, boolean or enum type.
Case labels must match or be automatically castable to the defined type of the
discriminator. The complete set of matching rules are shown in Table 3-11.
Name scoping rules require that the element declarators in a particular union be
unique. If the <switch_type_spec> is an <enum_type>, the identifier for the
enumeration is in the scope of the union; as a result, it must be distinct from the
element declarators.
It is not required that all possible values of the union discriminator be listed in the
<switch_body>. The value of a union is the value of the discriminator together with
one of the following:
• If the discriminator value was explicitly listed in a case statement, the value of
the element associated with that case statement;
• If a default case label was specified, the value of the element associated with the
default case label;
• No additional value.
Enumerations
Enumerated types consist of ordered lists of identifiers. The syntax is:
<enum_type> ::= “enum” <identifier> “{” <enumerator> { “,”
<enumerator> }∗ “}”
<enumerator > ::= <identifier>
Sequences
OMG IDL defines the sequence type sequence. A sequence is a one-dimensional
array with two characteristics: a maximum size (which is fixed at compile time) and a
length (which is determined at run time).
The second parameter in a sequence declaration indicates the maximum size of the
sequence. If a positive integer constant is specified for the maximum size, the sequence
is termed a bounded sequence. Prior to passing a bounded sequence as a function
argument (or as a field in a structure or union), the length of the sequence must be set
in a language-mapping dependent manner. After receiving a sequence result from an
operation invocation, the length of the returned sequence will have been set; this value
may be obtained in a language-mapping dependent manner.
A sequence type may be used as the type parameter for another sequence type. For
example, the following:
Strings
OMG IDL defines the string type string consisting of all possible 8-bit quantities
except null. A string is similar to a sequence of char. As with sequences of any type,
prior to passing a string as a function argument (or as a field in a structure or union),
the length of the string must be set in a language-mapping dependent manner. The
syntax is:
The argument to the string declaration is the maximum size of the string. If a positive
integer maximum size is specified, the string is termed a bounded string; if no
maximum size is specified, the string is termed an unbounded string.
Strings are singled out as a separate type because many languages have special built-in
functions or standard library functions for string manipulation. A separate string type
may permit substantial optimization in the handling of strings compared to what can be
done with sequences of general types.
Fixed Type
The fixed data type represents a fixed-point decimal number of up to 31 significant
digits. The scale factor is normally a non-negative integer less than or equal to the total
number of digits (note that constants with effectively negative scale, such as 10000, are
always permitted.). However, some languages and environments may be able to
accommodate types that have a negative scale or a scale greater than the number of
digits.
Arrays
OMG IDL defines multidimensional, fixed-size arrays. An array includes explicit sizes
for each dimension.
The array size (in each dimension) is fixed at compile time. When an array is passed as
a parameter in an operation invocation, all elements of the array are transmitted.
This declaration defines a new type with the specified name. A native type is similar
to an IDL basic type. The possible values of a native type are language-mapping
dependent, as are the means for constructing them and manipulating them. Any
interface that defines a native type requires each language mapping to define how the
native type is mapped into that programming language.
A native type may be used to define operation parameters and results. However, there
is no requirement that values of the type be permitted in remote invocations, either
directly or as a component of a constructed type. Any attempt to transmit a value of a
native type in a remote invocation may raise the MARSHAL standard exception.
module HypotheticalObjectAdapter {
native Servant;
interface HOA {
Object activate_object(in Servant x);
};
};
CORBA::Object_ptr activate_object(
HypotheticalObjectAdapter::Servant x);
Note – The native type declaration is provided specifically for use in object adapter
interfaces, which require parameters whose values are concrete representations of
object implementation instances. It is strongly recommended that it not be used in
service or application interfaces. The native type declaration allows object adapters to
define new primitive types without requiring changes to the OMG IDL language or to
OMG IDL com
<op_attribute>::=“oneway”
When a client invokes an operation with the oneway attribute, the invocation
semantics are best-effort, which does not guarantee delivery of the call; best-effort
implies that the operation will be invoked at most once. An operation with the oneway
attribute must not contain any output parameters and must specify a void return type.
An operation defined with the oneway attribute may not include a raises expression;
invocation of such an operation, however, may raise a standard exception.
The run-time system guarantees to make the value (if any) associated with each
<string_literal> in the client’s context available to the object implementation when
the request is delivered. The ORB and/or object is free to use information in this
request context during request resolution and performance.
The mechanism by which a client associates values with the context identifiers is
described in the Dynamic Invocation Interface chapter.
The optional readonly keyword indicates that there is only a single accessor
function—the retrieve value function. Consider the following example:
interface foo {
enum material_t {rubber, glass};
struct position_t {
float x, y;
};
•••
};
•••
float _get_radius ();
void _set_radius (in float r);
material_t _get_material ();
void _set_material (in material_t m);
position_t _get_position ();
•••
The actual accessor function names are language-mapping specific. The C, C++, and
Smalltalk mappings are described in separate chapters. The attribute name is subject to
OMG IDL’s name scoping rules; the accessor function names are guaranteed not to
collide with any legal operation names specifiable in OMG IDL.
Due to possible restrictions imposed by future language bindings, OMG IDL identifiers
are case insensitive; that is, two identifiers that differ only in the case of their
characters are considered redefinitions of one another. However, all references to a
definition must use the same case as the defining occurrence. (This allows natural
mappings to case-sensitive languages.)
Type names defined in a scope are available for immediate use within that scope. In
particular, see “Constructed Types” on page 3-25 on cycles in type definitions.
When a qualified name begins with “::”, the resolution process starts with the file
scope and locates subsequent identifiers in the qualified name by the rule described in
the previous paragraph.
Every OMG IDL definition in a file has a global name within that file. The global
name for a definition is constructed as follows.
Prior to starting to scan a file containing an OMG IDL specification, the name of the
current root is initially empty (“”) and the name of the current scope is initially empty
(“”). Whenever a module keyword is encountered, the string “::” and the associated
identifier are appended to the name of the current root; upon detection of the
termination of the module, the trailing “::” and identifier are deleted from the name of
the current root. Whenever an interface, struct, union, or exception keyword is
encountered, the string “::” and the associated identifier are appended to the name of
the current scope; upon detection of the termination of the interface, struct, union,
or exception, the trailing “::” and identifier are deleted from the name of the current
scope. Additionally, a new, unnamed, scope is entered when the parameters of an
operation declaration are processed; this allows the parameter names to duplicate other
identifiers; when parameter processing has completed, the unnamed scope is exited.
The global name of an OMG IDL definition is the concatenation of the current root,
the current scope, a “::”, and the <identifier>, which is the local name for that
definition.
Note that the global name in an OMG IDL files corresponds to an absolute
ScopedName in the Interface Repository. (See “Supporting Type Definitions” on
page 8-9).
Inheritance produces shadow copies of the inherited identifiers; that is, it introduces
names into the derived interface, but these names are considered to be semantically the
same as the original definition. Two shadow copies of the same original (as results
from the diamond shape in Figure 3-1 on page 3-17) introduce a single name into the
derived interface and don’t conflict with each other.
Inheritance introduces multiple global OMG IDL names for the inherited identifiers.
Consider the following example:
interface A {
exception E {
long L;
};
void f() raises(E);
};
interface B: A {
void g() raises(E);
};
In this example, the exception is known by the global names ::A::E and ::B::E.
Ambiguity can arise in specifications due to the nested naming scopes. For example:
interface A {
typedef string<128> string_t;
};
interface B {
typedef string<256> string_t;
};
interface C: A, B {
attribute string_t Title;/* AMBIGUOUS!!! */
};
The attribute declaration in C is ambiguous, since the compiler does not know which
string_t is desired. Ambiguous declarations yield compilation errors.
In order to bound the complexity in handling the standard exceptions, the set of
standard exceptions should be kept to a tractable size. This constraint forces the
definition of equivalence classes of exceptions rather than enumerating many similar
exceptions. For example, an operation invocation can fail at many different points due
to the inability to allocate dynamic memory. Rather than enumerate several different
exceptions corresponding to the different ways that memory allocation failure causes
the exception (during marshalling, unmarshalling, in the client, in the object
implementation, allocating network packets, ...), a single exception corresponding to
dynamic memory allocation failure is defined. Each standard exception includes a
minor code to designate the subcategory of the exception; the assignment of values to
the minor codes is left to each ORB implementation.
Each standard exception also includes a completion_status code which takes one of
the values {COMPLETED_YES, COMPLETED_NO, COMPLETED_MAYBE}.
These have the following meanings:
Bridges forward this exception to clients, also destroying any records they may hold
(for example, proxy objects used in reference translation). The clients could in turn
purge any of their own data structures.