2023-03-04 12:09:53 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2022-10-05 17:11:30 +00:00
|
|
|
syntax = "proto3";
|
|
|
|
|
|
|
|
package qtprotobufnamespace.tests;
|
|
|
|
|
|
|
|
message Message_Uderscore_name {
|
|
|
|
sint32 testField = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message MessageUderscorename {
|
|
|
|
sint32 testField = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message MessageUnderscoreField {
|
|
|
|
sint32 underScore_Message_field = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message PriorMessageUnderscoreField {
|
|
|
|
sint32 _underScoreMessageField = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message FollowingMessageUnderscoreField {
|
|
|
|
sint32 underScoreMessageField_ = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message CombinedMessageUnderscoreField {
|
|
|
|
sint32 _underScoreMessage_Field_ = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message MessageUpperCase {
|
|
|
|
sint32 TestField = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message MessageReserved {
|
|
|
|
sint32 import = 1;
|
|
|
|
sint32 property = 2;
|
|
|
|
sint32 id = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
message MessageUpperCaseReserved {
|
|
|
|
sint32 Import = 1;
|
|
|
|
sint32 Property = 2;
|
|
|
|
sint32 Id = 3;
|
|
|
|
}
|
|
|
|
|
2023-09-02 10:36:59 +00:00
|
|
|
message UseForwardDeclaredNestedMessage {
|
|
|
|
lowerCaseMessageName.nestedLowerCaseMessage lowerField = 1;
|
|
|
|
lowerCaseMessageName.NestedUpperCaseMessage UpperField = 2;
|
|
|
|
}
|
|
|
|
|
2022-10-05 17:11:30 +00:00
|
|
|
message lowerCaseMessageName {
|
2023-09-02 10:36:59 +00:00
|
|
|
message nestedLowerCaseMessage {
|
|
|
|
sint32 testField = 1;
|
|
|
|
}
|
|
|
|
message NestedUpperCaseMessage {
|
|
|
|
sint32 testField = 1;
|
|
|
|
}
|
|
|
|
enum nestedLowerCaseEnum {
|
|
|
|
val0 = 0;
|
|
|
|
}
|
|
|
|
enum NestedUpperCaseEnum {
|
|
|
|
Val0 = 0;
|
|
|
|
}
|
2022-10-05 17:11:30 +00:00
|
|
|
sint32 testField = 1;
|
2023-09-02 10:36:59 +00:00
|
|
|
nestedLowerCaseMessage testField1 = 2;
|
|
|
|
NestedUpperCaseMessage testField2 = 3;
|
2022-10-05 17:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message LowerCaseFieldMessageName {
|
|
|
|
lowerCaseMessageName testField = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message MessageEnumReserved {
|
|
|
|
enum ReservedEnum {
|
|
|
|
Import = 0;
|
|
|
|
Property = 1;
|
|
|
|
Id = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum LowerCaseEnum {
|
|
|
|
enumValue0 = 0;
|
|
|
|
enumValue1 = 1;
|
|
|
|
enumValue2 = 2;
|
|
|
|
}
|
|
|
|
|
2023-09-02 10:14:23 +00:00
|
|
|
enum UpperCaseEnum {
|
|
|
|
EnumValue0 = 0;
|
|
|
|
EnumValue1 = 1;
|
|
|
|
EnumValue2 = 2;
|
|
|
|
}
|
|
|
|
|
2022-10-05 17:11:30 +00:00
|
|
|
enum UnderScoreEnum {
|
|
|
|
_enumUnderscoreValue0 = 0;
|
|
|
|
_EnumUnderscoreValue1 = 1;
|
|
|
|
}
|
|
|
|
}
|
2023-09-02 10:58:29 +00:00
|
|
|
|
|
|
|
message CppKeywords {
|
|
|
|
bool private = 1;
|
|
|
|
bool if = 2;
|
|
|
|
bool else = 3;
|
|
|
|
bool for = 4;
|
|
|
|
bool while = 5;
|
|
|
|
bool switch = 6;
|
|
|
|
bool case = 7;
|
|
|
|
bool do = 8;
|
|
|
|
bool goto = 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
message int {
|
|
|
|
enum long {
|
|
|
|
bool = 0;
|
|
|
|
char = 1;
|
|
|
|
float = 2;
|
|
|
|
double = 3;
|
|
|
|
unsigned = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
long enum = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message if {
|
|
|
|
bool else = 1;
|
|
|
|
}
|
2024-03-19 13:07:19 +00:00
|
|
|
|
|
|
|
message QtCppKeywords {
|
|
|
|
sint32 slots = 1;
|
|
|
|
sint32 signals = 2;
|
|
|
|
bool emit = 3;
|
|
|
|
}
|
2024-10-03 13:22:24 +00:00
|
|
|
|
|
|
|
message NameClashing {
|
|
|
|
}
|
|
|
|
|
|
|
|
message NameClashingRepeated {
|
|
|
|
}
|
|
|
|
|
|
|
|
message NameClashing_Repeated {
|
|
|
|
}
|
2024-10-04 09:51:52 +00:00
|
|
|
|
|
|
|
message NameClashingMap {
|
|
|
|
map<int32, int32> field1 = 1;
|
|
|
|
int32 Field1_Entry = 2;
|
|
|
|
int32 Field2Entry = 3;
|
|
|
|
}
|
Long live mutable getters
The functionality is desirable by some users, we re-enable it.
New API addresses the core issue that is partially related to
QTBUG-119912, but has wider concequences in blind use in user
projects. We add the 'mut' prefix to all mutable getters to make
the mutable access explicit. Overload approach leads to unwanted
detaches not only whe is used be moc-generated code, but also
in user projects if developers do not pay enough attention to
const modifiers of their variables/references. We declined to
restore it, dispite it was the better looking API, in favor to
the code safety.
This also reveals the code clashing scenario, when the overload
might happen if the message has both 'a' and 'mutA' fields in
its definition. This scenario is kindly forbidden by our generator,
and sanitized at very early stages. We expect that it won't happen
in user projects, but even if it will, the solution is to rename
the field when generating Qt code. The serialization/deserialization
do not depend on field naming directly. json_name attribute also
will help to workaround this.
The undocumented ALLOW_MUTABLE_GETTER_CONFLICTS option allows clashing
the mutable getter names, but its usage currently limited by our
internal code only. The reason unfixed QTBUG-119912 issue in moc.
Once the issue is fixed, the moc version check should get the proper
version, but not '99' as for now and the ALLOW_MUTABLE_GETTER_CONFLICTS
will become public.
Another design solution is the use of overloaded functions that
return pointers, like it's done it the reference protobuf. But this
kind of API leaves the pointer ownership undefined and decided to
not be used.
[ChangeLog][Protobuf] The generated messages now have the mutable
getters for the fiels of the message type. The getters have 'mut'
prefix and implicily allocate the respective fields if needed, so the
use of intermediate message objects is not required.
Task-number: QTBUG-119913
Change-Id: I09b9ee37e1fbbe37b9c3cb501e92442da8ad3e4b
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-03-14 11:40:54 +00:00
|
|
|
|
|
|
|
message MutFieldMessage {
|
|
|
|
int32 data = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message NameClashingMutableGetters {
|
|
|
|
MutFieldMessage field = 1;
|
|
|
|
MutFieldMessage mutField = 2;
|
|
|
|
}
|