John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [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. |
Tom Sepez | 2311b78 | 2015-02-23 10:22:51 -0800 | [diff] [blame] | 4 | |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | ba038bc | 2015-10-08 12:03:00 -0700 | [diff] [blame] | 7 | // FXJS_V8 is a layer that makes it easier to define native objects in V8, but |
| 8 | // has no knowledge of PDF-specific native objects. It could in theory be used |
| 9 | // to implement other sets of native objects. |
| 10 | |
| 11 | // PDFium code should include this file rather than including V8 headers |
| 12 | // directly. |
Tom Sepez | 9a3f812 | 2015-04-07 15:35:48 -0700 | [diff] [blame] | 13 | |
dsinclair | b3f2467 | 2016-07-12 10:42:14 -0700 | [diff] [blame] | 14 | #ifndef FXJS_INCLUDE_FXJS_V8_H_ |
| 15 | #define FXJS_INCLUDE_FXJS_V8_H_ |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 16 | |
jinming_wang | 61dc96f | 2016-01-28 14:39:56 +0800 | [diff] [blame] | 17 | #include <v8-util.h> |
Dan Sinclair | 61046b9 | 2016-02-18 14:48:48 -0500 | [diff] [blame] | 18 | #include <v8.h> |
Lei Zhang | a688a04 | 2015-11-09 13:57:49 -0800 | [diff] [blame] | 19 | |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 20 | #include <map> |
Lei Zhang | d88a364 | 2015-11-10 09:38:57 -0800 | [diff] [blame] | 21 | #include <vector> |
| 22 | |
Dan Sinclair | a8a28e0 | 2016-03-23 15:41:39 -0400 | [diff] [blame] | 23 | #include "core/fxcrt/include/fx_string.h" |
Lei Zhang | d88a364 | 2015-11-10 09:38:57 -0800 | [diff] [blame] | 24 | |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 25 | class CFXJS_Engine; |
Lei Zhang | d88a364 | 2015-11-10 09:38:57 -0800 | [diff] [blame] | 26 | class CFXJS_ObjDefinition; |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 27 | |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 28 | // FXJS_V8 places no restrictions on this class; it merely passes it |
Tom Sepez | 3342090 | 2015-10-13 15:00:10 -0700 | [diff] [blame] | 29 | // on to caller-provided methods. |
| 30 | class IJS_Context; // A description of the event that caused JS execution. |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 31 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 32 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 33 | // FXJS_V8 places no interpreation on this calass; it merely passes it |
| 34 | // along to XFA. |
| 35 | class CFXJSE_RuntimeData; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 36 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 37 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | enum FXJSOBJTYPE { |
Tom Sepez | cd56a7d | 2015-10-06 11:45:28 -0700 | [diff] [blame] | 39 | FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. |
| 40 | FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. |
| 41 | FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 44 | struct FXJSErr { |
| 45 | const wchar_t* message; |
| 46 | const wchar_t* srcline; |
| 47 | unsigned linnum; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
jinming_wang | 61dc96f | 2016-01-28 14:39:56 +0800 | [diff] [blame] | 50 | // Global weak map to save dynamic objects. |
| 51 | class V8TemplateMapTraits : public v8::StdMapTraits<void*, v8::Object> { |
| 52 | public: |
| 53 | typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; |
| 54 | typedef void WeakCallbackDataType; |
| 55 | |
| 56 | static WeakCallbackDataType* WeakCallbackParameter( |
| 57 | MapType* map, |
| 58 | void* key, |
| 59 | const v8::Local<v8::Object>& value) { |
| 60 | return key; |
| 61 | } |
| 62 | static MapType* MapFromWeakCallbackInfo( |
| 63 | const v8::WeakCallbackInfo<WeakCallbackDataType>&); |
| 64 | |
| 65 | static void* KeyFromWeakCallbackInfo( |
| 66 | const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { |
| 67 | return data.GetParameter(); |
| 68 | } |
| 69 | static const v8::PersistentContainerCallbackType kCallbackType = |
| 70 | v8::kWeakWithInternalFields; |
| 71 | static void DisposeWeak( |
| 72 | const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} |
| 73 | static void OnWeakCallback( |
| 74 | const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} |
| 75 | static void Dispose(v8::Isolate* isolate, |
| 76 | v8::Global<v8::Object> value, |
| 77 | void* key); |
| 78 | static void DisposeCallbackData(WeakCallbackDataType* callbackData) {} |
| 79 | }; |
| 80 | |
| 81 | class V8TemplateMap { |
| 82 | public: |
| 83 | typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; |
| 84 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 85 | explicit V8TemplateMap(v8::Isolate* isolate); |
| 86 | ~V8TemplateMap(); |
| 87 | |
| 88 | void set(void* key, v8::Local<v8::Object> handle); |
| 89 | |
jinming_wang | 61dc96f | 2016-01-28 14:39:56 +0800 | [diff] [blame] | 90 | friend class V8TemplateMapTraits; |
| 91 | |
| 92 | private: |
| 93 | MapType m_map; |
| 94 | }; |
| 95 | |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 96 | class FXJS_PerIsolateData { |
| 97 | public: |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 98 | ~FXJS_PerIsolateData(); |
| 99 | |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 100 | static void SetUp(v8::Isolate* pIsolate); |
| 101 | static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 102 | |
jinming_wang | 61dc96f | 2016-01-28 14:39:56 +0800 | [diff] [blame] | 103 | void CreateDynamicObjsMap(v8::Isolate* pIsolate) { |
Tom Sepez | 9967cc5 | 2016-03-24 11:45:37 -0700 | [diff] [blame] | 104 | if (!m_pDynamicObjsMap) |
| 105 | m_pDynamicObjsMap = new V8TemplateMap(pIsolate); |
jinming_wang | 61dc96f | 2016-01-28 14:39:56 +0800 | [diff] [blame] | 106 | } |
| 107 | void ReleaseDynamicObjsMap() { |
| 108 | delete m_pDynamicObjsMap; |
| 109 | m_pDynamicObjsMap = nullptr; |
| 110 | } |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 111 | |
Lei Zhang | d88a364 | 2015-11-10 09:38:57 -0800 | [diff] [blame] | 112 | std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 113 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 114 | CFXJSE_RuntimeData* m_pFXJSERuntimeData; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 115 | #endif // PDF_ENABLE_XFA |
jinming_wang | 61dc96f | 2016-01-28 14:39:56 +0800 | [diff] [blame] | 116 | V8TemplateMap* m_pDynamicObjsMap; |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 117 | |
| 118 | protected: |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 119 | FXJS_PerIsolateData(); |
Tom Sepez | ed7b2b5 | 2015-09-22 08:36:17 -0700 | [diff] [blame] | 120 | }; |
| 121 | |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 122 | class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
Tom Sepez | 7d0fcbf | 2015-09-15 15:30:34 -0700 | [diff] [blame] | 123 | void* Allocate(size_t length) override; |
| 124 | void* AllocateUninitialized(size_t length) override; |
| 125 | void Free(void* data, size_t length) override; |
| 126 | }; |
| 127 | |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 128 | using FXJS_CONSTRUCTOR = void (*)(CFXJS_Engine* fxjs, |
| 129 | v8::Local<v8::Object> obj); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 130 | using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj); |
| 131 | |
Tom Sepez | a72e8e2 | 2015-10-07 10:17:53 -0700 | [diff] [blame] | 132 | void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 133 | void FXJS_Release(); |
| 134 | |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 135 | class CFXJS_Engine { |
| 136 | public: |
| 137 | CFXJS_Engine(); |
| 138 | ~CFXJS_Engine(); |
| 139 | |
| 140 | protected: |
| 141 | v8::Isolate* m_isolate; |
| 142 | v8::Global<v8::Context> m_context; |
| 143 | std::vector<v8::Global<v8::Object>*> m_StaticObjects; |
| 144 | std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; |
| 145 | }; |
| 146 | |
Tom Sepez | a72e8e2 | 2015-10-07 10:17:53 -0700 | [diff] [blame] | 147 | // Gets the global isolate set by FXJS_Initialize(), or makes a new one each |
| 148 | // time if there is no such isolate. Returns true if a new isolate had to be |
| 149 | // created. |
| 150 | bool FXJS_GetIsolate(v8::Isolate** pResultIsolate); |
| 151 | |
Lei Zhang | 3fa115b | 2015-10-08 12:04:47 -0700 | [diff] [blame] | 152 | // Get the global isolate's ref count. |
| 153 | size_t FXJS_GlobalIsolateRefCount(); |
| 154 | |
Tom Sepez | 142165e | 2015-09-11 13:21:50 -0700 | [diff] [blame] | 155 | // Always returns a valid, newly-created objDefnID. |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 156 | int FXJS_DefineObj(v8::Isolate* pIsolate, |
| 157 | const wchar_t* sObjName, |
| 158 | FXJSOBJTYPE eObjType, |
| 159 | FXJS_CONSTRUCTOR pConstructor, |
| 160 | FXJS_DESTRUCTOR pDestructor); |
Tom Sepez | 142165e | 2015-09-11 13:21:50 -0700 | [diff] [blame] | 161 | |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 162 | void FXJS_DefineObjMethod(v8::Isolate* pIsolate, |
Tom Sepez | 142165e | 2015-09-11 13:21:50 -0700 | [diff] [blame] | 163 | int nObjDefnID, |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 164 | const wchar_t* sMethodName, |
| 165 | v8::FunctionCallback pMethodCall); |
| 166 | void FXJS_DefineObjProperty(v8::Isolate* pIsolate, |
| 167 | int nObjDefnID, |
| 168 | const wchar_t* sPropName, |
| 169 | v8::AccessorGetterCallback pPropGet, |
| 170 | v8::AccessorSetterCallback pPropPut); |
| 171 | void FXJS_DefineObjAllProperties(v8::Isolate* pIsolate, |
| 172 | int nObjDefnID, |
| 173 | v8::NamedPropertyQueryCallback pPropQurey, |
| 174 | v8::NamedPropertyGetterCallback pPropGet, |
| 175 | v8::NamedPropertySetterCallback pPropPut, |
| 176 | v8::NamedPropertyDeleterCallback pPropDel); |
| 177 | void FXJS_DefineObjConst(v8::Isolate* pIsolate, |
| 178 | int nObjDefnID, |
| 179 | const wchar_t* sConstName, |
| 180 | v8::Local<v8::Value> pDefault); |
| 181 | void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, |
| 182 | const wchar_t* sMethodName, |
| 183 | v8::FunctionCallback pMethodCall); |
| 184 | void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, |
| 185 | const wchar_t* sConstName, |
Tom Sepez | 297b515 | 2016-03-04 13:43:46 -0800 | [diff] [blame] | 186 | v8::FunctionCallback pConstGetter); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 187 | |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 188 | // Called after FXJS_Define* calls made. |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 189 | void FXJS_InitializeEngine( |
Tom Sepez | 4237aed | 2015-11-10 15:19:17 -0800 | [diff] [blame] | 190 | v8::Isolate* pIsolate, |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 191 | CFXJS_Engine* pEngine, |
Tom Sepez | 4237aed | 2015-11-10 15:19:17 -0800 | [diff] [blame] | 192 | v8::Global<v8::Context>* pV8PersistentContext, |
| 193 | std::vector<v8::Global<v8::Object>*>* pStaticObjects); |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 194 | void FXJS_ReleaseEngine(v8::Isolate* pIsolate, |
| 195 | v8::Global<v8::Context>* pV8PersistentContext, |
| 196 | std::vector<v8::Global<v8::Object>*>* pStaticObjects); |
| 197 | CFXJS_Engine* FXJS_GetCurrentEngineFromIsolate(v8::Isolate* pIsolate); |
Tom Sepez | b8ec0a3 | 2015-11-20 14:23:02 -0800 | [diff] [blame] | 198 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 199 | #ifdef PDF_ENABLE_XFA |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 200 | // Called as part of FXJS_InitializeEngine, exposed so PDF can make its |
Tom Sepez | 4f4603c | 2015-11-10 15:03:12 -0800 | [diff] [blame] | 201 | // own contexts compatible with XFA or vice versa. |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 202 | void FXJS_SetEngineForV8Context(v8::Local<v8::Context> v8Context, |
| 203 | CFXJS_Engine* pEngine); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 204 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 4f4603c | 2015-11-10 15:03:12 -0800 | [diff] [blame] | 205 | |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 206 | // Called after FXJS_InitializeEngine call made. |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 207 | int FXJS_Execute(v8::Isolate* pIsolate, |
dsinclair | 884b4f9 | 2016-06-06 09:49:32 -0700 | [diff] [blame] | 208 | const CFX_WideString& script, |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 209 | FXJSErr* perror); |
Tom Sepez | 7d0fcbf | 2015-09-15 15:30:34 -0700 | [diff] [blame] | 210 | |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 211 | v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate, |
tsepez | a494191 | 2016-08-15 11:40:12 -0700 | [diff] [blame] | 212 | CFXJS_Engine* pEngine, |
jinming_wang | 61dc96f | 2016-01-28 14:39:56 +0800 | [diff] [blame] | 213 | int nObjDefnID, |
| 214 | bool bStatic = false); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 215 | v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate); |
| 216 | int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 217 | |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 218 | void FXJS_SetPrivate(v8::Isolate* pIsolate, |
| 219 | v8::Local<v8::Object> pObj, |
| 220 | void* p); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 221 | void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 222 | void FXJS_FreePrivate(void* p); |
| 223 | void FXJS_FreePrivate(v8::Local<v8::Object> pObj); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 224 | void FXJS_Error(v8::Isolate* isolate, const CFX_WideString& message); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 225 | |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 226 | v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate, |
| 227 | const CFX_WideString& wsPropertyName); |
tsepez | d0b6ed1 | 2016-08-11 19:50:57 -0700 | [diff] [blame] | 228 | |
| 229 | std::vector<CFX_WideString> FXJS_GetObjectPropertyNames( |
| 230 | v8::Isolate* pIsolate, |
| 231 | v8::Local<v8::Object> pObj); |
| 232 | v8::Local<v8::Value> FXJS_GetObjectProperty(v8::Isolate* pIsolate, |
| 233 | v8::Local<v8::Object> pObj, |
| 234 | const CFX_WideString& PropertyName); |
| 235 | |
| 236 | unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 237 | v8::Local<v8::Value> FXJS_GetArrayElement(v8::Isolate* pIsolate, |
| 238 | v8::Local<v8::Array> pArray, |
| 239 | unsigned index); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 240 | |
| 241 | void FXJS_PutObjectString(v8::Isolate* pIsolate, |
| 242 | v8::Local<v8::Object> pObj, |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 243 | const CFX_WideString& wsPropertyName, |
| 244 | const CFX_WideString& wsValue); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 245 | void FXJS_PutObjectNumber(v8::Isolate* pIsolate, |
| 246 | v8::Local<v8::Object> pObj, |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 247 | const CFX_WideString& PropertyName, |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 248 | int nValue); |
| 249 | void FXJS_PutObjectNumber(v8::Isolate* pIsolate, |
| 250 | v8::Local<v8::Object> pObj, |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 251 | const CFX_WideString& PropertyName, |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 252 | float fValue); |
| 253 | void FXJS_PutObjectNumber(v8::Isolate* pIsolate, |
| 254 | v8::Local<v8::Object> pObj, |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 255 | const CFX_WideString& PropertyName, |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 256 | double dValue); |
| 257 | void FXJS_PutObjectBoolean(v8::Isolate* pIsolate, |
| 258 | v8::Local<v8::Object> pObj, |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 259 | const CFX_WideString& PropertyName, |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 260 | bool bValue); |
| 261 | void FXJS_PutObjectObject(v8::Isolate* pIsolate, |
| 262 | v8::Local<v8::Object> pObj, |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 263 | const CFX_WideString& PropertyName, |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 264 | v8::Local<v8::Object> pPut); |
| 265 | void FXJS_PutObjectNull(v8::Isolate* pIsolate, |
| 266 | v8::Local<v8::Object> pObj, |
tsepez | 018935c | 2016-04-15 13:15:12 -0700 | [diff] [blame] | 267 | const CFX_WideString& PropertyName); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 268 | unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate, |
| 269 | v8::Local<v8::Array> pArray, |
| 270 | unsigned index, |
| 271 | v8::Local<v8::Value> pValue); |
| 272 | |
tsepez | 88b6686 | 2016-07-14 12:07:48 -0700 | [diff] [blame] | 273 | v8::Local<v8::Value> FXJS_NewNull(v8::Isolate* pIsolate); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 274 | v8::Local<v8::Array> FXJS_NewArray(v8::Isolate* pIsolate); |
| 275 | v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, int number); |
| 276 | v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, double number); |
| 277 | v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, float number); |
| 278 | v8::Local<v8::Value> FXJS_NewBoolean(v8::Isolate* pIsolate, bool b); |
Dan Sinclair | 3ebd121 | 2016-03-09 09:59:23 -0500 | [diff] [blame] | 279 | v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate, const wchar_t* str); |
tsepez | 135b998 | 2016-08-05 09:32:50 -0700 | [diff] [blame] | 280 | v8::Local<v8::Date> FXJS_NewDate(v8::Isolate* pIsolate, double d); |
Tom Sepez | 39bfe12 | 2015-09-17 15:25:23 -0700 | [diff] [blame] | 281 | |
| 282 | int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
| 283 | bool FXJS_ToBoolean(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
| 284 | double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
| 285 | v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, |
| 286 | v8::Local<v8::Value> pValue); |
| 287 | CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, |
| 288 | v8::Local<v8::Value> pValue); |
| 289 | v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 290 | v8::Local<v8::Value> pValue); |
dsinclair | b3f2467 | 2016-07-12 10:42:14 -0700 | [diff] [blame] | 291 | #endif // FXJS_INCLUDE_FXJS_V8_H_ |