summaryrefslogtreecommitdiff
path: root/upb/bindings/googlepb/proto1.cc
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2014-11-18 15:21:50 -0800
committerJosh Haberman <jhaberman@gmail.com>2014-11-18 15:21:50 -0800
commit3d0c7c45da5b72a88bfb03dc5ce3384b7f01cef6 (patch)
tree1c9fd69700e1162c7ed78458160800b586600c9b /upb/bindings/googlepb/proto1.cc
parent648afe3da654b6e08fe6ea26ae520581eb892e23 (diff)
Sync to Google-internal development.
Diffstat (limited to 'upb/bindings/googlepb/proto1.cc')
-rw-r--r--upb/bindings/googlepb/proto1.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/upb/bindings/googlepb/proto1.cc b/upb/bindings/googlepb/proto1.cc
index 0b46fed..68b572c 100644
--- a/upb/bindings/googlepb/proto1.cc
+++ b/upb/bindings/googlepb/proto1.cc
@@ -30,6 +30,10 @@
#undef private
#undef protected
+#ifdef GOOGLE_PROTOBUF_HAS_ARENAS
+namespace proto2 { class Arena; }
+#endif
+
#include "upb/def.h"
#include "upb/handlers.h"
#include "upb/shim/shim.h"
@@ -448,12 +452,35 @@ class P2R_Handlers {
class RepeatedMessageTypeHandler {
public:
typedef proto2::Message Type;
+#ifndef GOOGLE_PROTOBUF_HAS_ARENAS
// AddAllocated() calls this, but only if other objects are sitting
// around waiting for reuse, which we will not do.
static void Delete(Type* t) {
UPB_UNUSED(t);
assert(false);
}
+#else
+ static ::proto2::Arena* GetArena(Type* t) {
+ return t->GetArena();
+ }
+ static void* GetMaybeArenaPointer(Type* t) {
+ return t->GetMaybeArenaPointer();
+ }
+ static inline Type* NewFromPrototype(
+ const Type* prototype, ::proto2::Arena* arena = NULL) {
+ return prototype->New(arena);
+ }
+ // AddAllocated() calls this, but only if other objects are sitting
+ // around waiting for reuse, which we will not do.
+ static void Delete(Type* t, ::proto2::Arena* arena) {
+ UPB_UNUSED(t);
+ UPB_UNUSED(arena);
+ assert(false);
+ }
+ static void Merge(const Type& from, Type* to) {
+ to->MergeFrom(from);
+ }
+#endif
};
// Closure is a RepeatedPtrField<SubMessageType>*, but we access it through
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback