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}
This commit is contained in:
parent
0c12ff2db4
commit
8bdac10631
11
include/v8.h
11
include/v8.h
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user