Another archival checkin...

This commit is contained in:
David Given
2025-08-13 23:00:08 +02:00
parent 70bdcd0978
commit 0419df4b2d

View File

@@ -178,7 +178,7 @@ static ProtoField resolveProtoPath(
if (!field) if (!field)
fail(); fail();
return std::make_tuple(message, field, -1); return std::make_tuple(message, field, index);
} }
ProtoField makeProtoPath( ProtoField makeProtoPath(
@@ -221,7 +221,7 @@ static int32_t parseEnum(
const auto* enumvalue = enumfield->FindValueByName(value); const auto* enumvalue = enumfield->FindValueByName(value);
if (!enumvalue) if (!enumvalue)
error("unrecognised enum value '{}'", value); error("unrecognised enum value '{}'", value);
return enumvalue->index(); return enumvalue->number();
} }
template <typename T> template <typename T>
@@ -280,7 +280,7 @@ void setProtoFieldFromString(ProtoField& protoField, const std::string& value)
reflection->GetMutableRepeatedFieldRef<uint32_t>( reflection->GetMutableRepeatedFieldRef<uint32_t>(
message, field), message, field),
index, index,
(uint32_t)toUInt64(value)); (uint32_t)toUint64(value));
break; break;
case google::protobuf::FieldDescriptor::TYPE_UINT64: case google::protobuf::FieldDescriptor::TYPE_UINT64:
@@ -288,7 +288,7 @@ void setProtoFieldFromString(ProtoField& protoField, const std::string& value)
reflection->GetMutableRepeatedFieldRef<uint64_t>( reflection->GetMutableRepeatedFieldRef<uint64_t>(
message, field), message, field),
index, index,
toUInt64(value)); toUint64(value));
break; break;
case google::protobuf::FieldDescriptor::TYPE_STRING: case google::protobuf::FieldDescriptor::TYPE_STRING:
@@ -308,8 +308,11 @@ void setProtoFieldFromString(ProtoField& protoField, const std::string& value)
break; break;
case google::protobuf::FieldDescriptor::TYPE_ENUM: case google::protobuf::FieldDescriptor::TYPE_ENUM:
reflection->SetRepeatedEnum( updateRepeatedField(
message, field, index, parseEnum(field, value)); reflection->GetMutableRepeatedFieldRef<int32_t>(
message, field),
index,
parseEnum(field, value));
break; break;
case google::protobuf::FieldDescriptor::TYPE_MESSAGE: case google::protobuf::FieldDescriptor::TYPE_MESSAGE:
@@ -320,11 +323,6 @@ void setProtoFieldFromString(ProtoField& protoField, const std::string& value)
value); value);
break; break;
} }
if (field->containing_oneof() && value.empty())
{
reflection->MutableRepeatedMessage(message, field, index);
break;
}
/* fall through */ /* fall through */
default: default:
error("can't set this config value type"); error("can't set this config value type");
@@ -369,7 +367,7 @@ void setProtoFieldFromString(ProtoField& protoField, const std::string& value)
break; break;
case google::protobuf::FieldDescriptor::TYPE_ENUM: case google::protobuf::FieldDescriptor::TYPE_ENUM:
reflection->SetEnum(message, field, parseEnum(field, value)); reflection->SetEnumValue(message, field, parseEnum(field, value));
break; break;
case google::protobuf::FieldDescriptor::TYPE_MESSAGE: case google::protobuf::FieldDescriptor::TYPE_MESSAGE: