Home | History | Annotate | Download | only in javascript
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef FPDFSDK_SRC_JAVASCRIPT_UTIL_H_
      8 #define FPDFSDK_SRC_JAVASCRIPT_UTIL_H_
      9 
     10 #include <string>  // For std::wstring.
     11 
     12 #include "JS_Define.h"
     13 
     14 class util : public CJS_EmbedObj {
     15  public:
     16   util(CJS_Object* pJSObject);
     17   ~util() override;
     18 
     19  public:
     20   FX_BOOL printd(IJS_Context* cc,
     21                  const std::vector<CJS_Value>& params,
     22                  CJS_Value& vRet,
     23                  CFX_WideString& sError);
     24   FX_BOOL printf(IJS_Context* cc,
     25                  const std::vector<CJS_Value>& params,
     26                  CJS_Value& vRet,
     27                  CFX_WideString& sError);
     28   FX_BOOL printx(IJS_Context* cc,
     29                  const std::vector<CJS_Value>& params,
     30                  CJS_Value& vRet,
     31                  CFX_WideString& sError);
     32   FX_BOOL scand(IJS_Context* cc,
     33                 const std::vector<CJS_Value>& params,
     34                 CJS_Value& vRet,
     35                 CFX_WideString& sError);
     36   FX_BOOL byteToChar(IJS_Context* cc,
     37                      const std::vector<CJS_Value>& params,
     38                      CJS_Value& vRet,
     39                      CFX_WideString& sError);
     40 
     41  public:
     42   static void printd(const std::wstring& cFormat,
     43                      CJS_Date Date,
     44                      bool bXFAPicture,
     45                      std::wstring& cPurpose);
     46   static void printx(const std::string& cFormat,
     47                      const std::string& cSource,
     48                      std::string& cPurpose);
     49   static int ParstDataType(std::wstring* sFormat);
     50 };
     51 
     52 class CJS_Util : public CJS_Object {
     53  public:
     54   CJS_Util(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
     55   ~CJS_Util() override {}
     56 
     57   DECLARE_JS_CLASS();
     58 
     59   JS_STATIC_METHOD(printd, util);
     60   JS_STATIC_METHOD(printf, util);
     61   JS_STATIC_METHOD(printx, util);
     62   JS_STATIC_METHOD(scand, util);
     63   JS_STATIC_METHOD(byteToChar, util);
     64 };
     65 
     66 int64_t FX_atoi64(const char* nptr);
     67 
     68 #endif  // FPDFSDK_SRC_JAVASCRIPT_UTIL_H_
     69