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_XFA_FXJSE_H_ 8 #define FXJS_XFA_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 namespace pdfium { 15 namespace fxjse { 16 17 extern const char kFuncTag[]; 18 extern const char kClassTag[]; 19 20 } // namespace fxjse 21 } // namespace pdfium 22 23 class CFXJSE_Arguments; 24 class CFXJSE_FormCalcContext; 25 class CFXJSE_Value; 26 class CJS_Result; 27 class CXFA_Object; 28 29 // C++ object which is retrieved from v8 object's slot. 30 class CFXJSE_HostObject { 31 public: 32 virtual ~CFXJSE_HostObject(); 33 34 // Two subclasses. 35 virtual CFXJSE_FormCalcContext* AsFormCalcContext(); 36 virtual CXFA_Object* AsCXFAObject(); 37 38 protected: 39 CFXJSE_HostObject(); 40 }; 41 42 typedef CJS_Result (*FXJSE_MethodCallback)( 43 const v8::FunctionCallbackInfo<v8::Value>& info, 44 const WideString& functionName); 45 typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis, 46 ByteStringView szFuncName, 47 CFXJSE_Arguments& args); 48 typedef void (*FXJSE_PropAccessor)(CFXJSE_Value* pObject, 49 ByteStringView szPropName, 50 CFXJSE_Value* pValue); 51 typedef int32_t (*FXJSE_PropTypeGetter)(CFXJSE_Value* pObject, 52 ByteStringView szPropName, 53 bool bQueryIn); 54 55 enum FXJSE_ClassPropTypes { 56 FXJSE_ClassPropType_None, 57 FXJSE_ClassPropType_Property, 58 FXJSE_ClassPropType_Method 59 }; 60 61 struct FXJSE_FUNCTION_DESCRIPTOR { 62 const char* tag; // pdfium::kFuncTag always. 63 const char* name; 64 FXJSE_FuncCallback callbackProc; 65 }; 66 67 struct FXJSE_CLASS_DESCRIPTOR { 68 const char* tag; // pdfium::kClassTag always. 69 const char* name; 70 const FXJSE_FUNCTION_DESCRIPTOR* methods; 71 int32_t methNum; 72 FXJSE_PropTypeGetter dynPropTypeGetter; 73 FXJSE_PropAccessor dynPropGetter; 74 FXJSE_PropAccessor dynPropSetter; 75 FXJSE_MethodCallback dynMethodCall; 76 }; 77 78 extern const FXJSE_CLASS_DESCRIPTOR GlobalClassDescriptor; 79 extern const FXJSE_CLASS_DESCRIPTOR NormalClassDescriptor; 80 extern const FXJSE_CLASS_DESCRIPTOR VariablesClassDescriptor; 81 extern const FXJSE_CLASS_DESCRIPTOR kFormCalcFM2JSDescriptor; 82 83 void FXJSE_ThrowMessage(ByteStringView utf8Message); 84 85 #endif // FXJS_XFA_FXJSE_H_ 86