• 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 FXJS_FXJSE_H_
8 #define FXJS_FXJSE_H_
9 
10 #include "core/fxcrt/fx_string.h"
11 #include "core/fxcrt/fx_system.h"
12 #include "v8/include/v8.h"
13 
14 class CFXJSE_Arguments;
15 class CFXJSE_Value;
16 class CJS_Return;
17 
18 // C++ object which is retrieved from v8 object's slot.
19 class CFXJSE_HostObject {
20  public:
~CFXJSE_HostObject()21   virtual ~CFXJSE_HostObject() {}
22 
23   // Small layering violation here, but we need to distinguish between the
24   // two kinds of subclasses.
25   enum Type { kXFA, kFM2JS };
type()26   Type type() const { return type_; }
27 
28  protected:
CFXJSE_HostObject(Type type)29   explicit CFXJSE_HostObject(Type type) { type_ = type; }
30 
31   Type type_;
32 };
33 
34 typedef CJS_Return (*FXJSE_MethodCallback)(
35     const v8::FunctionCallbackInfo<v8::Value>& info,
36     const WideString& functionName);
37 typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis,
38                                    const ByteStringView& szFuncName,
39                                    CFXJSE_Arguments& args);
40 typedef void (*FXJSE_PropAccessor)(CFXJSE_Value* pObject,
41                                    const ByteStringView& szPropName,
42                                    CFXJSE_Value* pValue);
43 typedef int32_t (*FXJSE_PropTypeGetter)(CFXJSE_Value* pObject,
44                                         const ByteStringView& szPropName,
45                                         bool bQueryIn);
46 
47 enum FXJSE_ClassPropTypes {
48   FXJSE_ClassPropType_None,
49   FXJSE_ClassPropType_Property,
50   FXJSE_ClassPropType_Method
51 };
52 
53 struct FXJSE_FUNCTION_DESCRIPTOR {
54   const char* name;
55   FXJSE_FuncCallback callbackProc;
56 };
57 
58 struct FXJSE_CLASS_DESCRIPTOR {
59   const char* name;
60   const FXJSE_FUNCTION_DESCRIPTOR* methods;
61   int32_t methNum;
62   FXJSE_PropTypeGetter dynPropTypeGetter;
63   FXJSE_PropAccessor dynPropGetter;
64   FXJSE_PropAccessor dynPropSetter;
65   FXJSE_MethodCallback dynMethodCall;
66 };
67 
68 void FXJSE_ThrowMessage(const ByteStringView& utf8Message);
69 
70 #endif  // FXJS_FXJSE_H_
71