OMG IDL grammar rules

zhaozj2021-02-08  310

OMG IDL grammar rules

(This article is reproduced from Software Engineering Expert Network www.21cmm.com)

Su Yang

Omg IDL file overview

Essentially, the OMG IDL interface definition language is not used as a programming language in a CORBA architecture, but is used to describe the language of the client object and the interface between the client object and the service object. The OMG IDL file describes the data type and method framework, and the service object provides the above data and methods for a specified object.

The OMG IDL file describes the service feature provided by the server, and the client can propose a business request to the server based on the method described by the interface file. In most CORBA products, you provide IDL to related programming language compilers. Program designers simply enter the compiler of the defined interface file, set the interface frame file and auxiliary file related to the programming language after setting the compilation option. The IDL file application is shown in Figure 1.

Figure 1 OMG IDL file compilation process

In terms of grammar rules, similar to the definition of interfaces or objects in C or Java, OMG IDL adds some constructors to support IDL unique method call mechanisms. OMG IDL is just a descriptive language that supports a statement of constants, types, and methods in C syntax. The omg id1 illustrative language is to overcome the limitations of software systems integration and interoperability in a particular programming language, which is also the tempting of CORBA, and also embodies the use of CORBA constructive distributed applications in the network. The powerful vitality of the times. OMG IDL has developed mapping standards for IDL to advanced programming languages ​​for major advanced programming languages ​​such as C, C , Java. Project developers can independently develop CORBA-based applications as needed to independently develop CORBA-based applications, and do not affect the interoperability of software systems.

OMG IDL grammar rules

Omg IDL file example

Module Compute

{Typedef Double Radius;

Typedef long time;

Interface Pi

{Double GetResult (in Radius Aradius, in Times Time);}

}

The above interface definition file is mainly used for the client to request a request to the service object: calculate the π value. Therefore, a method of getResult () is defined in the module as a circular diameter (aRADIUS) and an iterative number (TIMES) as input parameters of the method.

2. OMG IDL lexical rules

OMG IDL uses the ASCII character set to form all identifiers defined by the interface. The identifier consists of any combination of letters, numbers, and underscores, but the first character must be an ASCII letter. IDL believes that uppercase letters and lowercase letters have the same meaning, such as Anexample and Anexamples.

Similar to C and Java, use "/ *" to comment a piece of code with "* /", with "//" start comment from "//" to start until all content of the end.

In addition, IDL retains 47 keywords, and programming staff cannot use keywords as variables or method names. It is necessary to pay attention to the case of keywords, for example:

Typedef double context;

// Error: The defined variable context is the keyword

Typedef double context;

// Error: Context conflicts with keyword Context

3. Data type

(1) Basic data type: OMG IDL basic data types include short, long, and corresponding non-symbolic (unsigned) types, indicated 16,32 bits, respectively.

(2) Floating point number: OMG IDL floating point number includes Float, Double, and long double types. Where float represents a single-precision floating point number, Double represents the number of double precision floating point, long double represents the extension of double precision floating point. (3) Characters and large character types: OMG IDL Defines the character type char to the single-byte character encoded by the zip-oriented code set; define type Wchar as a large character encoding from any character set.

(4) Logical Type: A variable defined with a Boolean keyword, with only true and false.

(5) Octa type: Definition with an OCTET keyword, the bit element sequence of high and low conversion is not performed during the network transmission.

(6) ANY Data Type: Introducing this type to represent any data type in the OMG IDL.

4. Constant

OMG IDL declares a constant with a const key, which is used to define the amount of unchanged in the module (Interface), such as:

Const Double Pi = 3.1415926;

In IDL, you can define constants for long, unsigned long, unsigned short, char, boolean, float, double, string type.

5. Construct data type

Similar to the grammar rules of C and C , the structure data types in the omg IDL include structures, joint, enumerations and other forms. Such examples:

(1) Structure type:

Typedef long goodsnumber;

Struct

{GoodsNumber Number;

String name;

Float price;

(2) Joint type:

Union stockin switch (short)

{CASE 1: Stocker: long;

Case 2: Goodsname1: string;

Case 3: goodsname2: string;

(3) Enumeration Type:

ENUM goodsstatus {goods_saled, goods_instock};

6. Array type

The array type of the omg IDL provides a multidimensional, unified data format, data storage method - arrays. The length of each dimension must be given when defined, and all data units must store the same type of elements. The following example defines an array of integers with a length of 20 × 100:

Typedef long adimension [20] [100];

7. Template type

OMG IDL provides two types of templates:

(1) Sequence type:

Use this method to define any number of storage sequences that can be varied, usually specify the length during defining, or may not be specified, such as:

Typedef Sequence ases;

// Length defined as 80

Typedef sequern anothersequence;

// Length is uncertain

(2) String sequence:

There are two definition methods for string sequence types:

TypeDef string <80> aname; // Length defined as 80

Typedef string anothername; // is uncertain

8. Interface in the first few lectures, all mentioned the CORBA interface, the interface as a detailed description of the service object function, encapsulates all the information provided by the service object, and the customer object uses the interface to obtain the properties of the service object, access the service object. Method.

The interface is declared with the keyword interface, which is open to all customer objects requested by the service request, as in the following examples:

Interface JobManager

{Readonly Attribute String FirstName;

Attribute string status;

String QueryJobStatus (in long number, out string property);}

转载请注明原文地址:https://www.9cbs.com/read-622.html

New Post(0)