Table of Contents Previous Next
Logo
The Slice Language : 4.17 Metadata
Copyright © 2003-2008 ZeroC, Inc.

4.17 Metadata

Slice has the concept of a metadata directive. For example:
["java:type:java.util.LinkedList"] sequence<int> IntSeq;
A metadata directive can appear as a prefix to any Slice definition. Metadata directives appear in a pair of square brackets and contain one or more string literals separated by commas. For example, the following is a syntactically valid metadata directives containing two strings:
["a", "b"] interface Example {};
Metadata directives are not part of the Slice language per se: the presence of a metadata directive has no effect on the client–server contract, that is, metadata directives do not change the Slice type system in any way. Instead, metadata directives are targeted at specific back-ends, such as the code generator for a particular language mapping. In the preceding example, the java: prefix indicates that the directive is targeted at the Java code generator.
Metadata directives permit you to provide supplementary information that does not change the Slice types being defined, but somehow influences how the compiler will generate code for these definitions. For example, a metadata directive java:type:java.util.LinkedList instructs the Java code generator to map a sequence to a linked list instead of an array (which is the default).
Metadata directives are also used to create proxies and skeletons that support Asynchronous Method Invocation (AMI) and Asynchronous Method Dispatch (AMD) (see Chapter 29).
Apart from metadata directives that are attached to a specific definition, there are also global metadata directives. For example:
[["java:package:com.acme"]]
Note that a global metadata directive is enclosed by double square brackets, whereas a local metadata directive (one that is attached to a specific definition) is enclosed by single square brackets. Global metadata directives are used to pass instructions that affect the entire compilation unit. For example, the preceding metadata directive instructs the Java code generator to generate the contents of the source file into the Java package com.acme. Global metadata directives must precede any definitions in a file (but can appear following any #include directives).
We discuss specific metadata directives in the relevant chapters to which they apply.
Table of Contents Previous Next
Logo