Rename LITE_RUNTIME to CODE_SIZE

This commit is contained in:
Ilya Lipnitskiy 2015-10-30 15:54:00 -07:00
parent 4eb49206ff
commit 0e2d3c09e2
6 changed files with 31 additions and 31 deletions

View File

@ -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 *

View File

@ -150,14 +150,14 @@ void EnumGenerator::GenerateValueInitializer(io::Printer *printer, int index)
{
const EnumValueDescriptor *vd = descriptor_->value(index);
map<string, string> 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"

View File

@ -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");
}

View File

@ -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");

View File

@ -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"

View File

@ -1,6 +1,6 @@
package foo;
option optimize_for = LITE_RUNTIME;
option optimize_for = CODE_SIZE;
enum TestEnumLite {
LITE = 0;