1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2023 Google LLC. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
8 #include "upb_generator/minitable/names_internal.h"
12 #include "absl/strings/str_replace.h"
13 #include "absl/strings/string_view.h"
14 #include "upb_generator/common/names.h"
21 std::string
ToCIdent(absl::string_view str
) {
22 return absl::StrReplaceAll(str
, {{".", "_"}, {"/", "_"}, {"-", "_"}});
27 std::string
MiniTableHeaderFilename(absl::string_view proto_filename
,
31 if (IsDescriptorProto(proto_filename
)) {
32 base
= "upb/reflection/stage1/";
34 base
= "upb_generator/stage1/";
37 return base
+ StripExtension(proto_filename
) + ".upb_minitable.h";
40 std::string
MiniTableFieldsVarName(absl::string_view msg_full_name
) {
41 return ToCIdent(msg_full_name
) + "__fields";
44 std::string
MiniTableSubMessagesVarName(absl::string_view msg_full_name
) {
45 return ToCIdent(msg_full_name
) + "__submsgs";
48 } // namespace generator