blob: 8f30faac307c7c51b8d7cd2536f5ff6061f5ac64 [file] [log] [blame]
Tom Sepez99ffdb02016-01-26 14:51:21 -08001// 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
Dan Sinclair3a8051c2016-03-15 15:42:31 -04007#ifndef XFA_FXJSE_INCLUDE_FXJSE_H_
8#define XFA_FXJSE_INCLUDE_FXJSE_H_
Tom Sepez99ffdb02016-01-26 14:51:21 -08009
Dan Sinclaira8a28e02016-03-23 15:41:39 -040010#include "core/fxcrt/include/fx_string.h"
11#include "core/fxcrt/include/fx_system.h"
dsinclairec3da5b2016-05-25 16:42:05 -070012#include "v8/include/v8.h"
Tom Sepez99ffdb02016-01-26 14:51:21 -080013
Dan Sinclair3a8051c2016-03-15 15:42:31 -040014class CFXJSE_Arguments;
dsinclair12a6b0c2016-05-26 11:14:08 -070015class CFXJSE_Value;
Tom Sepez99ffdb02016-01-26 14:51:21 -080016
tsepez2334e9e2016-06-09 09:32:44 -070017// C++ object which can be wrapped by CFXJSE_value.
18class CFXJSE_HostObject {
19 public:
20 virtual ~CFXJSE_HostObject() {}
21};
tsepez29adee72016-05-31 14:22:09 -070022
dsinclair12a6b0c2016-05-26 11:14:08 -070023typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis,
Tom Sepez99ffdb02016-01-26 14:51:21 -080024 const CFX_ByteStringC& szFuncName,
25 CFXJSE_Arguments& args);
dsinclair12a6b0c2016-05-26 11:14:08 -070026typedef void (*FXJSE_PropAccessor)(CFXJSE_Value* pObject,
Tom Sepez99ffdb02016-01-26 14:51:21 -080027 const CFX_ByteStringC& szPropName,
dsinclair12a6b0c2016-05-26 11:14:08 -070028 CFXJSE_Value* pValue);
29typedef int32_t (*FXJSE_PropTypeGetter)(CFXJSE_Value* pObject,
Tom Sepez99ffdb02016-01-26 14:51:21 -080030 const CFX_ByteStringC& szPropName,
31 FX_BOOL bQueryIn);
dsinclair12a6b0c2016-05-26 11:14:08 -070032typedef FX_BOOL (*FXJSE_PropDeleter)(CFXJSE_Value* pObject,
Tom Sepez99ffdb02016-01-26 14:51:21 -080033 const CFX_ByteStringC& szPropName);
Dan Sinclair3a8051c2016-03-15 15:42:31 -040034
Tom Sepez99ffdb02016-01-26 14:51:21 -080035enum FXJSE_ClassPropTypes {
36 FXJSE_ClassPropType_None,
37 FXJSE_ClassPropType_Property,
38 FXJSE_ClassPropType_Method
39};
Dan Sinclair3a8051c2016-03-15 15:42:31 -040040
tsepeze3b2a4e2016-05-26 12:39:34 -070041struct FXJSE_FUNCTION_DESCRIPTOR {
Dan Sinclair3a8051c2016-03-15 15:42:31 -040042 const FX_CHAR* name;
43 FXJSE_FuncCallback callbackProc;
44};
45
tsepeze3b2a4e2016-05-26 12:39:34 -070046struct FXJSE_PROPERTY_DESCRIPTOR {
Dan Sinclair3a8051c2016-03-15 15:42:31 -040047 const FX_CHAR* name;
48 FXJSE_PropAccessor getProc;
49 FXJSE_PropAccessor setProc;
50};
51
tsepeze3b2a4e2016-05-26 12:39:34 -070052struct FXJSE_CLASS_DESCRIPTOR {
Tom Sepez99ffdb02016-01-26 14:51:21 -080053 const FX_CHAR* name;
54 FXJSE_FuncCallback constructor;
tsepez1c9cfe12016-05-26 13:30:56 -070055 const FXJSE_PROPERTY_DESCRIPTOR* properties;
56 const FXJSE_FUNCTION_DESCRIPTOR* methods;
Tom Sepez99ffdb02016-01-26 14:51:21 -080057 int32_t propNum;
58 int32_t methNum;
59 FXJSE_PropTypeGetter dynPropTypeGetter;
60 FXJSE_PropAccessor dynPropGetter;
61 FXJSE_PropAccessor dynPropSetter;
62 FXJSE_PropDeleter dynPropDeleter;
63 FXJSE_FuncCallback dynMethodCall;
Tom Sepez2886a252016-02-23 12:09:25 -080064};
Dan Sinclair3a8051c2016-03-15 15:42:31 -040065
66void FXJSE_Initialize();
67void FXJSE_Finalize();
68
tsepezd5f72612016-06-01 14:01:31 -070069v8::Isolate* FXJSE_Runtime_Create_Own();
70void FXJSE_Runtime_Release(v8::Isolate* pIsolate);
Dan Sinclair3a8051c2016-03-15 15:42:31 -040071
dsinclair769b1372016-06-08 13:12:41 -070072void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Message);
Dan Sinclair3a8051c2016-03-15 15:42:31 -040073
Dan Sinclair3a8051c2016-03-15 15:42:31 -040074#endif // XFA_FXJSE_INCLUDE_FXJSE_H_