Type Declaration in IDL
CORBA IDL Series Continued (Part 3)
Apart from the basic types, interfaces and valuetypes, other customized types can also be created. This can be done either by
- Creating New Types
- Typedefining existing types to new types
Creating New Types
New types can be created either by using
- Structures
- Descriminated Unions
- Enumerations
Typedefining existing types to new types
By using the typedef keyword, existing types can be given new type names. This can be done by
- Simple type definition using existing base types to create new names
- Using templatized types such as sequence, string and wstring
- Arrays
General syntax
<type_dcl> ::= “typedef” <type_declarator>
| <struct_type>
| <union_type>
| <enum_type>
| <constr_forward_decl>
Structures, Unions and Enums:
<struct_type> ::= “struct” <identifier> “{” <member_list> “}”
<member_list> ::= <member>+
<member> ::= <type_spec> <declarators> “;”
<union_type> ::= “union” <identifier> “switch”
“(” <switch_type_spec> “)”
“{” <switch_body> “}”
<switch_type_spec> ::= <integer_type>
| <char_type>
| <boolean_type>
| <enum_type>
<switch_body> ::= <case>+
<case> ::= <case_label>+ <element_spec> “;”
<case_label> ::= “case” <const_exp> “:”
“default” “:”
<element_spec> ::= <type_spec> <declarator>
<enum_type> ::= “enum” <identifier>
“{” <enumerator> { “,” <enumerator> }* “}”
<enumerator> ::= <identifier>
Using typedef keyword
<type_declarator> ::= <type_spec> <declarators>
<type_spec> ::= <simple_type_spec>
| <constr_type_spec>
<simple_type_spec> ::= <base_type_spec>
| <template_type_spec>
<base_type_spec> ::= <floating_pt_type>
| <integer_type>
| <char_type>
| <wide_char_type>
| <boolean_type>
| <octet_type>
| <any_type>
| <object_type>
| <value_base_type>
<template_type_spec> ::= <sequence_type>
| <string_type>
| <wide_string_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>
0 Comments:
Post a Comment
<< Home