Give generated_code_support.h its own forwarding header.

This will allow us to refactor the underlying rules and headers without breaking the generated code.

PiperOrigin-RevId: 541517265
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent a3f0bce495
commit 47c9298ab9
  1. 36
      BUILD
  2. 56
      upb/generated_code_support.h
  3. 6
      upb/reflection/stage0/google/protobuf/descriptor.upb.c
  4. 9
      upb/reflection/stage0/google/protobuf/descriptor.upb.h
  5. 18
      upbc/protoc-gen-upb.cc
  6. 6
      upbc/stage0/google/protobuf/compiler/plugin.upb.c
  7. 9
      upbc/stage0/google/protobuf/compiler/plugin.upb.h

36
BUILD

@ -465,38 +465,21 @@ cc_library(
# give up any backward compatibility guarantees.
cc_library(
name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
hdrs = [
"upb/collections/array.h",
"upb/collections/array_internal.h",
"upb/collections/map_gencode_util.h",
"upb/collections/message_value.h",
"upb/extension_registry.h",
"upb/message/accessors.h",
"upb/message/accessors_internal.h",
"upb/message/extension_internal.h",
"upb/message/internal.h",
"upb/message/message.h",
"upb/mini_table/common.h",
"upb/mini_table/enum_internal.h",
"upb/mini_table/extension_internal.h",
"upb/mini_table/field_internal.h",
"upb/mini_table/file_internal.h",
"upb/mini_table/message_internal.h",
"upb/mini_table/sub_internal.h",
"upb/mini_table/types.h",
hdrs = ["upb/generated_code_support.h"],
copts = UPB_DEFAULT_COPTS,
textual_hdrs = [
"upb/port/def.inc",
"upb/port/undef.inc",
"upb/wire/decode.h",
"upb/wire/decode_fast.h",
"upb/wire/encode.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections_internal",
":hash",
":message_accessors",
":message_accessors_internal",
":message_internal",
":mini_table_internal",
":upb",
":wire_internal",
],
)
@ -1050,6 +1033,7 @@ upb_amalgamation(
":descriptor_upb_proto",
":eps_copy_input_stream",
":fastdecode",
":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
":hash",
":lex",
":mem_internal",
@ -1088,6 +1072,7 @@ upb_amalgamation(
":descriptor_upb_proto_reflection",
":eps_copy_input_stream",
":fastdecode",
":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
":hash",
":json",
":lex",
@ -1128,6 +1113,7 @@ upb_amalgamation(
":descriptor_upb_proto",
":eps_copy_input_stream",
":fastdecode",
":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
":hash",
":json",
":lex",

@ -0,0 +1,56 @@
/*
* Copyright (c) 2009-2023, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_GENERATED_CODE_SUPPORT_H_
#define UPB_GENERATED_CODE_SUPPORT_H_
// IWYU pragma: begin_exports
#include "upb/collections/array.h"
#include "upb/collections/array_internal.h"
#include "upb/collections/map_gencode_util.h"
#include "upb/collections/message_value.h"
#include "upb/extension_registry.h"
#include "upb/message/accessors.h"
#include "upb/message/accessors_internal.h"
#include "upb/message/extension_internal.h"
#include "upb/message/internal.h"
#include "upb/message/message.h"
#include "upb/mini_table/common.h"
#include "upb/mini_table/decode.h"
#include "upb/mini_table/enum_internal.h"
#include "upb/mini_table/extension_internal.h"
#include "upb/mini_table/field_internal.h"
#include "upb/mini_table/file_internal.h"
#include "upb/mini_table/message_internal.h"
#include "upb/mini_table/sub_internal.h"
#include "upb/mini_table/types.h"
#include "upb/wire/decode.h"
#include "upb/wire/decode_fast.h"
#include "upb/wire/encode.h"
// IWYU pragma: end_exports
#endif // UPB_GENERATED_CODE_SUPPORT_H_

@ -1,8 +1,5 @@
#include <stddef.h>
#include "upb/collections/array_internal.h"
#include "upb/message/internal.h"
#include "upb/mini_table/decode.h"
#include "upb/mini_table/enum_internal.h"
#include "upb/generated_code_support.h"
#include "google/protobuf/descriptor.upb.h"
static upb_Arena* upb_BootstrapArena() {
@ -414,4 +411,3 @@ const upb_MiniTableEnum* google_protobuf_MethodOptions_IdempotencyLevel_enum_ini
upb_BootstrapArena(), NULL);
return mini_table;
}

@ -9,14 +9,7 @@
#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
#define GOOGLE_PROTOBUF_DESCRIPTOR_PROTO_UPB_H_
#include "upb/collections/array_internal.h"
#include "upb/collections/map_gencode_util.h"
#include "upb/message/accessors.h"
#include "upb/message/internal.h"
#include "upb/mini_table/enum_internal.h"
#include "upb/wire/decode.h"
#include "upb/wire/decode_fast.h"
#include "upb/wire/encode.h"
#include "upb/generated_code_support.h"
// Must be last.
#include "upb/port/def.inc"

@ -841,14 +841,7 @@ void WriteHeader(const DefPoolPair& pools, upb::FileDefPtr file,
output(
"#ifndef $0_UPB_H_\n"
"#define $0_UPB_H_\n\n"
"#include \"upb/collections/array_internal.h\"\n"
"#include \"upb/collections/map_gencode_util.h\"\n"
"#include \"upb/message/accessors.h\"\n"
"#include \"upb/message/internal.h\"\n"
"#include \"upb/mini_table/enum_internal.h\"\n"
"#include \"upb/wire/decode.h\"\n"
"#include \"upb/wire/decode_fast.h\"\n"
"#include \"upb/wire/encode.h\"\n\n",
"#include \"upb/generated_code_support.h\"\n",
ToPreproc(file.name()));
for (int i = 0; i < file.public_dependency_count(); i++) {
@ -1544,9 +1537,7 @@ void WriteMiniTableSource(const DefPoolPair& pools, upb::FileDefPtr file,
output(
"#include <stddef.h>\n"
"#include \"upb/collections/array_internal.h\"\n"
"#include \"upb/message/internal.h\"\n"
"#include \"upb/mini_table/enum_internal.h\"\n"
"#include \"upb/generated_code_support.h\"\n"
"#include \"$0\"\n",
HeaderFilename(file));
@ -1638,10 +1629,7 @@ void WriteMiniDescriptorSource(const DefPoolPair& pools, upb::FileDefPtr file,
const Options& options, Output& output) {
output(
"#include <stddef.h>\n"
"#include \"upb/collections/array_internal.h\"\n"
"#include \"upb/message/internal.h\"\n"
"#include \"upb/mini_table/decode.h\"\n"
"#include \"upb/mini_table/enum_internal.h\"\n"
"#include \"upb/generated_code_support.h\"\n"
"#include \"$0\"\n\n",
HeaderFilename(file));

@ -1,8 +1,5 @@
#include <stddef.h>
#include "upb/collections/array_internal.h"
#include "upb/message/internal.h"
#include "upb/mini_table/decode.h"
#include "upb/mini_table/enum_internal.h"
#include "upb/generated_code_support.h"
#include "google/protobuf/compiler/plugin.upb.h"
#include "google/protobuf/descriptor.upb.h"
@ -65,4 +62,3 @@ const upb_MiniTableEnum* google_protobuf_compiler_CodeGeneratorResponse_Feature_
upb_BootstrapArena(), NULL);
return mini_table;
}

@ -9,14 +9,7 @@
#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_PROTO_UPB_H_
#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_PROTO_UPB_H_
#include "upb/collections/array_internal.h"
#include "upb/collections/map_gencode_util.h"
#include "upb/message/accessors.h"
#include "upb/message/internal.h"
#include "upb/mini_table/enum_internal.h"
#include "upb/wire/decode.h"
#include "upb/wire/decode_fast.h"
#include "upb/wire/encode.h"
#include "upb/generated_code_support.h"
// Must be last.
#include "upb/port/def.inc"

Loading…
Cancel
Save