summaryrefslogtreecommitdiff
path: root/upb/bindings/googlepb/proto1.cc
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2014-06-26 20:24:32 -0700
committerJosh Haberman <jhaberman@gmail.com>2014-06-26 20:24:32 -0700
commit2d10fa33071d52d7a35ce3b13bc459cd16a0aa33 (patch)
treebf47d38e2e1cc8ddb4711b23b26e7fd10742e07d /upb/bindings/googlepb/proto1.cc
parent7d565f1e7a0f107506d3cf31ef2e33e22a504d2b (diff)
Sync from internal Google development.
Diffstat (limited to 'upb/bindings/googlepb/proto1.cc')
-rw-r--r--upb/bindings/googlepb/proto1.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/upb/bindings/googlepb/proto1.cc b/upb/bindings/googlepb/proto1.cc
index c317cdf..0b46fed 100644
--- a/upb/bindings/googlepb/proto1.cc
+++ b/upb/bindings/googlepb/proto1.cc
@@ -16,13 +16,20 @@
// dynamic_cast<> in this file:
// https://groups.google.com/a/google.com/d/msg/c-style/7Zp_XCX0e7s/I6dpzno4l-MJ
-#include "upb/bindings/googlepb/proto1.h"
+#include "upb/bindings/googlepb/proto1.int.h"
#include <memory>
+// TEMPORARY measure until we update the friend declarations in proto1.
+// Can't do in a single CL because of components.
+#define private public
+#define protected public
#include "net/proto2/public/repeated_field.h"
#include "net/proto/internal_layout.h"
#include "net/proto/proto2_reflection.h"
+#undef private
+#undef protected
+
#include "upb/def.h"
#include "upb/handlers.h"
#include "upb/shim/shim.h"
@@ -36,7 +43,7 @@ template <class T> static T* GetPointer(void* message, size_t offset) {
}
namespace upb {
-namespace google {
+namespace googlepb {
class P2R_Handlers {
public:
@@ -466,18 +473,18 @@ class P2R_Handlers {
bool TrySetProto1WriteHandlers(const proto2::FieldDescriptor* proto2_f,
const proto2::Message& m,
const upb::FieldDef* upb_f, upb::Handlers* h) {
- return P2R_Handlers::TrySet(proto2_f, m, upb_f, h);
-}
-
-const proto2::Message* GetProto1WeakPrototype(
- const proto2::Message& m, const proto2::FieldDescriptor* f) {
- return P2R_Handlers::GetWeakPrototype(m, f);
+ return googlepb::P2R_Handlers::TrySet(proto2_f, m, upb_f, h);
}
const proto2::Message* GetProto1FieldPrototype(
const proto2::Message& m, const proto2::FieldDescriptor* f) {
- return P2R_Handlers::GetFieldPrototype(m, f);
+ const proto2::Message *weak = googlepb::P2R_Handlers::GetWeakPrototype(m, f);
+ if (weak) return weak;
+ if (f->cpp_type() != proto2::FieldDescriptor::CPPTYPE_MESSAGE) {
+ return NULL;
+ }
+ return googlepb::P2R_Handlers::GetFieldPrototype(m, f);
}
-} // namespace google
+} // namespace googlepb
} // namespace upb
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback