summaryrefslogtreecommitdiff
path: root/upb/bindings
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2016-05-12 11:54:34 -0700
committerJoshua Haberman <jhaberman@gmail.com>2016-05-12 11:54:34 -0700
commitfa338b70a602d9f5657528d0322535959a92d4b0 (patch)
treea7ec8b8d61a1ff3657aff99316ec51a8b81726ad /upb/bindings
parente16ed470be7d0d459e85e1d7b43893358a625d34 (diff)
Added UPB_ASSERT() that helps avoid unused var warnings.
* Added UPB_ASSERT() that helps avoid unused var warnings. * Addressed PR comments. * Fixed assert in the JIT.
Diffstat (limited to 'upb/bindings')
-rw-r--r--upb/bindings/googlepb/bridge.cc16
-rw-r--r--upb/bindings/googlepb/bridge.h4
-rw-r--r--upb/bindings/googlepb/proto1.cc22
-rw-r--r--upb/bindings/googlepb/proto2.cc38
-rw-r--r--upb/bindings/lua/upb.c12
-rw-r--r--upb/bindings/python/upb.c16
-rw-r--r--upb/bindings/ruby/upb.c22
-rw-r--r--upb/bindings/stdc/io.c4
8 files changed, 67 insertions, 67 deletions
diff --git a/upb/bindings/googlepb/bridge.cc b/upb/bindings/googlepb/bridge.cc
index c196140..adba3e7 100644
--- a/upb/bindings/googlepb/bridge.cc
+++ b/upb/bindings/googlepb/bridge.cc
@@ -18,7 +18,7 @@
#define ASSERT_STATUS(status) do { \
if (!upb_ok(status)) { \
fprintf(stderr, "upb status failure: %s\n", upb_status_errmsg(status)); \
- assert(upb_ok(status)); \
+ UPB_ASSERT(upb_ok(status)); \
} \
} while (0)
@@ -49,7 +49,7 @@ const goog::Message* TryGetFieldPrototype(const goog::Message& m,
const goog::Message* GetFieldPrototype(const goog::Message& m,
const goog::FieldDescriptor* f) {
const goog::Message* ret = TryGetFieldPrototype(m, f);
- assert(ret);
+ UPB_ASSERT(ret);
return ret;
}
@@ -66,7 +66,7 @@ const EnumDef* DefBuilder::GetEnumDef(const goog::EnumDescriptor* ed) {
for (int i = 0; i < ed->value_count(); i++) {
const goog::EnumValueDescriptor* val = ed->value(i);
bool success = e->AddValue(val->name(), val->number(), &status);
- UPB_ASSERT_VAR(success, success);
+ UPB_ASSERT(success);
}
e->Freeze(&status);
@@ -96,7 +96,7 @@ const MessageDef* DefBuilder::GetMaybeUnfrozenMessageDef(
for (size_t i = 0; i < fields.size(); i++) {
const goog::FieldDescriptor* proto2_f = fields[i];
- assert(proto2_f);
+ UPB_ASSERT(proto2_f);
md->AddField(NewFieldDef(proto2_f, m), &status);
}
ASSERT_STATUS(&status);
@@ -128,7 +128,7 @@ reffed_ptr<FieldDef> DefBuilder::NewFieldDef(const goog::FieldDescriptor* f,
subm = TryGetFieldPrototype(*m, f);
if (upb_f->type() == UPB_TYPE_MESSAGE) {
- assert(subm);
+ UPB_ASSERT(subm);
} else if (subm) {
// Weak field: subm will be weak prototype even though the proto2
// descriptor does not indicate a submessage field.
@@ -250,14 +250,14 @@ const Handlers* CodeCache::GetMaybeUnfrozenWriteHandlers(
if (!proto2_f) {
proto2_f = d->file()->pool()->FindExtensionByNumber(d, upb_f->number());
}
- assert(proto2_f);
+ UPB_ASSERT(proto2_f);
bool ok = WriteHandlers::AddFieldHandler(m, proto2_f, h);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
if (upb_f->type() == UPB_TYPE_MESSAGE) {
const goog::Message* prototype = GetFieldPrototype(m, proto2_f);
- assert(prototype);
+ UPB_ASSERT(prototype);
const upb::Handlers* sub_handlers =
GetMaybeUnfrozenWriteHandlers(upb_f->message_subdef(), *prototype);
h->SetSubHandlers(upb_f, sub_handlers);
diff --git a/upb/bindings/googlepb/bridge.h b/upb/bindings/googlepb/bridge.h
index ec8ac41..ce55dc6 100644
--- a/upb/bindings/googlepb/bridge.h
+++ b/upb/bindings/googlepb/bridge.h
@@ -128,7 +128,7 @@ class DefBuilder {
template <class T>
T* AddToCache(const void *proto2_descriptor, reffed_ptr<T> def) {
- assert(def_cache_.find(proto2_descriptor) == def_cache_.end());
+ UPB_ASSERT(def_cache_.find(proto2_descriptor) == def_cache_.end());
def_cache_[proto2_descriptor] = def;
return def.get(); // Continued lifetime is guaranteed by cache.
}
@@ -207,7 +207,7 @@ class CodeCache {
const MessageDef* md, const ::google::protobuf::Message& m);
Handlers* AddToCache(const MessageDef* md, reffed_ptr<Handlers> handlers) {
- assert(handlers_cache_.find(md) == handlers_cache_.end());
+ UPB_ASSERT(handlers_cache_.find(md) == handlers_cache_.end());
handlers_cache_[md] = handlers;
return handlers.get(); // Continue lifetime is guaranteed by the cache.
}
diff --git a/upb/bindings/googlepb/proto1.cc b/upb/bindings/googlepb/proto1.cc
index fa51f79..c85bfca 100644
--- a/upb/bindings/googlepb/proto1.cc
+++ b/upb/bindings/googlepb/proto1.cc
@@ -35,7 +35,7 @@ namespace proto2 { class Arena; }
#include "upb/sink.h"
// Unconditionally evaluate, but also assert in debug mode.
-#define CHKRET(x) do { bool ok = (x); UPB_UNUSED(ok); assert(ok); } while (0)
+#define CHKRET(x) do { bool ok = (x); UPB_ASSERT(ok); } while (0)
template <class T> static T* GetPointer(void* message, size_t offset) {
return reinterpret_cast<T*>(static_cast<char*>(message) + offset);
@@ -58,7 +58,7 @@ class P2R_Handlers {
dynamic_cast<const _pi::Proto2Reflection*>(base_r);
if (!r) return false;
// Extensions don't exist in proto1.
- assert(!proto2_f->is_extension());
+ UPB_ASSERT(!proto2_f->is_extension());
#define PRIMITIVE(name, type_name) \
case _pi::CREP_REQUIRED_##name: \
@@ -107,7 +107,7 @@ class P2R_Handlers {
SetWeakMessageHandlers(proto2_f, m, r, upb_f, h);
return true;
default:
- assert(false);
+ UPB_ASSERT(false);
return false;
}
}
@@ -147,10 +147,10 @@ class P2R_Handlers {
} else if (dynamic_cast<const _pi::Proto2Reflection*>(m.GetReflection())) {
// Since proto1 has no dynamic message, it must be from the generated
// factory.
- assert(f->cpp_type() == proto2::FieldDescriptor::CPPTYPE_MESSAGE);
+ UPB_ASSERT(f->cpp_type() == proto2::FieldDescriptor::CPPTYPE_MESSAGE);
ret = proto2::MessageFactory::generated_factory()->GetPrototype(
f->message_type());
- assert(ret);
+ UPB_ASSERT(ret);
return ret;
} else {
return NULL;
@@ -175,7 +175,7 @@ class P2R_Handlers {
}
void SetHasbit(void* message) const {
- assert(!is_repeated_);
+ UPB_ASSERT(!is_repeated_);
uint8_t* byte = GetPointer<uint8_t>(message, hasbyte_);
*byte |= mask_;
}
@@ -193,13 +193,13 @@ class P2R_Handlers {
upb::Handlers::Type type) {
upb::Handlers::Selector selector;
bool ok = upb::Handlers::GetSelector(f, type, &selector);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return selector;
}
static int16_t GetHasbit(const proto2::FieldDescriptor* f,
const _pi::Proto2Reflection* r) {
- assert(!f->is_repeated());
+ UPB_ASSERT(!f->is_repeated());
return (r->layout_->has_bit_offset * 8) + r->GetFieldLayout(f)->has_index;
}
@@ -303,7 +303,7 @@ class P2R_Handlers {
const proto2::FieldDescriptor* proto2_f, const _pi::Proto2Reflection* r,
const upb::FieldDef* f, upb::Handlers* h) {
// This type is only used for non-repeated string fields.
- assert(!f->IsSequence());
+ UPB_ASSERT(!f->IsSequence());
CHKRET(h->SetStartStringHandler(
f, UpbBind(StartOutOfLineString, new FieldOffset(proto2_f, r))));
CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringBuf)));
@@ -452,7 +452,7 @@ class P2R_Handlers {
// around waiting for reuse, which we will not do.
static void Delete(Type* t) {
UPB_UNUSED(t);
- assert(false);
+ UPB_ASSERT(false);
}
#else
static ::proto2::Arena* GetArena(Type* t) {
@@ -470,7 +470,7 @@ class P2R_Handlers {
static void Delete(Type* t, ::proto2::Arena* arena) {
UPB_UNUSED(t);
UPB_UNUSED(arena);
- assert(false);
+ UPB_ASSERT(false);
}
static void Merge(const Type& from, Type* to) {
to->MergeFrom(from);
diff --git a/upb/bindings/googlepb/proto2.cc b/upb/bindings/googlepb/proto2.cc
index ee31d34..bfd5ba2 100644
--- a/upb/bindings/googlepb/proto2.cc
+++ b/upb/bindings/googlepb/proto2.cc
@@ -21,14 +21,14 @@
namespace {
template<typename To, typename From> To CheckDownCast(From* f) {
- assert(f == NULL || dynamic_cast<To>(f) != NULL);
+ UPB_ASSERT(f == NULL || dynamic_cast<To>(f) != NULL);
return static_cast<To>(f);
}
}
// Unconditionally evaluate, but also assert in debug mode.
-#define CHKRET(x) do { bool ok = (x); UPB_UNUSED(ok); assert(ok); } while (0)
+#define CHKRET(x) do { bool ok = (x); UPB_ASSERT(ok); } while (0)
namespace upb {
namespace google_google3 { class GMR_Handlers; }
@@ -222,7 +222,7 @@ case goog::FieldDescriptor::cpptype: \
upb::Handlers::Type type) {
upb::Handlers::Selector selector;
bool ok = upb::Handlers::GetSelector(f, type, &selector);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return selector;
}
@@ -230,7 +230,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* f,
const goog::internal::GeneratedMessageReflection* r) {
// proto2 does not store hasbits for repeated fields.
- assert(!f->is_repeated());
+ UPB_ASSERT(!f->is_repeated());
return (r->has_bits_offset_ * 8) + f->index();
}
@@ -238,7 +238,7 @@ case goog::FieldDescriptor::cpptype: \
static size_t GetOneofDiscriminantOffset(
const goog::FieldDescriptor* f,
const goog::internal::GeneratedMessageReflection* r) {
- assert(f->containing_oneof());
+ UPB_ASSERT(f->containing_oneof());
return r->oneof_case_offset_ + f->containing_oneof()->index();
}
#endif
@@ -326,7 +326,7 @@ case goog::FieldDescriptor::cpptype: \
}
void SetHasbit(void* m) const {
- assert(!is_repeated_);
+ UPB_ASSERT(!is_repeated_);
uint8_t* byte = GetPointer<uint8_t>(m, hasbyte_);
*byte |= mask_;
}
@@ -470,7 +470,7 @@ case goog::FieldDescriptor::cpptype: \
return ONEOF_TYPE_STRINGPIECE;
#endif
default:
- assert(false);
+ UPB_ASSERT(false);
return ONEOF_TYPE_NONE;
}
}
@@ -582,7 +582,7 @@ case goog::FieldDescriptor::cpptype: \
}
#ifdef GOOGLE_PROTOBUF_HAS_ONEOF
else if (proto2_f->containing_oneof()) {
- assert(!proto2_f->is_repeated());
+ UPB_ASSERT(!proto2_f->is_repeated());
CHKRET(h->SetValueHandler<T>(
f, UpbBindT(SetOneofPrimitive<T>,
new OneofFieldHandlerData(proto2_f, r))));
@@ -656,7 +656,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* proto2_f,
const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) {
- assert(!proto2_f->is_extension());
+ UPB_ASSERT(!proto2_f->is_extension());
scoped_ptr<EnumHandlerData> data(new EnumHandlerData(proto2_f, r, f));
if (f->IsSequence()) {
CHKRET(h->SetInt32Handler(f, UpbBind(AppendEnum, data.release())));
@@ -696,7 +696,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* proto2_f,
const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) {
- assert(proto2_f->is_extension());
+ UPB_ASSERT(proto2_f->is_extension());
scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r));
if (f->IsSequence()) {
CHKRET(
@@ -745,11 +745,11 @@ case goog::FieldDescriptor::cpptype: \
const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f,
upb::Handlers* h) {
- assert(!proto2_f->is_extension());
+ UPB_ASSERT(!proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(&OnStringBuf<T>)));
#ifdef GOOGLE_PROTOBUF_HAS_ONEOF
if (proto2_f->containing_oneof()) {
- assert(!f->IsSequence());
+ UPB_ASSERT(!f->IsSequence());
CHKRET(h->SetStartStringHandler(
f, UpbBindT(&StartOneofString<T>,
new OneofFieldHandlerData(proto2_f, r))));
@@ -835,7 +835,7 @@ case goog::FieldDescriptor::cpptype: \
const goog::FieldDescriptor* proto2_f,
const goog::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) {
- assert(proto2_f->is_extension());
+ UPB_ASSERT(proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandlerT(OnStringBuf<T>)));
scoped_ptr<ExtensionFieldData> data(new ExtensionFieldData(proto2_f, r));
if (f->IsSequence()) {
@@ -908,7 +908,7 @@ case goog::FieldDescriptor::cpptype: \
new SubMessageHandlerData(proto2_f, r, field_prototype));
#ifdef GOOGLE_PROTOBUF_HAS_ONEOF
if (proto2_f->containing_oneof()) {
- assert(!f->IsSequence());
+ UPB_ASSERT(!f->IsSequence());
CHKRET(h->SetStartSubMessageHandler(
f, UpbBind(StartOneofSubMessage, new OneofSubMessageHandlerData(
proto2_f, r, field_prototype))));
@@ -965,7 +965,7 @@ case goog::FieldDescriptor::cpptype: \
// around waiting for reuse, which we will not do.
static void Delete(Type* t) {
UPB_UNUSED(t);
- assert(false);
+ UPB_ASSERT(false);
}
#endif // ifdef GOOGLE_PROTOBUF_HAS_ARENAS
@@ -1089,7 +1089,7 @@ case goog::FieldDescriptor::cpptype: \
// "We could speed this up by using CordReader internals."
Cord piece(*source_cord);
piece.RemovePrefix(handle->object_offset() + (buf - handle->buffer()));
- assert(piece.size() >= n);
+ UPB_ASSERT(piece.size() >= n);
piece.RemoveSuffix(piece.size() - n);
c->Append(piece);
@@ -1102,7 +1102,7 @@ case goog::FieldDescriptor::cpptype: \
const proto2::FieldDescriptor* proto2_f,
const proto2::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) {
- assert(!proto2_f->is_extension());
+ UPB_ASSERT(!proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandler(&OnCordBuf)));
if (f->IsSequence()) {
SetStartRepeatedField<Cord>(proto2_f, r, f, h);
@@ -1139,7 +1139,7 @@ case goog::FieldDescriptor::cpptype: \
const proto2::FieldDescriptor* proto2_f,
const proto2::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) {
- assert(!proto2_f->is_extension());
+ UPB_ASSERT(!proto2_f->is_extension());
CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnStringPieceBuf)));
if (f->IsSequence()) {
SetStartRepeatedPtrField<proto2::internal::StringPieceField>(proto2_f, r,
@@ -1194,7 +1194,7 @@ case goog::FieldDescriptor::cpptype: \
const proto2::Message& m,
const proto2::internal::GeneratedMessageReflection* r,
const upb::FieldDef* f, upb::Handlers* h) {
- assert(!proto2_f->is_repeated());
+ UPB_ASSERT(!proto2_f->is_repeated());
const goog::Message* field_prototype = GetFieldPrototype(m, proto2_f);
CHKRET(h->SetStringHandler(f, UpbMakeHandler(OnLazyFieldBuf)));
if (proto2_f->is_extension()) {
diff --git a/upb/bindings/lua/upb.c b/upb/bindings/lua/upb.c
index 4768212..1483676 100644
--- a/upb/bindings/lua/upb.c
+++ b/upb/bindings/lua/upb.c
@@ -141,7 +141,7 @@ static void *newudata_with_userval(lua_State *L, size_t size,
/* Set metatable. */
luaL_getmetatable(L, type);
- assert(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */
+ UPB_ASSERT(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */
lua_setmetatable(L, -2);
lua_newtable(L);
@@ -322,7 +322,7 @@ bool lupb_refcounted_pushwrapper(lua_State *L, const upb_refcounted *obj,
/* Lookup our cache in the registry (we don't put our objects in the registry
* directly because we need our cache to be a weak table). */
lua_getfield(L, LUA_REGISTRYINDEX, LUPB_OBJCACHE);
- assert(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */
+ UPB_ASSERT(!lua_isnil(L, -1)); /* Should have been created by luaopen_upb. */
lua_pushlightuserdata(L, (void*)obj);
lua_rawget(L, -2);
/* Stack is now: objcache, cached value. */
@@ -382,7 +382,7 @@ void lupb_refcounted_pushnewrapper(lua_State *L, const upb_refcounted *obj,
const char *type, const void *ref_donor) {
bool created =
lupb_refcounted_pushwrapper(L, obj, type, ref_donor, sizeof(void *));
- UPB_ASSERT_VAR(created, created == true);
+ UPB_ASSERT(created == true);
}
static int lupb_refcounted_gc(lua_State *L) {
@@ -461,7 +461,7 @@ bool lupb_def_pushwrapper(lua_State *L, const upb_def *def,
void lupb_def_pushnewrapper(lua_State *L, const upb_def *def,
const void *ref_donor) {
bool created = lupb_def_pushwrapper(L, def, ref_donor);
- UPB_ASSERT_VAR(created, created == true);
+ UPB_ASSERT(created == true);
}
static int lupb_def_type(lua_State *L) {
@@ -1310,7 +1310,7 @@ static int lupb_filedefiter_next(lua_State *L) {
const upb_def *def;
def = upb_filedef_def(f, i);
- assert(def);
+ UPB_ASSERT(def);
if (type == UPB_DEF_ANY || upb_def_type(def) == type) {
lua_pushinteger(L, i + 1);
@@ -1738,7 +1738,7 @@ static lupb_msgdef *lupb_msg_assignoffsets(lua_State *L, int narg) {
upb_fielddef *f = upb_msg_iter_field(&i);
if (upb_fielddef_type(f) == UPB_TYPE_MESSAGE) {
bool created = lupb_def_pushwrapper(L, upb_fielddef_subdef(f), NULL);
- UPB_ASSERT_VAR(created, !created);
+ UPB_ASSERT(!created);
lupb_msg_assignoffsets(L, -1);
lua_rawseti(L, -2, idx++); /* Append to uservalue. */
}
diff --git a/upb/bindings/python/upb.c b/upb/bindings/python/upb.c
index 778b821..1646acc 100644
--- a/upb/bindings/python/upb.c
+++ b/upb/bindings/python/upb.c
@@ -63,7 +63,7 @@ static PyObject *weakref_callback = NULL;
static PyObject *PyUpb_StringForPointer(const void *ptr) {
PyObject *o = PyString_FromStringAndSize((const char *)&ptr, sizeof(void*));
- assert(o);
+ UPB_ASSERT(o);
return o;
}
@@ -73,11 +73,11 @@ static PyObject *PyUpb_ObjCacheDeleteCallback(PyObject *self, PyObject *ref) {
// remove from the cache. As a result we are forced to keep a second map
// mapping weakref->C pointer.
PyObject *ptr_str = PyDict_GetItem(reverse_cache, ref);
- assert(ptr_str);
+ UPB_ASSERT(ptr_str);
int err = PyDict_DelItem(obj_cache, ptr_str);
- assert(!err);
+ UPB_ASSERT(!err);
err = PyDict_DelItem(reverse_cache, ref);
- assert(!err);
+ UPB_ASSERT(!err);
return Py_None;
}
@@ -87,7 +87,7 @@ static PyObject *PyUpb_ObjCacheGet(const void *obj, PyTypeObject *type) {
PyObject *ret;
if (ref) {
ret = PyWeakref_GetObject(ref);
- assert(ret != Py_None);
+ UPB_ASSERT(ret != Py_None);
Py_INCREF(ret);
} else {
PyUpb_ObjWrapper *wrapper = (PyUpb_ObjWrapper*)type->tp_alloc(type, 0);
@@ -95,12 +95,12 @@ static PyObject *PyUpb_ObjCacheGet(const void *obj, PyTypeObject *type) {
wrapper->weakreflist = NULL;
ret = (PyObject*)wrapper;
ref = PyWeakref_NewRef(ret, weakref_callback);
- assert(PyWeakref_GetObject(ref) == ret);
- assert(ref);
+ UPB_ASSERT(PyWeakref_GetObject(ref) == ret);
+ UPB_ASSERT(ref);
PyDict_SetItem(obj_cache, kv, ref);
PyDict_SetItem(reverse_cache, ref, kv);
}
- assert(ret);
+ UPB_ASSERT(ret);
Py_DECREF(kv);
return ret;
}
diff --git a/upb/bindings/ruby/upb.c b/upb/bindings/ruby/upb.c
index ea0fcc8..7598bac 100644
--- a/upb/bindings/ruby/upb.c
+++ b/upb/bindings/ruby/upb.c
@@ -161,8 +161,8 @@ static void objcache_init() {
// Call to uninitialize the cache. Should be done once on process shutdown.
static void objcache_uninit(ruby_vm_t *vm) {
- assert(objcache_initialized);
- assert(upb_inttable_count(&objcache) == 0);
+ UPB_ASSERT(objcache_initialized);
+ UPB_ASSERT(upb_inttable_count(&objcache) == 0);
objcache_initialized = false;
upb_inttable_uninit(&objcache);
@@ -171,7 +171,7 @@ static void objcache_uninit(ruby_vm_t *vm) {
// Looks up the given object in the cache. If the corresponding Ruby wrapper
// object is found, returns it, otherwise creates the wrapper and returns that.
static VALUE objcache_getorcreate(const void *obj, createfunc *func) {
- assert(objcache_initialized);
+ UPB_ASSERT(objcache_initialized);
upb_value v;
if (!upb_inttable_lookupptr(&objcache, obj, &v)) {
@@ -184,10 +184,10 @@ static VALUE objcache_getorcreate(const void *obj, createfunc *func) {
// Removes the given object from the cache. Should only be called by the code
// that is freeing the wrapper object.
static void objcache_remove(const void *obj) {
- assert(objcache_initialized);
+ UPB_ASSERT(objcache_initialized);
bool removed = upb_inttable_removeptr(&objcache, obj, NULL);
- UPB_ASSERT_VAR(removed, removed);
+ UPB_ASSERT(removed);
}
/* message layout *************************************************************/
@@ -256,7 +256,7 @@ static size_t rupb_sizeof(const upb_fielddef *f) {
default:
break;
}
- assert(false);
+ UPB_ASSERT(false);
return 0;
}
@@ -656,7 +656,7 @@ static VALUE msg_accessor(int argc, VALUE *argv, VALUE obj) {
rupb_Message *msg = msg_get(obj);
// method_missing protocol: (method [, arg1, arg2, ...])
- assert(argc >= 1 && SYMBOL_P(argv[0]));
+ UPB_ASSERT(argc >= 1 && SYMBOL_P(argv[0]));
// OPT(haberman): find a better way to get the method name.
// This is allocating a new string each time, which should not be necessary.
VALUE method = rb_id2str(SYM2ID(argv[0]));
@@ -668,7 +668,7 @@ static VALUE msg_accessor(int argc, VALUE *argv, VALUE obj) {
// foo.bar = x
//
// Ruby should guarantee that we have exactly one more argument (x)
- assert(argc == 2);
+ UPB_ASSERT(argc == 2);
return msg_setter(msg, method, argv[1]);
} else {
// Call was:
@@ -1011,14 +1011,14 @@ static const upb_handlers *new_fill_handlers(const rupb_MessageDef *rmd,
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
upb_selector_t ret;
bool ok = upb_handlers_getselector(f, type, &ret);
- UPB_ASSERT_VAR(ok, ok);
+ UPB_ASSERT(ok);
return ret;
}
static void putstr(VALUE str, const upb_fielddef *f, upb_sink *sink) {
if (str == Qnil) return;
- assert(BUILTIN_TYPE(str) == RUBY_T_STRING);
+ UPB_ASSERT(BUILTIN_TYPE(str) == RUBY_T_STRING);
upb_sink subsink;
upb_sink_startstr(sink, getsel(f, UPB_HANDLER_STARTSTR), RSTRING_LEN(str),
@@ -1042,7 +1042,7 @@ static void putsubmsg(VALUE submsg, const upb_fielddef *f, upb_sink *sink) {
static void putary(VALUE ary, const upb_fielddef *f, upb_sink *sink) {
if (ary == Qnil) return;
- assert(BUILTIN_TYPE(ary) == RUBY_T_ARRAY);
+ UPB_ASSERT(BUILTIN_TYPE(ary) == RUBY_T_ARRAY);
upb_sink subsink;
upb_sink_startseq(sink, getsel(f, UPB_HANDLER_STARTSEQ), &subsink);
diff --git a/upb/bindings/stdc/io.c b/upb/bindings/stdc/io.c
index a95eb48..fe82014 100644
--- a/upb/bindings/stdc/io.c
+++ b/upb/bindings/stdc/io.c
@@ -36,7 +36,7 @@ static upb_stdio_buf *upb_stdio_rotatebufs(upb_stdio *s) {
reuse[num_reused++] = buf;
}
}
- assert(num_reused + num_inuse == s->nbuf);
+ UPB_ASSERT(num_reused + num_inuse == s->nbuf);
memcpy(s->bufs + num_inuse, reuse, num_reused * sizeof(upb_stdio_buf*));
if (num_reused == 0) {
++s->nbuf;
@@ -78,7 +78,7 @@ retry:
return upb_errno_is_wouldblock(errno) ?
UPB_BYTE_WOULDBLOCK : UPB_BYTE_ERROR;
}
- assert(false);
+ UPB_ASSERT(false);
}
return UPB_BYTE_OK;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback