23 #include <google/protobuf/compiler/objectivec/objectivec_helpers.h>
32 #ifdef SUPPORT_OBJC_PREFIX_VALIDATION
64 if (!pb_runtime_import_prefix.empty()) {
65 local_header = pb_runtime_import_prefix +
"/" + file_name;
69 "GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS";
84 return FEATURE_PROTO3_OPTIONAL;
91 if (
file->service_count() == 0) {
96 #ifdef SUPPORT_OBJC_PREFIX_VALIDATION
103 bool grpc_local_import =
false;
107 std::vector<::std::string> params_list =
109 for (
auto param_str = params_list.begin(); param_str != params_list.end();
111 std::vector<::std::string> param =
113 if (param[0] ==
"generate_for_named_framework") {
114 if (param.size() != 2) {
116 std::string(
"Format: generate_for_named_framework=<Framework>");
118 }
else if (param[1].
empty()) {
120 std::string(
"Name of framework cannot be empty for parameter: ") +
125 }
else if (param[0] ==
"runtime_import_prefix") {
126 if (param.size() != 2) {
130 pb_runtime_import_prefix = param[1];
132 }
else if (param[0] ==
"grpc_local_import_prefix") {
133 grpc_local_import =
true;
134 if (param.size() != 2) {
138 grpc_local_import_prefix = param[1];
146 "GPB_GRPC_FORWARD_DECLARE_MESSAGE_PROTO";
154 if (!parameter.empty()) {
155 std::vector<std::string> parameters_list =
157 for (
auto parameter_string = parameters_list.begin();
158 parameter_string != parameters_list.end(); parameter_string++) {
159 std::vector<std::string> param =
161 if (param[0] ==
"no_v1_compatibility") {
169 "// Code generated by gRPC proto compiler. DO NOT EDIT!\n"
184 if (grpc_local_import) {
186 LocalImport(grpc_local_import_prefix +
"ProtoRPC/ProtoService.h");
189 LocalImport(grpc_local_import_prefix +
"ProtoRPC/ProtoRPC.h");
191 system_imports +=
LocalImport(grpc_local_import_prefix +
192 "ProtoRPC/ProtoRPCLegacy.h");
193 system_imports +=
LocalImport(grpc_local_import_prefix +
194 "RxLibrary/GRXWriteable.h");
196 LocalImport(grpc_local_import_prefix +
"RxLibrary/GRXWriter.h");
199 system_imports =
SystemImport(
"ProtoRPC/ProtoService.h");
203 system_imports +=
SystemImport(
"ProtoRPC/ProtoRPCLegacy.h");
204 system_imports +=
SystemImport(
"RxLibrary/GRXWriteable.h");
205 system_imports +=
SystemImport(
"RxLibrary/GRXWriter.h");
210 "@class GRPCUnaryProtoCall;\n"
211 "@class GRPCStreamingProtoCall;\n"
212 "@class GRPCCallOptions;\n"
213 "@protocol GRPCProtoResponseHandler;\n";
215 forward_declarations +=
"@class GRPCProtoCall;\n";
217 forward_declarations +=
"\n";
223 for (
int i = 0;
i <
file->dependency_count();
i++) {
224 class_imports += ImportProtoHeaders(
229 for (
int i = 0;
i <
file->service_count();
i++) {
235 for (
int i = 0;
i <
file->service_count();
i++) {
242 for (
int i = 0;
i <
file->service_count();
i++) {
249 file_header +
SystemImport(
"Foundation/Foundation.h") +
"\n" +
252 class_declarations +
"\n" +
254 forward_declarations +
"\n" + kNonNullBegin +
"\n" +
255 ng_protocols + protocols +
"\n" +
256 PreprocIfNot(kProtocolOnly, interfaces) +
"\n" + kNonNullEnd +
272 if (grpc_local_import) {
275 LocalImport(grpc_local_import_prefix +
"ProtoRPC/ProtoRPC.h");
278 "ProtoRPC/ProtoRPCLegacy.h");
280 "RxLibrary/GRXWriter+Immediate.h");
287 imports +=
SystemImport(
"RxLibrary/GRXWriter+Immediate.h");
292 for (
int i = 0;
i <
file->dependency_count();
i++) {
293 class_imports += ImportProtoHeaders(
file->dependency(
i),
"",
framework,
294 pb_runtime_import_prefix);
298 for (
int i = 0;
i <
file->service_count();
i++) {
306 PreprocIfNot(kProtocolOnly, imports +
"\n" + class_imports +
307 "\n" + definitions));
317 std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream>
output(
320 coded_out.WriteRaw(
code.data(),
code.size());
324 int main(
int argc,
char* argv[]) {