Commit 8bdac106 authored by bashi's avatar bashi Committed by Commit bot

Add Cast() to Boolean

We should be able to cast a Value to Boolean when IsBoolean() is true.

Review URL: https://codereview.chromium.org/990943003

Cr-Commit-Position: refs/heads/master@{#27124}
parent 0c12ff2d
......@@ -2007,7 +2007,10 @@ class V8_EXPORT Primitive : public Value { };
class V8_EXPORT Boolean : public Primitive {
public:
bool Value() const;
V8_INLINE static Boolean* Cast(v8::Value* obj);
V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value);
private:
static void CheckCast(v8::Value* obj);
};
......@@ -7314,6 +7317,14 @@ Local<Uint32> Value::ToUint32() const {
Local<Int32> Value::ToInt32() const { return ToInt32(Isolate::GetCurrent()); }
Boolean* Boolean::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
#endif
return static_cast<Boolean*>(value);
}
Name* Name::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS
CheckCast(value);
......
......@@ -2933,6 +2933,14 @@ void v8::Function::CheckCast(Value* that) {
}
void v8::Boolean::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
Utils::ApiCheck(obj->IsBoolean(),
"v8::Boolean::Cast()",
"Could not convert to boolean");
}
void v8::Name::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
Utils::ApiCheck(obj->IsName(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment