Open source fixes: builds on OS X again.

pull/13171/head
Joshua Haberman 12 years ago
parent cfdb9907cb
commit 70293f5faa
  1. 10
      Makefile
  2. 1
      upb/def.c
  3. 2
      upb/google/bridge.cc
  4. 4
      upb/google/proto2.cc
  5. 28
      upb/handlers.h
  6. 1
      upb/pb/decoder.c
  7. 4
      upb/table.c

@ -49,7 +49,7 @@ CXX=g++
CFLAGS=-std=gnu99
CXXFLAGS=-Ibindings/cpp
INCLUDE=-Itests -I.
CPPFLAGS=$(INCLUDE) -Wall -Wextra $(USER_CFLAGS)
CPPFLAGS=$(INCLUDE) -Wall -Wextra -Wno-sign-compare $(USER_CFLAGS)
LDLIBS=-lpthread upb/libupb.a
LUA=lua5.1 # 5.1 and 5.2 should both be supported
@ -82,7 +82,7 @@ deps: Makefile $(ALLSRC)
# The core library.
CORE= \
upb/bytestream.c \
upb/bytestream.upb.c \
upb/def.c \
upb/descriptor/reader.c \
upb/descriptor/descriptor.upb.c \
@ -101,9 +101,10 @@ CORE= \
PB= \
upb/pb/decoder.c \
upb/pb/glue.c \
upb/pb/textprinter.c \
upb/pb/varint.c \
#upb/pb/textprinter.c \
# Rules. #######################################################################
@ -247,7 +248,8 @@ $(SIMPLE_CXX_TESTS): % : %.cc
$(E) CXX $<
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ tests/testmain.o $< $(LIBUPB)
VALGRIND=valgrind --leak-check=full --error-exitcode=1
#VALGRIND=valgrind --leak-check=full --error-exitcode=1 --track-origins=yes
VALGRIND=
test: tests
@echo Running all tests under valgrind.
@set -e # Abort on error.

@ -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) {

@ -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<const goog::FieldDescriptor*> fields;
std::vector<const goog::FieldDescriptor*> fields;
d->file()->pool()->FindAllExtensions(d, &fields);
for (int i = 0; i < d->field_count(); i++) {
fields.push_back(d->field(i));

@ -409,7 +409,7 @@ case goog::FieldDescriptor::cpptype: \
static_cast<const EnumHandlerData*>(frame->handler_data());
if (data->IsValidValue(val)) {
goog::RepeatedField<int32_t>* r =
data->GetFieldPointer<goog::RepeatedField<int32_t>>(m);
data->GetFieldPointer<goog::RepeatedField<int32_t> >(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<T>* data = new StringHandlerData<T>(proto2_f, r);
h->SetStartStringHandler(f, &StartString<T>, data,
&upb::DeletePointer<StringHandlerData<T>>);
&upb::DeletePointer<StringHandlerData<T> >);
}
}

@ -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<ctype>( \
const FieldDef* f, \
typename Handlers::Value<ctype>::Handler* handler, \
handlertype* handler, \
void* data, Handlers::Free* cleanup) { \
return upb_handlers_set ## type(this, f, handler, data, cleanup); \
} \
template<> \
inline bool Handlers::SetValueHandler<ctype>( \
const char* f, \
typename Handlers::Value<ctype>::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

@ -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);

@ -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);
}

Loading…
Cancel
Save