| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef XFA_FXJSE_VALUE_H_ | 7 #ifndef XFA_FXJSE_VALUE_H_ |
| 8 #define XFA_FXJSE_VALUE_H_ | 8 #define XFA_FXJSE_VALUE_H_ |
| 9 | 9 |
| 10 #include "xfa/fxjse/scope_inline.h" | 10 #include "xfa/fxjse/scope_inline.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 118 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
| 119 return static_cast<FX_BOOL>(hValue->BooleanValue()); | 119 return static_cast<FX_BOOL>(hValue->BooleanValue()); |
| 120 } | 120 } |
| 121 V8_INLINE FX_FLOAT ToFloat() const { | 121 V8_INLINE FX_FLOAT ToFloat() const { |
| 122 ASSERT(!m_hValue.IsEmpty()); | 122 ASSERT(!m_hValue.IsEmpty()); |
| 123 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 123 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
| 124 v8::Local<v8::Value> hValue = | 124 v8::Local<v8::Value> hValue = |
| 125 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 125 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
| 126 return static_cast<FX_FLOAT>(hValue->NumberValue()); | 126 return static_cast<FX_FLOAT>(hValue->NumberValue()); |
| 127 } | 127 } |
| 128 V8_INLINE FXJSE_DOUBLE ToDouble() const { | 128 V8_INLINE double ToDouble() const { |
| 129 ASSERT(!m_hValue.IsEmpty()); | 129 ASSERT(!m_hValue.IsEmpty()); |
| 130 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 130 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
| 131 v8::Local<v8::Value> hValue = | 131 v8::Local<v8::Value> hValue = |
| 132 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 132 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
| 133 return static_cast<FXJSE_DOUBLE>(hValue->NumberValue()); | 133 return static_cast<double>(hValue->NumberValue()); |
| 134 } | 134 } |
| 135 V8_INLINE int32_t ToInteger() const { | 135 V8_INLINE int32_t ToInteger() const { |
| 136 ASSERT(!m_hValue.IsEmpty()); | 136 ASSERT(!m_hValue.IsEmpty()); |
| 137 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 137 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
| 138 v8::Local<v8::Value> hValue = | 138 v8::Local<v8::Value> hValue = |
| 139 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 139 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
| 140 return static_cast<int32_t>(hValue->NumberValue()); | 140 return static_cast<int32_t>(hValue->NumberValue()); |
| 141 } | 141 } |
| 142 V8_INLINE void ToString(CFX_ByteString& szStrOutput) const { | 142 V8_INLINE void ToString(CFX_ByteString& szStrOutput) const { |
| 143 ASSERT(!m_hValue.IsEmpty()); | 143 ASSERT(!m_hValue.IsEmpty()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 165 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); | 165 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); |
| 166 v8::Local<v8::Value> hValue = | 166 v8::Local<v8::Value> hValue = |
| 167 v8::Boolean::New(m_pIsolate, bBoolean != FALSE); | 167 v8::Boolean::New(m_pIsolate, bBoolean != FALSE); |
| 168 m_hValue.Reset(m_pIsolate, hValue); | 168 m_hValue.Reset(m_pIsolate, hValue); |
| 169 } | 169 } |
| 170 V8_INLINE void SetInteger(int32_t nInteger) { | 170 V8_INLINE void SetInteger(int32_t nInteger) { |
| 171 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); | 171 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); |
| 172 v8::Local<v8::Value> hValue = v8::Integer::New(m_pIsolate, nInteger); | 172 v8::Local<v8::Value> hValue = v8::Integer::New(m_pIsolate, nInteger); |
| 173 m_hValue.Reset(m_pIsolate, hValue); | 173 m_hValue.Reset(m_pIsolate, hValue); |
| 174 } | 174 } |
| 175 V8_INLINE void SetDouble(FXJSE_DOUBLE dDouble) { | 175 V8_INLINE void SetDouble(double dDouble) { |
| 176 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); | 176 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); |
| 177 v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, dDouble); | 177 v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, dDouble); |
| 178 m_hValue.Reset(m_pIsolate, hValue); | 178 m_hValue.Reset(m_pIsolate, hValue); |
| 179 } | 179 } |
| 180 V8_INLINE void SetString(const CFX_ByteStringC& szString) { | 180 V8_INLINE void SetString(const CFX_ByteStringC& szString) { |
| 181 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); | 181 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); |
| 182 v8::Local<v8::Value> hValue = v8::String::NewFromUtf8( | 182 v8::Local<v8::Value> hValue = v8::String::NewFromUtf8( |
| 183 m_pIsolate, reinterpret_cast<const char*>(szString.GetPtr()), | 183 m_pIsolate, reinterpret_cast<const char*>(szString.GetPtr()), |
| 184 v8::String::kNormalString, szString.GetLength()); | 184 v8::String::kNormalString, szString.GetLength()); |
| 185 m_hValue.Reset(m_pIsolate, hValue); | 185 m_hValue.Reset(m_pIsolate, hValue); |
| 186 } | 186 } |
| 187 V8_INLINE void SetFloat(FX_FLOAT fFloat); | 187 V8_INLINE void SetFloat(FX_FLOAT fFloat); |
| 188 V8_INLINE void SetJSObject() { | 188 V8_INLINE void SetJSObject() { |
| 189 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 189 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
| 190 v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate); | 190 v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate); |
| 191 m_hValue.Reset(m_pIsolate, hValue); | 191 m_hValue.Reset(m_pIsolate, hValue); |
| 192 } | 192 } |
| 193 void SetHostObject(void* lpObject, CFXJSE_Class* lpClass); | 193 void SetHostObject(void* lpObject, CFXJSE_Class* lpClass); |
| 194 void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); | 194 void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); |
| 195 void SetDate(FXJSE_DOUBLE dDouble); | 195 void SetDate(double dDouble); |
| 196 | 196 |
| 197 public: | 197 public: |
| 198 FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName, | 198 FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName, |
| 199 CFXJSE_Value* lpPropValue); | 199 CFXJSE_Value* lpPropValue); |
| 200 FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName, | 200 FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName, |
| 201 CFXJSE_Value* lpPropValue); | 201 CFXJSE_Value* lpPropValue); |
| 202 FX_BOOL GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); | 202 FX_BOOL GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); |
| 203 FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); | 203 FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); |
| 204 FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName); | 204 FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName); |
| 205 FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName, | 205 FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 232 static CFXJSE_Value* Create(v8::Isolate* pIsolate); | 232 static CFXJSE_Value* Create(v8::Isolate* pIsolate); |
| 233 | 233 |
| 234 protected: | 234 protected: |
| 235 v8::Isolate* m_pIsolate; | 235 v8::Isolate* m_pIsolate; |
| 236 v8::Global<v8::Value> m_hValue; | 236 v8::Global<v8::Value> m_hValue; |
| 237 friend class CFXJSE_Context; | 237 friend class CFXJSE_Context; |
| 238 friend class CFXJSE_Class; | 238 friend class CFXJSE_Class; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 #endif // XFA_FXJSE_VALUE_H_ | 241 #endif // XFA_FXJSE_VALUE_H_ |
| OLD | NEW |