|
CS 696 Emerging Technologies: Distributed Objects |
|
---|
Spring Semester, 1998
CORBA IDL
To Lecture Notes Index
© 1998, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 21-Apr-98
Contents of Doc 20, CORBA IDL
- References
- Overview
- Module
- Interface
- Basic Data Types
- Basic Data Types - Java Mappings
CORBA Specification V2.1 Chapter 3 OMG IDL Syntax and Semantics, August 1997
CORBA Specification V2.2 Chapter 24, Mapping of OMG IDL to Java, February
1998
OrbixWeb Programmer's Guide, IONA Technologies PLC, November 1997,
chapter 5 Introduction to CORBA IDL, chapter 6 IDL to Java Mapping pp 79 -
140
Iona's IDL compiler
OMG IDL is purely a descriptive language
OMG IDL obeys the same lexical rules as C++
OMG IDL grammar is a subset of ANSI C++ standard with additional constructs to
support operation invocation mechanism
Uses C/C++ #includes and #pragma preprocessor commands
Basics
/* standard C/C++ comments
*/
// standard C++ comments
An identifiers is an arbitrarily long sequence of alphabetic, digits, and
underscore("_") characters
First character must be alphabetic
All characters are significant
IDL is NOT case sensitive, that is NOT == not == NoT
All files containing IDL must end in '.idl' or '.IDL'
CORBA_USES_THE_UNDERSCORE_TO separate words in a name
Keywords
any | double | interface | readonly | unsigned |
attribute | enum | long | sequence | union |
boolean | exception | module | short | void |
case | FALSE | Object | string | wchar |
char | fixed | octet | struct | wstring |
const | float | oneway | switch | |
context | in | out | TRUE | |
default | inout | raises | typedef | |
Keywords must be typed as given above
Boolean will result in a compile error
Literals
Integer
- 12
- 014
- 0XC
Character
- 8 bit with value between 0 and 255
-
- Uses ISO Latin-1 character set
-
Standard Escape Sequences
newline | \n |
horizontal tab | \t |
backspace | \b |
carriage return | \t |
form feed | \f |
alert | \a |
backslash | \\ |
question mark | \? |
single quote | \' |
double quote | \" |
octal number | \000 |
hex number | \xhh |
Floating-point Literals
- 123.321e12
- 123.321E12
- 123.321
- .123
- 123.
Fixed-Point Literals
- 123.321d
- 123.321D
- .123d
- 123.d
String Literals
- "hi Mom"
-
- Adjacent literals are concatenated
- "this is""a test" = "this isa test"
-
- Characters in concatenated strings are kept distinct
- "\xA""B"
-
- has two characters after concatenation: '\xA' and 'B'
-
- A string literal may not contain '\0' (zero)
Module defines a name space, like Java's package
Module is mapped to a package in Java
Interface is mapped to a Java interface
Module Example
module Bank
{
interface Account
{
readonly attribute float balance;
};
}; // yes you need these semi-colons
Module compiled to Java
//
// Java generated by the OrbixWeb IDL compiler
//
package Bank;
public interface Account
extends org.omg.CORBA.Object
{
public float balance();
public java.lang.Object _deref() ;
}
Modules can span several files
Modules can be reopened
The scoping operator is ::
File Bank.idl
module Bank
{
interface Account
{
readonly attribute float balance;
};
}; // yes you need these ';'
module Security
{
interface Algorithms
{
string MD5(in float data);
// using the scoping operator here
Bank::Account idToAccount( in string id);
};
};
// reopening the Bank module
module Bank
{
interface Teller
{
Account getAccount( in string customerID );
};
};
Nesting of Modules
module sdsu
{
module whitney
{
module cs696
{
interface ReportCard
{
readonly attribute short grade;
};
};
};
};
One Pass compiler - Forward Declarations
module Bank
{
// Forward declare customer
interface Customer;
interface Account
{
Customer getOwner();
};
interface Customer
{
Account getAccount();
}
};
The Module with No Name
interface Account
{
readonly attribute float balance;
};
Maps to a Java interface in the no name package
Interface is mapped to a Java interface
An OMG IDL Interface:
- supports multiple inheritance
-
- contains:
- type declarations
-
- constants declarations
-
- exception declarations
-
- attributes declarations
-
- operations declarations
Inheritance
interface Right {
string getRightMessage(in string ID);
};
interface Left {
string getLeftMessage(in string ID);
};
interface Bottom : Right, Left {
readonly attribute short lecture;
};
The
order of listing of multiple direct base interfaces is not important
An
interface is called a direct base if it is mentioned in the parent class
list of a class, i.e. a direct parent
An interface is called an indirect base if is not a direct base, but is
an ancestor of an interface
An interface can only be listed once as a direct base interface of a class, but
can be an indirect base of a class more than once
It is currently illegal to inherit from two interfaces with the same operation
name or attribute name, or to redefine the an operation or attribute name in
the derived interface
An interface can inherit from two interfaces that contain a constant, type, or
exception definition of the same name
You must fully scope that name when using the constant, type or exception
IDL Type | Range |
short | (16 bit) |
unsigned short | (16 bit) |
long | (32 bit) |
unsigned long | (32 bit) |
long long | (64 bit) |
unsigned long long | (64 bit) |
| |
float | IEEE single-precision floating point |
double | IEEE double-precision floating point |
long double | IEEE double-extended floating point |
| |
char | 8-bit value |
wchar | 16 bit value |
boolean | TRUE or FALSE |
octet | 8-bit |
any | |
string | |
wstring | |
long double has an exponent of at least 15 bits and a signed fraction of at least 64 bits
octet
- An 8-bit quantity which is guaranteed not to undergo any conversion when
transmitted by the communication system
- encodes a single-byte character from any byte-oriented code set
-
- or
-
- 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
-
- The ISO 8859-1 (Latin1) character set standard defines the meaning of and
representation of all possible graphic characters used in OMG IDL
-
- During transmission may be converted to different form, but a character's
meaning can not be changed
wchar
- encodes wide characters from any character set
-
- An implementation is free to use any code set internally
-
- The size of wchar is implementation-dependent
-
- During transmission may be converted to different form, but a character's
meaning can not be changed
IDL Type | Java type |
short | short |
unsigned short | short |
long | int |
unsigned long | int |
long long | long |
unsigned long long | long |
| |
float | float |
double | double |
long double | no mapping at this time |
| |
char | char |
wcahr | char |
boolean | boolean |
octet | byte |
any | org.omg.CORBA.Any |
string | java.lang.String |
wstring | java.lang.String |
unsigned values
- Java does not support unsigned values
- Programmer must insure that unsigned types are in the proper range
char
- Java char' are 16 bit
-
- If a Java char is sent to a OMG IDL char and is not in the proper range a
CORBA::DATA_CONVERSTION exception will be thrown
string
- Java strings are made up of 16 bit chars
- If a Java string is sent to a OMG IDL string and a char is not in the
proper range a CORBA::DATA_CONVERSTION exception will be thrown
-
- CORBA::MARSHAL exceptions can also be thrown in converting between
java.lang.String and OMG IDL string
wstring
- CORBA::MARSHAL exception can also be thrown in converting between
java.lang.String and wstring
visitors since 17-Mar-98