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