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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 FX_BOOL FXJSE_Value_ToBoolean(FXJSE_HVALUE hValue) { | 64 FX_BOOL FXJSE_Value_ToBoolean(FXJSE_HVALUE hValue) { |
65 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToBoolean(); | 65 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToBoolean(); |
66 } | 66 } |
67 | 67 |
68 FX_FLOAT FXJSE_Value_ToFloat(FXJSE_HVALUE hValue) { | 68 FX_FLOAT FXJSE_Value_ToFloat(FXJSE_HVALUE hValue) { |
69 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToFloat(); | 69 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToFloat(); |
70 } | 70 } |
71 | 71 |
72 FXJSE_DOUBLE FXJSE_Value_ToDouble(FXJSE_HVALUE hValue) { | 72 double FXJSE_Value_ToDouble(FXJSE_HVALUE hValue) { |
73 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToDouble(); | 73 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToDouble(); |
74 } | 74 } |
75 | 75 |
76 void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, | 76 void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, |
77 CFX_ByteString& szStrOutput) { | 77 CFX_ByteString& szStrOutput) { |
78 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToString(szStrOutput); | 78 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToString(szStrOutput); |
79 } | 79 } |
80 | 80 |
81 int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue) { | 81 int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue) { |
82 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToInteger(); | 82 return reinterpret_cast<CFXJSE_Value*>(hValue)->ToInteger(); |
(...skipping 22 matching lines...) Expand all Loading... |
105 } | 105 } |
106 | 106 |
107 void FXJSE_Value_SetInteger(FXJSE_HVALUE hValue, int32_t nInteger) { | 107 void FXJSE_Value_SetInteger(FXJSE_HVALUE hValue, int32_t nInteger) { |
108 reinterpret_cast<CFXJSE_Value*>(hValue)->SetInteger(nInteger); | 108 reinterpret_cast<CFXJSE_Value*>(hValue)->SetInteger(nInteger); |
109 } | 109 } |
110 | 110 |
111 void FXJSE_Value_SetFloat(FXJSE_HVALUE hValue, FX_FLOAT fFloat) { | 111 void FXJSE_Value_SetFloat(FXJSE_HVALUE hValue, FX_FLOAT fFloat) { |
112 reinterpret_cast<CFXJSE_Value*>(hValue)->SetFloat(fFloat); | 112 reinterpret_cast<CFXJSE_Value*>(hValue)->SetFloat(fFloat); |
113 } | 113 } |
114 | 114 |
115 void FXJSE_Value_SetDouble(FXJSE_HVALUE hValue, FXJSE_DOUBLE dDouble) { | 115 void FXJSE_Value_SetDouble(FXJSE_HVALUE hValue, double dDouble) { |
116 reinterpret_cast<CFXJSE_Value*>(hValue)->SetDouble(dDouble); | 116 reinterpret_cast<CFXJSE_Value*>(hValue)->SetDouble(dDouble); |
117 } | 117 } |
118 | 118 |
119 void FXJSE_Value_SetObject(FXJSE_HVALUE hValue, | 119 void FXJSE_Value_SetObject(FXJSE_HVALUE hValue, |
120 void* lpObject, | 120 void* lpObject, |
121 FXJSE_HCLASS hClass) { | 121 FXJSE_HCLASS hClass) { |
122 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); | 122 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); |
123 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); | 123 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); |
124 if (!lpClass) { | 124 if (!lpClass) { |
125 ASSERT(!lpObject); | 125 ASSERT(!lpObject); |
126 lpValue->SetJSObject(); | 126 lpValue->SetJSObject(); |
127 } else { | 127 } else { |
128 lpValue->SetHostObject(lpObject, lpClass); | 128 lpValue->SetHostObject(lpObject, lpClass); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 void FXJSE_Value_SetArray(FXJSE_HVALUE hValue, | 132 void FXJSE_Value_SetArray(FXJSE_HVALUE hValue, |
133 uint32_t uValueCount, | 133 uint32_t uValueCount, |
134 FXJSE_HVALUE* rgValues) { | 134 FXJSE_HVALUE* rgValues) { |
135 reinterpret_cast<CFXJSE_Value*>(hValue) | 135 reinterpret_cast<CFXJSE_Value*>(hValue) |
136 ->SetArray(uValueCount, reinterpret_cast<CFXJSE_Value**>(rgValues)); | 136 ->SetArray(uValueCount, reinterpret_cast<CFXJSE_Value**>(rgValues)); |
137 } | 137 } |
138 | 138 |
139 void FXJSE_Value_SetDate(FXJSE_HVALUE hValue, FXJSE_DOUBLE dDouble) { | 139 void FXJSE_Value_SetDate(FXJSE_HVALUE hValue, double dDouble) { |
140 reinterpret_cast<CFXJSE_Value*>(hValue)->SetDate(dDouble); | 140 reinterpret_cast<CFXJSE_Value*>(hValue)->SetDate(dDouble); |
141 } | 141 } |
142 | 142 |
143 void FXJSE_Value_Set(FXJSE_HVALUE hValue, FXJSE_HVALUE hOriginalValue) { | 143 void FXJSE_Value_Set(FXJSE_HVALUE hValue, FXJSE_HVALUE hOriginalValue) { |
144 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); | 144 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); |
145 CFXJSE_Value* lpOriginalValue = | 145 CFXJSE_Value* lpOriginalValue = |
146 reinterpret_cast<CFXJSE_Value*>(hOriginalValue); | 146 reinterpret_cast<CFXJSE_Value*>(hOriginalValue); |
147 ASSERT(lpValue && lpOriginalValue); | 147 ASSERT(lpValue && lpOriginalValue); |
148 lpValue->Assign(lpOriginalValue); | 148 lpValue->Assign(lpOriginalValue); |
149 } | 149 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 for (uint32_t i = 0; i < uValueCount; i++) { | 354 for (uint32_t i = 0; i < uValueCount; i++) { |
355 if (rgValues[i]) { | 355 if (rgValues[i]) { |
356 hArrayObject->Set(i, v8::Local<v8::Value>::New( | 356 hArrayObject->Set(i, v8::Local<v8::Value>::New( |
357 m_pIsolate, rgValues[i]->DirectGetValue())); | 357 m_pIsolate, rgValues[i]->DirectGetValue())); |
358 } | 358 } |
359 } | 359 } |
360 } | 360 } |
361 m_hValue.Reset(m_pIsolate, hArrayObject); | 361 m_hValue.Reset(m_pIsolate, hArrayObject); |
362 } | 362 } |
363 | 363 |
364 void CFXJSE_Value::SetDate(FXJSE_DOUBLE dDouble) { | 364 void CFXJSE_Value::SetDate(double dDouble) { |
365 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 365 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
366 v8::Local<v8::Value> hDate = v8::Date::New(m_pIsolate, dDouble); | 366 v8::Local<v8::Value> hDate = v8::Date::New(m_pIsolate, dDouble); |
367 m_hValue.Reset(m_pIsolate, hDate); | 367 m_hValue.Reset(m_pIsolate, hDate); |
368 } | 368 } |
369 | 369 |
370 FX_BOOL CFXJSE_Value::SetObjectProperty(const CFX_ByteStringC& szPropName, | 370 FX_BOOL CFXJSE_Value::SetObjectProperty(const CFX_ByteStringC& szPropName, |
371 CFXJSE_Value* lpPropValue) { | 371 CFXJSE_Value* lpPropValue) { |
372 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); | 372 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); |
373 v8::Local<v8::Value> hObject = | 373 v8::Local<v8::Value> hObject = |
374 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); | 374 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 if (lpRetValue) | 573 if (lpRetValue) |
574 lpRetValue->ForceSetValue(hReturnValue); | 574 lpRetValue->ForceSetValue(hReturnValue); |
575 | 575 |
576 if (lpLocalArgs) { | 576 if (lpLocalArgs) { |
577 for (uint32_t i = 0; i < nArgCount; i++) | 577 for (uint32_t i = 0; i < nArgCount; i++) |
578 lpLocalArgs[i].~Local(); | 578 lpLocalArgs[i].~Local(); |
579 FX_Free(lpLocalArgs); | 579 FX_Free(lpLocalArgs); |
580 } | 580 } |
581 return bRetValue; | 581 return bRetValue; |
582 } | 582 } |
OLD | NEW |