OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FXJSE_INCLUDE_FXJSE_H_ | 7 #ifndef XFA_FXJSE_INCLUDE_FXJSE_H_ |
8 #define XFA_FXJSE_INCLUDE_FXJSE_H_ | 8 #define XFA_FXJSE_INCLUDE_FXJSE_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_string.h" | 10 #include "core/fxcrt/include/fx_string.h" |
11 #include "core/fxcrt/include/fx_system.h" | 11 #include "core/fxcrt/include/fx_system.h" |
12 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
13 | 13 |
14 class CFXJSE_Arguments; | 14 class CFXJSE_Arguments; |
15 class CFXJSE_Class; | 15 class CFXJSE_Class; |
16 class CFXJSE_Context; | 16 class CFXJSE_Context; |
| 17 class CFXJSE_Value; |
17 | 18 |
18 typedef struct FXJSE_HVALUE_ { void* pData; } * FXJSE_HVALUE; | 19 typedef void (*FXJSE_FuncCallback)(CFXJSE_Value* pThis, |
19 // NOLINTNEXTLINE | |
20 typedef struct FXJSE_HOBJECT_ : public FXJSE_HVALUE_{} * FXJSE_HOBJECT; | |
21 | |
22 typedef void (*FXJSE_FuncCallback)(FXJSE_HOBJECT hThis, | |
23 const CFX_ByteStringC& szFuncName, | 20 const CFX_ByteStringC& szFuncName, |
24 CFXJSE_Arguments& args); | 21 CFXJSE_Arguments& args); |
25 typedef void (*FXJSE_PropAccessor)(FXJSE_HOBJECT hObject, | 22 typedef void (*FXJSE_PropAccessor)(CFXJSE_Value* pObject, |
26 const CFX_ByteStringC& szPropName, | 23 const CFX_ByteStringC& szPropName, |
27 FXJSE_HVALUE hValue); | 24 CFXJSE_Value* pValue); |
28 typedef int32_t (*FXJSE_PropTypeGetter)(FXJSE_HOBJECT hObject, | 25 typedef int32_t (*FXJSE_PropTypeGetter)(CFXJSE_Value* pObject, |
29 const CFX_ByteStringC& szPropName, | 26 const CFX_ByteStringC& szPropName, |
30 FX_BOOL bQueryIn); | 27 FX_BOOL bQueryIn); |
31 typedef FX_BOOL (*FXJSE_PropDeleter)(FXJSE_HOBJECT hObject, | 28 typedef FX_BOOL (*FXJSE_PropDeleter)(CFXJSE_Value* pObject, |
32 const CFX_ByteStringC& szPropName); | 29 const CFX_ByteStringC& szPropName); |
33 | 30 |
34 enum FXJSE_ClassPropTypes { | 31 enum FXJSE_ClassPropTypes { |
35 FXJSE_ClassPropType_None, | 32 FXJSE_ClassPropType_None, |
36 FXJSE_ClassPropType_Property, | 33 FXJSE_ClassPropType_Property, |
37 FXJSE_ClassPropType_Method | 34 FXJSE_ClassPropType_Method |
38 }; | 35 }; |
39 | 36 |
40 enum FXJSE_CompatibleModeFlags { | 37 enum FXJSE_CompatibleModeFlags { |
41 FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS = (1 << 0), | 38 FXJSE_COMPATIBLEMODEFLAG_CONSTRUCTOREXTRAMETHODS = (1 << 0), |
(...skipping 28 matching lines...) Expand all Loading... |
70 void FXJSE_Initialize(); | 67 void FXJSE_Initialize(); |
71 void FXJSE_Finalize(); | 68 void FXJSE_Finalize(); |
72 | 69 |
73 v8::Isolate* FXJSE_Runtime_Create(); | 70 v8::Isolate* FXJSE_Runtime_Create(); |
74 void FXJSE_Runtime_Release(v8::Isolate* pIsolate, bool bOwnedRuntime); | 71 void FXJSE_Runtime_Release(v8::Isolate* pIsolate, bool bOwnedRuntime); |
75 | 72 |
76 CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate, | 73 CFXJSE_Context* FXJSE_Context_Create(v8::Isolate* pIsolate, |
77 const FXJSE_CLASS* lpGlobalClass = nullptr, | 74 const FXJSE_CLASS* lpGlobalClass = nullptr, |
78 void* lpGlobalObject = nullptr); | 75 void* lpGlobalObject = nullptr); |
79 void FXJSE_Context_Release(CFXJSE_Context* pContext); | 76 void FXJSE_Context_Release(CFXJSE_Context* pContext); |
80 FXJSE_HVALUE FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext); | 77 CFXJSE_Value* FXJSE_Context_GetGlobalObject(CFXJSE_Context* pContext); |
81 | 78 |
82 void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext, | 79 void FXJSE_Context_EnableCompatibleMode(CFXJSE_Context* pContext, |
83 uint32_t dwCompatibleFlags); | 80 uint32_t dwCompatibleFlags); |
84 | 81 |
85 CFXJSE_Class* FXJSE_DefineClass(CFXJSE_Context* pContext, | 82 CFXJSE_Class* FXJSE_DefineClass(CFXJSE_Context* pContext, |
86 const FXJSE_CLASS* lpClass); | 83 const FXJSE_CLASS* lpClass); |
87 | 84 |
88 FXJSE_HVALUE FXJSE_Value_Create(v8::Isolate* pIsolate); | 85 CFXJSE_Value* FXJSE_Value_Create(v8::Isolate* pIsolate); |
89 void FXJSE_Value_Release(FXJSE_HVALUE hValue); | 86 void FXJSE_Value_Release(CFXJSE_Value* pValue); |
90 | 87 |
91 FX_BOOL FXJSE_Value_IsUndefined(FXJSE_HVALUE hValue); | 88 FX_BOOL FXJSE_Value_IsUndefined(CFXJSE_Value* pValue); |
92 FX_BOOL FXJSE_Value_IsNull(FXJSE_HVALUE hValue); | 89 FX_BOOL FXJSE_Value_IsNull(CFXJSE_Value* pValue); |
93 FX_BOOL FXJSE_Value_IsBoolean(FXJSE_HVALUE hValue); | 90 FX_BOOL FXJSE_Value_IsBoolean(CFXJSE_Value* pValue); |
94 FX_BOOL FXJSE_Value_IsUTF8String(FXJSE_HVALUE hValue); | 91 FX_BOOL FXJSE_Value_IsUTF8String(CFXJSE_Value* pValue); |
95 FX_BOOL FXJSE_Value_IsNumber(FXJSE_HVALUE hValue); | 92 FX_BOOL FXJSE_Value_IsNumber(CFXJSE_Value* pValue); |
96 FX_BOOL FXJSE_Value_IsObject(FXJSE_HVALUE hValue); | 93 FX_BOOL FXJSE_Value_IsObject(CFXJSE_Value* pValue); |
97 FX_BOOL FXJSE_Value_IsArray(FXJSE_HVALUE hValue); | 94 FX_BOOL FXJSE_Value_IsArray(CFXJSE_Value* pValue); |
98 FX_BOOL FXJSE_Value_IsFunction(FXJSE_HVALUE hValue); | 95 FX_BOOL FXJSE_Value_IsFunction(CFXJSE_Value* pValue); |
99 | 96 |
100 FX_BOOL FXJSE_Value_ToBoolean(FXJSE_HVALUE hValue); | 97 FX_BOOL FXJSE_Value_ToBoolean(CFXJSE_Value* pValue); |
101 FX_FLOAT FXJSE_Value_ToFloat(FXJSE_HVALUE hValue); | 98 FX_FLOAT FXJSE_Value_ToFloat(CFXJSE_Value* pValue); |
102 double FXJSE_Value_ToDouble(FXJSE_HVALUE hValue); | 99 double FXJSE_Value_ToDouble(CFXJSE_Value* pValue); |
103 int32_t FXJSE_Value_ToInteger(FXJSE_HVALUE hValue); | 100 int32_t FXJSE_Value_ToInteger(CFXJSE_Value* pValue); |
104 void FXJSE_Value_ToUTF8String(FXJSE_HVALUE hValue, CFX_ByteString& szStrOutput); | 101 void FXJSE_Value_ToUTF8String(CFXJSE_Value* pValue, |
105 void* FXJSE_Value_ToObject(FXJSE_HVALUE hValue, CFXJSE_Class* hClass); | 102 CFX_ByteString& szStrOutput); |
| 103 void* FXJSE_Value_ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); |
106 | 104 |
107 void FXJSE_Value_SetUndefined(FXJSE_HVALUE hValue); | 105 void FXJSE_Value_SetUndefined(CFXJSE_Value* pValue); |
108 void FXJSE_Value_SetNull(FXJSE_HVALUE hValue); | 106 void FXJSE_Value_SetNull(CFXJSE_Value* pValue); |
109 void FXJSE_Value_SetBoolean(FXJSE_HVALUE hValue, FX_BOOL bBoolean); | 107 void FXJSE_Value_SetBoolean(CFXJSE_Value* pValue, FX_BOOL bBoolean); |
110 void FXJSE_Value_SetUTF8String(FXJSE_HVALUE hValue, | 108 void FXJSE_Value_SetUTF8String(CFXJSE_Value* pValue, |
111 const CFX_ByteStringC& szString); | 109 const CFX_ByteStringC& szString); |
112 void FXJSE_Value_SetInteger(FXJSE_HVALUE hValue, int32_t nInteger); | 110 void FXJSE_Value_SetInteger(CFXJSE_Value* pValue, int32_t nInteger); |
113 void FXJSE_Value_SetFloat(FXJSE_HVALUE hValue, FX_FLOAT fFloat); | 111 void FXJSE_Value_SetFloat(CFXJSE_Value* pValue, FX_FLOAT fFloat); |
114 void FXJSE_Value_SetDouble(FXJSE_HVALUE hValue, double dDouble); | 112 void FXJSE_Value_SetDouble(CFXJSE_Value* pValue, double dDouble); |
115 void FXJSE_Value_SetObject(FXJSE_HVALUE hValue, | 113 void FXJSE_Value_SetObject(CFXJSE_Value* pValue, |
116 void* lpObject, | 114 void* lpObject, |
117 CFXJSE_Class* pClass); | 115 CFXJSE_Class* pClass); |
118 void FXJSE_Value_SetArray(FXJSE_HVALUE hValue, | 116 void FXJSE_Value_SetArray(CFXJSE_Value* pValue, |
119 uint32_t uValueCount, | 117 uint32_t uValueCount, |
120 FXJSE_HVALUE* rgValues); | 118 CFXJSE_Value** rgValues); |
121 void FXJSE_Value_Set(FXJSE_HVALUE hValue, FXJSE_HVALUE hOriginalValue); | 119 void FXJSE_Value_Set(CFXJSE_Value* pValue, CFXJSE_Value* pOriginalValue); |
122 | 120 |
123 FX_BOOL FXJSE_Value_GetObjectProp(FXJSE_HVALUE hValue, | 121 FX_BOOL FXJSE_Value_GetObjectProp(CFXJSE_Value* pValue, |
124 const CFX_ByteStringC& szPropName, | 122 const CFX_ByteStringC& szPropName, |
125 FXJSE_HVALUE hPropValue); | 123 CFXJSE_Value* pPropValue); |
126 FX_BOOL FXJSE_Value_SetObjectProp(FXJSE_HVALUE hValue, | 124 FX_BOOL FXJSE_Value_SetObjectProp(CFXJSE_Value* pValue, |
127 const CFX_ByteStringC& szPropName, | 125 const CFX_ByteStringC& szPropName, |
128 FXJSE_HVALUE hPropValue); | 126 CFXJSE_Value* pPropValue); |
129 FX_BOOL FXJSE_Value_GetObjectPropByIdx(FXJSE_HVALUE hValue, | 127 FX_BOOL FXJSE_Value_GetObjectPropByIdx(CFXJSE_Value* pValue, |
130 uint32_t uPropIdx, | 128 uint32_t uPropIdx, |
131 FXJSE_HVALUE hPropValue); | 129 CFXJSE_Value* pPropValue); |
132 FX_BOOL FXJSE_Value_DeleteObjectProp(FXJSE_HVALUE hValue, | 130 FX_BOOL FXJSE_Value_DeleteObjectProp(CFXJSE_Value* pValue, |
133 const CFX_ByteStringC& szPropName); | 131 const CFX_ByteStringC& szPropName); |
134 FX_BOOL FXJSE_Value_ObjectHasOwnProp(FXJSE_HVALUE hValue, | 132 FX_BOOL FXJSE_Value_ObjectHasOwnProp(CFXJSE_Value* pValue, |
135 const CFX_ByteStringC& szPropName, | 133 const CFX_ByteStringC& szPropName, |
136 FX_BOOL bUseTypeGetter); | 134 FX_BOOL bUseTypeGetter); |
137 FX_BOOL FXJSE_Value_SetObjectOwnProp(FXJSE_HVALUE hValue, | 135 FX_BOOL FXJSE_Value_SetObjectOwnProp(CFXJSE_Value* pValue, |
138 const CFX_ByteStringC& szPropName, | 136 const CFX_ByteStringC& szPropName, |
139 FXJSE_HVALUE hPropValue); | 137 CFXJSE_Value* pPropValue); |
140 | 138 |
141 FX_BOOL FXJSE_Value_SetFunctionBind(FXJSE_HVALUE hValue, | 139 FX_BOOL FXJSE_Value_SetFunctionBind(CFXJSE_Value* pValue, |
142 FXJSE_HVALUE hOldFunction, | 140 CFXJSE_Value* pOldFunction, |
143 FXJSE_HVALUE hNewThis); | 141 CFXJSE_Value* pNewThis); |
144 | 142 |
145 FX_BOOL FXJSE_ExecuteScript(CFXJSE_Context* pContext, | 143 FX_BOOL FXJSE_ExecuteScript(CFXJSE_Context* pContext, |
146 const FX_CHAR* szScript, | 144 const FX_CHAR* szScript, |
147 FXJSE_HVALUE hRetValue, | 145 CFXJSE_Value* pRetValue, |
148 FXJSE_HVALUE hNewThisObject = nullptr); | 146 CFXJSE_Value* pNewThisObject = nullptr); |
149 | 147 |
150 void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name, | 148 void FXJSE_ThrowMessage(const CFX_ByteStringC& utf8Name, |
151 const CFX_ByteStringC& utf8Message); | 149 const CFX_ByteStringC& utf8Message); |
152 | 150 |
153 #endif // XFA_FXJSE_INCLUDE_FXJSE_H_ | 151 #endif // XFA_FXJSE_INCLUDE_FXJSE_H_ |
OLD | NEW |