This allows rust generator to use this function directly in order to generate symbol names for Message MiniTables. PiperOrigin-RevId: 584054361pull/14803/head
parent
c33967fcbc
commit
9b8b2760f8
4 changed files with 53 additions and 9 deletions
@ -0,0 +1,21 @@ |
|||||||
|
#include "upb_generator/mangle.h" |
||||||
|
|
||||||
|
#include <string> |
||||||
|
|
||||||
|
#include "absl/strings/str_replace.h" |
||||||
|
#include "absl/strings/string_view.h" |
||||||
|
|
||||||
|
// Generate a mangled C name for a proto object.
|
||||||
|
static std::string MangleName(absl::string_view name) { |
||||||
|
return absl::StrReplaceAll(name, {{"_", "_0"}, {".", "__"}}); |
||||||
|
} |
||||||
|
|
||||||
|
namespace upb { |
||||||
|
namespace generator { |
||||||
|
|
||||||
|
std::string MessageInit(absl::string_view full_name) { |
||||||
|
return MangleName(full_name) + "_msg_init"; |
||||||
|
} |
||||||
|
|
||||||
|
} // namespace generator
|
||||||
|
} // namespace upb
|
@ -0,0 +1,16 @@ |
|||||||
|
#ifndef THIRD_PARTY_UPB_UPB_GENERATOR_MANGLE_H_ |
||||||
|
#define THIRD_PARTY_UPB_UPB_GENERATOR_MANGLE_H_ |
||||||
|
|
||||||
|
#include <string> |
||||||
|
|
||||||
|
#include "absl/strings/string_view.h" |
||||||
|
|
||||||
|
namespace upb { |
||||||
|
namespace generator { |
||||||
|
|
||||||
|
std::string MessageInit(absl::string_view full_name); |
||||||
|
|
||||||
|
} // namespace generator
|
||||||
|
} // namespace upb
|
||||||
|
|
||||||
|
#endif // THIRD_PARTY_UPB_UPB_GENERATOR_MANGLE_H_
|
Loading…
Reference in new issue