xref: /aosp_15_r20/external/pigweed/pw_protobuf/py/pw_protobuf/edition_constants.py (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14"""Temporary constant definitions."""
15
16import enum
17
18# TODO: pwbug.dev/366316523 - These constants should all come from the generated
19# FileDescriptorProto, which requires upgrading our Protobuf libraries.
20# Remove this file once the upgrade is complete.
21
22# From the CodeGeneratorResponse message, indicating that a generator plugin
23# supports Protobuf editions.
24#
25# https://cs.opensource.google/protobuf/protobuf/+/main:src/google/protobuf/compiler/plugin.proto;l=102;drc=cba41100fb1e998660ef4fb12aeef2871a15427c
26FEATURE_SUPPORTS_EDITIONS = 2
27
28
29# Field presence enum from the FeatureSet message.
30# https://cs.opensource.google/protobuf/protobuf/+/main:src/google/protobuf/descriptor.proto;l=965;drc=5a68dddcf9564f92815296099f07f7dfe8713908
31class FieldPresence(enum.Enum):
32    FIELD_PRESENCE_UNKNOWN = 0
33    EXPLICIT = 1
34    IMPLICIT = 2
35    LEGACY_REQUIRED = 3
36
37
38# Edition enum from the descriptor proto.
39# https://cs.opensource.google/protobuf/protobuf/+/main:src/google/protobuf/descriptor.proto;l=68;drc=9d7236b421634afcecc24b6fd63da0ff5b506394
40class Edition(enum.Enum):
41    EDITION_UNKNOWN = 0
42    EDITION_LEGACY = 900
43    EDITION_PROTO2 = 998
44    EDITION_PROTO3 = 999
45    EDITION_2023 = 1000
46