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

Side by Side Diff: fpdfsdk/javascript/util.cpp

Issue 1838543002: Add test for util.byteToChar() and fix error msg. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: static cast. Created 4 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 | « no previous file | testing/resources/javascript/util_bytetochar.in » ('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 "fpdfsdk/javascript/util.h" 7 #include "fpdfsdk/javascript/util.h"
8 8
9 #include <time.h> 9 #include <time.h>
10 10
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 vRet.SetNull(); 439 vRet.SetNull();
440 } 440 }
441 441
442 return TRUE; 442 return TRUE;
443 } 443 }
444 444
445 FX_BOOL util::byteToChar(IJS_Context* cc, 445 FX_BOOL util::byteToChar(IJS_Context* cc,
446 const std::vector<CJS_Value>& params, 446 const std::vector<CJS_Value>& params,
447 CJS_Value& vRet, 447 CJS_Value& vRet,
448 CFX_WideString& sError) { 448 CFX_WideString& sError) {
449 int iSize = params.size(); 449 CJS_Context* pContext = static_cast<CJS_Context*>(cc);
450 if (iSize == 0) 450 if (params.size() < 1) {
451 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
451 return FALSE; 452 return FALSE;
452 int nByte = params[0].ToInt(); 453 }
453 unsigned char cByte = (unsigned char)nByte; 454 int arg = params[0].ToInt();
454 CFX_WideString csValue; 455 if (arg < 0 || arg > 255) {
455 csValue.Format(L"%c", cByte); 456 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
456 vRet = csValue.c_str(); 457 return FALSE;
458 }
459 CFX_WideString wStr(static_cast<FX_WCHAR>(arg));
460 vRet = wStr.c_str();
457 return TRUE; 461 return TRUE;
458 } 462 }
OLDNEW
« no previous file with comments | « no previous file | testing/resources/javascript/util_bytetochar.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698