#include "env-inl.h"
#include "util.h"
#include "util-inl.h"
-
#include "v8.h"
-#include <assert.h>
namespace node {
const v8::Handle<v8::Function> cb,
int argc,
v8::Handle<v8::Value>* argv) {
- assert(env()->context() == env()->isolate()->GetCurrentContext());
+ CHECK_EQ(env()->context(), env()->isolate()->GetCurrentContext());
v8::Local<v8::Object> context = object();
v8::Local<v8::Object> process = env()->process_object();
if (env()->using_domains())
return MakeDomainCallback(cb, argc, argv);
- assert(env()->context() == env()->isolate()->GetCurrentContext());
+ CHECK_EQ(env()->context(), env()->isolate()->GetCurrentContext());
v8::Local<v8::Object> context = object();
v8::Local<v8::Object> process = env()->process_object();
v8::Handle<v8::Value>* argv) {
v8::Local<v8::Value> cb_v = object()->Get(symbol);
v8::Local<v8::Function> cb = cb_v.As<v8::Function>();
- assert(cb->IsFunction());
+ CHECK(cb->IsFunction());
return MakeCallback(cb, argc, argv);
}
v8::Handle<v8::Value>* argv) {
v8::Local<v8::Value> cb_v = object()->Get(index);
v8::Local<v8::Function> cb = cb_v.As<v8::Function>();
- assert(cb->IsFunction());
+ CHECK(cb->IsFunction());
return MakeCallback(cb, argc, argv);
}
#include "util-inl.h"
#include "v8.h"
-#include <assert.h>
-
namespace node {
inline BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> handle)
: handle_(env->isolate(), handle),
env_(env) {
- assert(!handle.IsEmpty());
+ CHECK_EQ(false, handle.IsEmpty());
}
inline BaseObject::~BaseObject() {
- assert(handle_.IsEmpty());
+ CHECK(handle_.IsEmpty());
}
inline void BaseObject::MakeWeak(Type* ptr) {
v8::HandleScope scope(env_->isolate());
v8::Local<v8::Object> handle = object();
- assert(handle->InternalFieldCount() > 0);
+ CHECK_GT(handle->InternalFieldCount(), 0);
Wrap<Type>(handle, ptr);
handle_.MarkIndependent();
handle_.SetWeak<Type>(ptr, WeakCallback<Type>);
#include "util.h"
#include "uv.h"
-#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
/* call back into c-ares for possibly processing timeouts. */
static void ares_timeout(uv_timer_t* handle) {
Environment* env = Environment::from_cares_timer_handle(handle);
- assert(!RB_EMPTY(env->cares_task_list()));
+ CHECK_EQ(false, RB_EMPTY(env->cares_task_list()));
ares_process_fd(env->cares_channel(), ARES_SOCKET_BAD, ARES_SOCKET_BAD);
}
/* If this is the first socket then start the timer. */
uv_timer_t* timer_handle = env->cares_timer_handle();
if (!uv_is_active(reinterpret_cast<uv_handle_t*>(timer_handle))) {
- assert(RB_EMPTY(env->cares_task_list()));
+ CHECK(RB_EMPTY(env->cares_task_list()));
uv_timer_start(timer_handle, ares_timeout, 1000, 1000);
}
/* read == 0 and write == 0 this is c-ares's way of notifying us that */
/* the socket is now closed. We must free the data associated with */
/* socket. */
- assert(task &&
- "When an ares socket is closed we should have a handle for it");
+ CHECK(task &&
+ "When an ares socket is closed we should have a handle for it");
RB_REMOVE(ares_task_list, env->cares_task_list(), task);
uv_close(reinterpret_cast<uv_handle_t*>(&task->poll_watcher),
}
virtual ~QueryWrap() {
- assert(!persistent().IsEmpty());
+ CHECK_EQ(false, persistent().IsEmpty());
persistent().Reset();
}
// Subclasses should implement the appropriate Send method.
virtual int Send(const char* name) {
- assert(0);
+ UNREACHABLE();
return 0;
}
virtual int Send(const char* name, int family) {
- assert(0);
+ UNREACHABLE();
return 0;
}
}
void ParseError(int status) {
- assert(status != ARES_SUCCESS);
+ CHECK_NE(status, ARES_SUCCESS);
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());
Local<Value> arg;
// Subclasses should implement the appropriate Parse method.
virtual void Parse(unsigned char* buf, int len) {
- assert(0);
+ UNREACHABLE();
};
virtual void Parse(struct hostent* host) {
- assert(0);
+ UNREACHABLE();
};
};
static void Query(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(!args.IsConstructCall());
- assert(args[0]->IsObject());
- assert(args[1]->IsString());
+ CHECK_EQ(false, args.IsConstructCall());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsString());
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<String> string = args[1].As<String>();
// strings for each IP and filling the results array.
address = res;
while (address) {
- assert(address->ai_socktype == SOCK_STREAM);
+ CHECK_EQ(address->ai_socktype, SOCK_STREAM);
// Ignore random ai_family types.
if (address->ai_family == AF_INET) {
// Iterate over the IPv6 responses putting them in the array.
address = res;
while (address) {
- assert(address->ai_socktype == SOCK_STREAM);
+ CHECK_EQ(address->ai_socktype, SOCK_STREAM);
// Ignore random ai_family types.
if (address->ai_family == AF_INET6) {
static void GetAddrInfo(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args[0]->IsObject());
- assert(args[1]->IsString());
- assert(args[2]->IsInt32());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsString());
+ CHECK(args[2]->IsInt32());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value hostname(args[1]);
family = AF_INET6;
break;
default:
- assert(0 && "bad address family");
+ CHECK(0 && "bad address family");
abort();
}
ares_addr_node* servers;
int r = ares_get_servers(env->cares_channel(), &servers);
- assert(r == ARES_SUCCESS);
+ CHECK_EQ(r, ARES_SUCCESS);
ares_addr_node* cur = servers;
const void* caddr = static_cast<const void*>(&cur->addr);
int err = uv_inet_ntop(cur->family, caddr, ip, sizeof(ip));
- assert(err == 0);
+ CHECK_EQ(err, 0);
Local<String> addr = OneByteString(env->isolate(), ip);
server_array->Set(i, addr);
static void SetServers(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args[0]->IsArray());
+ CHECK(args[0]->IsArray());
Local<Array> arr = Local<Array>::Cast(args[0]);
int err;
for (uint32_t i = 0; i < len; i++) {
- assert(arr->Get(i)->IsArray());
+ CHECK(arr->Get(i)->IsArray());
Local<Array> elm = Local<Array>::Cast(arr->Get(i));
- assert(elm->Get(0)->Int32Value());
- assert(elm->Get(1)->IsString());
+ CHECK(elm->Get(0)->Int32Value());
+ CHECK(elm->Get(1)->IsString());
int fam = elm->Get(0)->Int32Value();
node::Utf8Value ip(elm->Get(1));
err = uv_inet_pton(AF_INET6, *ip, &cur->addr);
break;
default:
- assert(0 && "Bad address family.");
+ CHECK(0 && "Bad address family.");
abort();
}
Environment* env = Environment::GetCurrent(context);
int r = ares_library_init(ARES_LIB_INIT_ALL);
- assert(r == ARES_SUCCESS);
+ CHECK_EQ(r, ARES_SUCCESS);
struct ares_options options;
memset(&options, 0, sizeof(options));
r = ares_init_options(env->cares_channel_ptr(),
&options,
ARES_OPT_FLAGS | ARES_OPT_SOCK_STATE_CB);
- assert(r == ARES_SUCCESS);
+ CHECK_EQ(r, ARES_SUCCESS);
/* Initialize the timeout timer. The timer won't be started until the */
/* first socket is opened. */
FSEventWrap::~FSEventWrap() {
- assert(initialized_ == false);
+ CHECK_EQ(initialized_, false);
}
void FSEventWrap::New(const FunctionCallbackInfo<Value>& args) {
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new FSEventWrap(env, args.This());
}
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
- assert(wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(wrap->persistent().IsEmpty(), false);
// We're in a bind here. libuv can set both UV_RENAME and UV_CHANGE but
// the Node API only lets us pass a single event to JS land.
} else if (events & UV_CHANGE) {
event_string = env->change_string();
} else {
- assert(0 && "bad fs events flag");
+ CHECK(0 && "bad fs events flag");
abort();
}
if (wrap == NULL || wrap->handle__ == NULL)
return;
- assert(!wrap->persistent().IsEmpty());
+ CHECK_EQ(false, wrap->persistent().IsEmpty());
uv_close(wrap->handle__, OnClose);
wrap->handle__ = NULL;
HandleWrap::~HandleWrap() {
- assert(persistent().IsEmpty());
+ CHECK(persistent().IsEmpty());
QUEUE_REMOVE(&handle_wrap_queue_);
}
HandleScope scope(env->isolate());
// The wrap object should still be there.
- assert(wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(wrap->persistent().IsEmpty(), false);
// But the handle pointer should be gone.
- assert(wrap->handle__ == NULL);
+ CHECK_EQ(wrap->handle__, NULL);
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
#include "v8-profiler.h"
#include "zlib.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h> // PATH_MAX
#include <locale.h>
void SetupAsyncListener(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args[0]->IsObject());
- assert(args[1]->IsFunction());
- assert(args[2]->IsFunction());
- assert(args[3]->IsFunction());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsFunction());
+ CHECK(args[2]->IsFunction());
+ CHECK(args[3]->IsFunction());
env->set_async_listener_run_function(args[1].As<Function>());
env->set_async_listener_load_function(args[2].As<Function>());
process_object->Set(env->tick_callback_string(), tick_callback_function);
env->set_tick_callback_function(tick_callback_function);
- assert(args[0]->IsArray());
- assert(args[1]->IsObject());
+ CHECK(args[0]->IsArray());
+ CHECK(args[1]->IsObject());
env->set_domain_array(args[0].As<Array>());
void SetupNextTick(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args[0]->IsObject());
- assert(args[1]->IsFunction());
- assert(args[2]->IsObject());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsFunction());
+ CHECK(args[2]->IsObject());
// Values use to cross communicate with processNextTick.
Local<Object> tick_info_obj = args[0].As<Object>();
int argc,
Handle<Value> argv[]) {
// If you hit this assertion, you forgot to enter the v8::Context first.
- assert(env->context() == env->isolate()->GetCurrentContext());
+ CHECK_EQ(env->context(), env->isolate()->GetCurrentContext());
Local<Object> process = env->process_object();
Local<Object> object, domain;
return MakeDomainCallback(env, recv, callback, argc, argv);
// If you hit this assertion, you forgot to enter the v8::Context first.
- assert(env->context() == env->isolate()->GetCurrentContext());
+ CHECK_EQ(env->context(), env->isolate()->GetCurrentContext());
Local<Object> process = env->process_object();
int argc,
Handle<Value> argv[]) {
Local<Function> callback = recv->Get(index).As<Function>();
- assert(callback->IsFunction());
+ CHECK(callback->IsFunction());
return MakeCallback(env, recv.As<Value>(), callback, argc, argv);
}
int argc,
Handle<Value> argv[]) {
Local<Function> callback = recv->Get(symbol).As<Function>();
- assert(callback->IsFunction());
+ CHECK(callback->IsFunction());
return MakeCallback(env, recv.As<Value>(), callback, argc, argv);
}
if (val->IsArray()) {
fprintf(stderr, "'raw' encoding (array of integers) has been removed. "
"Use 'binary'.\n");
- assert(0);
+ UNREACHABLE();
return -1;
}
filename_string,
linenum,
sourceline_string);
- assert(off >= 0);
+ CHECK_GE(off, 0);
// Print wavy underline (GetUnderline is deprecated).
for (int i = 0; i < start; i++) {
static_cast<size_t>(off) >= sizeof(arrow)) {
break;
}
- assert(static_cast<size_t>(off) < sizeof(arrow));
+ CHECK_LT(static_cast<size_t>(off), sizeof(arrow));
arrow[off++] = (sourceline_string[i] == '\t') ? '\t' : ' ';
}
for (int i = start; i < end; i++) {
static_cast<size_t>(off) >= sizeof(arrow)) {
break;
}
- assert(static_cast<size_t>(off) < sizeof(arrow));
+ CHECK_LT(static_cast<size_t>(off), sizeof(arrow));
arrow[off++] = '^';
}
- assert(static_cast<size_t>(off - 1) <= sizeof(arrow) - 1);
+ CHECK_LE(static_cast<size_t>(off - 1), sizeof(arrow) - 1);
arrow[off++] = '\n';
arrow[off] = '\0';
mp->nm_link = modlist_builtin;
modlist_builtin = mp;
} else {
- assert(modpending == NULL);
+ CHECK_EQ(modpending, NULL);
modpending = mp;
}
}
break;
}
- assert(mp == NULL || (mp->nm_flags & NM_F_BUILTIN) != 0);
+ CHECK(mp == NULL || (mp->nm_flags & NM_F_BUILTIN) != 0);
return (mp);
}
if (mod != NULL) {
exports = Object::New(env->isolate());
// Internal bindings don't have a "module" object, only exports.
- assert(mod->nm_register_func == NULL);
- assert(mod->nm_context_register_func != NULL);
+ CHECK_EQ(mod->nm_register_func, NULL);
+ CHECK_NE(mod->nm_context_register_func, NULL);
Local<Value> unused = Undefined(env->isolate());
mod->nm_context_register_func(exports, unused,
env->context(), mod->nm_priv);
static void RawDebug(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args.Length() == 1 && args[0]->IsString() &&
- "must be called with a single string");
+ CHECK(args.Length() == 1 && args[0]->IsString() &&
+ "must be called with a single string");
node::Utf8Value message(args[0]);
fprintf(stderr, "%s\n", *message);
ReportException(env, try_catch);
exit(10);
}
- assert(f_value->IsFunction());
+ CHECK(f_value->IsFunction());
Local<Function> f = Local<Function>::Cast(f_value);
// Now we call 'f' with the 'process' variable that we've built up with
InstallEarlyDebugSignalHandler();
#endif
- assert(argc > 0);
+ CHECK_GT(argc, 0);
// Hack around with the argv pointer. Used for process.title = "blah".
argv = uv_setup_args(argc, argv);
#include "v8-profiler.h"
#include "v8.h"
-#include <assert.h>
#include <string.h>
#include <limits.h>
char* obj_data = static_cast<char*>( \
obj->GetIndexedPropertiesExternalArrayData()); \
if (obj_length > 0) \
- assert(obj_data != NULL);
+ CHECK_NE(obj_data, NULL);
#define SLICE_START_END(start_arg, end_arg, end_max) \
size_t start; \
char* Data(Handle<Value> val) {
- assert(val->IsObject());
+ CHECK(val->IsObject());
// Use a fully qualified name here to work around a bug in gcc 4.2.
// It mistakes an unadorned call to Data() for the v8::String::Data type.
return node::Buffer::Data(val.As<Object>());
char* Data(Handle<Object> obj) {
- assert(obj->HasIndexedPropertiesInExternalArrayData());
+ CHECK(obj->HasIndexedPropertiesInExternalArrayData());
return static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData());
}
size_t Length(Handle<Value> val) {
- assert(val->IsObject());
+ CHECK(val->IsObject());
return Length(val.As<Object>());
}
size_t Length(Handle<Object> obj) {
- assert(obj->HasIndexedPropertiesInExternalArrayData());
+ CHECK(obj->HasIndexedPropertiesInExternalArrayData());
return obj->GetIndexedPropertiesExternalArrayDataLength();
}
Local<Object> New(Environment* env, size_t length) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
Local<Object> New(Environment* env, const char* data, size_t length) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
void* hint) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
Local<Object> Use(Environment* env, char* data, uint32_t length) {
EscapableHandleScope scope(env->isolate());
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
Local<Value> arg = Uint32::NewFromUnsigned(env->isolate(), length);
Local<Object> obj = env->buffer_constructor_function()->NewInstance(1, &arg);
void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args[0]->IsFunction());
+ CHECK(args[0]->IsFunction());
Local<Function> bv = args[0].As<Function>();
env->set_buffer_constructor_function(bv);
Local<Value> proto_v = bv->Get(env->prototype_string());
- assert(proto_v->IsObject());
+ CHECK(proto_v->IsObject());
Local<Object> proto = proto_v.As<Object>();
Uint32::New(env->isolate(), 0),
v8::ReadOnly);
- assert(args[1]->IsObject());
+ CHECK(args[1]->IsObject());
Local<Object> internal = args[1].As<Object>();
ASSERT(internal->IsObject());
"binding:script");
Local<Script> script = Script::Compile(code, fname);
clone_property_method = Local<Function>::Cast(script->Run());
- assert(clone_property_method->IsFunction());
+ CHECK(clone_property_method->IsFunction());
}
Local<Value> args[] = { global, key, sandbox };
clone_property_method->Call(global, ARRAY_SIZE(args), args);
FIXED_ONE_BYTE_STRING(env->isolate(), "_contextifyHidden");
// Don't allow contextifying a sandbox multiple times.
- assert(sandbox->GetHiddenValue(hidden_name).IsEmpty());
+ CHECK(sandbox->GetHiddenValue(hidden_name).IsEmpty());
TryCatch try_catch;
ContextifyContext* context = new ContextifyContext(env, sandbox);
static void crypto_lock_cb(int mode, int n, const char* file, int line) {
- assert((mode & CRYPTO_LOCK) || (mode & CRYPTO_UNLOCK));
- assert((mode & CRYPTO_READ) || (mode & CRYPTO_WRITE));
+ CHECK((mode & CRYPTO_LOCK) || (mode & CRYPTO_UNLOCK));
+ CHECK((mode & CRYPTO_READ) || (mode & CRYPTO_WRITE));
if (mode & CRYPTO_LOCK) {
if (mode & CRYPTO_READ)
void SecureContext::AddRootCerts(const FunctionCallbackInfo<Value>& args) {
SecureContext* sc = Unwrap<SecureContext>(args.Holder());
- assert(sc->ca_store_ == NULL);
+ CHECK_EQ(sc->ca_store_, NULL);
if (!root_cert_store) {
root_cert_store = X509_STORE_new();
int rv;
ext = X509_get_ext(cert, index);
- assert(ext != NULL);
+ CHECK_NE(ext, NULL);
rv = X509V3_EXT_print(bio, ext, 0, 0);
- assert(rv == 1);
+ CHECK_EQ(rv, 1);
BIO_get_mem_ptr(bio, &mem);
info->Set(keys[i],
return;
int slen = i2d_SSL_SESSION(sess, NULL);
- assert(slen > 0);
+ CHECK_GT(slen, 0);
unsigned char* sbuf = new unsigned char[slen];
unsigned char* p = sbuf;
// OpenSSL takes control of the pointer after accepting it
char* data = reinterpret_cast<char*>(malloc(len));
- assert(data != NULL);
+ CHECK_NE(data, NULL);
memcpy(data, resp, len);
if (!SSL_set_tlsext_status_ocsp_resp(s, data, len))
BUF_MEM* mem;
BIO *bio;
- assert(err == SSL_ERROR_SSL || err == SSL_ERROR_SYSCALL);
+ CHECK(err == SSL_ERROR_SSL || err == SSL_ERROR_SYSCALL);
// XXX We need to drain the error queue for this thread or else OpenSSL
// has the possibility of blocking connections? This problem is not well
// We should clear the error in JS-land
Local<String> error_key = ssl_env()->error_string();
Local<Value> error = object()->Get(error_key);
- assert(error->BooleanValue() == false);
+ CHECK_EQ(error->BooleanValue(), false);
#endif // NDEBUG
}
void CipherBase::New(const FunctionCallbackInfo<Value>& args) {
- assert(args.IsConstructCall() == true);
+ CHECK_EQ(args.IsConstructCall(), true);
CipherKind kind = args[0]->IsTrue() ? kCipher : kDecipher;
Environment* env = Environment::GetCurrent(args.GetIsolate());
new CipherBase(env, args.This(), kind);
int key_buf_len) {
HandleScope scope(env()->isolate());
- assert(cipher_ == NULL);
+ CHECK_EQ(cipher_, NULL);
cipher_ = EVP_get_cipherbyname(cipher_type);
if (cipher_ == NULL) {
return env()->ThrowError("Unknown cipher");
void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) {
HandleScope scope(env()->isolate());
- assert(md_ == NULL);
+ CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(hash_type);
if (md_ == NULL) {
return env()->ThrowError("Unknown message digest");
bool Hash::HashInit(const char* hash_type) {
- assert(md_ == NULL);
+ CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(hash_type);
if (md_ == NULL)
return false;
SignBase::Error Sign::SignInit(const char* sign_type) {
- assert(md_ == NULL);
+ CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(sign_type);
if (!md_)
return kSignUnknownDigest;
SignBase::Error Verify::VerifyInit(const char* verify_type) {
- assert(md_ == NULL);
+ CHECK_EQ(md_, NULL);
md_ = EVP_get_digestbyname(verify_type);
if (md_ == NULL)
return kSignUnknownDigest;
hlen,
args[1],
encoding);
- assert(hwritten == hlen);
+ CHECK_EQ(hwritten, hlen);
} else {
hbuf = Buffer::Data(args[1]);
}
}
BN_free(key);
- assert(size >= 0);
+ CHECK_GE(size, 0);
// DH_size returns number of bytes in a prime number
// DH_compute_key returns number of bytes in a remainder of exponent, which
// may have less bytes than a prime number. Therefore add 0-padding to the
// allocated buffer.
if (size != dataSize) {
- assert(dataSize > size);
+ CHECK(dataSize > size);
memmove(data + dataSize - size, data, size);
memset(data, 0, dataSize - size);
}
void EIO_PBKDF2After(uv_work_t* work_req, int status) {
- assert(status == 0);
+ CHECK_EQ(status, 0);
PBKDF2Request* req = ContainerOf(&PBKDF2Request::work_req_, work_req);
Environment* env = req->env();
HandleScope handle_scope(env->isolate());
void RandomBytesAfter(uv_work_t* work_req, int status) {
- assert(status == 0);
+ CHECK_EQ(status, 0);
RandomBytesRequest* req =
ContainerOf(&RandomBytesRequest::work_req_, work_req);
Environment* env = req->env();
return args.GetReturnValue().Set(i);
char* data = Buffer::Data(args[0]);
- assert(data != NULL);
+ CHECK_NE(data, NULL);
i = certificate->VerifySpkac(data, length);
return args.GetReturnValue().SetEmptyString();
char* data = Buffer::Data(args[0]);
- assert(data != NULL);
+ CHECK_NE(data, NULL);
const char* pkey = certificate->ExportPublicKey(data, length);
if (pkey == NULL)
return args.GetReturnValue().SetEmptyString();
char* data = Buffer::Data(args[0]);
- assert(data != NULL);
+ CHECK_NE(data, NULL);
const char* cert = crt->ExportChallenge(data, len);
if (cert == NULL)
STACK_OF(SSL_COMP)* comp_methods = SSL_COMP_get_compression_methods();
#endif
sk_SSL_COMP_zero(comp_methods);
- assert(sk_SSL_COMP_num(comp_methods) == 0);
+ CHECK_EQ(sk_SSL_COMP_num(comp_methods), 0);
#endif
#ifndef OPENSSL_NO_ENGINE
cert_ = NULL;
issuer_ = NULL;
} else {
- assert(ca_store_ == NULL);
+ CHECK_EQ(ca_store_, NULL);
}
}
};
session_callbacks_(false),
new_session_wait_(false) {
ssl_ = SSL_new(sc->ctx_);
- assert(ssl_ != NULL);
+ CHECK_NE(ssl_, NULL);
}
~SSLWrap() {
#include "node_crypto_bio.h"
#include "openssl/bio.h"
+#include "util.h"
+#include "util-inl.h"
#include <string.h>
namespace node {
*reinterpret_cast<void**>(ptr) = NULL;
break;
case BIO_C_SET_BUF_MEM:
- assert(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
+ CHECK(0 && "Can't use SET_BUF_MEM_PTR with NodeBIO");
abort();
break;
case BIO_C_GET_BUF_MEM_PTR:
- assert(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
+ CHECK(0 && "Can't use GET_BUF_MEM_PTR with NodeBIO");
ret = 0;
break;
case BIO_CTRL_GET_CLOSE:
size_t left = size;
while (bytes_read < expected) {
- assert(read_head_->read_pos_ <= read_head_->write_pos_);
+ CHECK_LE(read_head_->read_pos_, read_head_->write_pos_);
size_t avail = read_head_->write_pos_ - read_head_->read_pos_;
if (avail > left)
avail = left;
TryMoveReadHead();
}
- assert(expected == bytes_read);
+ CHECK_EQ(expected, bytes_read);
length_ -= bytes_read;
// Free all empty buffers, but write_head's child
Buffer* prev = child;
while (cur != read_head_) {
- assert(cur != write_head_);
- assert(cur->write_pos_ == cur->read_pos_);
+ CHECK_NE(cur, write_head_);
+ CHECK_EQ(cur->write_pos_, cur->read_pos_);
Buffer* next = cur->next_;
delete cur;
Buffer* current = read_head_;
while (bytes_read < max) {
- assert(current->read_pos_ <= current->write_pos_);
+ CHECK_LE(current->read_pos_, current->write_pos_);
size_t avail = current->write_pos_ - current->read_pos_;
if (avail > left)
avail = left;
current = current->next_;
}
}
- assert(max == bytes_read);
+ CHECK_EQ(max, bytes_read);
return max;
}
while (left > 0) {
size_t to_write = left;
- assert(write_head_->write_pos_ <= write_head_->len_);
+ CHECK_LE(write_head_->write_pos_, write_head_->len_);
size_t avail = write_head_->len_ - write_head_->write_pos_;
if (to_write > avail)
offset += to_write;
length_ += to_write;
write_head_->write_pos_ += to_write;
- assert(write_head_->write_pos_ <= write_head_->len_);
+ CHECK_LE(write_head_->write_pos_, write_head_->len_);
// Go to next buffer if there still are some bytes to write
if (left != 0) {
- assert(write_head_->write_pos_ == write_head_->len_);
+ CHECK_EQ(write_head_->write_pos_, write_head_->len_);
TryAllocateForWrite(left);
write_head_ = write_head_->next_;
TryMoveReadHead();
}
}
- assert(left == 0);
+ CHECK_EQ(left, 0);
}
void NodeBIO::Commit(size_t size) {
write_head_->write_pos_ += size;
length_ += size;
- assert(write_head_->write_pos_ <= write_head_->len_);
+ CHECK_LE(write_head_->write_pos_, write_head_->len_);
// Allocate new buffer if write head is full,
// and there're no other place to go
return;
while (read_head_->read_pos_ != read_head_->write_pos_) {
- assert(read_head_->write_pos_ > read_head_->read_pos_);
+ CHECK(read_head_->write_pos_ > read_head_->read_pos_);
length_ -= read_head_->write_pos_ - read_head_->read_pos_;
read_head_->write_pos_ = 0;
read_head_ = read_head_->next_;
}
write_head_ = read_head_;
- assert(length_ == 0);
+ CHECK_EQ(length_, 0);
}
#define SRC_NODE_CRYPTO_BIO_H_
#include "openssl/bio.h"
-#include <assert.h>
+#include "util.h"
+#include "util-inl.h"
namespace node {
}
static inline NodeBIO* FromBIO(BIO* bio) {
- assert(bio->ptr != NULL);
+ CHECK_NE(bio->ptr, NULL);
return static_cast<NodeBIO*>(bio->ptr);
}
#ifndef SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_
#define SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_
-#include <assert.h>
+#include "util.h"
+#include "util-inl.h"
namespace node {
return;
Reset();
- assert(onhello_cb != NULL);
+ CHECK_NE(onhello_cb, NULL);
state_ = kWaiting;
onhello_cb_ = onhello_cb;
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <assert.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
static void After(uv_fs_t *req) {
FSReqWrap* req_wrap = static_cast<FSReqWrap*>(req->data);
- assert(&req_wrap->req_ == req);
+ CHECK_EQ(&req_wrap->req_, req);
req_wrap->ReleaseEarly(); // Free memory that's no longer used now.
Environment* env = req_wrap->env();
break;
default:
- assert(0 && "Unhandled eio response");
+ CHECK(0 && "Unhandled eio response");
}
}
Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
// If you hit this assertion, you forgot to enter the v8::Context first.
- assert(env->context() == env->isolate()->GetCurrentContext());
+ CHECK_EQ(env->context(), env->isolate()->GetCurrentContext());
EscapableHandleScope handle_scope(env->isolate());
} else {
SYNC_CALL(readdir, *path, *path, 0 /*flags*/)
- assert(SYNC_REQ.result >= 0);
+ CHECK_GE(SYNC_REQ.result, 0);
int r;
Local<Array> names = Array::New(env->isolate(), 0);
static void WriteBuffer(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args[0]->IsInt32());
- assert(Buffer::HasInstance(args[1]));
+ CHECK(args[0]->IsInt32());
+ CHECK(Buffer::HasInstance(args[1]));
int fd = args[0]->Int32Value();
Local<Object> obj = args[1].As<Object>();
void FSInitialize(const FunctionCallbackInfo<Value>& args) {
Local<Function> stats_constructor = args[0].As<Function>();
- assert(stats_constructor->IsFunction());
+ CHECK(stats_constructor->IsFunction());
Environment* env = Environment::GetCurrent(args.GetIsolate());
env->set_fs_stats_constructor_function(stats_constructor);
fields_[num_fields_ - 1].Reset();
}
- assert(num_fields_ < static_cast<int>(ARRAY_SIZE(fields_)));
- assert(num_fields_ == num_values_ + 1);
+ CHECK_LT(num_fields_, static_cast<int>(ARRAY_SIZE(fields_)));
+ CHECK_EQ(num_fields_, num_values_ + 1);
fields_[num_fields_ - 1].Update(at, length);
values_[num_values_ - 1].Reset();
}
- assert(num_values_ < static_cast<int>(ARRAY_SIZE(values_)));
- assert(num_values_ == num_fields_);
+ CHECK_LT(num_values_, static_cast<int>(ARRAY_SIZE(values_)));
+ CHECK_EQ(num_values_, num_fields_);
values_[num_values_ - 1].Update(at, length);
Environment* env = Environment::GetCurrent(args.GetIsolate());
http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value());
- assert(type == HTTP_REQUEST || type == HTTP_RESPONSE);
+ CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE);
new Parser(env, args.This(), type);
}
Environment* env = Environment::GetCurrent(args.GetIsolate());
Parser* parser = Unwrap<Parser>(args.Holder());
- assert(parser->current_buffer_.IsEmpty());
- assert(parser->current_buffer_len_ == 0);
- assert(parser->current_buffer_data_ == NULL);
- assert(Buffer::HasInstance(args[0]) == true);
+ CHECK(parser->current_buffer_.IsEmpty());
+ CHECK_EQ(parser->current_buffer_len_, 0);
+ CHECK_EQ(parser->current_buffer_data_, NULL);
+ CHECK_EQ(Buffer::HasInstance(args[0]), true);
Local<Object> buffer_obj = args[0].As<Object>();
char* buffer_data = Buffer::Data(buffer_obj);
Parser* parser = Unwrap<Parser>(args.Holder());
- assert(parser->current_buffer_.IsEmpty());
+ CHECK(parser->current_buffer_.IsEmpty());
parser->got_exception_ = false;
int rv = http_parser_execute(&(parser->parser_), &settings, NULL, 0);
http_parser_type type =
static_cast<http_parser_type>(args[0]->Int32Value());
- assert(type == HTTP_REQUEST || type == HTTP_RESPONSE);
+ CHECK(type == HTTP_REQUEST || type == HTTP_RESPONSE);
Parser* parser = Unwrap<Parser>(args.Holder());
// Should always be called from the same context.
- assert(env == parser->env());
+ CHECK_EQ(env, parser->env());
parser->Init(type);
}
Environment* env = Environment::GetCurrent(args.GetIsolate());
Parser* parser = Unwrap<Parser>(args.Holder());
// Should always be called from the same context.
- assert(env == parser->env());
+ CHECK_EQ(env, parser->env());
http_parser_pause(&parser->parser_, should_pause);
}
#include "uv.h"
#include "v8.h"
-#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include "util.h"
#include "util-inl.h"
-#include <assert.h>
#include <string.h>
#include <stdlib.h>
const uv_stat_t* prev,
const uv_stat_t* curr) {
StatWatcher* wrap = static_cast<StatWatcher*>(handle->data);
- assert(wrap->watcher_ == handle);
+ CHECK_EQ(wrap->watcher_, handle);
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
void StatWatcher::New(const FunctionCallbackInfo<Value>& args) {
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new StatWatcher(env, args.This());
}
void StatWatcher::Start(const FunctionCallbackInfo<Value>& args) {
- assert(args.Length() == 3);
+ CHECK_EQ(args.Length(), 3);
StatWatcher* wrap = Unwrap<StatWatcher>(args.Holder());
node::Utf8Value path(args[0]);
#include "env.h"
#include "env-inl.h"
#include "util.h"
-#include <assert.h>
namespace node {
sizeof(dataDescriptors) / \
sizeof(*dataDescriptors), \
dataDescriptors); \
- assert(status == ERROR_SUCCESS);
+ CHECK_EQ(status, ERROR_SUCCESS);
void NODE_HTTP_SERVER_REQUEST(node_dtrace_http_server_request_t* req,
etw_events_enable_callback,
NULL,
&node_provider);
- assert(status == ERROR_SUCCESS);
+ CHECK_EQ(status, ERROR_SUCCESS);
}
}
}
~ZCtx() {
- assert(!write_in_progress_ && "write in progress");
+ CHECK_EQ(false, write_in_progress_ && "write in progress");
Close();
}
}
pending_close_ = false;
- assert(init_done_ && "close before init");
- assert(mode_ <= UNZIP);
+ CHECK(init_done_ && "close before init");
+ CHECK_LE(mode_, UNZIP);
if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) {
(void)deflateEnd(&strm_);
// write(flush, in, in_off, in_len, out, out_off, out_len)
template <bool async>
static void Write(const FunctionCallbackInfo<Value>& args) {
- assert(args.Length() == 7);
+ CHECK_EQ(args.Length(), 7);
ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
- assert(ctx->init_done_ && "write before init");
- assert(ctx->mode_ != NONE && "already finalized");
+ CHECK(ctx->init_done_ && "write before init");
+ CHECK(ctx->mode_ != NONE && "already finalized");
- assert(!ctx->write_in_progress_ && "write already in progress");
- assert(!ctx->pending_close_ && "close is pending");
+ CHECK_EQ(false, ctx->write_in_progress_ && "write already in progress");
+ CHECK_EQ(false, ctx->pending_close_ && "close is pending");
ctx->write_in_progress_ = true;
ctx->Ref();
- assert(!args[0]->IsUndefined() && "must provide flush value");
+ CHECK_EQ(false, args[0]->IsUndefined() && "must provide flush value");
unsigned int flush = args[0]->Uint32Value();
flush != Z_FULL_FLUSH &&
flush != Z_FINISH &&
flush != Z_BLOCK) {
- assert(0 && "Invalid flush value");
+ CHECK(0 && "Invalid flush value");
}
Bytef *in;
in_len = 0;
in_off = 0;
} else {
- assert(Buffer::HasInstance(args[1]));
+ CHECK(Buffer::HasInstance(args[1]));
Local<Object> in_buf;
in_buf = args[1]->ToObject();
in_off = args[2]->Uint32Value();
in_len = args[3]->Uint32Value();
- assert(Buffer::IsWithinBounds(in_off, in_len, Buffer::Length(in_buf)));
+ CHECK(Buffer::IsWithinBounds(in_off, in_len, Buffer::Length(in_buf)));
in = reinterpret_cast<Bytef *>(Buffer::Data(in_buf) + in_off);
}
- assert(Buffer::HasInstance(args[4]));
+ CHECK(Buffer::HasInstance(args[4]));
Local<Object> out_buf = args[4]->ToObject();
out_off = args[5]->Uint32Value();
out_len = args[6]->Uint32Value();
- assert(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf)));
+ CHECK(Buffer::IsWithinBounds(out_off, out_len, Buffer::Length(out_buf)));
out = reinterpret_cast<Bytef *>(Buffer::Data(out_buf) + out_off);
// build up the work request
}
break;
default:
- assert(0 && "wtf?");
+ CHECK(0 && "wtf?");
}
// pass any errors back to the main thread to deal with.
// v8 land!
static void After(uv_work_t* work_req, int status) {
- assert(status == 0);
+ CHECK_EQ(status, 0);
ZCtx* ctx = ContainerOf(&ZCtx::work_req_, work_req);
Environment* env = ctx->env();
Environment* env = ctx->env();
// If you hit this assertion, you forgot to enter the v8::Context first.
- assert(env->context() == env->isolate()->GetCurrentContext());
+ CHECK_EQ(env->context(), env->isolate()->GetCurrentContext());
if (ctx->strm_.msg != NULL) {
message = ctx->strm_.msg;
static void Init(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert((args.Length() == 4 || args.Length() == 5) &&
+ CHECK((args.Length() == 4 || args.Length() == 5) &&
"init(windowBits, level, memLevel, strategy, [dictionary])");
ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
int windowBits = args[0]->Uint32Value();
- assert((windowBits >= 8 && windowBits <= 15) && "invalid windowBits");
+ CHECK((windowBits >= 8 && windowBits <= 15) && "invalid windowBits");
int level = args[1]->Int32Value();
- assert((level >= -1 && level <= 9) && "invalid compression level");
+ CHECK((level >= -1 && level <= 9) && "invalid compression level");
int memLevel = args[2]->Uint32Value();
- assert((memLevel >= 1 && memLevel <= 9) && "invalid memlevel");
+ CHECK((memLevel >= 1 && memLevel <= 9) && "invalid memlevel");
int strategy = args[3]->Uint32Value();
- assert((strategy == Z_FILTERED ||
+ CHECK((strategy == Z_FILTERED ||
strategy == Z_HUFFMAN_ONLY ||
strategy == Z_RLE ||
strategy == Z_FIXED ||
static void Params(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
- assert(args.Length() == 2 && "params(level, strategy)");
+ CHECK(args.Length() == 2 && "params(level, strategy)");
ZCtx* ctx = Unwrap<ZCtx>(args.Holder());
->AdjustAmountOfExternalAllocatedMemory(kInflateContextSize);
break;
default:
- assert(0 && "wtf?");
+ CHECK(0 && "wtf?");
}
if (ctx->err_ != Z_OK) {
}
void Unref() {
- assert(refs_ > 0);
+ CHECK_GT(refs_, 0);
if (--refs_ == 0) {
MakeWeak<ZCtx>(this);
}
Local<Object> PipeWrap::Instantiate(Environment* env) {
EscapableHandleScope handle_scope(env->isolate());
- assert(!env->pipe_constructor_template().IsEmpty());
+ CHECK_EQ(false, env->pipe_constructor_template().IsEmpty());
Local<Function> constructor = env->pipe_constructor_template()->GetFunction();
- assert(!constructor.IsEmpty());
+ CHECK_EQ(false, constructor.IsEmpty());
Local<Object> instance = constructor->NewInstance();
- assert(!instance.IsEmpty());
+ CHECK_EQ(false, instance.IsEmpty());
return handle_scope.Escape(instance);
}
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new PipeWrap(env, args.This(), args[0]->IsTrue());
}
reinterpret_cast<uv_stream_t*>(&handle_),
AsyncWrap::PROVIDER_PIPEWRAP) {
int r = uv_pipe_init(env->event_loop(), &handle_, ipc);
- assert(r == 0); // How do we proxy this error up to javascript?
+ CHECK_EQ(r, 0); // How do we proxy this error up to javascript?
// Suggestion: uv_pipe_init() returns void.
UpdateWriteQueueSize();
}
// TODO(bnoordhuis) maybe share with TCPWrap?
void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
PipeWrap* pipe_wrap = static_cast<PipeWrap*>(handle->data);
- assert(&pipe_wrap->handle_ == reinterpret_cast<uv_pipe_t*>(handle));
+ CHECK_EQ(&pipe_wrap->handle_, reinterpret_cast<uv_pipe_t*>(handle));
Environment* env = pipe_wrap->env();
HandleScope handle_scope(env->isolate());
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
- assert(pipe_wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(pipe_wrap->persistent().IsEmpty(), false);
Local<Value> argv[] = {
Integer::New(env->isolate(), status),
void PipeWrap::AfterConnect(uv_connect_t* req, int status) {
ConnectWrap* req_wrap = static_cast<ConnectWrap*>(req->data);
PipeWrap* wrap = static_cast<PipeWrap*>(req->handle->data);
- assert(req_wrap->env() == wrap->env());
+ CHECK_EQ(req_wrap->env(), wrap->env());
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
// The wrap and request objects should still be there.
- assert(req_wrap->persistent().IsEmpty() == false);
- assert(wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
+ CHECK_EQ(wrap->persistent().IsEmpty(), false);
bool readable, writable;
PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
- assert(args[0]->IsObject());
- assert(args[1]->IsString());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsString());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value name(args[1]);
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new ProcessWrap(env, args.This());
}
Local<String> handle_key = env->handle_string();
Local<Object> handle = stdio->Get(handle_key).As<Object>();
uv_stream_t* stream = HandleToStream(env, handle);
- assert(stream != NULL);
+ CHECK_NE(stream, NULL);
options->stdio[i].flags = UV_INHERIT_STREAM;
options->stdio[i].data.stream = stream;
int err = uv_spawn(env->event_loop(), &wrap->process_, &options);
if (err == 0) {
- assert(wrap->process_.data == wrap);
+ CHECK_EQ(wrap->process_.data, wrap);
wrap->object()->Set(env->pid_string(),
Integer::New(env->isolate(), wrap->process_.pid));
}
int64_t exit_status,
int term_signal) {
ProcessWrap* wrap = static_cast<ProcessWrap*>(handle->data);
- assert(wrap != NULL);
- assert(&wrap->process_ == handle);
+ CHECK_NE(wrap, NULL);
+ CHECK_EQ(&wrap->process_, handle);
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
~ReqWrap() {
QUEUE_REMOVE(&req_wrap_queue_);
// Assert that someone has called Dispatched()
- assert(req_.data == this);
- assert(!persistent().IsEmpty());
+ CHECK_EQ(req_.data, this);
+ CHECK_EQ(false, persistent().IsEmpty());
persistent().Reset();
}
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new SignalWrap(env, args.This());
}
reinterpret_cast<uv_handle_t*>(&handle_),
AsyncWrap::PROVIDER_SIGNALWRAP) {
int r = uv_signal_init(env->event_loop(), &handle_);
- assert(r == 0);
+ CHECK_EQ(r, 0);
}
~SignalWrap() {
#include "v8.h"
#include <string.h>
-#include <assert.h>
#define ALLOC_ID (0xA10C)
Local<Object> source = args[0].As<Object>();
Local<Object> dest = args[1].As<Object>();
- assert(source->HasIndexedPropertiesInExternalArrayData());
- assert(!dest->HasIndexedPropertiesInExternalArrayData());
+ CHECK(source->HasIndexedPropertiesInExternalArrayData());
+ CHECK_EQ(false, dest->HasIndexedPropertiesInExternalArrayData());
char* source_data = static_cast<char*>(
source->GetIndexedPropertiesExternalArrayData());
source->GetIndexedPropertiesExternalArrayDataType();
size_t source_size = ExternalArraySize(source_type);
- assert(source_size != 0);
+ CHECK_NE(source_size, 0);
size_t start = args[2]->Uint32Value();
size_t end = args[3]->Uint32Value();
size_t length = end - start;
if (source_size > 1) {
- assert(length * source_size >= length);
+ CHECK_GE(length * source_size, length);
length *= source_size;
}
- assert(source_data != NULL || length == 0);
- assert(end <= source_len);
- assert(start <= end);
+ CHECK(source_data != NULL || length == 0);
+ CHECK_LE(end, source_len);
+ CHECK_LE(start, end);
dest->SetIndexedPropertiesToExternalArrayData(source_data + start,
source_type,
} else {
array_type = static_cast<ExternalArrayType>(args[2]->Uint32Value());
size_t type_length = ExternalArraySize(array_type);
- assert(type_length * length >= length);
+ CHECK_GE(type_length * length, length);
length *= type_length;
}
enum ExternalArrayType type) {
size_t type_size = ExternalArraySize(type);
- assert(length <= kMaxLength);
- assert(type_size > 0);
+ CHECK_LE(length, kMaxLength);
+ CHECK_GT(type_size, 0);
if (length == 0)
return Alloc(env, obj, NULL, length, type);
char* data,
size_t length,
enum ExternalArrayType type) {
- assert(!obj->HasIndexedPropertiesInExternalArrayData());
+ CHECK_EQ(false, obj->HasIndexedPropertiesInExternalArrayData());
env->isolate()->AdjustAmountOfExternalAllocatedMemory(length);
size_t size = length / ExternalArraySize(type);
obj->SetIndexedPropertiesToExternalArrayData(data, type, size);
obj->GetIndexedPropertiesExternalArrayDataType();
size_t array_size = ExternalArraySize(array_type);
- assert(array_size > 0);
- assert(length * array_size >= length);
+ CHECK_GT(array_size, 0);
+ CHECK_GE(length * array_size, length);
length *= array_size;
FreeCallback fn,
void* hint,
enum ExternalArrayType type) {
- assert(length <= kMaxLength);
+ CHECK_LE(length, kMaxLength);
size_t type_size = ExternalArraySize(type);
- assert(type_size > 0);
- assert(length * type_size >= length);
+ CHECK_GT(type_size, 0);
+ CHECK_GE(length * type_size, length);
length *= type_size;
FreeCallback fn,
void* hint,
enum ExternalArrayType type) {
- assert(!obj->HasIndexedPropertiesInExternalArrayData());
+ CHECK_EQ(false, obj->HasIndexedPropertiesInExternalArrayData());
Isolate* isolate = env->isolate();
HandleScope handle_scope(isolate);
env->set_using_smalloc_alloc_cb(true);
void SyncProcessOutputBuffer::OnRead(const uv_buf_t* buf, size_t nread) {
// If we hand out the same chunk twice, this should catch it.
- assert(buf->base == data_ + used());
+ CHECK_EQ(buf->base, data_ + used());
used_ += static_cast<unsigned int>(nread);
}
shutdown_req_(),
lifecycle_(kUninitialized) {
- assert(readable || writable);
+ CHECK(readable || writable);
}
SyncProcessStdioPipe::~SyncProcessStdioPipe() {
- assert(lifecycle_ == kUninitialized || lifecycle_ == kClosed);
+ CHECK(lifecycle_ == kUninitialized || lifecycle_ == kClosed);
SyncProcessOutputBuffer* buf;
SyncProcessOutputBuffer* next;
int SyncProcessStdioPipe::Initialize(uv_loop_t* loop) {
- assert(lifecycle_ == kUninitialized);
+ CHECK_EQ(lifecycle_, kUninitialized);
int r = uv_pipe_init(loop, uv_pipe(), 0);
if (r < 0)
int SyncProcessStdioPipe::Start() {
- assert(lifecycle_ == kInitialized);
+ CHECK_EQ(lifecycle_, kInitialized);
// Set the busy flag already. If this function fails no recovery is
// possible.
if (readable()) {
if (input_buffer_.len > 0) {
- assert(input_buffer_.base != NULL);
+ CHECK_NE(input_buffer_.base, NULL);
int r = uv_write(&write_req_,
uv_stream(),
void SyncProcessStdioPipe::Close() {
- assert(lifecycle_ == kInitialized || lifecycle_ == kStarted);
+ CHECK(lifecycle_ == kInitialized || lifecycle_ == kStarted);
uv_close(uv_handle(), CloseCallback);
uv_pipe_t* SyncProcessStdioPipe::uv_pipe() const {
- assert(lifecycle_ < kClosing);
+ CHECK_LT(lifecycle_, kClosing);
return &uv_pipe_;
}
void SyncProcessStdioPipe::SetError(int error) {
- assert(error != 0);
+ CHECK_NE(error, 0);
process_handler_->SetPipeError(error);
}
SyncProcessRunner::~SyncProcessRunner() {
- assert(lifecycle_ == kHandlesClosed);
+ CHECK_EQ(lifecycle_, kHandlesClosed);
if (stdio_pipes_ != NULL) {
for (size_t i = 0; i < stdio_count_; i++) {
Local<Object> SyncProcessRunner::Run(Local<Value> options) {
EscapableHandleScope scope(env()->isolate());
- assert(lifecycle_ == kUninitialized);
+ CHECK_EQ(lifecycle_, kUninitialized);
TryInitializeAndRunLoop(options);
CloseHandlesAndDeleteLoop();
// There is no recovery from failure inside TryInitializeAndRunLoop - the
// only option we'd have is to close all handles and destroy the loop.
- assert(lifecycle_ == kUninitialized);
+ CHECK_EQ(lifecycle_, kUninitialized);
lifecycle_ = kInitialized;
uv_loop_ = new uv_loop_t;
abort();
// If we get here the process should have exited.
- assert(exit_status_ >= 0);
+ CHECK_GE(exit_status_, 0);
}
void SyncProcessRunner::CloseHandlesAndDeleteLoop() {
- assert(lifecycle_ < kHandlesClosed);
+ CHECK_LT(lifecycle_, kHandlesClosed);
if (uv_loop_ != NULL) {
CloseStdioPipes();
} else {
// If the loop doesn't exist, neither should any pipes or timers.
- assert(!stdio_pipes_initialized_);
- assert(!kill_timer_initialized_);
+ CHECK_EQ(false, stdio_pipes_initialized_);
+ CHECK_EQ(false, kill_timer_initialized_);
}
lifecycle_ = kHandlesClosed;
void SyncProcessRunner::CloseStdioPipes() {
- assert(lifecycle_ < kHandlesClosed);
+ CHECK_LT(lifecycle_, kHandlesClosed);
if (stdio_pipes_initialized_) {
- assert(stdio_pipes_ != NULL);
- assert(uv_loop_ != NULL);
+ CHECK_NE(stdio_pipes_, NULL);
+ CHECK_NE(uv_loop_, NULL);
for (uint32_t i = 0; i < stdio_count_; i++) {
if (stdio_pipes_[i] != NULL)
void SyncProcessRunner::CloseKillTimer() {
- assert(lifecycle_ < kHandlesClosed);
+ CHECK_LT(lifecycle_, kHandlesClosed);
if (kill_timer_initialized_) {
- assert(timeout_ > 0);
- assert(uv_loop_ != NULL);
+ CHECK_GT(timeout_, 0);
+ CHECK_NE(uv_loop_, NULL);
uv_handle_t* uv_timer_handle = reinterpret_cast<uv_handle_t*>(&uv_timer_);
uv_ref(uv_timer_handle);
SetError(r);
r = uv_process_kill(&uv_process_, SIGKILL);
- assert(r >= 0 || r == UV_ESRCH);
+ CHECK(r >= 0 || r == UV_ESRCH);
}
}
Local<Array> SyncProcessRunner::BuildOutputArray() {
- assert(lifecycle_ >= kInitialized);
- assert(stdio_pipes_ != NULL);
+ CHECK_GE(lifecycle_, kInitialized);
+ CHECK_NE(stdio_pipes_, NULL);
EscapableHandleScope scope(env()->isolate());
Local<Array> js_output = Array::New(env()->isolate(), stdio_count_);
return AddStdioInheritFD(child_fd, inherit_fd);
} else {
- assert(0 && "invalid child stdio type");
+ CHECK(0 && "invalid child stdio type");
return UV_EINVAL;
}
}
int SyncProcessRunner::AddStdioIgnore(uint32_t child_fd) {
- assert(child_fd < stdio_count_);
- assert(stdio_pipes_[child_fd] == NULL);
+ CHECK_LT(child_fd, stdio_count_);
+ CHECK_EQ(stdio_pipes_[child_fd], NULL);
uv_stdio_containers_[child_fd].flags = UV_IGNORE;
bool readable,
bool writable,
uv_buf_t input_buffer) {
- assert(child_fd < stdio_count_);
- assert(stdio_pipes_[child_fd] == NULL);
+ CHECK_LT(child_fd, stdio_count_);
+ CHECK_EQ(stdio_pipes_[child_fd], NULL);
SyncProcessStdioPipe* h = new SyncProcessStdioPipe(this,
readable,
int SyncProcessRunner::AddStdioInheritFD(uint32_t child_fd, int inherit_fd) {
- assert(child_fd < stdio_count_);
- assert(stdio_pipes_[child_fd] == NULL);
+ CHECK_LT(child_fd, stdio_count_);
+ CHECK_EQ(stdio_pipes_[child_fd], NULL);
uv_stdio_containers_[child_fd].flags = UV_INHERIT_FD;
uv_stdio_containers_[child_fd].data.fd = inherit_fd;
size_t suggested_size,
uv_buf_t* buf) {
StreamWrap* wrap = static_cast<StreamWrap*>(handle->data);
- assert(wrap->stream() == reinterpret_cast<uv_stream_t*>(handle));
+ CHECK_EQ(wrap->stream(), reinterpret_cast<uv_stream_t*>(handle));
wrap->callbacks()->DoAlloc(handle, suggested_size, buf);
}
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
- assert(wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(wrap->persistent().IsEmpty(), false);
if (nread > 0) {
if (wrap->is_tcp()) {
size_t StreamWrap::WriteBuffer(Handle<Value> val, uv_buf_t* buf) {
- assert(Buffer::HasInstance(val));
+ CHECK(Buffer::HasInstance(val));
// Simple non-writev case
buf->base = Buffer::Data(val);
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
- assert(args[0]->IsObject());
- assert(Buffer::HasInstance(args[1]));
+ CHECK(args[0]->IsObject());
+ CHECK(Buffer::HasInstance(args[1]));
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<Object> buf_obj = args[1].As<Object>();
goto done;
if (count == 0)
goto done;
- assert(count == 1);
+ CHECK_EQ(count, 1);
// Allocate, or write rest
storage = new char[sizeof(WriteWrap)];
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
- assert(args[0]->IsObject());
- assert(args[1]->IsString());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsString());
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<String> string = args[1].As<String>();
goto done;
// Partial write
- assert(count == 1);
+ CHECK_EQ(count, 1);
}
storage = new char[sizeof(WriteWrap) + storage_size + 15];
encoding);
}
- assert(data_size <= storage_size);
+ CHECK_LE(data_size, storage_size);
buf = uv_buf_init(data, data_size);
send_handle = wrap->GetHandle();
// Reference StreamWrap instance to prevent it from being garbage
// collected before `AfterWrite` is called.
- assert(!req_wrap->persistent().IsEmpty());
+ CHECK_EQ(false, req_wrap->persistent().IsEmpty());
req_wrap->object()->Set(env->handle_string(), send_handle_obj);
}
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
- assert(args[0]->IsObject());
- assert(args[1]->IsArray());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsArray());
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<Array> chunks = args[1].As<Array>();
// Write string
offset = ROUND_UP(offset, 16);
- assert(offset < storage_size);
+ CHECK_LT(offset, storage_size);
char* str_storage = storage + offset;
size_t str_size = storage_size - offset;
void StreamWrap::SetBlocking(const FunctionCallbackInfo<Value>& args) {
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
- assert(args.Length() > 0);
+ CHECK_GT(args.Length(), 0);
int err = uv_stream_set_blocking(wrap->stream(), args[0]->IsTrue());
args.GetReturnValue().Set(err);
}
Context::Scope context_scope(env->context());
// The wrap and request objects should still be there.
- assert(req_wrap->persistent().IsEmpty() == false);
- assert(wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
+ CHECK_EQ(wrap->persistent().IsEmpty(), false);
// Unref handle property
Local<Object> req_wrap_obj = req_wrap->object();
StreamWrap* wrap = Unwrap<StreamWrap>(args.Holder());
- assert(args[0]->IsObject());
+ CHECK(args[0]->IsObject());
Local<Object> req_wrap_obj = args[0].As<Object>();
ShutdownWrap* req_wrap = new ShutdownWrap(env,
Environment* env = wrap->env();
// The wrap and request objects should still be there.
- assert(req_wrap->persistent().IsEmpty() == false);
- assert(wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
+ CHECK_EQ(wrap->persistent().IsEmpty(), false);
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
}
char* base = static_cast<char*>(realloc(buf->base, nread));
- assert(static_cast<size_t>(nread) <= buf->len);
+ CHECK_LE(static_cast<size_t>(nread), buf->len);
argv[1] = Buffer::Use(env, base, nread);
Local<Object> pending_obj;
} else if (pending == UV_UDP) {
pending_obj = AcceptHandle<UDPWrap, uv_udp_t>(env, handle);
} else {
- assert(pending == UV_UNKNOWN_HANDLE);
+ CHECK_EQ(pending, UV_UNKNOWN_HANDLE);
}
if (!pending_obj.IsEmpty()) {
// This is just to keep the compiler happy. It should never be called, since
// we don't use exceptions in node.
- void operator delete(void* ptr, char* storage) { assert(0); }
+ void operator delete(void* ptr, char* storage) { UNREACHABLE(); }
inline StreamWrap* wrap() const {
return wrap_;
private:
// People should not be using the non-placement new and delete operator on a
// WriteWrap. Ensure this never happens.
- void* operator new(size_t size) { assert(0); }
- void operator delete(void* ptr) { assert(0); }
+ void* operator new(size_t size) { UNREACHABLE(); }
+ void operator delete(void* ptr) { UNREACHABLE(); }
StreamWrap* const wrap_;
};
#include "node_buffer.h"
#include "v8.h"
-#include <assert.h>
#include <limits.h>
#include <string.h> // memcpy
break;
default:
- assert(0 && "unknown encoding");
+ CHECK(0 && "unknown encoding");
break;
}
break;
case HEX:
- assert(str->Length() % 2 == 0 && "invalid hex string length");
+ CHECK(str->Length() % 2 == 0 && "invalid hex string length");
data_size = str->Length() / 2;
break;
default:
- assert(0 && "unknown encoding");
+ CHECK(0 && "unknown encoding");
break;
}
break;
default:
- assert(0 && "unknown encoding");
+ CHECK(0 && "unknown encoding");
break;
}
char* dst,
size_t dlen) {
// We know how much we'll write, just make sure that there's space.
- assert(dlen >= base64_encoded_size(slen) &&
- "not enough space provided for base64 encode");
+ CHECK(dlen >= base64_encoded_size(slen) &&
+ "not enough space provided for base64 encode");
dlen = base64_encoded_size(slen);
static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
// We know how much we'll write, just make sure that there's space.
- assert(dlen >= slen * 2 &&
+ CHECK(dlen >= slen * 2 &&
"not enough space provided for hex encode");
dlen = slen * 2;
enum encoding encoding) {
EscapableHandleScope scope(isolate);
- assert(buflen <= Buffer::kMaxLength);
+ CHECK_LE(buflen, Buffer::kMaxLength);
if (!buflen && encoding != BUFFER)
return scope.Escape(String::Empty(isolate));
char* dst = new char[dlen];
size_t written = base64_encode(buf, buflen, dst, dlen);
- assert(written == dlen);
+ CHECK_EQ(written, dlen);
if (dlen < EXTERN_APEX) {
val = OneByteString(isolate, dst, dlen);
size_t dlen = buflen * 2;
char* dst = new char[dlen];
size_t written = hex_encode(buf, buflen, dst, dlen);
- assert(written == dlen);
+ CHECK_EQ(written, dlen);
if (dlen < EXTERN_APEX) {
val = OneByteString(isolate, dst, dlen);
}
default:
- assert(0 && "unknown encoding");
+ CHECK(0 && "unknown encoding");
break;
}
Local<Object> TCPWrap::Instantiate(Environment* env) {
EscapableHandleScope handle_scope(env->isolate());
- assert(env->tcp_constructor_template().IsEmpty() == false);
+ CHECK_EQ(env->tcp_constructor_template().IsEmpty(), false);
Local<Function> constructor = env->tcp_constructor_template()->GetFunction();
- assert(constructor.IsEmpty() == false);
+ CHECK_EQ(constructor.IsEmpty(), false);
Local<Object> instance = constructor->NewInstance();
- assert(instance.IsEmpty() == false);
+ CHECK_EQ(instance.IsEmpty(), false);
return handle_scope.Escape(instance);
}
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
TCPWrap* wrap = new TCPWrap(env, args.This());
- assert(wrap);
+ CHECK(wrap);
}
reinterpret_cast<uv_stream_t*>(&handle_),
AsyncWrap::PROVIDER_TCPWRAP) {
int r = uv_tcp_init(env->event_loop(), &handle_);
- assert(r == 0); // How do we proxy this error up to javascript?
+ CHECK_EQ(r, 0); // How do we proxy this error up to javascript?
// Suggestion: uv_tcp_init() returns void.
UpdateWriteQueueSize();
}
TCPWrap::~TCPWrap() {
- assert(persistent().IsEmpty());
+ CHECK(persistent().IsEmpty());
}
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
- assert(args[0]->IsObject());
+ CHECK(args[0]->IsObject());
Local<Object> out = args[0].As<Object>();
int addrlen = sizeof(address);
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
- assert(args[0]->IsObject());
+ CHECK(args[0]->IsObject());
Local<Object> out = args[0].As<Object>();
int addrlen = sizeof(address);
void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
TCPWrap* tcp_wrap = static_cast<TCPWrap*>(handle->data);
- assert(&tcp_wrap->handle_ == reinterpret_cast<uv_tcp_t*>(handle));
+ CHECK_EQ(&tcp_wrap->handle_, reinterpret_cast<uv_tcp_t*>(handle));
Environment* env = tcp_wrap->env();
HandleScope handle_scope(env->isolate());
// We should not be getting this callback if someone as already called
// uv_close() on the handle.
- assert(tcp_wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(tcp_wrap->persistent().IsEmpty(), false);
Local<Value> argv[2] = {
Integer::New(env->isolate(), status),
void TCPWrap::AfterConnect(uv_connect_t* req, int status) {
ConnectWrap* req_wrap = static_cast<ConnectWrap*>(req->data);
TCPWrap* wrap = static_cast<TCPWrap*>(req->handle->data);
- assert(req_wrap->env() == wrap->env());
+ CHECK_EQ(req_wrap->env(), wrap->env());
Environment* env = wrap->env();
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());
// The wrap and request objects should still be there.
- assert(req_wrap->persistent().IsEmpty() == false);
- assert(wrap->persistent().IsEmpty() == false);
+ CHECK_EQ(req_wrap->persistent().IsEmpty(), false);
+ CHECK_EQ(wrap->persistent().IsEmpty(), false);
Local<Object> req_wrap_obj = req_wrap->object();
Local<Value> argv[5] = {
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
- assert(args[0]->IsObject());
- assert(args[1]->IsString());
- assert(args[2]->Uint32Value());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsString());
+ CHECK(args[2]->Uint32Value());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value ip_address(args[1]);
TCPWrap* wrap = Unwrap<TCPWrap>(args.Holder());
- assert(args[0]->IsObject());
- assert(args[1]->IsString());
- assert(args[2]->Uint32Value());
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsString());
+ CHECK(args[2]->Uint32Value());
Local<Object> req_wrap_obj = args[0].As<Object>();
node::Utf8Value ip_address(args[1]);
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new TimerWrap(env, args.This());
}
reinterpret_cast<uv_handle_t*>(&handle_),
AsyncWrap::PROVIDER_TIMERWRAP) {
int r = uv_timer_init(env->event_loop(), &handle_);
- assert(r == 0);
+ CHECK_EQ(r, 0);
}
~TimerWrap() {
wrap->started_ = true;
// Send ClientHello handshake
- assert(wrap->is_client());
+ CHECK(wrap->is_client());
wrap->ClearOut();
wrap->EncOut();
}
size_t size[ARRAY_SIZE(data)];
size_t count = ARRAY_SIZE(data);
write_size_ = NodeBIO::FromBIO(enc_out_)->PeekMultiple(data, size, &count);
- assert(write_size_ != 0 && count != 0);
+ CHECK(write_size_ != 0 && count != 0);
write_req_.data = this;
uv_buf_t buf[ARRAY_SIZE(data)];
memcpy(error_buf_, str, avail);
error_off_ += avail;
- assert(error_off_ < sizeof(error_buf_));
+ CHECK_LT(error_off_, sizeof(error_buf_));
// Zero-terminate
error_buf_[error_off_] = '\0';
break;
default:
{
- assert(*err == SSL_ERROR_SSL || *err == SSL_ERROR_SYSCALL);
+ CHECK(*err == SSL_ERROR_SSL || *err == SSL_ERROR_SYSCALL);
const char* buf = PrintErrors();
Local<Value> exception = Exception::Error(message);
if (msg != NULL) {
- assert(*msg == NULL);
+ CHECK_EQ(*msg, NULL);
*msg = buf;
}
HandleScope handle_scope(env()->isolate());
Context::Scope context_scope(env()->context());
- assert(ssl_ != NULL);
+ CHECK_NE(ssl_, NULL);
char out[kClearOutChunkSize];
int read;
size_t avail = 0;
char* data = clear_in_->Peek(&avail);
written = SSL_write(ssl_, data, avail);
- assert(written == -1 || written == static_cast<int>(avail));
+ CHECK(written == -1 || written == static_cast<int>(avail));
if (written == -1)
break;
clear_in_->Read(NULL, avail);
// All written
if (clear_in_->Length() == 0) {
- assert(written >= 0);
+ CHECK_GE(written, 0);
return true;
}
size_t count,
uv_stream_t* send_handle,
uv_write_cb cb) {
- assert(send_handle == NULL);
+ CHECK_EQ(send_handle, NULL);
bool empty = true;
int written = 0;
for (i = 0; i < count; i++) {
written = SSL_write(ssl_, bufs[i].base, bufs[i].len);
- assert(written == -1 || written == static_cast<int>(bufs[i].len));
+ CHECK(written == -1 || written == static_cast<int>(bufs[i].len));
if (written == -1)
break;
}
}
// Only client connections can receive data
- assert(ssl_ != NULL);
+ CHECK_NE(ssl_, NULL);
// Commit read data
NodeBIO* enc_in = NodeBIO::FromBIO(enc_in_);
if (!hello_parser_.IsEnded()) {
size_t avail = 0;
uint8_t* data = reinterpret_cast<uint8_t*>(enc_in->Peek(&avail));
- assert(avail == 0 || data != NULL);
+ CHECK(avail == 0 || data != NULL);
return hello_parser_.Parse(data, avail);
}
void TTYWrap::GuessHandleType(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
int fd = args[0]->Int32Value();
- assert(fd >= 0);
+ CHECK_GE(fd, 0);
uv_handle_type t = uv_guess_handle(fd);
const char* type = NULL;
void TTYWrap::IsTTY(const FunctionCallbackInfo<Value>& args) {
int fd = args[0]->Int32Value();
- assert(fd >= 0);
+ CHECK_GE(fd, 0);
bool rc = uv_guess_handle(fd) == UV_TTY;
args.GetReturnValue().Set(rc);
}
Environment* env = Environment::GetCurrent(args.GetIsolate());
TTYWrap* wrap = Unwrap<TTYWrap>(args.Holder());
- assert(args[0]->IsArray());
+ CHECK(args[0]->IsArray());
int width, height;
int err = uv_tty_get_winsize(&wrap->handle_, &width, &height);
// This constructor should not be exposed to public javascript.
// Therefore we assert that we are not trying to call this as a
// normal function.
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
int fd = args[0]->Int32Value();
- assert(fd >= 0);
+ CHECK_GE(fd, 0);
TTYWrap* wrap = new TTYWrap(env, args.This(), fd, args[1]->IsTrue());
wrap->UpdateWriteQueueSize();
reinterpret_cast<uv_handle_t*>(&handle_),
AsyncWrap::PROVIDER_UDPWRAP) {
int r = uv_udp_init(env->event_loop(), &handle_);
- assert(r == 0); // can't fail anyway
+ CHECK_EQ(r, 0); // can't fail anyway
}
void UDPWrap::New(const FunctionCallbackInfo<Value>& args) {
- assert(args.IsConstructCall());
+ CHECK(args.IsConstructCall());
Environment* env = Environment::GetCurrent(args.GetIsolate());
new UDPWrap(env, args.This());
}
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
// bind(ip, port, flags)
- assert(args.Length() == 3);
+ CHECK_EQ(args.Length(), 3);
node::Utf8Value address(args[0]);
const int port = args[1]->Uint32Value();
err = uv_ip6_addr(*address, port, reinterpret_cast<sockaddr_in6*>(&addr));
break;
default:
- assert(0 && "unexpected address family");
+ CHECK(0 && "unexpected address family");
abort();
}
#define X(name, fn) \
void UDPWrap::name(const FunctionCallbackInfo<Value>& args) { \
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder()); \
- assert(args.Length() == 1); \
+ CHECK_EQ(args.Length(), 1); \
int flag = args[0]->Int32Value(); \
int err = fn(&wrap->handle_, flag); \
args.GetReturnValue().Set(err); \
uv_membership membership) {
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
- assert(args.Length() == 2);
+ CHECK_EQ(args.Length(), 2);
node::Utf8Value address(args[0]);
node::Utf8Value iface(args[1]);
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
// send(req, buffer, offset, length, port, address)
- assert(args[0]->IsObject());
- assert(Buffer::HasInstance(args[1]));
- assert(args[2]->IsUint32());
- assert(args[3]->IsUint32());
- assert(args[4]->IsUint32());
- assert(args[5]->IsString());
- assert(args[6]->IsBoolean());
+ CHECK(args[0]->IsObject());
+ CHECK(Buffer::HasInstance(args[1]));
+ CHECK(args[2]->IsUint32());
+ CHECK(args[3]->IsUint32());
+ CHECK(args[4]->IsUint32());
+ CHECK(args[5]->IsString());
+ CHECK(args[6]->IsBoolean());
Local<Object> req_wrap_obj = args[0].As<Object>();
Local<Object> buffer_obj = args[1].As<Object>();
node::Utf8Value address(args[5]);
const bool have_callback = args[6]->IsTrue();
- assert(length <= Buffer::Length(buffer_obj) - offset);
+ CHECK_LE(length, Buffer::Length(buffer_obj) - offset);
SendWrap* req_wrap = new SendWrap(env, req_wrap_obj, have_callback);
err = uv_ip6_addr(*address, port, reinterpret_cast<sockaddr_in6*>(&addr));
break;
default:
- assert(0 && "unexpected address family");
+ CHECK(0 && "unexpected address family");
abort();
}
struct sockaddr_storage address;
UDPWrap* wrap = Unwrap<UDPWrap>(args.Holder());
- assert(args[0]->IsObject());
+ CHECK(args[0]->IsObject());
Local<Object> obj = args[0].As<Object>();
int addrlen = sizeof(address);
Local<Object> UDPWrap::Instantiate(Environment* env) {
// If this assert fires then Initialize hasn't been called yet.
- assert(env->udp_constructor_function().IsEmpty() == false);
+ CHECK_EQ(env->udp_constructor_function().IsEmpty(), false);
return env->udp_constructor_function()->NewInstance();
}
#include "util.h"
-#include <assert.h>
-
namespace node {
template <typename Inner, typename Outer>
template <typename TypeName>
void Wrap(v8::Local<v8::Object> object, TypeName* pointer) {
- assert(!object.IsEmpty());
- assert(object->InternalFieldCount() > 0);
+ CHECK_EQ(false, object.IsEmpty());
+ CHECK_GT(object->InternalFieldCount(), 0);
object->SetAlignedPointerInInternalField(0, pointer);
}
template <typename TypeName>
TypeName* Unwrap(v8::Local<v8::Object> object) {
- assert(!object.IsEmpty());
- assert(object->InternalFieldCount() > 0);
+ CHECK_EQ(false, object.IsEmpty());
+ CHECK_GT(object->InternalFieldCount(), 0);
void* pointer = object->GetAlignedPointerFromInternalField(0);
return static_cast<TypeName*>(pointer);
}