Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 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 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 7 | #ifndef FXJS_FXJSE_H_ |
| 8 | #define FXJS_FXJSE_H_ |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 9 | |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 10 | #include "core/fxcrt/fx_string.h" |
| 11 | #include "core/fxcrt/fx_system.h" |
dsinclair | ec3da5b | 2016-05-25 16:42:05 -0700 | [diff] [blame] | 12 | #include "v8/include/v8.h" |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 13 | |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 14 | class CFXJSE_Arguments; |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 15 | class CFXJSE_Value; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 16 | |
tsepez | 2334e9e | 2016-06-09 09:32:44 -0700 | [diff] [blame] | 17 | // C++ object which can be wrapped by CFXJSE_value. |
| 18 | class CFXJSE_HostObject { |
| 19 | public: |
| 20 | virtual ~CFXJSE_HostObject() {} |
| 21 | }; |
tsepez | 29adee7 | 2016-05-31 14:22:09 -0700 | [diff] [blame] | 22 | |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 23 | typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis, |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 24 | const CFX_ByteStringC& szFuncName, |
| 25 | CFXJSE_Arguments& args); |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 26 | typedef void (*FXJSE_PropAccessor)(CFXJSE_Value* pObject, |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 27 | const CFX_ByteStringC& szPropName, |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 28 | CFXJSE_Value* pValue); |
| 29 | typedef int32_t (*FXJSE_PropTypeGetter)(CFXJSE_Value* pObject, |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 30 | const CFX_ByteStringC& szPropName, |
tsepez | 304bb91 | 2016-11-03 06:10:26 -0700 | [diff] [blame] | 31 | bool bQueryIn); |
| 32 | typedef bool (*FXJSE_PropDeleter)(CFXJSE_Value* pObject, |
| 33 | const CFX_ByteStringC& szPropName); |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 34 | |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 35 | enum FXJSE_ClassPropTypes { |
| 36 | FXJSE_ClassPropType_None, |
| 37 | FXJSE_ClassPropType_Property, |
| 38 | FXJSE_ClassPropType_Method |
| 39 | }; |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 40 | |
tsepez | e3b2a4e | 2016-05-26 12:39:34 -0700 | [diff] [blame] | 41 | struct FXJSE_FUNCTION_DESCRIPTOR { |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 42 | const FX_CHAR* name; |
| 43 | FXJSE_FuncCallback callbackProc; |
| 44 | }; |
| 45 | |
tsepez | e3b2a4e | 2016-05-26 12:39:34 -0700 | [diff] [blame] | 46 | struct FXJSE_PROPERTY_DESCRIPTOR { |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 47 | const FX_CHAR* name; |
| 48 | FXJSE_PropAccessor getProc; |
| 49 | FXJSE_PropAccessor setProc; |
| 50 | }; |
| 51 | |
tsepez | e3b2a4e | 2016-05-26 12:39:34 -0700 | [diff] [blame] | 52 | struct FXJSE_CLASS_DESCRIPTOR { |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 53 | const FX_CHAR* name; |
| 54 | FXJSE_FuncCallback constructor; |
tsepez | 1c9cfe1 | 2016-05-26 13:30:56 -0700 | [diff] [blame] | 55 | const FXJSE_PROPERTY_DESCRIPTOR* properties; |
| 56 | const FXJSE_FUNCTION_DESCRIPTOR* methods; |
Tom Sepez | 99ffdb0 | 2016-01-26 14:51:21 -0800 | [diff] [blame] | 57 | 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 Sepez | 2886a25 | 2016-02-23 12:09:25 -0800 | [diff] [blame] | 64 | }; |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 65 | |
| 66 | void FXJSE_Initialize(); |
| 67 | void FXJSE_Finalize(); |
| 68 | |
tsepez | d5f7261 | 2016-06-01 14:01:31 -0700 | [diff] [blame] | 69 | v8::Isolate* FXJSE_Runtime_Create_Own(); |
| 70 | void FXJSE_Runtime_Release(v8::Isolate* pIsolate); |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 71 | |
dsinclair | 769b137 | 2016-06-08 13:12:41 -0700 | [diff] [blame] | 72 | void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Message); |
Dan Sinclair | 3a8051c | 2016-03-15 15:42:31 -0400 | [diff] [blame] | 73 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 74 | #endif // FXJS_FXJSE_H_ |