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

Side by Side Diff: fpdfsdk/src/javascript/global.cpp

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

Powered by Google App Engine
This is Rietveld 408576698