1ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann// Copyright 2014 PDFium Authors. All rights reserved. 2ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann// Use of this source code is governed by a BSD-style license that can be 3ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann// found in the LICENSE file. 4ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 5ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 7ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann#ifndef FXJSE_VALUE_H_ 8ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann#define FXJSE_VALUE_H_ 9ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann#include "scope_inline.h" 10ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannclass CFXJSE_Value { 11ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 12ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} 13ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 14ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann protected: 15ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value(); 16ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value(const CFXJSE_Value&); 17ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value& operator=(const CFXJSE_Value&); 18ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 19ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 20ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsUndefined() const { 21ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 22ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 23ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 24ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 25ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 26ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 27ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsUndefined(); 28ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 29ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsNull() const { 30ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 31ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 32ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 33ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 34ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 35ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 36ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsNull(); 37ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 38ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsBoolean() const { 39ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 40ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 41ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 42ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 43ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 44ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 45ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsBoolean(); 46ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 47ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsString() const { 48ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 49ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 50ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 51ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 52ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 53ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 54ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsString(); 55ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 56ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsNumber() const { 57ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 58ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 59ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 60ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 61ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 62ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 63ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsNumber(); 64ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 65ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsInteger() const { 66ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 67ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 68ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 69ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 70ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 71ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 72ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsInt32(); 73ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 74ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsObject() const { 75ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 76ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 77ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 78ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 79ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 80ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 81ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsObject(); 82ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 83ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsArray() const { 84ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 85ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 86ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 87ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 88ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 89ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 90ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsArray(); 91ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 92ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsFunction() const { 93ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 94ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 95ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 96ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 97ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 98ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 99ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsFunction(); 100ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 101ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL IsDate() const { 102ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (m_hValue.IsEmpty()) { 103ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return FALSE; 104ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 105ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 106ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 107ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 108ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return hValue->IsDate(); 109ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 110ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 111ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 112ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_BOOL ToBoolean() const { 113ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann ASSERT(!m_hValue.IsEmpty()); 114ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 115ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 116ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 117ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return static_cast<FX_BOOL>(hValue->BooleanValue()); 118ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 119ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FX_FLOAT ToFloat() const { 120ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann ASSERT(!m_hValue.IsEmpty()); 121ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 122ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 123ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 124ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return static_cast<FX_FLOAT>(hValue->NumberValue()); 125ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 126ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE FXJSE_DOUBLE ToDouble() const { 127ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann ASSERT(!m_hValue.IsEmpty()); 128ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 129ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 130ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 131ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return static_cast<FXJSE_DOUBLE>(hValue->NumberValue()); 132ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 133ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE int32_t ToInteger() const { 134ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann ASSERT(!m_hValue.IsEmpty()); 135ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 136ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 137ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 138ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return static_cast<int32_t>(hValue->NumberValue()); 139ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 140ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void ToString(CFX_ByteString& szStrOutput) const { 141ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann ASSERT(!m_hValue.IsEmpty()); 142ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 143ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 144ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 145ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::String> hString = hValue->ToString(); 146ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::String::Utf8Value hStringVal(hString); 147ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann szStrOutput = *hStringVal; 148ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 149ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void* ToObject(CFXJSE_Class* lpClass) const; 150ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 151ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 152ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetUndefined() { 153ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 154ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate); 155ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 156ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 157ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetNull() { 158ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 159ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = v8::Null(m_pIsolate); 160ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 161ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 162ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetBoolean(FX_BOOL bBoolean) { 163ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 164ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = 165ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Boolean::New(m_pIsolate, bBoolean != FALSE); 166ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 167ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 168ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetInteger(int32_t nInteger) { 169ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 170ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = v8::Integer::New(m_pIsolate, nInteger); 171ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 172ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 173ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetDouble(FXJSE_DOUBLE dDouble) { 174ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 175ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, dDouble); 176ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 177ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 178ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetString(const CFX_ByteStringC& szString) { 179ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 180ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = v8::String::NewFromUtf8( 181ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_pIsolate, reinterpret_cast<const char*>(szString.GetPtr()), 182ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::String::kNormalString, szString.GetLength()); 183ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 184ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 185ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetFloat(FX_FLOAT fFloat); 186ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void SetJSObject() { 187ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 188ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate); 189ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 190ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 191ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void SetHostObject(void* lpObject, CFXJSE_Class* lpClass); 192ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); 193ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann void SetDate(FXJSE_DOUBLE dDouble); 194ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 195ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 196ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName, 197ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value* lpPropValue); 198ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName, 199ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value* lpPropValue); 200ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); 201ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); 202ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName); 203ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName, 204ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL bUseTypeGetter); 205ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL SetObjectOwnProperty(const CFX_ByteStringC& szPropName, 206ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value* lpPropValue); 207ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis); 208ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FX_BOOL Call(CFXJSE_Value* lpReceiver, 209ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann CFXJSE_Value* lpRetValue, 210ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann uint32_t nArgCount, 211ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann FXJSE_HVALUE* lpArgs); 212ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 213ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 214ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE v8::Isolate* GetIsolate() const { return m_pIsolate; } 215ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE const v8::Global<v8::Value>& DirectGetValue() const { 216ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann return m_hValue; 217ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 218ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void ForceSetValue(v8::Local<v8::Value> hValue) { 219ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, hValue); 220ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 221ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann V8_INLINE void Assign(const CFXJSE_Value* lpValue) { 222ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann if (lpValue) { 223ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(m_pIsolate, lpValue->m_hValue); 224ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } else { 225ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann m_hValue.Reset(); 226ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 227ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann } 228ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 229ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann public: 230ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann static CFXJSE_Value* Create(v8::Isolate* pIsolate); 231ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 232ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann protected: 233ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Isolate* m_pIsolate; 234ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann v8::Global<v8::Value> m_hValue; 235ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann friend class CFXJSE_Context; 236ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann friend class CFXJSE_Class; 237ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann}; 238ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann#endif 239