Avoid using CHECK in files using node headesr

Node has its own CHECK macro which requires linking with node::Assert.
This commit is contained in:
Cheng Zhao 2016-07-21 16:44:30 +09:00
parent cef86f5257
commit 39bd2bee8e
3 changed files with 8 additions and 13 deletions

View file

@ -111,32 +111,31 @@ base::Value* V8ValueConverter::FromV8Value(
v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
v8::Isolate* isolate, const base::Value* value) const {
CHECK(value);
switch (value->GetType()) {
case base::Value::TYPE_NULL:
return v8::Null(isolate);
case base::Value::TYPE_BOOLEAN: {
bool val = false;
CHECK(value->GetAsBoolean(&val));
value->GetAsBoolean(&val);
return v8::Boolean::New(isolate, val);
}
case base::Value::TYPE_INTEGER: {
int val = 0;
CHECK(value->GetAsInteger(&val));
value->GetAsInteger(&val);
return v8::Integer::New(isolate, val);
}
case base::Value::TYPE_DOUBLE: {
double val = 0.0;
CHECK(value->GetAsDouble(&val));
value->GetAsDouble(&val);
return v8::Number::New(isolate, val);
}
case base::Value::TYPE_STRING: {
std::string val;
CHECK(value->GetAsString(&val));
value->GetAsString(&val);
return v8::String::NewFromUtf8(
isolate, val.c_str(), v8::String::kNormalString, val.length());
}
@ -164,10 +163,9 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Array(
for (size_t i = 0; i < val->GetSize(); ++i) {
const base::Value* child = nullptr;
CHECK(val->Get(i, &child));
val->Get(i, &child);
v8::Local<v8::Value> child_v8 = ToV8ValueImpl(isolate, child);
CHECK(!child_v8.IsEmpty());
v8::TryCatch try_catch;
result->Set(static_cast<uint32_t>(i), child_v8);
@ -187,7 +185,6 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Object(
!iter.IsAtEnd(); iter.Advance()) {
const std::string& key = iter.key();
v8::Local<v8::Value> child_v8 = ToV8ValueImpl(isolate, &iter.value());
CHECK(!child_v8.IsEmpty());
v8::TryCatch try_catch;
result.Set(key, child_v8);
@ -211,8 +208,6 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
FromV8ValueState* state,
v8::Local<v8::Value> val,
v8::Isolate* isolate) const {
CHECK(!val.IsEmpty());
FromV8ValueState::Level state_level(state);
if (state->HasReachedMaxRecursionDepth())
return nullptr;