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 #include "xfa/fxjse/value.h" | 7 #include "xfa/fxjse/value.h" |
8 | 8 |
9 #include <math.h> | 9 #include <math.h> |
10 | 10 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, | 66 void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, |
67 CFX_ByteString& szStrOutput) { | 67 CFX_ByteString& szStrOutput) { |
68 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToString(szStrOutput); | 68 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToString(szStrOutput); |
69 } | 69 } |
70 | 70 |
71 int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue) { | 71 int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue) { |
72 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToInteger(); | 72 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToInteger(); |
73 } | 73 } |
74 | 74 |
75 void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue, FXJSE_HCLASS hClass) { | 75 void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue) { |
76 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); | 76 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToObject(); |
77 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToObject(lpClass); | |
78 } | 77 } |
79 | 78 |
80 void FXJSE_Value_SetUndefined(FXJSE_HVALUE hValue) { | 79 void FXJSE_Value_SetUndefined(FXJSE_HVALUE hValue) { |
81 reinterpret_cast<CFXJSE_Value*>(hValue)->SetUndefined(); | 80 reinterpret_cast<CFXJSE_Value*>(hValue)->SetUndefined(); |
82 } | 81 } |
83 | 82 |
84 void FXJSE_Value_SetNull(FXJSE_HVALUE hValue) { | 83 void FXJSE_Value_SetNull(FXJSE_HVALUE hValue) { |
85 reinterpret_cast<CFXJSE_Value*>(hValue)->SetNull(); | 84 reinterpret_cast<CFXJSE_Value*>(hValue)->SetNull(); |
86 } | 85 } |
87 | 86 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 utf8Name.GetLength())); | 230 utf8Name.GetLength())); |
232 } | 231 } |
233 } | 232 } |
234 pIsolate->ThrowException(hError); | 233 pIsolate->ThrowException(hError); |
235 } | 234 } |
236 | 235 |
237 CFXJSE_Value* CFXJSE_Value::Create(v8::Isolate* pIsolate) { | 236 CFXJSE_Value* CFXJSE_Value::Create(v8::Isolate* pIsolate) { |
238 return new CFXJSE_Value(pIsolate); | 237 return new CFXJSE_Value(pIsolate); |
239 } | 238 } |
240 | 239 |
241 void* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const { | 240 void* CFXJSE_Value::ToObject() const { |
242 ASSERT(!m_hValue.IsEmpty()); | 241 ASSERT(!m_hValue.IsEmpty()); |
243 | 242 |
244 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 243 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
245 v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 244 v8::Local<v8::Value> hValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
246 ASSERT(!hValue.IsEmpty()); | 245 ASSERT(!hValue.IsEmpty()); |
247 | 246 |
248 if (!hValue->IsObject()) | 247 if (!hValue->IsObject()) |
249 return nullptr; | 248 return nullptr; |
250 | 249 |
251 return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass); | 250 return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>()); |
252 } | 251 } |
253 | 252 |
254 V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) { | 253 V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) { |
255 if (sizeof(FX_FLOAT) != 4) { | 254 if (sizeof(FX_FLOAT) != 4) { |
256 ASSERT(FALSE); | 255 ASSERT(FALSE); |
257 return fNumber; | 256 return fNumber; |
258 } | 257 } |
259 | 258 |
260 uint32_t nFloatBits = (uint32_t&)fNumber; | 259 uint32_t nFloatBits = (uint32_t&)fNumber; |
261 uint8_t nExponent = (uint8_t)(nFloatBits >> 16 >> 7); | 260 uint8_t nExponent = (uint8_t)(nFloatBits >> 16 >> 7); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 if (lpRetValue) | 532 if (lpRetValue) |
534 lpRetValue->ForceSetValue(hReturnValue); | 533 lpRetValue->ForceSetValue(hReturnValue); |
535 | 534 |
536 if (lpLocalArgs) { | 535 if (lpLocalArgs) { |
537 for (uint32_t i = 0; i < nArgCount; i++) | 536 for (uint32_t i = 0; i < nArgCount; i++) |
538 lpLocalArgs[i].~Local(); | 537 lpLocalArgs[i].~Local(); |
539 FX_Free(lpLocalArgs); | 538 FX_Free(lpLocalArgs); |
540 } | 539 } |
541 return bRetValue; | 540 return bRetValue; |
542 } | 541 } |
OLD | NEW |