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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 165 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
166 return static_cast<double>(hValue->NumberValue()); | 166 return static_cast<double>(hValue->NumberValue()); |
167 } | 167 } |
168 V8_INLINE int32_t ToInteger() const { | 168 V8_INLINE int32_t ToInteger() const { |
169 ASSERT(!m_hValue.IsEmpty()); | 169 ASSERT(!m_hValue.IsEmpty()); |
170 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 170 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
171 v8::Local<v8::Value> hValue = | 171 v8::Local<v8::Value> hValue = |
172 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 172 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
173 return static_cast<int32_t>(hValue->NumberValue()); | 173 return static_cast<int32_t>(hValue->NumberValue()); |
174 } | 174 } |
175 V8_INLINE void ToString(CFX_ByteString& szStrOutput) const { | 175 V8_INLINE CFX_ByteString ToString() const { |
176 ASSERT(!m_hValue.IsEmpty()); | 176 ASSERT(!m_hValue.IsEmpty()); |
177 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 177 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
178 v8::Local<v8::Value> hValue = | 178 v8::Local<v8::Value> hValue = |
179 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 179 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
180 v8::Local<v8::String> hString = hValue->ToString(); | 180 v8::Local<v8::String> hString = hValue->ToString(); |
181 v8::String::Utf8Value hStringVal(hString); | 181 v8::String::Utf8Value hStringVal(hString); |
182 szStrOutput = *hStringVal; | 182 return CFX_ByteString(*hStringVal); |
183 } | |
184 V8_INLINE CFX_ByteStringC ToStringC() const { return ToString().AsStringC(); } | |
Tom Sepez
2016/06/09 16:43:56
Nope. The call to ToString() creates a temporary b
dsinclair
2016/06/09 17:26:54
Done.
| |
185 V8_INLINE CFX_WideString ToWideString() const { | |
186 return CFX_WideString::FromUTF8(ToStringC()); | |
Tom Sepez
2016/06/09 16:47:55
Note that ToWideString() will be fine (once we fix
| |
183 } | 187 } |
184 CFXJSE_HostObject* ToHostObject(CFXJSE_Class* lpClass) const; | 188 CFXJSE_HostObject* ToHostObject(CFXJSE_Class* lpClass) const; |
185 | 189 |
186 V8_INLINE void SetUndefined() { | 190 V8_INLINE void SetUndefined() { |
187 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); | 191 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); |
188 v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate); | 192 v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate); |
189 m_hValue.Reset(m_pIsolate, hValue); | 193 m_hValue.Reset(m_pIsolate, hValue); |
190 } | 194 } |
191 V8_INLINE void SetNull() { | 195 V8_INLINE void SetNull() { |
192 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); | 196 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 | 276 |
273 CFXJSE_Value(); | 277 CFXJSE_Value(); |
274 CFXJSE_Value(const CFXJSE_Value&); | 278 CFXJSE_Value(const CFXJSE_Value&); |
275 CFXJSE_Value& operator=(const CFXJSE_Value&); | 279 CFXJSE_Value& operator=(const CFXJSE_Value&); |
276 | 280 |
277 v8::Isolate* m_pIsolate; | 281 v8::Isolate* m_pIsolate; |
278 v8::Global<v8::Value> m_hValue; | 282 v8::Global<v8::Value> m_hValue; |
279 }; | 283 }; |
280 | 284 |
281 #endif // XFA_FXJSE_VALUE_H_ | 285 #endif // XFA_FXJSE_VALUE_H_ |
OLD | NEW |