// Generated from idltype.y - manual changes will be lost
ifdef::sidebartoc[]
include::_Sidebar.adoc[]
endif::[]


























Data type and constant definitions
----------------------------------

All data types manipulated by Genom are described with a subset of the OMG
IDL syntax. Those types map into traditional programming languages types
using the specific mappings described in the
link:../mappings/index{outfilesuffix}[GenoM IDL mappings] section.



=== Type specification

The following set of type specifiers to represent
typed values is available:

****
[horizontal]
(57) `*type-spec             ::=*` ::
   <<grammar#dotgen-rule-simple-type-spec,`simple-type-spec`>> +
                              `|` <<grammar#dotgen-rule-constructed-type-spec,`constructed-type-spec`>>
(58) `*simple-type-spec      ::=*` ::
   <<grammar#dotgen-rule-base-type-spec,`base-type-spec`>> +
                              `|` <<grammar#dotgen-rule-template-type-spec,`template-type-spec`>> +
                              `|` <<grammar#dotgen-rule-named-type,`named-type`>>
(93) `*constructed-type-spec ::=*` ::
   <<grammar#dotgen-rule-constructed-type,`constructed-type`>>
****

==== Subtopics

* link:idltype-base{outfilesuffix}[IDL base types]:
  integers, floating point values ...
* link:idltype-tmpl{outfilesuffix}[IDL template types]:
  sequences, strings ...
* link:idltype-constr{outfilesuffix}[IDL constructed types]:
  structs, unions, enums, ...





































=== Type declaration

Type defined with the following syntax can then be used in the component
interface definition and anywhere a type value is expected.

****
[horizontal]
(59) `*type-dcl              ::=*` ::
   `"typedef"` <<grammar#dotgen-rule-type-declarator,`type-declarator`>> `";"` +
                              `|` `"native"` <<grammar#dotgen-rule-identifier,`identifier`>> `";"` +
                              `|` `"exception"` <<grammar#dotgen-rule-exception-list,`exception-list`>> `";"` +
                              `|` <<grammar#dotgen-rule-constructed-type,`constructed-type`>> `";"` +
                              `|` <<grammar#dotgen-rule-forward-dcl,`forward-dcl`>> `";"`
(94) `*constructed-type      ::=*` ::
   <<grammar#dotgen-rule-struct-type,`struct-type`>> +
                              `|` <<grammar#dotgen-rule-union-type,`union-type`>> +
                              `|` <<grammar#dotgen-rule-enum-type,`enum-type`>>
(60) `*type-declarator       ::=*` ::
   `(` <<grammar#dotgen-rule-type-spec,`type-spec`>> +
                              `|` <<grammar#dotgen-rule-type-declarator,`type-declarator`>> `","` `)` <<grammar#dotgen-rule-declarator,`declarator`>>
****

==== Typedef

Types are most often given a unique name thanks to a `typedef` declaration;
a name is also associated with a data type via the `struct`, `union`,
`enum`, `native` and `exception` declarations.

==== Native types

It is possible to hide the actual definition of a data type from Genom (and
its IDL parser) when it will never be directly used in the interface of the
component, but can nevertheless be needed by codels. These types can be
declared using the `native` attribute.

For example: `native foo;`













































==== Exceptions

Exceptions are thrown by services in case of error. The `exception` keyword
declares an exception, which is an identifier with an optional associated
data type.

****
[horizontal]
(61) `*exception-list        ::=*` ::
   `{` <<grammar#dotgen-rule-exception-dcl,`exception-dcl`>> `","` `}` <<grammar#dotgen-rule-exception-dcl,`exception-dcl`>>
(62) `*exception-dcl         ::=*` ::
   <<grammar#dotgen-rule-exception-name,`exception-name`>> <<grammar#dotgen-rule-opt-member-list,`opt-member-list`>>
(63) `*opt-member-list       ::=*` ::
   `[` `"{"` `(` `"}"` +
                              `|` <<grammar#dotgen-rule-member-list,`member-list`>> `"}"` `)` `]`
****

A simple exception declaration would be :

----
exception INVALID_SPEED;
----

or with an associated type (to store the actual value for instance):

----
exception INVALID_SPEED {
  double speed;
};
----









































































=== Constant declaration

Constants define read-only values that are used by the component, like the
maximal speed allowed for a motor or the physical bounds of a process that
will be controlled. The syntax is again very similar to `C` or `C++`:

****
[horizontal]
(69) `*const-dcl             ::=*` ::
   `"const"` <<grammar#dotgen-rule-const-type,`const-type`>> <<grammar#dotgen-rule-identifier,`identifier`>> `"="` <<grammar#dotgen-rule-const-expr,`const-expr`>> `";"`
(70) `*const-type            ::=*` ::
   <<grammar#dotgen-rule-integer-type,`integer-type`>> +
                              `|` <<grammar#dotgen-rule-char-type,`char-type`>> +
                              `|` <<grammar#dotgen-rule-boolean-type,`boolean-type`>> +
                              `|` <<grammar#dotgen-rule-floating-pt-type,`floating-pt-type`>> +
                              `|` <<grammar#dotgen-rule-octet-type,`octet-type`>> +
                              `|` <<grammar#dotgen-rule-string-type,`string-type`>> +
                              `|` <<grammar#dotgen-rule-named-type,`named-type`>>
****

For example: `const double max_speed = 72.0;`


















// eof
