KasperskyOS Community Edition 1.0

IDL data types

Primitive IDL data types

IDL supports the following primitive data types:

  • SInt8, SInt16, SInt32, SInt64 (signed integer);
  • UInt8, UInt16, UInt32, UInt64 (unsigned integer);
  • Handle (handle).

Example declarations of primitive variable types:

SInt32 value;

UInt8 ch;

Handle ResID;

For primitive types (except the Handle type), you can declare a named constant using the reserved word const:

const UInt32 c0 = 0;

const UInt32 c1 = 1;

Let us now examine complex (composite) data types: union (variant type), struct (structure), array and sequence.

union type

The union variant type, similar to the normal union in C, allows storing different types of values within one memory area. However, when transmitting an IPC message, the union type is provided with an additional tag field that lets you define which union field is used in the transmitted value. For this reason, the union type is also called a union with a tag. Example declaration of a union variable type:

union foo {

UInt32 bar;

UInt8 baz;

}

A variant type declaration is a top-level declaration.

struct type

Structures in the IDL language are analogous to structures in C. Example structure declaration:

struct BazInfo {

UInt64 x;

UInt64 y;

}

A structure declaration is a top-level declaration.

array type

An array has a constant size that is defined during declaration:

array <ElementType, ElementsCount>

In IDL, arrays are anonymous and may be declared directly when declaring other complex types, and when declaring interfaces.

The reserved word typedef is used to assign a name to a declared array type, for example:

typedef array <SInt8, 1024> String;

sequence type

A sequence resembles a variable-sized array. When declaring a sequence, the maximum number of elements is specified. However, you can actually transmit fewer elements. In this case, only an amount of memory necessary for the transmitted elements will be used.

Similarly to arrays, sequences are anonymous and may be declared directly when declaring interfaces, and when declaring other complex types:

sequence <ElementType, ElementsCount>

Example declaration of a named sequence:

typedef sequence <SInt8, 1024> String;

Embedded complex types

Complex types can be used when declaring other complex types. Arrays and sequences can be declared directly inside another composite type:

struct BazInfo {

UInt64 x;

array <UInt8, 100> y;

sequence <sequence <UInt32, 100>, 200> z;

}

The union or struct types must be declared prior to use:

union foo {

UInt32 value1;

UInt8 value2;

}

struct bar {

UInt32 a;

UInt8 b;

}

struct BazInfo {

foo x;

bar y;

}

Type synonym declaration (typedef)

The reserved word typedef declares a name that, within its scope, is a synonym for the specified type. For example:

typedef array <UInt32, 20> value;

The typedef struct and typedef union constructs are invalid. A new name for a structure or variant type can be entered only if they were previously declared:

union foo {

UInt32 value1;

UInt8 value2;

}

typedef foo bar;

A typedef declaration does not introduce a new data type; it declares new names for already existing types.