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/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 { | 130 { |
131 continue; | 131 continue; |
132 } | 132 } |
133 else break; | 133 else break; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 return -1; | 137 return -1; |
138 } | 138 } |
139 | 139 |
140 FX_BOOL util::printf(OBJ_METHOD_PARAMS) | 140 FX_BOOL util::printf(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) |
141 { | 141 { |
142 int iSize = params.size(); | 142 int iSize = params.size(); |
143 if (iSize < 1) | 143 if (iSize < 1) |
144 return FALSE; | 144 return FALSE; |
145 std::wstring c_ConvChar((const wchar_t*)(FX_LPCWSTR)params[0].operator
CFX_WideString()); | 145 std::wstring c_ConvChar((const wchar_t*)(FX_LPCWSTR)params[0].operator
CFX_WideString()); |
146 std::vector<std::wstring> c_strConvers; | 146 std::vector<std::wstring> c_strConvers; |
147 int iOffset = 0; | 147 int iOffset = 0; |
148 int iOffend = 0; | 148 int iOffend = 0; |
149 c_ConvChar.insert(c_ConvChar.begin(),L'S'); | 149 c_ConvChar.insert(c_ConvChar.begin(),L'S'); |
150 while(iOffset != -1) | 150 while(iOffset != -1) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 break; | 195 break; |
196 } | 196 } |
197 c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1); | 197 c_strResult += strSegment.GetBuffer(strSegment.GetLength()+1); |
198 } | 198 } |
199 | 199 |
200 c_strResult.erase(c_strResult.begin()); | 200 c_strResult.erase(c_strResult.begin()); |
201 vRet = c_strResult.c_str(); | 201 vRet = c_strResult.c_str(); |
202 return TRUE; | 202 return TRUE; |
203 } | 203 } |
204 | 204 |
205 FX_BOOL util::printd(OBJ_METHOD_PARAMS) | 205 FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) |
206 { | 206 { |
207 v8::Isolate* isolate = GetIsolate(cc); | 207 v8::Isolate* isolate = GetIsolate(cc); |
208 | 208 |
209 int iSize = params.size(); | 209 int iSize = params.size(); |
210 if (iSize < 2) | 210 if (iSize < 2) |
211 return FALSE; | 211 return FALSE; |
212 | 212 |
213 CJS_Value p1(isolate); | 213 CJS_Value p1(isolate); |
214 p1 = params[0]; | 214 p1 = params[0]; |
215 | 215 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 | 457 |
458 CFX_WideString strFormat; | 458 CFX_WideString strFormat; |
459 // strFormat.Format(L"%d,%d,%d,%d,%d,%d",iYear, iMonth, iDay, iHour
, iMin, iSec); | 459 // strFormat.Format(L"%d,%d,%d,%d,%d,%d",iYear, iMonth, iDay, iHour
, iMin, iSec); |
460 // CString strFormat = cppTm.Format(cFormat.c_str()); | 460 // CString strFormat = cppTm.Format(cFormat.c_str()); |
461 wchar_t buf[64] = {0}; | 461 wchar_t buf[64] = {0}; |
462 strFormat = wcsftime(buf, 64, cFormat.c_str(), &time); | 462 strFormat = wcsftime(buf, 64, cFormat.c_str(), &time); |
463 cFormat = buf; | 463 cFormat = buf; |
464 cPurpose = cFormat; | 464 cPurpose = cFormat; |
465 } | 465 } |
466 | 466 |
467 FX_BOOL util::printx(OBJ_METHOD_PARAMS) | 467 FX_BOOL util::printx(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) |
468 { | 468 { |
469 int iSize = params.size(); | 469 int iSize = params.size(); |
470 if (iSize<2) | 470 if (iSize<2) |
471 return FALSE; | 471 return FALSE; |
472 CFX_WideString sFormat = params[0].operator CFX_WideString(); | 472 CFX_WideString sFormat = params[0].operator CFX_WideString(); |
473 CFX_WideString sSource = params[1].operator CFX_WideString(); | 473 CFX_WideString sSource = params[1].operator CFX_WideString(); |
474 std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str(); | 474 std::string cFormat = CFX_ByteString::FromUnicode(sFormat).c_str(); |
475 std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str(); | 475 std::string cSource = CFX_ByteString::FromUnicode(sSource).c_str(); |
476 std::string cDest; | 476 std::string cDest; |
477 printx(cFormat,cSource,cDest); | 477 printx(cFormat,cSource,cDest); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 case '=': | 571 case '=': |
572 break; | 572 break; |
573 default: | 573 default: |
574 //cPurpose.push_back(letter); | 574 //cPurpose.push_back(letter); |
575 cPurpose += letter; | 575 cPurpose += letter; |
576 break; | 576 break; |
577 } | 577 } |
578 } | 578 } |
579 } | 579 } |
580 | 580 |
581 FX_BOOL util::scand(OBJ_METHOD_PARAMS) | 581 FX_BOOL util::scand(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
vRet, JS_ErrorString& sError) |
582 { | 582 { |
583 v8::Isolate* isolate = GetIsolate(cc); | 583 v8::Isolate* isolate = GetIsolate(cc); |
584 int iSize = params.size(); | 584 int iSize = params.size(); |
585 if (iSize < 2) | 585 if (iSize < 2) |
586 return FALSE; | 586 return FALSE; |
587 CFX_WideString sFormat = params[0].operator CFX_WideString(); | 587 CFX_WideString sFormat = params[0].operator CFX_WideString(); |
588 CFX_WideString sDate = params[1].operator CFX_WideString(); | 588 CFX_WideString sDate = params[1].operator CFX_WideString(); |
589 | 589 |
590 double dDate = JS_GetDateTime(); | 590 double dDate = JS_GetDateTime(); |
591 if (sDate.GetLength() > 0) | 591 if (sDate.GetLength() > 0) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 total = 10 * total + (c - '0'); /* accumulate digit */ | 628 total = 10 * total + (c - '0'); /* accumulate digit */ |
629 c = (int)(unsigned char)*nptr++; /* get next char */ | 629 c = (int)(unsigned char)*nptr++; /* get next char */ |
630 } | 630 } |
631 | 631 |
632 if (sign == '-') | 632 if (sign == '-') |
633 return -total; | 633 return -total; |
634 else | 634 else |
635 return total; /* return result, negated if necessary */ | 635 return total; /* return result, negated if necessary */ |
636 } | 636 } |
637 | 637 |
638 FX_BOOL util::byteToChar(OBJ_METHOD_PARAMS) | 638 FX_BOOL util::byteToChar(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Va
lue& vRet, JS_ErrorString& sError) |
639 { | 639 { |
640 int iSize = params.size(); | 640 int iSize = params.size(); |
641 if (iSize == 0) | 641 if (iSize == 0) |
642 return FALSE; | 642 return FALSE; |
643 int nByte = (int)params[0]; | 643 int nByte = (int)params[0]; |
644 unsigned char cByte = (unsigned char)nByte; | 644 unsigned char cByte = (unsigned char)nByte; |
645 CFX_WideString csValue; | 645 CFX_WideString csValue; |
646 csValue.Format(L"%c", cByte); | 646 csValue.Format(L"%c", cByte); |
647 vRet = csValue; | 647 vRet = csValue; |
648 return TRUE; | 648 return TRUE; |
649 } | 649 } |
OLD | NEW |