|
8 | 8 | #ifndef GOOGLE_PROTOBUF_HPB_INTERNAL_INTERNAL_H__ |
9 | 9 | #define GOOGLE_PROTOBUF_HPB_INTERNAL_INTERNAL_H__ |
10 | 10 |
|
11 | | -#include <cstdint> |
12 | | -#include <utility> |
13 | | - |
14 | | -#include "upb/mem/arena.h" |
15 | | -#include "upb/message/message.h" |
16 | | - |
17 | | -namespace hpb::internal { |
18 | | - |
19 | | -struct PrivateAccess { |
20 | | - template <typename T> |
21 | | - static auto* GetInternalMsg(T&& message) { |
22 | | - return message->msg(); |
23 | | - } |
24 | | - template <typename T> |
25 | | - static auto* GetInternalArena(T&& message) { |
26 | | - return message->arena(); |
27 | | - } |
28 | | - template <typename T> |
29 | | - static auto* GetInternalUPBArena(T&& arena) { |
30 | | - return arena.arena_.ptr(); |
31 | | - } |
32 | | - template <typename T> |
33 | | - static auto Proxy(upb_Message* p, upb_Arena* arena) { |
34 | | - return typename T::Proxy(p, arena); |
35 | | - } |
36 | | - template <typename T> |
37 | | - static auto CProxy(const upb_Message* p, upb_Arena* arena) { |
38 | | - return typename T::CProxy(p, arena); |
39 | | - } |
40 | | - template <typename T> |
41 | | - static auto CreateMessage(upb_Arena* arena) { |
42 | | - return typename T::Proxy(upb_Message_New(T::minitable(), arena), arena); |
43 | | - } |
44 | | - |
45 | | - template <typename T, typename... Args> |
46 | | - static constexpr auto InvokeConstructor(Args&&... args) { |
47 | | - return T(std::forward<Args>(args)...); |
48 | | - } |
49 | | - |
50 | | - template <typename ExtensionId> |
51 | | - static constexpr uint32_t GetExtensionNumber(const ExtensionId& id) { |
52 | | - return id.number(); |
53 | | - } |
54 | | - |
55 | | - template <typename ExtensionId> |
56 | | - static decltype(auto) GetDefaultValue(const ExtensionId& id) { |
57 | | - return id.default_value(); |
58 | | - } |
59 | | -}; |
60 | | - |
61 | | -template <typename T> |
62 | | -struct AssociatedUpbTypes; |
63 | | - |
64 | | -} // namespace hpb::internal |
| 11 | +#include "hpb/multibackend.h" |
| 12 | +#if HPB_INTERNAL_BACKEND == HPB_INTERNAL_BACKEND_UPB |
| 13 | +#include "hpb/backend/upb/internal.h" |
| 14 | +#elif HPB_INTERNAL_BACKEND == HPB_INTERNAL_BACKEND_CPP |
| 15 | +#include "hpb/backend/cpp/internal.h" |
| 16 | +#else |
| 17 | +#error "Unsupported hpb backend" |
| 18 | +#endif |
65 | 19 |
|
66 | 20 | #endif // GOOGLE_PROTOBUF_HPB_INTERNAL_INTERNAL_H__ |
0 commit comments