From 0e2d3c09e219903d758838a723cb322e7979c78e Mon Sep 17 00:00:00 2001 From: Ilya Lipnitskiy Date: Fri, 30 Oct 2015 15:54:00 -0700 Subject: [PATCH] Rename LITE_RUNTIME to CODE_SIZE --- protobuf-c/protobuf-c.h | 6 +++--- protoc-c/c_enum.cc | 20 ++++++++++---------- protoc-c/c_field.cc | 4 ++-- protoc-c/c_message.cc | 14 +++++++------- protoc-c/c_service.cc | 16 ++++++++-------- t/test-optimized.proto | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/protobuf-c/protobuf-c.h b/protobuf-c/protobuf-c.h index 153729a..460cc1f 100644 --- a/protobuf-c/protobuf-c.h +++ b/protobuf-c/protobuf-c.h @@ -806,7 +806,7 @@ protobuf_c_version_number(void); * \return * A `ProtobufCEnumValue` object. * \retval NULL - * If not found or if the optimize_for = LITE_RUNTIME option was set. + * If not found or if the optimize_for = CODE_SIZE option was set. */ PROTOBUF_C__API const ProtobufCEnumValue * @@ -846,7 +846,7 @@ protobuf_c_enum_descriptor_get_value( * \return * A `ProtobufCFieldDescriptor` object. * \retval NULL - * If not found or if the optimize_for = LITE_RUNTIME option was set. + * If not found or if the optimize_for = CODE_SIZE option was set. */ PROTOBUF_C__API const ProtobufCFieldDescriptor * @@ -1020,7 +1020,7 @@ protobuf_c_service_destroy(ProtobufCService *service); * \return * A `ProtobufCMethodDescriptor` object. * \retval NULL - * If not found or if the optimize_for = LITE_RUNTIME option was set. + * If not found or if the optimize_for = CODE_SIZE option was set. */ PROTOBUF_C__API const ProtobufCMethodDescriptor * diff --git a/protoc-c/c_enum.cc b/protoc-c/c_enum.cc index c4167ca..d86366e 100644 --- a/protoc-c/c_enum.cc +++ b/protoc-c/c_enum.cc @@ -150,14 +150,14 @@ void EnumGenerator::GenerateValueInitializer(io::Printer *printer, int index) { const EnumValueDescriptor *vd = descriptor_->value(index); map vars; - bool lite_runtime = descriptor_->file()->options().has_optimize_for() && + bool optimize_code_size = descriptor_->file()->options().has_optimize_for() && descriptor_->file()->options().optimize_for() == - FileOptions_OptimizeMode_LITE_RUNTIME; + FileOptions_OptimizeMode_CODE_SIZE; vars["enum_value_name"] = vd->name(); vars["c_enum_value_name"] = FullNameToUpper(descriptor_->full_name()) + "__" + vd->name(); vars["value"] = SimpleItoa(vd->number()); - if (lite_runtime) - printer->Print(vars, " { NULL, NULL, $value$ }, /* LITE_RUNTIME */\n"); + if (optimize_code_size) + printer->Print(vars, " { NULL, NULL, $value$ }, /* CODE_SIZE */\n"); else printer->Print(vars, " { \"$enum_value_name$\", \"$c_enum_value_name$\", $value$ },\n"); @@ -190,9 +190,9 @@ void EnumGenerator::GenerateEnumDescriptor(io::Printer* printer) { vars["packagename"] = descriptor_->file()->package(); vars["value_count"] = SimpleItoa(descriptor_->value_count()); - bool lite_runtime = descriptor_->file()->options().has_optimize_for() && + bool optimize_code_size = descriptor_->file()->options().has_optimize_for() && descriptor_->file()->options().optimize_for() == - FileOptions_OptimizeMode_LITE_RUNTIME; + FileOptions_OptimizeMode_CODE_SIZE; // Sort by name and value, dropping duplicate values if they appear later. // TODO: use a c++ paradigm for this! @@ -276,7 +276,7 @@ void EnumGenerator::GenerateEnumDescriptor(io::Printer* printer) { } vars["n_ranges"] = SimpleItoa(n_ranges); - if (!lite_runtime) { + if (!optimize_code_size) { qsort(value_index, descriptor_->value_count(), sizeof(ValueIndex), compare_value_indices_by_name); printer->Print(vars, @@ -290,15 +290,15 @@ void EnumGenerator::GenerateEnumDescriptor(io::Printer* printer) { printer->Print(vars, "};\n"); } - if (lite_runtime) { + if (optimize_code_size) { printer->Print(vars, "const ProtobufCEnumDescriptor $lcclassname$__descriptor =\n" "{\n" " PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC,\n" - " NULL,NULL,NULL,NULL, /* LITE_RUNTIME */\n" + " NULL,NULL,NULL,NULL, /* CODE_SIZE */\n" " $unique_value_count$,\n" " $lcclassname$__enum_values_by_number,\n" - " 0, NULL, /* LITE_RUNTIME */\n" + " 0, NULL, /* CODE_SIZE */\n" " $n_ranges$,\n" " $lcclassname$__value_ranges,\n" " NULL,NULL,NULL,NULL /* reserved[1234] */\n" diff --git a/protoc-c/c_field.cc b/protoc-c/c_field.cc index 2144135..cee26d9 100644 --- a/protoc-c/c_field.cc +++ b/protoc-c/c_field.cc @@ -142,8 +142,8 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer, printer->Print("{\n"); if (descriptor_->file()->options().has_optimize_for() && descriptor_->file()->options().optimize_for() == - FileOptions_OptimizeMode_LITE_RUNTIME) { - printer->Print(" NULL, /* LITE_RUNTIME */\n"); + FileOptions_OptimizeMode_CODE_SIZE) { + printer->Print(" NULL, /* CODE_SIZE */\n"); } else { printer->Print(variables, " \"$proto_name$\",\n"); } diff --git a/protoc-c/c_message.cc b/protoc-c/c_message.cc index f2b2a3f..54d1847 100644 --- a/protoc-c/c_message.cc +++ b/protoc-c/c_message.cc @@ -387,9 +387,9 @@ GenerateMessageDescriptor(io::Printer* printer) { vars["n_fields"] = SimpleItoa(descriptor_->field_count()); vars["packagename"] = descriptor_->file()->package(); - bool lite_runtime = descriptor_->file()->options().has_optimize_for() && + bool optimize_code_size = descriptor_->file()->options().has_optimize_for() && descriptor_->file()->options().optimize_for() == - FileOptions_OptimizeMode_LITE_RUNTIME; + FileOptions_OptimizeMode_CODE_SIZE; for (int i = 0; i < descriptor_->nested_type_count(); i++) { nested_generators_[i]->GenerateMessageDescriptor(printer); @@ -492,7 +492,7 @@ GenerateMessageDescriptor(io::Printer* printer) { printer->Outdent(); printer->Print(vars, "};\n"); - if (!lite_runtime) { + if (!optimize_code_size) { NameIndex *field_indices = new NameIndex [descriptor_->field_count()]; for (int i = 0; i < descriptor_->field_count(); i++) { field_indices[i].name = sorted_fields[i]->name().c_str(); @@ -537,8 +537,8 @@ GenerateMessageDescriptor(io::Printer* printer) { "const ProtobufCMessageDescriptor $lcclassname$__descriptor =\n" "{\n" " PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,\n"); - if (lite_runtime) { - printer->Print(" NULL,NULL,NULL,NULL, /* LITE_RUNTIME */\n"); + if (optimize_code_size) { + printer->Print(" NULL,NULL,NULL,NULL, /* CODE_SIZE */\n"); } else { printer->Print(vars, " \"$fullname$\",\n" @@ -550,8 +550,8 @@ GenerateMessageDescriptor(io::Printer* printer) { " sizeof($classname$),\n" " $n_fields$,\n" " $lcclassname$__field_descriptors,\n"); - if (lite_runtime) { - printer->Print(" NULL, /* LITE_RUNTIME */\n"); + if (optimize_code_size) { + printer->Print(" NULL, /* CODE_SIZE */\n"); } else { printer->Print(vars, " $lcclassname$__field_indices_by_name,\n"); diff --git a/protoc-c/c_service.cc b/protoc-c/c_service.cc index af54156..ad09ff1 100644 --- a/protoc-c/c_service.cc +++ b/protoc-c/c_service.cc @@ -198,9 +198,9 @@ void ServiceGenerator::GenerateServiceDescriptor(io::Printer* printer) int n_methods = descriptor_->method_count(); MethodIndexAndName *mi_array = new MethodIndexAndName[n_methods]; - bool lite_runtime = descriptor_->file()->options().has_optimize_for() && + bool optimize_code_size = descriptor_->file()->options().has_optimize_for() && descriptor_->file()->options().optimize_for() == - FileOptions_OptimizeMode_LITE_RUNTIME; + FileOptions_OptimizeMode_CODE_SIZE; vars_["n_methods"] = SimpleItoa(n_methods); printer->Print(vars_, "static const ProtobufCMethodDescriptor $lcfullname$__method_descriptors[$n_methods$] =\n" @@ -210,9 +210,9 @@ void ServiceGenerator::GenerateServiceDescriptor(io::Printer* printer) vars_["method"] = method->name(); vars_["input_descriptor"] = "&" + FullNameToLower(method->input_type()->full_name()) + "__descriptor"; vars_["output_descriptor"] = "&" + FullNameToLower(method->output_type()->full_name()) + "__descriptor"; - if (lite_runtime) { + if (optimize_code_size) { printer->Print(vars_, - " { NULL, $input_descriptor$, $output_descriptor$ }, /* LITE_RUNTIME */\n"); + " { NULL, $input_descriptor$, $output_descriptor$ }, /* CODE_SIZE */\n"); } else { printer->Print(vars_, " { \"$method$\", $input_descriptor$, $output_descriptor$ },\n"); @@ -222,7 +222,7 @@ void ServiceGenerator::GenerateServiceDescriptor(io::Printer* printer) } printer->Print(vars_, "};\n"); - if (!lite_runtime) { + if (!optimize_code_size) { qsort ((void*)mi_array, n_methods, sizeof (MethodIndexAndName), compare_method_index_and_name_by_name); printer->Print(vars_, "const unsigned $lcfullname$__method_indices_by_name[] = {\n"); @@ -236,14 +236,14 @@ void ServiceGenerator::GenerateServiceDescriptor(io::Printer* printer) vars_["name"] = descriptor_->name(); } - if (lite_runtime) { + if (optimize_code_size) { printer->Print(vars_, "const ProtobufCServiceDescriptor $lcfullname$__descriptor =\n" "{\n" " PROTOBUF_C__SERVICE_DESCRIPTOR_MAGIC,\n" - " NULL,NULL,NULL,NULL, /* LITE_RUNTIME */\n" + " NULL,NULL,NULL,NULL, /* CODE_SIZE */\n" " $n_methods$,\n" " $lcfullname$__method_descriptors,\n" - " NULL /* LITE_RUNTIME */\n" + " NULL /* CODE_SIZE */\n" "};\n"); } else { printer->Print(vars_, "const ProtobufCServiceDescriptor $lcfullname$__descriptor =\n" diff --git a/t/test-optimized.proto b/t/test-optimized.proto index d9fde89..d126881 100644 --- a/t/test-optimized.proto +++ b/t/test-optimized.proto @@ -1,6 +1,6 @@ package foo; -option optimize_for = LITE_RUNTIME; +option optimize_for = CODE_SIZE; enum TestEnumLite { LITE = 0;