SDSU 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

  1. References
    1. Overview
    2. Module
    3. Interface
    4. Basic Data Types
    5. Basic Data Types - Java Mappings

References


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


Doc 20, CORBA IDL Slide # 2

Overview


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

Doc 20, CORBA IDL Slide # 3
Keywords
anydoubleinterfacereadonlyunsigned
attributeenumlongsequenceunion
booleanexceptionmoduleshortvoid
caseFALSEObjectstringwchar
charfixedoctetstructwstring
constfloatonewayswitch
contextinoutTRUE
defaultinoutraisestypedef

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

Doc 20, CORBA IDL Slide # 4
Standard Escape Sequences
Floating-point Literals
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
123.321e12
123.321E12
123.321
.123
123.

Fixed-Point Literals
123.321d
123.321D
.123d
123.d


Doc 20, CORBA IDL Slide # 5

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)


Doc 20, CORBA IDL Slide # 6

Module



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() ;
}

Doc 20, CORBA IDL Slide # 7
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 );
      };
   };

Doc 20, CORBA IDL Slide # 8
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();
      }
   };

Doc 20, CORBA IDL Slide # 9
The Module with No Name
interface Account
   {
   readonly attribute float balance;
   };

Maps to a Java interface in the no name package

Interface


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


Doc 20, CORBA IDL Slide # 10
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


Doc 20, CORBA IDL Slide # 11

Basic Data Types

long double has an exponent of at least 15 bits and a signed fraction of at least 64 bits
IDL TypeRange
short (16 bit)
unsigned short (16 bit)
long (32 bit)
unsigned long (32 bit)
long long (64 bit)
unsigned long long (64 bit)
floatIEEE single-precision floating point
doubleIEEE double-precision floating point
long doubleIEEE double-extended floating point
char8-bit value
wchar16 bit value
booleanTRUE or FALSE
octet8-bit
any
string
wstring
octet
An 8-bit quantity which is guaranteed not to undergo any conversion when transmitted by the communication system

Doc 20, CORBA IDL Slide # 12
char
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


Doc 20, CORBA IDL Slide # 13

Basic Data Types - Java Mappings

IDL TypeJava type
shortshort
unsigned shortshort
longint
unsigned longint
long longlong
unsigned long longlong
floatfloat
doubledouble
long doubleno mapping at this time
charchar
wcahrchar
booleanboolean
octetbyte
anyorg.omg.CORBA.Any
stringjava.lang.String
wstringjava.lang.String

unsigned values
Java does not support unsigned values
Programmer must insure that unsigned types are in the proper range


Doc 20, CORBA IDL Slide # 14

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