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

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

Issue 1395713002: Merge to XFA: Rename IFXJS_Runtime and IFXJS_Context to IJS_. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 2 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/util.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.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 "util.h" 7 #include "util.h"
8 8
9 #include "../../include/javascript/IJavaScript.h" 9 #include "../../include/javascript/IJavaScript.h"
10 #include "JS_Context.h" 10 #include "JS_Context.h"
11 #include "JS_Define.h" 11 #include "JS_Define.h"
12 #include "JS_EventHandler.h" 12 #include "JS_EventHandler.h"
13 #include "JS_Object.h" 13 #include "JS_Object.h"
14 #include "JS_Runtime.h" 14 #include "JS_Runtime.h"
15 #include "JS_Value.h" 15 #include "JS_Value.h"
16 #include "PublicMethods.h" 16 #include "PublicMethods.h"
17 #include "resource.h" 17 #include "resource.h"
18 18
19 #if _FX_OS_ == _FX_ANDROID_ 19 #if _FX_OS_ == _FX_ANDROID_
20 #include <ctype.h> 20 #include <ctype.h>
21 #endif 21 #endif
22 22
23 static v8::Isolate* GetIsolate(IFXJS_Context* cc) { 23 static v8::Isolate* GetIsolate(IJS_Context* cc) {
24 CJS_Context* pContext = (CJS_Context*)cc; 24 CJS_Context* pContext = (CJS_Context*)cc;
25 ASSERT(pContext != NULL); 25 ASSERT(pContext != NULL);
26 26
27 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); 27 CJS_Runtime* pRuntime = pContext->GetJSRuntime();
28 ASSERT(pRuntime != NULL); 28 ASSERT(pRuntime != NULL);
29 29
30 return pRuntime->GetIsolate(); 30 return pRuntime->GetIsolate();
31 } 31 }
32 32
33 BEGIN_JS_STATIC_CONST(CJS_Util) 33 BEGIN_JS_STATIC_CONST(CJS_Util)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 CJS_PublicMethods::IsDigit(c)) { 117 CJS_PublicMethods::IsDigit(c)) {
118 continue; 118 continue;
119 } 119 }
120 break; 120 break;
121 } 121 }
122 } 122 }
123 123
124 return -1; 124 return -1;
125 } 125 }
126 126
127 FX_BOOL util::printf(IFXJS_Context* cc, 127 FX_BOOL util::printf(IJS_Context* cc,
128 const CJS_Parameters& params, 128 const CJS_Parameters& params,
129 CJS_Value& vRet, 129 CJS_Value& vRet,
130 CFX_WideString& sError) { 130 CFX_WideString& sError) {
131 int iSize = params.size(); 131 int iSize = params.size();
132 if (iSize < 1) 132 if (iSize < 1)
133 return FALSE; 133 return FALSE;
134 std::wstring c_ConvChar(params[0].ToCFXWideString().c_str()); 134 std::wstring c_ConvChar(params[0].ToCFXWideString().c_str());
135 std::vector<std::wstring> c_strConvers; 135 std::vector<std::wstring> c_strConvers;
136 int iOffset = 0; 136 int iOffset = 0;
137 int iOffend = 0; 137 int iOffend = 0;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 break; 180 break;
181 } 181 }
182 c_strResult += strSegment.GetBuffer(strSegment.GetLength() + 1); 182 c_strResult += strSegment.GetBuffer(strSegment.GetLength() + 1);
183 } 183 }
184 184
185 c_strResult.erase(c_strResult.begin()); 185 c_strResult.erase(c_strResult.begin());
186 vRet = c_strResult.c_str(); 186 vRet = c_strResult.c_str();
187 return TRUE; 187 return TRUE;
188 } 188 }
189 189
190 FX_BOOL util::printd(IFXJS_Context* cc, 190 FX_BOOL util::printd(IJS_Context* cc,
191 const CJS_Parameters& params, 191 const CJS_Parameters& params,
192 CJS_Value& vRet, 192 CJS_Value& vRet,
193 CFX_WideString& sError) { 193 CFX_WideString& sError) {
194 v8::Isolate* isolate = GetIsolate(cc); 194 v8::Isolate* isolate = GetIsolate(cc);
195 195
196 int iSize = params.size(); 196 int iSize = params.size();
197 if (iSize < 2) 197 if (iSize < 2)
198 return FALSE; 198 return FALSE;
199 199
200 CJS_Value p1(isolate); 200 CJS_Value p1(isolate);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 } 394 }
395 395
396 CFX_WideString strFormat; 396 CFX_WideString strFormat;
397 wchar_t buf[64] = {}; 397 wchar_t buf[64] = {};
398 strFormat = wcsftime(buf, 64, cFormat.c_str(), &time); 398 strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
399 cFormat = buf; 399 cFormat = buf;
400 cPurpose = cFormat; 400 cPurpose = cFormat;
401 } 401 }
402 402
403 FX_BOOL util::printx(IFXJS_Context* cc, 403 FX_BOOL util::printx(IJS_Context* cc,
404 const CJS_Parameters& params, 404 const CJS_Parameters& params,
405 CJS_Value& vRet, 405 CJS_Value& vRet,
406 CFX_WideString& sError) { 406 CFX_WideString& sError) {
407 int iSize = params.size(); 407 int iSize = params.size();
408 if (iSize < 2) 408 if (iSize < 2)
409 return FALSE; 409 return FALSE;
410 CFX_WideString sFormat = params[0].ToCFXWideString(); 410 CFX_WideString sFormat = params[0].ToCFXWideString();
411 CFX_WideString sSource = params[1].ToCFXWideString(); 411 CFX_WideString sSource = params[1].ToCFXWideString();
412 std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str(); 412 std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str();
413 std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str(); 413 std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 493 }
494 case '=': 494 case '=':
495 break; 495 break;
496 default: 496 default:
497 cPurpose += letter; 497 cPurpose += letter;
498 break; 498 break;
499 } 499 }
500 } 500 }
501 } 501 }
502 502
503 FX_BOOL util::scand(IFXJS_Context* cc, 503 FX_BOOL util::scand(IJS_Context* cc,
504 const CJS_Parameters& params, 504 const CJS_Parameters& params,
505 CJS_Value& vRet, 505 CJS_Value& vRet,
506 CFX_WideString& sError) { 506 CFX_WideString& sError) {
507 v8::Isolate* isolate = GetIsolate(cc); 507 v8::Isolate* isolate = GetIsolate(cc);
508 int iSize = params.size(); 508 int iSize = params.size();
509 if (iSize < 2) 509 if (iSize < 2)
510 return FALSE; 510 return FALSE;
511 511
512 CFX_WideString sFormat = params[0].ToCFXWideString(); 512 CFX_WideString sFormat = params[0].ToCFXWideString();
513 CFX_WideString sDate = params[1].ToCFXWideString(); 513 CFX_WideString sDate = params[1].ToCFXWideString();
(...skipping 30 matching lines...) Expand all
544 total = 0; 544 total = 0;
545 545
546 while (isdigit(c)) { 546 while (isdigit(c)) {
547 total = 10 * total + (c - '0'); /* accumulate digit */ 547 total = 10 * total + (c - '0'); /* accumulate digit */
548 c = (int)(unsigned char)*nptr++; /* get next char */ 548 c = (int)(unsigned char)*nptr++; /* get next char */
549 } 549 }
550 550
551 return sign == '-' ? -total : total; 551 return sign == '-' ? -total : total;
552 } 552 }
553 553
554 FX_BOOL util::byteToChar(IFXJS_Context* cc, 554 FX_BOOL util::byteToChar(IJS_Context* cc,
555 const CJS_Parameters& params, 555 const CJS_Parameters& params,
556 CJS_Value& vRet, 556 CJS_Value& vRet,
557 CFX_WideString& sError) { 557 CFX_WideString& sError) {
558 int iSize = params.size(); 558 int iSize = params.size();
559 if (iSize == 0) 559 if (iSize == 0)
560 return FALSE; 560 return FALSE;
561 int nByte = params[0].ToInt(); 561 int nByte = params[0].ToInt();
562 unsigned char cByte = (unsigned char)nByte; 562 unsigned char cByte = (unsigned char)nByte;
563 CFX_WideString csValue; 563 CFX_WideString csValue;
564 csValue.Format(L"%c", cByte); 564 csValue.Format(L"%c", cByte);
565 vRet = csValue.c_str(); 565 vRet = csValue.c_str();
566 return TRUE; 566 return TRUE;
567 } 567 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/util.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698