summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--tests/test_handlers.c8
-rw-r--r--tests/test_pipeline.c2
-rw-r--r--upb/descriptor/reader.c1
-rw-r--r--upb/google/bridge.cc4
-rw-r--r--upb/handlers-inl.h13
-rw-r--r--upb/handlers.h22
7 files changed, 39 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index bccf860..e8f8422 100644
--- a/Makefile
+++ b/Makefile
@@ -216,6 +216,8 @@ tests/test.proto.pb: tests/test.proto
SIMPLE_TESTS= \
tests/test_def \
tests/test_varint \
+ tests/test_pipeline \
+ tests/test_handlers
SIMPLE_CXX_TESTS= \
tests/test_cpp \
diff --git a/tests/test_handlers.c b/tests/test_handlers.c
index fb0564a..36881fe 100644
--- a/tests/test_handlers.c
+++ b/tests/test_handlers.c
@@ -11,7 +11,11 @@
#include <stdlib.h>
#include <string.h>
-static bool startmsg(void *c, const void *hd) { return true; }
+static bool startmsg(void *c, const void *hd) {
+ UPB_UNUSED(c);
+ UPB_UNUSED(hd);
+ return true;
+}
static void test_error() {
upb_handlers *h = upb_handlers_new(GOOGLE_PROTOBUF_DESCRIPTORPROTO, NULL, &h);
@@ -33,6 +37,8 @@ static void test_error() {
}
int run_tests(int argc, char *argv[]) {
+ UPB_UNUSED(argc);
+ UPB_UNUSED(argv);
test_error();
return 0;
}
diff --git a/tests/test_pipeline.c b/tests/test_pipeline.c
index d54d15c..7214ca5 100644
--- a/tests/test_pipeline.c
+++ b/tests/test_pipeline.c
@@ -108,6 +108,8 @@ static void test_realloc() {
}
int run_tests(int argc, char *argv[]) {
+ UPB_UNUSED(argc);
+ UPB_UNUSED(argv);
test_empty();
test_only_initial();
test_with_alloc_func();
diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c
index e1b0c92..43bbdea 100644
--- a/upb/descriptor/reader.c
+++ b/upb/descriptor/reader.c
@@ -296,6 +296,7 @@ static bool enum_startmsg(void *closure, const void *hd) {
}
static bool enum_endmsg(void *closure, const void *hd, upb_status *status) {
+ UPB_UNUSED(hd);
upb_descreader *r = closure;
upb_enumdef *e = upb_downcast_enumdef_mutable(upb_descreader_last(r));
if (upb_def_fullname(upb_descreader_last(r)) == NULL) {
diff --git a/upb/google/bridge.cc b/upb/google/bridge.cc
index 97a91ea..9386427 100644
--- a/upb/google/bridge.cc
+++ b/upb/google/bridge.cc
@@ -131,8 +131,8 @@ FieldDef* AddFieldDef(const goog::Message& m, const goog::FieldDescriptor* f,
: upb::FieldDef::ConvertDescriptorType(f->type()));
if (weak_prototype) {
- const string& name = weak_prototype->GetDescriptor()->full_name();
- upb_f->set_subdef_name(name, &status);
+ upb_f->set_subdef_name(
+ weak_prototype->GetDescriptor()->full_name(), &status);
} else {
switch (upb_f->type()) {
case UPB_TYPE_INT32:
diff --git a/upb/handlers-inl.h b/upb/handlers-inl.h
index 65f21a2..6b46b47 100644
--- a/upb/handlers-inl.h
+++ b/upb/handlers-inl.h
@@ -303,8 +303,8 @@ inline Handlers::StringHandler BindHandler(
template <> \
inline bool Handlers::SetValueHandler<vtype>( \
const FieldDef *f, \
- const typename ValueHandler<typename CanonicalType<vtype>::Type>::H & \
- handler) { \
+ const Handlers::utype ## Handler& handler) { \
+ assert(!handler.registered_); \
handler.registered_ = true; \
return upb_handlers_set##ltype(this, f, handler.handler_, handler.data_, \
handler.cleanup_); \
@@ -394,54 +394,63 @@ inline const MessageDef *Handlers::message_def() const {
}
inline bool Handlers::SetStartMessageHandler(
const Handlers::StartMessageHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setstartmsg(this, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetEndMessageHandler(
const Handlers::EndMessageHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setendmsg(this, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetStartStringHandler(const FieldDef *f,
const StartStringHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setstartstr(this, f, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetEndStringHandler(const FieldDef *f,
const EndFieldHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setendstr(this, f, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetStringHandler(const FieldDef *f,
const StringHandler& handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setstring(this, f, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetStartSequenceHandler(
const FieldDef *f, const StartFieldHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setstartseq(this, f, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetStartSubMessageHandler(
const FieldDef *f, const StartFieldHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setstartsubmsg(this, f, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f,
const EndFieldHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setendsubmsg(this, f, handler.handler_, handler.data_,
handler.cleanup_);
}
inline bool Handlers::SetEndSequenceHandler(const FieldDef *f,
const EndFieldHandler &handler) {
+ assert(!handler.registered_);
handler.registered_ = true;
return upb_handlers_setendseq(this, f, handler.handler_, handler.data_,
handler.cleanup_);
diff --git a/upb/handlers.h b/upb/handlers.h
index a80e401..2108046 100644
--- a/upb/handlers.h
+++ b/upb/handlers.h
@@ -116,13 +116,13 @@ class upb::Handlers {
typedef Handler<bool(*)(void *, const void *, T)> H;
};
- typedef ValueHandler<upb_int32_t>::H Int32Handler;
- typedef ValueHandler<upb_int64_t>::H Int64Handler;
- typedef ValueHandler<upb_uint32_t>::H UInt32Handler;
- typedef ValueHandler<upb_uint64_t>::H UInt64Handler;
- typedef ValueHandler<float>::H FloatHandler;
- typedef ValueHandler<double>::H DoubleHandler;
- typedef ValueHandler<bool>::H BoolHandler;
+ typedef ValueHandler<int32_t>::H Int32Handler;
+ typedef ValueHandler<int64_t>::H Int64Handler;
+ typedef ValueHandler<uint32_t>::H UInt32Handler;
+ typedef ValueHandler<uint64_t>::H UInt64Handler;
+ typedef ValueHandler<float>::H FloatHandler;
+ typedef ValueHandler<double>::H DoubleHandler;
+ typedef ValueHandler<bool>::H BoolHandler;
// Any function pointer can be converted to this and converted back to its
// correct type.
@@ -470,8 +470,14 @@ template <class T> class Handler {
Handler(FuncPtr h, void *d, void (*c)(void *))
: handler_(h), data_(d), cleanup_(c), registered_(false) {}
- Handler(const Handler&);
void operator=(const Handler&);
+#ifdef UPB_CXX11
+ // C++98 doesn't support binding a const ref to a temporary, at least
+ // according to Clang. It is still intended that users NOT create instances
+ // of this object via this copy constructor, and any attempts to register
+ // such an object more than once will assert-fail.
+ Handler(const Handler&);
+#endif
FuncPtr handler_;
void *data_;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback