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 "../../include/javascript/IJavaScript.h" | 7 #include "../../include/javascript/IJavaScript.h" |
8 #include "../../include/javascript/JS_Context.h" | 8 #include "../../include/javascript/JS_Context.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_EventHandler.h" | 10 #include "../../include/javascript/JS_EventHandler.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 case VT_number: | 167 case VT_number: |
168 { | 168 { |
169 double dData; | 169 double dData; |
170 vp >> dData; | 170 vp >> dData; |
171 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_NUMBER, dData, false, "", v8::Handle<v8::Object>(), FALSE); | 171 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_NUMBER, dData, false, "", v8::Handle<v8::Object>(), FALSE); |
172 } | 172 } |
173 case VT_boolean: | 173 case VT_boolean: |
174 { | 174 { |
175 bool bData; | 175 bool bData; |
176 vp >> bData; | 176 vp >> bData; |
177 » » » » return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_BOOLEAN, 0, (bool)vp, "", v8::Handle<v8::Object>(), FALSE); | 177 » » » » return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_BOOLEAN, 0, bData, "", v8::Handle<v8::Object>(), FALSE); |
178 } | 178 } |
179 case VT_string: | 179 case VT_string: |
180 { | 180 { |
181 CFX_ByteString sData; | 181 CFX_ByteString sData; |
182 vp >> sData; | 182 vp >> sData; |
183 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_STRING, 0, false, sData, v8::Handle<v8::Object>(), FALSE); | 183 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_STRING, 0, false, sData, v8::Handle<v8::Object>(), FALSE); |
184 } | 184 } |
185 case VT_object: | 185 case VT_object: |
186 { | 186 { |
187 » » » » JSObject pData = (JSObject)vp; | 187 » » » » JSObject pData; |
| 188 » » » » vp >> pData; |
188 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_OBJECT, 0, false, "", pData, FALSE); | 189 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_OBJECT, 0, false, "", pData, FALSE); |
189 // else | |
190 // { | |
191 // if (vp.IsArrayObject()) | |
192 // { | |
193 // CJS_Array array; | |
194 // vp.ConvertToArray(array); | |
195 // return SetGlobalVariables(sPropN
ame, JS_GLOBALDATA_TYPE_OBJECT, 0, false, "", | |
196 // (Dobject*)(Darray*)array
, FALSE); | |
197 // } | |
198 // else | |
199 // return FALSE; | |
200 // } | |
201 } | 190 } |
202 case VT_null: | 191 case VT_null: |
203 { | 192 { |
204 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_NULL, 0, false, "", v8::Handle<v8::Object>(), FALSE); | 193 return SetGlobalVariables(sPropName, JS_GLOBALDA
TA_TYPE_NULL, 0, false, "", v8::Handle<v8::Object>(), FALSE); |
205 } | 194 } |
206 case VT_undefined: | 195 case VT_undefined: |
207 { | 196 { |
208 DelProperty(cc, propname, sError); | 197 DelProperty(cc, propname, sError); |
209 return TRUE; | 198 return TRUE; |
210 } | 199 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 260 |
272 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, CFX_WideString& sError) | 261 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, CFX_WideString& sError) |
273 { | 262 { |
274 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 263 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
275 if (params.size() != 2) | 264 if (params.size() != 2) |
276 { | 265 { |
277 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); | 266 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
278 return FALSE; | 267 return FALSE; |
279 } | 268 } |
280 | 269 |
281 » CFX_ByteString sName = params[0]; | 270 » CFX_ByteString sName = params[0].ToCFXByteString(); |
282 | 271 |
283 js_global_data* pData = NULL; | 272 js_global_data* pData = NULL; |
284 if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) | 273 if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) |
285 { | 274 { |
286 if (pData && !pData->bDeleted) | 275 if (pData && !pData->bDeleted) |
287 { | 276 { |
288 » » » pData->bPersistent = (bool)params[1]; | 277 » » » pData->bPersistent = params[1].ToBool(); |
289 return TRUE; | 278 return TRUE; |
290 } | 279 } |
291 } | 280 } |
292 | 281 |
293 sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL); | 282 sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL); |
294 return FALSE; | 283 return FALSE; |
295 } | 284 } |
296 | 285 |
297 void global_alternate::UpdateGlobalPersistentVariables() | 286 void global_alternate::UpdateGlobalPersistentVariables() |
298 { | 287 { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 { | 416 { |
428 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 417 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
429 pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN; | 418 pObjElement->nType = JS_GLOBALDATA_TYPE_BOOLEAN; |
430 pObjElement->sKey = sKey; | 419 pObjElement->sKey = sKey; |
431 pObjElement->dData = JS_ToBoolean(v); | 420 pObjElement->dData = JS_ToBoolean(v); |
432 array.Add(pObjElement); | 421 array.Add(pObjElement); |
433 } | 422 } |
434 break; | 423 break; |
435 case VT_string: | 424 case VT_string: |
436 { | 425 { |
437 » » » » CFX_ByteString sValue = CJS_Value(isolate, v, VT
_string); | 426 » » » » CFX_ByteString sValue = CJS_Value(isolate, v, VT
_string).ToCFXByteString(); |
438 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 427 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
439 pObjElement->nType = JS_GLOBALDATA_TYPE_STRING; | 428 pObjElement->nType = JS_GLOBALDATA_TYPE_STRING; |
440 pObjElement->sKey = sKey; | 429 pObjElement->sKey = sKey; |
441 pObjElement->sData = sValue; | 430 pObjElement->sData = sValue; |
442 array.Add(pObjElement); | 431 array.Add(pObjElement); |
443 } | 432 } |
444 break; | 433 break; |
445 case VT_object: | 434 case VT_object: |
446 { | 435 { |
447 CJS_KeyValue* pObjElement = new CJS_KeyValue; | 436 CJS_KeyValue* pObjElement = new CJS_KeyValue; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 if (nHash == JSCONST_nDateHash) | 624 if (nHash == JSCONST_nDateHash) |
636 return VT_date; | 625 return VT_date; |
637 if (nHash == JSCONST_nObjectHash) | 626 if (nHash == JSCONST_nObjectHash) |
638 return VT_object; | 627 return VT_object; |
639 if (nHash == JSCONST_nFXobjHash) | 628 if (nHash == JSCONST_nFXobjHash) |
640 return VT_fxobject; | 629 return VT_fxobject; |
641 | 630 |
642 return VT_unknown; | 631 return VT_unknown; |
643 } | 632 } |
644 | 633 |
OLD | NEW |