python_private_generator.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_INTERNAL_COMPILER_PYTHON_PRIVATE_GENERATOR_H
20 #define GRPC_INTERNAL_COMPILER_PYTHON_PRIVATE_GENERATOR_H
21 
22 #include <iostream>
23 #include <vector>
24 
27 
28 namespace grpc_python_generator {
29 
30 namespace {
31 
32 // Tucks all generator state in an anonymous namespace away from
33 // PythonGrpcGenerator and the header file, mostly to encourage future changes
34 // to not require updates to the grpcio-tools C++ code part. Assumes that it is
35 // only ever used from a single thread.
36 struct PrivateGenerator {
37  const GeneratorConfiguration& config;
39 
41 
42  PrivateGenerator(const GeneratorConfiguration& config,
43  const grpc_generator::File* file);
44 
45  std::pair<bool, std::string> GetGrpcServices();
46 
47  private:
48  bool PrintPreamble(grpc_generator::Printer* out);
49  bool PrintBetaPreamble(grpc_generator::Printer* out);
50  bool PrintGAServices(grpc_generator::Printer* out);
51  bool PrintBetaServices(grpc_generator::Printer* out);
52 
53  bool PrintAddServicerToServer(
54  const std::string& package_qualified_service_name,
56  bool PrintServicer(const grpc_generator::Service* service,
58  bool PrintStub(const std::string& package_qualified_service_name,
61 
62  bool PrintServiceClass(const std::string& package_qualified_service_name,
65  bool PrintBetaServicer(const grpc_generator::Service* service,
67  bool PrintBetaServerFactory(const std::string& package_qualified_service_name,
70  bool PrintBetaStub(const grpc_generator::Service* service,
72  bool PrintBetaStubFactory(const std::string& package_qualified_service_name,
75 
76  // Get all comments (leading, leading_detached, trailing) and print them as a
77  // docstring. Any leading space of a line will be removed, but the line
78  // wrapping will not be changed.
79  void PrintAllComments(std::vector<std::string> comments,
81 };
82 
83 } // namespace
84 
85 } // namespace grpc_python_generator
86 
87 #endif // GRPC_INTERNAL_COMPILER_PYTHON_PRIVATE_GENERATOR_H
config
const GeneratorConfiguration & config
Definition: python_private_generator.h:37
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
grpc_python_generator
Definition: src/compiler/python_generator.cc:53
grpc_generator::Service
Definition: schema_interface.h:80
file
const grpc_generator::File * file
Definition: python_private_generator.h:38
grpc_generator::File
Definition: schema_interface.h:102
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
file
Definition: bloaty/third_party/zlib/examples/gzappend.c:170
generate_in_pb2_grpc
bool generate_in_pb2_grpc
Definition: python_private_generator.h:40
grpc_generator::Printer
Definition: schema_interface.h:89
config_s
Definition: bloaty/third_party/zlib/deflate.c:120
schema_interface.h
service
__attribute__((deprecated("Please use GRPCProtoMethod."))) @interface ProtoMethod NSString * service
Definition: ProtoMethod.h:25
python_generator.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:59