• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_JAVASCRIPT_UTIL_H_
8 #define FPDFSDK_JAVASCRIPT_UTIL_H_
9 
10 #include <string>
11 #include <vector>
12 
13 #include "fpdfsdk/javascript/JS_Define.h"
14 
15 class util : public CJS_EmbedObj {
16  public:
17   explicit util(CJS_Object* pJSObject);
18   ~util() override;
19 
20   bool printd(CJS_Runtime* pRuntime,
21               const std::vector<CJS_Value>& params,
22               CJS_Value& vRet,
23               CFX_WideString& sError);
24   bool printf(CJS_Runtime* pRuntime,
25               const std::vector<CJS_Value>& params,
26               CJS_Value& vRet,
27               CFX_WideString& sError);
28   bool printx(CJS_Runtime* pRuntime,
29               const std::vector<CJS_Value>& params,
30               CJS_Value& vRet,
31               CFX_WideString& sError);
32   bool scand(CJS_Runtime* pRuntime,
33              const std::vector<CJS_Value>& params,
34              CJS_Value& vRet,
35              CFX_WideString& sError);
36   bool byteToChar(CJS_Runtime* pRuntime,
37                   const std::vector<CJS_Value>& params,
38                   CJS_Value& vRet,
39                   CFX_WideString& sError);
40 
41   static CFX_WideString printx(const CFX_WideString& cFormat,
42                                const CFX_WideString& cSource);
43 };
44 
45 class CJS_Util : public CJS_Object {
46  public:
CJS_Util(v8::Local<v8::Object> pObject)47   explicit CJS_Util(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Util()48   ~CJS_Util() override {}
49 
50   DECLARE_JS_CLASS();
51 
52   JS_STATIC_METHOD(printd, util);
53   JS_STATIC_METHOD(printf, util);
54   JS_STATIC_METHOD(printx, util);
55   JS_STATIC_METHOD(scand, util);
56   JS_STATIC_METHOD(byteToChar, util);
57 };
58 
59 #endif  // FPDFSDK_JAVASCRIPT_UTIL_H_
60