• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "v8_native_boolean.h"
17 
V8NativeBoolean(V8NativeEngine * engine,v8::Local<v8::Value> value)18 V8NativeBoolean::V8NativeBoolean(V8NativeEngine* engine, v8::Local<v8::Value> value) : V8NativeValue(engine, value) {}
19 
V8NativeBoolean(V8NativeEngine * engine,bool value)20 V8NativeBoolean::V8NativeBoolean(V8NativeEngine* engine, bool value)
21     : V8NativeBoolean(engine, v8::Boolean::New(engine->GetIsolate(), value))
22 {
23 }
24 
~V8NativeBoolean()25 V8NativeBoolean::~V8NativeBoolean() {}
26 
GetInterface(int interfaceId)27 void* V8NativeBoolean::GetInterface(int interfaceId)
28 {
29     return (NativeBoolean::INTERFACE_ID == interfaceId) ? (NativeBoolean*)this : nullptr;
30 }
31 
operator bool()32 V8NativeBoolean::operator bool()
33 {
34     v8::Local<v8::Boolean> value = value_;
35     return value->Value();
36 }
37