From 70293f5faabe08fc9bdef26ad0b1d6afe19e8f79 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Sat, 11 May 2013 17:56:13 -0700 Subject: Open source fixes: builds on OS X again. --- upb/def.c | 1 + upb/google/bridge.cc | 2 +- upb/google/proto2.cc | 4 ++-- upb/handlers.h | 28 ++++++++++++++-------------- upb/pb/decoder.c | 1 - upb/table.c | 4 ---- 6 files changed, 18 insertions(+), 22 deletions(-) (limited to 'upb') diff --git a/upb/def.c b/upb/def.c index aad0e51..b8d3259 100644 --- a/upb/def.c +++ b/upb/def.c @@ -676,6 +676,7 @@ upb_descriptortype_t upb_fielddef_descriptortype(const upb_fielddef *f) { return upb_fielddef_istagdelim(f) ? UPB_DESCRIPTOR_TYPE_GROUP : UPB_DESCRIPTOR_TYPE_MESSAGE; } + return 0; } bool upb_fielddef_setlabel(upb_fielddef *f, upb_label_t label) { diff --git a/upb/google/bridge.cc b/upb/google/bridge.cc index f5b664c..93e5c27 100644 --- a/upb/google/bridge.cc +++ b/upb/google/bridge.cc @@ -208,7 +208,7 @@ static upb::MessageDef* NewMessageDef(const goog::Message& m, const void* owner, // Must do this before processing submessages to prevent infinite recursion. defs->AddMessage(&m, md); - vector fields; + std::vector fields; d->file()->pool()->FindAllExtensions(d, &fields); for (int i = 0; i < d->field_count(); i++) { fields.push_back(d->field(i)); diff --git a/upb/google/proto2.cc b/upb/google/proto2.cc index d7ad919..8f9bcd8 100644 --- a/upb/google/proto2.cc +++ b/upb/google/proto2.cc @@ -409,7 +409,7 @@ case goog::FieldDescriptor::cpptype: \ static_cast(frame->handler_data()); if (data->IsValidValue(val)) { goog::RepeatedField* r = - data->GetFieldPointer>(m); + data->GetFieldPointer >(m); r->Add(val); } else { data->mutable_unknown_fields(m)->AddVarint(data->field_number(), val); @@ -487,7 +487,7 @@ case goog::FieldDescriptor::cpptype: \ } else { StringHandlerData* data = new StringHandlerData(proto2_f, r); h->SetStartStringHandler(f, &StartString, data, - &upb::DeletePointer>); + &upb::DeletePointer >); } } diff --git a/upb/handlers.h b/upb/handlers.h index 582ba43..79ca0d8 100644 --- a/upb/handlers.h +++ b/upb/handlers.h @@ -915,37 +915,37 @@ inline bool Handlers::SetUInt64Handler( } #endif -#define SET_VALUE_HANDLER(type, ctype) \ +#define SET_VALUE_HANDLER(type, ctype, handlertype) \ template<> \ inline bool Handlers::SetValueHandler( \ const FieldDef* f, \ - typename Handlers::Value::Handler* handler, \ + handlertype* handler, \ void* data, Handlers::Free* cleanup) { \ return upb_handlers_set ## type(this, f, handler, data, cleanup); \ } \ template<> \ inline bool Handlers::SetValueHandler( \ const char* f, \ - typename Handlers::Value::Handler* handler, \ + handlertype* handler, \ void* data, Handlers::Free* cleanup) { \ return upb_handlers_set ## type ## _n(this, f, handler, data, cleanup); \ } -SET_VALUE_HANDLER(double, double); -SET_VALUE_HANDLER(float, float); -SET_VALUE_HANDLER(uint64, upb_uint64_t); -SET_VALUE_HANDLER(uint32, upb_uint32_t); -SET_VALUE_HANDLER(int64, upb_int64_t); -SET_VALUE_HANDLER(int32, upb_int32_t); -SET_VALUE_HANDLER(bool, bool); +SET_VALUE_HANDLER(double, double, DoubleHandler); +SET_VALUE_HANDLER(float, float, FloatHandler); +SET_VALUE_HANDLER(uint64, upb_uint64_t, UInt64Handler); +SET_VALUE_HANDLER(uint32, upb_uint32_t, UInt32Handler); +SET_VALUE_HANDLER(int64, upb_int64_t, Int64Handler); +SET_VALUE_HANDLER(int32, upb_int32_t, Int32Handler); +SET_VALUE_HANDLER(bool, bool, BoolHandler); #ifdef UPB_TWO_32BIT_TYPES -SET_VALUE_HANDLER(int32alt, upb_int32alt_t); -SET_VALUE_HANDLER(uint32alt, upb_uint32alt_t); +SET_VALUE_HANDLER(int32alt, upb_int32alt_t, Int32Handler2); +SET_VALUE_HANDLER(uint32alt, upb_uint32alt_t, UInt32Handler2); #endif #ifdef UPB_TWO_64BIT_TYPES -SET_VALUE_HANDLER(int64alt, upb_int64alt_t); -SET_VALUE_HANDLER(uint64alt, upb_uint64alt_t); +SET_VALUE_HANDLER(int64alt, upb_int64alt_t, Int64Handler2); +SET_VALUE_HANDLER(uint64alt, upb_uint64alt_t, UInt64Handler2); #endif #undef SET_VALUE_HANDLER diff --git a/upb/pb/decoder.c b/upb/pb/decoder.c index 2bfc717..da4c48d 100644 --- a/upb/pb/decoder.c +++ b/upb/pb/decoder.c @@ -290,7 +290,6 @@ static void suspendjmp(upb_pbdecoder *d) { } static void advancetobuf(upb_pbdecoder *d, const char *buf, size_t len) { - assert(len >= 0); assert(d->ptr == d->end); d->bufstart_ofs += (d->ptr - d->buf); switchtobuf(d, buf, buf + len); diff --git a/upb/table.c b/upb/table.c index a54e715..40f841d 100644 --- a/upb/table.c +++ b/upb/table.c @@ -22,12 +22,8 @@ static const double MAX_LOAD = 0.85; static const double MIN_DENSITY = 0.1; int upb_log2(uint64_t v) { -#ifdef __GNUC__ - int ret = 31 - __builtin_clz(v); -#else int ret = 0; while (v >>= 1) ret++; -#endif return UPB_MIN(UPB_MAXARRSIZE, ret); } -- cgit v1.2.3