Slice and Slice Compilers
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
2 min read
IDL
Slice is Ice’s Interface Definition Language (IDL). It allows you to describe your network API in a clear and concise manner.
Defining the customary Greeter interface in Slice is straightforward:
/// Represents a simple greeter.interface Greeter{ /// Creates a personalized greeting. /// @param name The name of the person to greet. /// @return The greeting. string greet(string name);}With Ice, each Ice object implements a Slice interface with one or more operations.
Interfaces, operations, and the types of data that are exchanged between client and server are defined using the Slice language. Slice allows you to define the client-server contract in a way that is independent of a specific programming language, such as C++, Java, or C#.
Slice Compilers
A Slice compiler uses your Slice definitions to generate code for one programming language. For each Slice interface, this generated code includes the proxy code that a client uses to call the interface's operations and the skeleton code that a server implements; for each Slice type, it includes the corresponding type in that language.
The rules that govern how each Slice construct maps to a programming language are collectively known as a language mapping. For example, the C++ mapping maps a Slice sequence to a std::vector, whereas the Java mapping maps it to a Java array. With the Slice definition and the mapping rules, you know what the generated API looks like without reading the generated code.
Ice provides language mappings for C++, C#, Java, JavaScript, Python, Swift, and, for the client side, MATLAB, PHP, and Ruby.