Просмотр исходного кода

[CodeGenLib] Translator for enums containing type aliases and static properties (#1733)

Motivation:

In the generated code we want to have:

- enums for each namespace containing enums for all their services
- enums for each service (inside the corresponding namespace enum) containing
enums for all their methods, an array of all corresponding MethodDescriptors and type aliases for streaming and non-streaming protocols
- enums for each method (inside the corresponding service enum) containing
type aliases for the input and output types and a method descriptor (GRPCCore)

Modifications:

- Created the Translator protocol defining the 'translate()' function.
- Implemented the IDLToStructuredSwiftTranslator struct which conforms to the Translator protocol and creates the StructuredSwiftRepresentation for a CodeGenerationRequest calling the Specialized translators' functions.
- Created the SpecializedTranslator protocol.
- Implemented the TypeAliasTranslator, the first of the 3 SpecializedTranslators that takes in a CodeGenerationRequest object and creates all the enums, type aliases and properties mentioned in the Motivation, in StructuredSwiftRepresentation format.
- Created CodeGenError.
- Wrote SnippetTests.

Result:

The generated code will contain useful type aliases for message types and
protocol names, organized in namespace, service and method specific enums.
Stefana-Ioana Dranca 2 лет назад
Родитель
Сommit
3ef1b20eb0
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      NOTICES.txt

+ 1 - 1
NOTICES.txt

@@ -62,7 +62,7 @@ This product uses derivations of swift-extras/swift-extras-base64 'Base64.swift'
 
 This product uses derivations of apple/swift-openapi-generator 'StructuredSwiftRepresentation.swift',
 'TypeName.swift', 'TypeUsage.swift', 'Builtins.swift', 'RendererProtocol.swift', 'TextBasedProtocol',
-and 'Test_TextBasedRenderer'.
+'Test_TextBasedRenderer', and 'SnippetBasedReferenceTests.swift'.
     
     * LICENSE (Apache License 2.0):
       * https://github.com/apple/swift-openapi-generator/blob/main/LICENSE.txt