Fixes to compile on GCC 4.2, as shipped with XCode.

pull/13171/head
Josh Haberman 12 years ago
parent bada1e94f4
commit 228872a5c6
  1. 2
      Makefile
  2. 8
      tests/test_handlers.c
  3. 2
      tests/test_pipeline.c
  4. 1
      upb/descriptor/reader.c
  5. 4
      upb/google/bridge.cc
  6. 13
      upb/handlers-inl.h
  7. 22
      upb/handlers.h

@ -216,6 +216,8 @@ tests/test.proto.pb: tests/test.proto
SIMPLE_TESTS= \ SIMPLE_TESTS= \
tests/test_def \ tests/test_def \
tests/test_varint \ tests/test_varint \
tests/test_pipeline \
tests/test_handlers
SIMPLE_CXX_TESTS= \ SIMPLE_CXX_TESTS= \
tests/test_cpp \ tests/test_cpp \

@ -11,7 +11,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.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() { static void test_error() {
upb_handlers *h = upb_handlers_new(GOOGLE_PROTOBUF_DESCRIPTORPROTO, NULL, &h); 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[]) { int run_tests(int argc, char *argv[]) {
UPB_UNUSED(argc);
UPB_UNUSED(argv);
test_error(); test_error();
return 0; return 0;
} }

@ -108,6 +108,8 @@ static void test_realloc() {
} }
int run_tests(int argc, char *argv[]) { int run_tests(int argc, char *argv[]) {
UPB_UNUSED(argc);
UPB_UNUSED(argv);
test_empty(); test_empty();
test_only_initial(); test_only_initial();
test_with_alloc_func(); test_with_alloc_func();

@ -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) { static bool enum_endmsg(void *closure, const void *hd, upb_status *status) {
UPB_UNUSED(hd);
upb_descreader *r = closure; upb_descreader *r = closure;
upb_enumdef *e = upb_downcast_enumdef_mutable(upb_descreader_last(r)); upb_enumdef *e = upb_downcast_enumdef_mutable(upb_descreader_last(r));
if (upb_def_fullname(upb_descreader_last(r)) == NULL) { if (upb_def_fullname(upb_descreader_last(r)) == NULL) {

@ -131,8 +131,8 @@ FieldDef* AddFieldDef(const goog::Message& m, const goog::FieldDescriptor* f,
: upb::FieldDef::ConvertDescriptorType(f->type())); : upb::FieldDef::ConvertDescriptorType(f->type()));
if (weak_prototype) { if (weak_prototype) {
const string& name = weak_prototype->GetDescriptor()->full_name(); upb_f->set_subdef_name(
upb_f->set_subdef_name(name, &status); weak_prototype->GetDescriptor()->full_name(), &status);
} else { } else {
switch (upb_f->type()) { switch (upb_f->type()) {
case UPB_TYPE_INT32: case UPB_TYPE_INT32:

@ -303,8 +303,8 @@ inline Handlers::StringHandler BindHandler(
template <> \ template <> \
inline bool Handlers::SetValueHandler<vtype>( \ inline bool Handlers::SetValueHandler<vtype>( \
const FieldDef *f, \ const FieldDef *f, \
const typename ValueHandler<typename CanonicalType<vtype>::Type>::H & \ const Handlers::utype ## Handler& handler) { \
handler) { \ assert(!handler.registered_); \
handler.registered_ = true; \ handler.registered_ = true; \
return upb_handlers_set##ltype(this, f, handler.handler_, handler.data_, \ return upb_handlers_set##ltype(this, f, handler.handler_, handler.data_, \
handler.cleanup_); \ handler.cleanup_); \
@ -394,54 +394,63 @@ inline const MessageDef *Handlers::message_def() const {
} }
inline bool Handlers::SetStartMessageHandler( inline bool Handlers::SetStartMessageHandler(
const Handlers::StartMessageHandler &handler) { const Handlers::StartMessageHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setstartmsg(this, handler.handler_, handler.data_, return upb_handlers_setstartmsg(this, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetEndMessageHandler( inline bool Handlers::SetEndMessageHandler(
const Handlers::EndMessageHandler &handler) { const Handlers::EndMessageHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setendmsg(this, handler.handler_, handler.data_, return upb_handlers_setendmsg(this, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetStartStringHandler(const FieldDef *f, inline bool Handlers::SetStartStringHandler(const FieldDef *f,
const StartStringHandler &handler) { const StartStringHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setstartstr(this, f, handler.handler_, handler.data_, return upb_handlers_setstartstr(this, f, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetEndStringHandler(const FieldDef *f, inline bool Handlers::SetEndStringHandler(const FieldDef *f,
const EndFieldHandler &handler) { const EndFieldHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setendstr(this, f, handler.handler_, handler.data_, return upb_handlers_setendstr(this, f, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetStringHandler(const FieldDef *f, inline bool Handlers::SetStringHandler(const FieldDef *f,
const StringHandler& handler) { const StringHandler& handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setstring(this, f, handler.handler_, handler.data_, return upb_handlers_setstring(this, f, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetStartSequenceHandler( inline bool Handlers::SetStartSequenceHandler(
const FieldDef *f, const StartFieldHandler &handler) { const FieldDef *f, const StartFieldHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setstartseq(this, f, handler.handler_, handler.data_, return upb_handlers_setstartseq(this, f, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetStartSubMessageHandler( inline bool Handlers::SetStartSubMessageHandler(
const FieldDef *f, const StartFieldHandler &handler) { const FieldDef *f, const StartFieldHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setstartsubmsg(this, f, handler.handler_, handler.data_, return upb_handlers_setstartsubmsg(this, f, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f, inline bool Handlers::SetEndSubMessageHandler(const FieldDef *f,
const EndFieldHandler &handler) { const EndFieldHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setendsubmsg(this, f, handler.handler_, handler.data_, return upb_handlers_setendsubmsg(this, f, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);
} }
inline bool Handlers::SetEndSequenceHandler(const FieldDef *f, inline bool Handlers::SetEndSequenceHandler(const FieldDef *f,
const EndFieldHandler &handler) { const EndFieldHandler &handler) {
assert(!handler.registered_);
handler.registered_ = true; handler.registered_ = true;
return upb_handlers_setendseq(this, f, handler.handler_, handler.data_, return upb_handlers_setendseq(this, f, handler.handler_, handler.data_,
handler.cleanup_); handler.cleanup_);

@ -116,13 +116,13 @@ class upb::Handlers {
typedef Handler<bool(*)(void *, const void *, T)> H; typedef Handler<bool(*)(void *, const void *, T)> H;
}; };
typedef ValueHandler<upb_int32_t>::H Int32Handler; typedef ValueHandler<int32_t>::H Int32Handler;
typedef ValueHandler<upb_int64_t>::H Int64Handler; typedef ValueHandler<int64_t>::H Int64Handler;
typedef ValueHandler<upb_uint32_t>::H UInt32Handler; typedef ValueHandler<uint32_t>::H UInt32Handler;
typedef ValueHandler<upb_uint64_t>::H UInt64Handler; typedef ValueHandler<uint64_t>::H UInt64Handler;
typedef ValueHandler<float>::H FloatHandler; typedef ValueHandler<float>::H FloatHandler;
typedef ValueHandler<double>::H DoubleHandler; typedef ValueHandler<double>::H DoubleHandler;
typedef ValueHandler<bool>::H BoolHandler; typedef ValueHandler<bool>::H BoolHandler;
// Any function pointer can be converted to this and converted back to its // Any function pointer can be converted to this and converted back to its
// correct type. // correct type.
@ -470,8 +470,14 @@ template <class T> class Handler {
Handler(FuncPtr h, void *d, void (*c)(void *)) Handler(FuncPtr h, void *d, void (*c)(void *))
: handler_(h), data_(d), cleanup_(c), registered_(false) {} : handler_(h), data_(d), cleanup_(c), registered_(false) {}
Handler(const Handler&);
void operator=(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_; FuncPtr handler_;
void *data_; void *data_;

Loading…
Cancel
Save