Skip to content

Commit f88a9c0

Browse files
Add SourceFile type for CodeGenLib (#1723)
Motivation: The CodeRenderer needs to create objects of some type representing the files containing the generated code. This type is SourceFile. Modifications: Implemented the SourceFile struct, containing a name as a String and the generated code as Data. Result: The Code Renderer can now be brought from the OpenAPI generator, as it will have an output type. The code generator will use objects of this type to create the files containing the generated Swift code.
1 parent 2971c0a commit f88a9c0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2023, gRPC Authors All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/// Representation of the file to be created by the code generator, that contains the
18+
/// generated Swift source code.
19+
public struct SourceFile: Sendable, Hashable {
20+
/// The base name of the file.
21+
public var name: String
22+
23+
/// The generated code as a String.
24+
public var contents: String
25+
26+
/// Creates a representation of a file containing Swift code with the specified name
27+
/// and contents.
28+
public init(name: String, contents: String) {
29+
self.name = name
30+
self.contents = contents
31+
}
32+
}

0 commit comments

Comments
 (0)