External classes only include external features, i.e. features that are not written in Eiffel but are rather methods or functions already existing on a .NET Framework type. They do not include any logic; they are just needed for the Eiffel type system. This means that the Eiffel.NET compiler does not generate any IL code for these classes. Any call to functions on external classes are direct calls to the .NET Framework type; there are no indirections and thus no performance penalty. All the features of an external class belong to the same .NET Framework type. They are declared as follows:
indexing
external_name: "System.Console"
frozen external class
SYSTEM_CONSOLE
The string that follows external_name contains the name of the .NET Framework type that the external class wraps. Since .NET types might be sealed (they might forbid other types to inherit from them) and since such a concept does not exist in Eiffel, Eiffel.NET introduces a new use for the Eiffel keyword frozen. frozen in front of external tells the Eiffel.NET compiler that no Eiffel.NET class can inherit from the .NET Framework type.
The external class then list all the public features available on the .NET Framework type. All these features are external features. The syntax for an external .NET Framework feature is the following:
frozen read_line: STRING is
external
"IL static signature :System.String use System.Console"
alias
"ReadLine"
end
The keyword frozen indicates that the feature may not be redefined in a descendant. read_line is the Eiffel.NET feature name and STRING the return type of the feature. The string that follows the external keyword specifies the kind of external, the .NET Framework function signature, as well as the .NET Framework type on which the function is defined. The string following the alias keyword contains the .NET Framework name of the function. There are different kinds of external features, depending on the type of method they provide access to. Eiffel.NET defines seven new kinds of externals listed in the following table:
.NET Framework Function Kind | Eiffel External |
Method | "IL signature ... use class_name" |
Static Method | "IL static signature ... use class_name" |
Abstract Method | "IL abstract signature ... use class_name" |
Field | "IL field signature ... use class_name" |
Static Field | "IL static_field signature ... use class_name" |
Constructor | "IL creator signature ... use class_name" |
Operator | "IL operator signature ... use class_name" |