-
Notifications
You must be signed in to change notification settings - Fork 1
Reference
The input language for Ecore2Thrift is a subset of ECore from the Eclipse Modelling Framework with the following restrictions:
- No element may share its name with a Thrift reserved word. This includes keywords from many languages that Thrift supports, which means that names such as "list" and "delete" are forbidden.
- A class may have EOperations or fields (EAttributes and EReferences), but not both, and must have at least one.
- All types of fields, operations, and parameters must correspond to a native Thrift type or defined elsewhere in the file.
ECore type | Native Thrift type |
---|---|
EByte | byte |
EByteObject | byte |
EByteArray | binary |
EBooleanObject | bool |
EBoolean | bool |
EChar | string |
ECharacterObect | string |
EDouble | double |
EDoubleObject | double |
EFloat | double |
EFloatObject | double |
EInt | i32 |
EIntegerObject | i32 |
ELong | i64 |
ELongObject | i64 |
EShort | i16 |
EShortObject | i16 |
EString | string |
One caveat is that doubles are used instead of floats because Thrift has no single-width float support.
Ecore2Thrift recognizes a number of Thrift-specific annotations, all with the namespace thrift
:
-
javans
: specifies the Java namespace the generated Thrift will use. This is only valid when applied to the EPackage and its value must be a valid Java package name. -
n
: overrides the parameter, field, or exception numbering. This is only valid when applied to an EParameter, EAttribute, EReference, or EException. -
union
: causes the structure to compile into aunion
. This is only valid when applied to an EClass that is being compiled to a structure.
There is also the annotation with the source thrift.map
and the keys key
and value
. This annotation must be applied to an EClass with no EOperations, and the values of the keys key
and value
must be names of EAttributes or EReferences the EClass contains. This specifies that it should be compiled into a map
(with the specified key and value) when it would otherwise be compiled into a list
.
Ecore2Thrift recognizes the following annotations with the doc
source:
-
d
: this must be a string, and represents documentation of part of the specification. This documentation is copied verbatim into the Thrift as a comment. -
optional
: this must be applied to an EParamater or EAttribute, and its value must be a boolean value (either "true" or "false"). If set to "true", the parameter or field in the output is marked as "optional", if set as "false" it is marked as "required". The default is "required" for types not marked as unions, and "optional" for unions.