Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: xfa/src/fxjse/src/value.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fxjse/src/value.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../../foxitlib.h" 7 #include "../../foxitlib.h"
8 #include "fxv8.h" 8 #include "fxv8.h"
9 #include "value.h" 9 #include "value.h"
10 #include "class.h" 10 #include "class.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 77 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
78 ASSERT(lpValue); 78 ASSERT(lpValue);
79 return lpValue->ToDouble(); 79 return lpValue->ToDouble();
80 } 80 }
81 void FXJSE_Value_ToUTF8String (FXJSE_HVALUE hValue, CFX_ByteSt ring& szStrOutput) 81 void FXJSE_Value_ToUTF8String (FXJSE_HVALUE hValue, CFX_ByteSt ring& szStrOutput)
82 { 82 {
83 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 83 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
84 ASSERT(lpValue); 84 ASSERT(lpValue);
85 return lpValue->ToString(szStrOutput); 85 return lpValue->ToString(szStrOutput);
86 } 86 }
87 FX_INT32» FXJSE_Value_ToInteger» » (FXJSE_HVALUE hValue) 87 int32_t»FXJSE_Value_ToInteger» » (FXJSE_HVALUE hValue)
88 { 88 {
89 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 89 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
90 ASSERT(lpValue); 90 ASSERT(lpValue);
91 return lpValue->ToInteger(); 91 return lpValue->ToInteger();
92 } 92 }
93 FX_LPVOID FXJSE_Value_ToObject (FXJSE_HVALUE hValue, FXJSE_HCLA SS hClass) 93 FX_LPVOID FXJSE_Value_ToObject (FXJSE_HVALUE hValue, FXJSE_HCLA SS hClass)
94 { 94 {
95 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 95 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
96 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); 96 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass);
97 ASSERT(lpValue); 97 ASSERT(lpValue);
(...skipping 16 matching lines...) Expand all
114 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 114 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
115 ASSERT(lpValue); 115 ASSERT(lpValue);
116 return lpValue->SetBoolean(bBoolean); 116 return lpValue->SetBoolean(bBoolean);
117 } 117 }
118 void FXJSE_Value_SetUTF8String (FXJSE_HVALUE hValue, FX_BSTR szString) 118 void FXJSE_Value_SetUTF8String (FXJSE_HVALUE hValue, FX_BSTR szString)
119 { 119 {
120 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 120 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
121 ASSERT(lpValue); 121 ASSERT(lpValue);
122 return lpValue->SetString(szString); 122 return lpValue->SetString(szString);
123 } 123 }
124 void» » FXJSE_Value_SetInteger» » (FXJSE_HVALUE hValue, FX_INT32 nInteger) 124 void» » FXJSE_Value_SetInteger» » (FXJSE_HVALUE hValue, int32_t n Integer)
125 { 125 {
126 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 126 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
127 ASSERT(lpValue); 127 ASSERT(lpValue);
128 return lpValue->SetInteger(nInteger); 128 return lpValue->SetInteger(nInteger);
129 } 129 }
130 void FXJSE_Value_SetFloat (FXJSE_HVALUE hValue, FX_FLOAT fFloat) 130 void FXJSE_Value_SetFloat (FXJSE_HVALUE hValue, FX_FLOAT fFloat)
131 { 131 {
132 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 132 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
133 ASSERT(lpValue); 133 ASSERT(lpValue);
134 return lpValue->SetFloat(fFloat); 134 return lpValue->SetFloat(fFloat);
135 } 135 }
136 void FXJSE_Value_SetDouble (FXJSE_HVALUE hValue, FXJSE_DOUB LE dDouble) 136 void FXJSE_Value_SetDouble (FXJSE_HVALUE hValue, FXJSE_DOUB LE dDouble)
137 { 137 {
138 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 138 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
139 ASSERT(lpValue); 139 ASSERT(lpValue);
140 return lpValue->SetDouble(dDouble); 140 return lpValue->SetDouble(dDouble);
141 } 141 }
142 void FXJSE_Value_SetObject (FXJSE_HVALUE hValue, FX_LPVOID lpObject, FXJSE_HCLASS hClass) 142 void FXJSE_Value_SetObject (FXJSE_HVALUE hValue, FX_LPVOID lpObject, FXJSE_HCLASS hClass)
143 { 143 {
144 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 144 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
145 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); 145 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass);
146 if(lpClass == NULL) { 146 if(lpClass == NULL) {
147 ASSERT(lpObject == NULL); 147 ASSERT(lpObject == NULL);
148 lpValue->SetJSObject(); 148 lpValue->SetJSObject();
149 } else if(lpClass != NULL) { 149 } else if(lpClass != NULL) {
150 lpValue->SetHostObject(lpObject, lpClass); 150 lpValue->SetHostObject(lpObject, lpClass);
151 } 151 }
152 } 152 }
153 void» » FXJSE_Value_SetArray» » (FXJSE_HVALUE hValue, FX_UINT32 uValueCount, FXJSE_HVALUE* rgValues) 153 void» » FXJSE_Value_SetArray» » (FXJSE_HVALUE hValue, uint32_t u ValueCount, FXJSE_HVALUE* rgValues)
154 { 154 {
155 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 155 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
156 return lpValue->SetArray(uValueCount, reinterpret_cast<CFXJSE_Value**>(rgVal ues)); 156 return lpValue->SetArray(uValueCount, reinterpret_cast<CFXJSE_Value**>(rgVal ues));
157 } 157 }
158 void FXJSE_Value_SetDate (FXJSE_HVALUE hValue, FX JSE_DOUBLE dDouble) 158 void FXJSE_Value_SetDate (FXJSE_HVALUE hValue, FX JSE_DOUBLE dDouble)
159 { 159 {
160 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 160 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
161 return lpValue->SetDate(dDouble); 161 return lpValue->SetDate(dDouble);
162 } 162 }
163 void FXJSE_Value_Set (FXJSE_HVALUE hValue, FX JSE_HVALUE hOriginalValue) 163 void FXJSE_Value_Set (FXJSE_HVALUE hValue, FX JSE_HVALUE hOriginalValue)
(...skipping 10 matching lines...) Expand all
174 ASSERT(lpValue && lpPropValue); 174 ASSERT(lpValue && lpPropValue);
175 return lpValue->GetObjectProperty(szPropName, lpPropValue); 175 return lpValue->GetObjectProperty(szPropName, lpPropValue);
176 } 176 }
177 FX_BOOL FXJSE_Value_SetObjectProp (FXJSE_HVALUE hValue, FX _BSTR szPropName, FXJSE_HVALUE hPropValue) 177 FX_BOOL FXJSE_Value_SetObjectProp (FXJSE_HVALUE hValue, FX _BSTR szPropName, FXJSE_HVALUE hPropValue)
178 { 178 {
179 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 179 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
180 CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue); 180 CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue);
181 ASSERT(lpValue && lpPropValue); 181 ASSERT(lpValue && lpPropValue);
182 return lpValue->SetObjectProperty(szPropName, lpPropValue); 182 return lpValue->SetObjectProperty(szPropName, lpPropValue);
183 } 183 }
184 FX_BOOL»» FXJSE_Value_GetObjectPropByIdx» (FXJSE_HVALUE hValue, FX_UINT32» uPropIdx,» FXJSE_HVALUE hPropValue) 184 FX_BOOL»» FXJSE_Value_GetObjectPropByIdx» (FXJSE_HVALUE hValue, uint32_t» uPropIdx,» FXJSE_HVALUE hPropValue)
185 { 185 {
186 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 186 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
187 CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue); 187 CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue);
188 ASSERT(lpValue && lpPropValue); 188 ASSERT(lpValue && lpPropValue);
189 return lpValue->GetObjectProperty(uPropIdx, lpPropValue); 189 return lpValue->GetObjectProperty(uPropIdx, lpPropValue);
190 } 190 }
191 FX_BOOL»» FXJSE_Value_SetObjectPropByIdx» (FXJSE_HVALUE hValue, FX_UINT32» uPropIdx,» FXJSE_HVALUE hPropValue) 191 FX_BOOL»» FXJSE_Value_SetObjectPropByIdx» (FXJSE_HVALUE hValue, uint32_t» uPropIdx,» FXJSE_HVALUE hPropValue)
192 { 192 {
193 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 193 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
194 CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue); 194 CFXJSE_Value* lpPropValue = reinterpret_cast<CFXJSE_Value*>(hPropValue);
195 ASSERT(lpValue && lpPropValue); 195 ASSERT(lpValue && lpPropValue);
196 return lpValue->SetObjectProperty(uPropIdx, lpPropValue); 196 return lpValue->SetObjectProperty(uPropIdx, lpPropValue);
197 } 197 }
198 FX_BOOL FXJSE_Value_DeleteObjectProp (FXJSE_HVALUE hValue, FX_BSTR sz PropName) 198 FX_BOOL FXJSE_Value_DeleteObjectProp (FXJSE_HVALUE hValue, FX_BSTR sz PropName)
199 { 199 {
200 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 200 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
201 ASSERT(lpValue); 201 ASSERT(lpValue);
(...skipping 13 matching lines...) Expand all
215 return lpValue->SetObjectOwnProperty(szPropName, lpPropValue); 215 return lpValue->SetObjectOwnProperty(szPropName, lpPropValue);
216 } 216 }
217 FX_BOOL FXJSE_Value_SetFunctionBind (FXJSE_HVALUE hValue, FXJSE_HVAL UE hOldFunction, FXJSE_HVALUE hNewThis) 217 FX_BOOL FXJSE_Value_SetFunctionBind (FXJSE_HVALUE hValue, FXJSE_HVAL UE hOldFunction, FXJSE_HVALUE hNewThis)
218 { 218 {
219 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); 219 CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue);
220 CFXJSE_Value* lpOldFunction = reinterpret_cast<CFXJSE_Value*>(hOldFunction); 220 CFXJSE_Value* lpOldFunction = reinterpret_cast<CFXJSE_Value*>(hOldFunction);
221 CFXJSE_Value* lpNewThis = reinterpret_cast<CFXJSE_Value*>(hNewThis); 221 CFXJSE_Value* lpNewThis = reinterpret_cast<CFXJSE_Value*>(hNewThis);
222 ASSERT(lpValue && lpOldFunction && lpNewThis); 222 ASSERT(lpValue && lpOldFunction && lpNewThis);
223 return lpValue->SetFunctionBind(lpOldFunction, lpNewThis); 223 return lpValue->SetFunctionBind(lpOldFunction, lpNewThis);
224 } 224 }
225 FX_BOOL»FXJSE_Value_CallFunction(FXJSE_HVALUE hFunction, FXJSE_HVALUE hThis, FXJ SE_HVALUE hRetValue, FX_UINT32 nArgCount, FXJSE_HVALUE* lpArgs) 225 FX_BOOL»FXJSE_Value_CallFunction(FXJSE_HVALUE hFunction, FXJSE_HVALUE hThis, FXJ SE_HVALUE hRetValue, uint32_t nArgCount, FXJSE_HVALUE* lpArgs)
226 { 226 {
227 CFXJSE_Value* lpFunction = reinterpret_cast<CFXJSE_Value*>(hFunction); 227 CFXJSE_Value* lpFunction = reinterpret_cast<CFXJSE_Value*>(hFunction);
228 CFXJSE_Value* lpThis = reinterpret_cast<CFXJSE_Value*>(hThis); 228 CFXJSE_Value* lpThis = reinterpret_cast<CFXJSE_Value*>(hThis);
229 CFXJSE_Value* lpRetValue = reinterpret_cast<CFXJSE_Value*>(hRetValue); 229 CFXJSE_Value* lpRetValue = reinterpret_cast<CFXJSE_Value*>(hRetValue);
230 ASSERT(lpFunction); 230 ASSERT(lpFunction);
231 return lpFunction->Call(lpThis, lpRetValue, nArgCount, lpArgs); 231 return lpFunction->Call(lpThis, lpRetValue, nArgCount, lpArgs);
232 } 232 }
233 FXJSE_HVALUE FXJSE_Value_Create (FXJSE_HRUNTIME hRuntime) 233 FXJSE_HVALUE FXJSE_Value_Create (FXJSE_HRUNTIME hRuntime)
234 { 234 {
235 CFXJSE_Value* lpValue = CFXJSE_Value::Create(reinterpret_cast<v8::Isolate*>( hRuntime)); 235 CFXJSE_Value* lpValue = CFXJSE_Value::Create(reinterpret_cast<v8::Isolate*>( hRuntime));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return NULL; 286 return NULL;
287 } 287 }
288 return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass); 288 return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass);
289 } 289 }
290 V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) 290 V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber)
291 { 291 {
292 if(sizeof(FX_FLOAT) != 4) { 292 if(sizeof(FX_FLOAT) != 4) {
293 ASSERT(FALSE); 293 ASSERT(FALSE);
294 return fNumber; 294 return fNumber;
295 } 295 }
296 FX_UINT32 nFloatBits = (FX_UINT32&)fNumber; 296 uint32_t nFloatBits = (uint32_t&)fNumber;
297 FX_UINT8 nExponent = (FX_UINT8)(nFloatBits >> 16 >> 7 ); 297 uint8_t nExponent = (uint8_t)(nFloatBits >> 16 >> 7 );
298 if(nExponent == 0 || nExponent == 255) { 298 if(nExponent == 0 || nExponent == 255) {
299 return fNumber; 299 return fNumber;
300 } 300 }
301 FX_INT8 nErrExp = nExponent - 127 - 23; 301 int8_t nErrExp = nExponent - 127 - 23;
302 if(nErrExp >= 0) { 302 if(nErrExp >= 0) {
303 return fNumber; 303 return fNumber;
304 } 304 }
305 double dwError = pow(2.0, nErrExp), dwErrorHalf = dwError / 2; 305 double dwError = pow(2.0, nErrExp), dwErrorHalf = dwError / 2;
306 double dNumber = fNumber, dNumberAbs = fabs(fNumber); 306 double dNumber = fNumber, dNumberAbs = fabs(fNumber);
307 double dNumberAbsMin = dNumberAbs - dwErrorHalf, dNumberAbsMax = dNumberAbs + dwErrorHalf; 307 double dNumberAbsMin = dNumberAbs - dwErrorHalf, dNumberAbsMax = dNumberAbs + dwErrorHalf;
308 FX_INT32 iErrPos = 0; 308 int32_t iErrPos = 0;
309 if(floor(dNumberAbsMin) == floor(dNumberAbsMax)) { 309 if(floor(dNumberAbsMin) == floor(dNumberAbsMax)) {
310 dNumberAbsMin = fmod(dNumberAbsMin, 1.0); 310 dNumberAbsMin = fmod(dNumberAbsMin, 1.0);
311 dNumberAbsMax = fmod(dNumberAbsMax, 1.0); 311 dNumberAbsMax = fmod(dNumberAbsMax, 1.0);
312 FX_INT32 iErrPosMin = 1, iErrPosMax = 38; 312 int32_t iErrPosMin = 1, iErrPosMax = 38;
313 do { 313 do {
314 FX_INT32 iMid = (iErrPosMin + iErrPosMax) / 2; 314 int32_t iMid = (iErrPosMin + iErrPosMax) / 2;
315 double dPow = pow(10.0, iMid); 315 double dPow = pow(10.0, iMid);
316 if(floor(dNumberAbsMin * dPow) == floor(dNumberAbsMax * dPow)) { 316 if(floor(dNumberAbsMin * dPow) == floor(dNumberAbsMax * dPow)) {
317 iErrPosMin = iMid + 1; 317 iErrPosMin = iMid + 1;
318 } else { 318 } else {
319 iErrPosMax = iMid; 319 iErrPosMax = iMid;
320 } 320 }
321 } while (iErrPosMin < iErrPosMax); 321 } while (iErrPosMin < iErrPosMax);
322 iErrPos = iErrPosMax; 322 iErrPos = iErrPosMax;
323 } 323 }
324 double dPow = pow(10.0, iErrPos); 324 double dPow = pow(10.0, iErrPos);
325 return fNumber < 0 ? ceil(dNumber * dPow - 0.5) / dPow : floor(dNumber * dPo w + 0.5) / dPow; 325 return fNumber < 0 ? ceil(dNumber * dPow - 0.5) / dPow : floor(dNumber * dPo w + 0.5) / dPow;
326 } 326 }
327 void CFXJSE_Value::SetFloat(FX_FLOAT fFloat) 327 void CFXJSE_Value::SetFloat(FX_FLOAT fFloat)
328 { 328 {
329 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 329 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
330 v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, FXJSE_ftod(fFloat) ); 330 v8::Local<v8::Value> hValue = v8::Number::New(m_pIsolate, FXJSE_ftod(fFloat) );
331 m_hValue.Reset(m_pIsolate, hValue); 331 m_hValue.Reset(m_pIsolate, hValue);
332 } 332 }
333 void CFXJSE_Value::SetHostObject(FX_LPVOID lpObject, CFXJSE_Class* lpClass) 333 void CFXJSE_Value::SetHostObject(FX_LPVOID lpObject, CFXJSE_Class* lpClass)
334 { 334 {
335 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 335 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
336 ASSERT(lpClass); 336 ASSERT(lpClass);
337 v8::Local<v8::FunctionTemplate> hClass = v8::Local<v8::FunctionTemplate>::Ne w(m_pIsolate, lpClass->m_hTemplate); 337 v8::Local<v8::FunctionTemplate> hClass = v8::Local<v8::FunctionTemplate>::Ne w(m_pIsolate, lpClass->m_hTemplate);
338 v8::Local<v8::Object> hObject = hClass->InstanceTemplate()->NewInstance(); 338 v8::Local<v8::Object> hObject = hClass->InstanceTemplate()->NewInstance();
339 FXJSE_UpdateObjectBinding(hObject, lpObject); 339 FXJSE_UpdateObjectBinding(hObject, lpObject);
340 m_hValue.Reset(m_pIsolate, hObject); 340 m_hValue.Reset(m_pIsolate, hObject);
341 } 341 }
342 void CFXJSE_Value::SetArray(FX_UINT32 uValueCount, CFXJSE_Value** rgValues) 342 void CFXJSE_Value::SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues)
343 { 343 {
344 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 344 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
345 v8::Local<v8::Array> hArrayObject = v8::Array::New(m_pIsolate, uValueCount); 345 v8::Local<v8::Array> hArrayObject = v8::Array::New(m_pIsolate, uValueCount);
346 if (rgValues) { 346 if (rgValues) {
347 for(FX_UINT32 i = 0; i < uValueCount; i++) { 347 for(uint32_t i = 0; i < uValueCount; i++) {
348 if(rgValues[i]) { 348 if(rgValues[i]) {
349 hArrayObject->Set(i, v8::Local<v8::Value>::New(m_pIsolate, rgVal ues[i]->DirectGetValue())); 349 hArrayObject->Set(i, v8::Local<v8::Value>::New(m_pIsolate, rgVal ues[i]->DirectGetValue()));
350 } 350 }
351 } 351 }
352 } 352 }
353 m_hValue.Reset(m_pIsolate, hArrayObject); 353 m_hValue.Reset(m_pIsolate, hArrayObject);
354 } 354 }
355 void CFXJSE_Value::SetDate(FXJSE_DOUBLE dDouble) 355 void CFXJSE_Value::SetDate(FXJSE_DOUBLE dDouble)
356 { 356 {
357 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 357 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
(...skipping 14 matching lines...) Expand all
372 { 372 {
373 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 373 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
374 v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValu e); 374 v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValu e);
375 if(!hObject->IsObject()) { 375 if(!hObject->IsObject()) {
376 return FALSE; 376 return FALSE;
377 } 377 }
378 v8::Local<v8::Value> hPropValue = hObject.As<v8::Object>()->Get(v8::String:: NewFromUtf8(m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, szPropN ame.GetLength())); 378 v8::Local<v8::Value> hPropValue = hObject.As<v8::Object>()->Get(v8::String:: NewFromUtf8(m_pIsolate, szPropName.GetCStr(), v8::String::kNormalString, szPropN ame.GetLength()));
379 lpPropValue->ForceSetValue(hPropValue); 379 lpPropValue->ForceSetValue(hPropValue);
380 return TRUE; 380 return TRUE;
381 } 381 }
382 FX_BOOL CFXJSE_Value::SetObjectProperty(FX_UINT32 uPropIdx, CFXJSE_Value* lpProp Value) 382 FX_BOOL CFXJSE_Value::SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropV alue)
383 { 383 {
384 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 384 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
385 v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValu e); 385 v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValu e);
386 if(!hObject->IsObject()) { 386 if(!hObject->IsObject()) {
387 return FALSE; 387 return FALSE;
388 } 388 }
389 v8::Local<v8::Value> hPropValue = v8::Local<v8::Value>::New(m_pIsolate, lpPr opValue->DirectGetValue()); 389 v8::Local<v8::Value> hPropValue = v8::Local<v8::Value>::New(m_pIsolate, lpPr opValue->DirectGetValue());
390 return (FX_BOOL)hObject.As<v8::Object>()->Set(uPropIdx, hPropValue); 390 return (FX_BOOL)hObject.As<v8::Object>()->Set(uPropIdx, hPropValue);
391 } 391 }
392 FX_BOOL CFXJSE_Value::GetObjectProperty(FX_UINT32 uPropIdx, CFXJSE_Value* lpProp Value) 392 FX_BOOL CFXJSE_Value::GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropV alue)
393 { 393 {
394 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 394 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
395 v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValu e); 395 v8::Local<v8::Value> hObject = v8::Local<v8::Value>::New(m_pIsolate, m_hValu e);
396 if(!hObject->IsObject()) { 396 if(!hObject->IsObject()) {
397 return FALSE; 397 return FALSE;
398 } 398 }
399 v8::Local<v8::Value> hPropValue = hObject.As<v8::Object>()->Get(uPropIdx); 399 v8::Local<v8::Value> hPropValue = hObject.As<v8::Object>()->Get(uPropIdx);
400 lpPropValue->ForceSetValue(hPropValue); 400 lpPropValue->ForceSetValue(hPropValue);
401 return TRUE; 401 return TRUE;
402 } 402 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 rgArgs[1] = hNewThis; 446 rgArgs[1] = hNewThis;
447 v8::Local<v8::String> hBinderFuncSource = v8::String::NewFromUtf8(m_pIsolate , "(function (oldfunction, newthis) { return oldfunction.bind(newthis); })"); 447 v8::Local<v8::String> hBinderFuncSource = v8::String::NewFromUtf8(m_pIsolate , "(function (oldfunction, newthis) { return oldfunction.bind(newthis); })");
448 v8::Local<v8::Function> hBinderFunc = v8::Script::Compile(hBinderFuncSource) ->Run().As<v8::Function>(); 448 v8::Local<v8::Function> hBinderFunc = v8::Script::Compile(hBinderFuncSource) ->Run().As<v8::Function>();
449 v8::Local<v8::Value> hBoundFunction = hBinderFunc->Call(m_pIsolate->GetCurre ntContext()->Global(), 2, rgArgs); 449 v8::Local<v8::Value> hBoundFunction = hBinderFunc->Call(m_pIsolate->GetCurre ntContext()->Global(), 2, rgArgs);
450 if(hBoundFunction.IsEmpty() || !hBoundFunction->IsFunction()) { 450 if(hBoundFunction.IsEmpty() || !hBoundFunction->IsFunction()) {
451 return FALSE; 451 return FALSE;
452 } 452 }
453 m_hValue.Reset(m_pIsolate, hBoundFunction); 453 m_hValue.Reset(m_pIsolate, hBoundFunction);
454 return TRUE; 454 return TRUE;
455 } 455 }
456 #define FXJSE_INVALID_PTR ((FX_LPVOID)(FX_INTPTR)-1) 456 #define FXJSE_INVALID_PTR ((FX_LPVOID)(intptr_t)-1)
457 FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, CFXJSE_Value* lpRetValue, F X_UINT32 nArgCount, FXJSE_HVALUE* lpArgs) 457 FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver, CFXJSE_Value* lpRetValue, u int32_t nArgCount, FXJSE_HVALUE* lpArgs)
458 { 458 {
459 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 459 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
460 v8::Local<v8::Value> hFunctionValue = v8::Local<v8::Value>::New(m_pIsolate, DirectGetValue()); 460 v8::Local<v8::Value> hFunctionValue = v8::Local<v8::Value>::New(m_pIsolate, DirectGetValue());
461 v8::Local<v8::Object> hFunctionObject = !hFunctionValue.IsEmpty() && hFuncti onValue->IsObject() ? hFunctionValue.As<v8::Object>() : v8::Local<v8::Object>(); 461 v8::Local<v8::Object> hFunctionObject = !hFunctionValue.IsEmpty() && hFuncti onValue->IsObject() ? hFunctionValue.As<v8::Object>() : v8::Local<v8::Object>();
462 v8::TryCatch trycatch; 462 v8::TryCatch trycatch;
463 if (hFunctionObject.IsEmpty() || !hFunctionObject->IsCallable()) { 463 if (hFunctionObject.IsEmpty() || !hFunctionObject->IsCallable()) {
464 if(lpRetValue) { 464 if(lpRetValue) {
465 lpRetValue->ForceSetValue(FXJSE_CreateReturnValue(m_pIsolate, trycat ch)); 465 lpRetValue->ForceSetValue(FXJSE_CreateReturnValue(m_pIsolate, trycat ch));
466 } 466 }
467 return FALSE; 467 return FALSE;
468 } 468 }
469 v8::Local<v8::Value> hReturnValue; 469 v8::Local<v8::Value> hReturnValue;
470 v8::Local<v8::Value>* lpLocalArgs = NULL; 470 v8::Local<v8::Value>* lpLocalArgs = NULL;
471 if(nArgCount) { 471 if(nArgCount) {
472 lpLocalArgs = FX_Alloc(v8::Local<v8::Value>, nArgCount); 472 lpLocalArgs = FX_Alloc(v8::Local<v8::Value>, nArgCount);
473 if (!lpLocalArgs) { 473 if (!lpLocalArgs) {
474 return FALSE; 474 return FALSE;
475 } 475 }
476 for (FX_UINT32 i = 0; i < nArgCount; i++) { 476 for (uint32_t i = 0; i < nArgCount; i++) {
477 new (lpLocalArgs + i) v8::Local<v8::Value>; 477 new (lpLocalArgs + i) v8::Local<v8::Value>;
478 CFXJSE_Value* lpArg = (CFXJSE_Value*)lpArgs[i]; 478 CFXJSE_Value* lpArg = (CFXJSE_Value*)lpArgs[i];
479 if(lpArg) { 479 if(lpArg) {
480 lpLocalArgs[i] = v8::Local<v8::Value>::New(m_pIsolate, lpArg->Di rectGetValue()); 480 lpLocalArgs[i] = v8::Local<v8::Value>::New(m_pIsolate, lpArg->Di rectGetValue());
481 } 481 }
482 if (lpLocalArgs[i].IsEmpty()) { 482 if (lpLocalArgs[i].IsEmpty()) {
483 lpLocalArgs[i] = v8::Undefined(m_pIsolate); 483 lpLocalArgs[i] = v8::Undefined(m_pIsolate);
484 } 484 }
485 } 485 }
486 } 486 }
(...skipping 11 matching lines...) Expand all
498 hReturnValue = hFunctionObject->CallAsFunction(hReceiver, nArgCount, lpL ocalArgs); 498 hReturnValue = hFunctionObject->CallAsFunction(hReceiver, nArgCount, lpL ocalArgs);
499 } 499 }
500 if(trycatch.HasCaught()) { 500 if(trycatch.HasCaught()) {
501 hReturnValue = FXJSE_CreateReturnValue(m_pIsolate, trycatch); 501 hReturnValue = FXJSE_CreateReturnValue(m_pIsolate, trycatch);
502 bRetValue = FALSE; 502 bRetValue = FALSE;
503 } 503 }
504 if(lpRetValue) { 504 if(lpRetValue) {
505 lpRetValue->ForceSetValue(hReturnValue); 505 lpRetValue->ForceSetValue(hReturnValue);
506 } 506 }
507 if(lpLocalArgs) { 507 if(lpLocalArgs) {
508 for (FX_UINT32 i = 0; i < nArgCount; i++) { 508 for (uint32_t i = 0; i < nArgCount; i++) {
509 lpLocalArgs[i].~Local(); 509 lpLocalArgs[i].~Local();
510 } 510 }
511 FX_Free(lpLocalArgs); 511 FX_Free(lpLocalArgs);
512 } 512 }
513 return bRetValue; 513 return bRetValue;
514 } 514 }
OLDNEW
« no previous file with comments | « xfa/src/fxjse/src/value.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698