From 3d0c7c45da5b72a88bfb03dc5ce3384b7f01cef6 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Tue, 18 Nov 2014 15:21:50 -0800 Subject: Sync to Google-internal development. --- upb/bindings/googlepb/proto1.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'upb/bindings/googlepb/proto1.cc') 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*, but we access it through -- cgit v1.2.3