| 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 // FXJS_V8 is a layer that makes it easier to define native objects in V8, but | 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 | 8 // has no knowledge of PDF-specific native objects. It could in theory be used |
| 9 // to implement other sets of native objects. | 9 // to implement other sets of native objects. |
| 10 | 10 |
| 11 // PDFium code should include this file rather than including V8 headers | 11 // PDFium code should include this file rather than including V8 headers |
| 12 // directly. | 12 // directly. |
| 13 | 13 |
| 14 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 14 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
| 15 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 15 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
| 16 | 16 |
| 17 #include <v8.h> | 17 #include <v8.h> |
| 18 | 18 |
| 19 #include "core/include/fxcrt/fx_basic.h" | 19 #include <vector> |
| 20 |
| 21 #include "core/include/fxcrt/fx_string.h" |
| 22 |
| 23 class CFXJS_ObjDefinition; |
| 20 | 24 |
| 21 // FXJS_V8 places no restrictions on these two classes; it merely passes them | 25 // FXJS_V8 places no restrictions on these two classes; it merely passes them |
| 22 // on to caller-provided methods. | 26 // on to caller-provided methods. |
| 23 class IJS_Context; // A description of the event that caused JS execution. | 27 class IJS_Context; // A description of the event that caused JS execution. |
| 24 class IJS_Runtime; // A native runtime, typically owns the v8::Context. | 28 class IJS_Runtime; // A native runtime, typically owns the v8::Context. |
| 25 | 29 |
| 26 enum FXJSOBJTYPE { | 30 enum FXJSOBJTYPE { |
| 27 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. | 31 FXJSOBJTYPE_DYNAMIC = 0, // Created by native method and returned to JS. |
| 28 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. | 32 FXJSOBJTYPE_STATIC, // Created by init and hung off of global object. |
| 29 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). | 33 FXJSOBJTYPE_GLOBAL, // The global object itself (may only appear once). |
| 30 }; | 34 }; |
| 31 | 35 |
| 32 struct FXJSErr { | 36 struct FXJSErr { |
| 33 const wchar_t* message; | 37 const wchar_t* message; |
| 34 const wchar_t* srcline; | 38 const wchar_t* srcline; |
| 35 unsigned linnum; | 39 unsigned linnum; |
| 36 }; | 40 }; |
| 37 | 41 |
| 38 class FXJS_PerIsolateData { | 42 class FXJS_PerIsolateData { |
| 39 public: | 43 public: |
| 40 static void SetUp(v8::Isolate* pIsolate); | 44 static void SetUp(v8::Isolate* pIsolate); |
| 41 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); | 45 static FXJS_PerIsolateData* Get(v8::Isolate* pIsolate); |
| 42 | 46 |
| 43 CFX_PtrArray m_ObjectDefnArray; | 47 std::vector<CFXJS_ObjDefinition*> m_ObjectDefnArray; |
| 44 | 48 |
| 45 protected: | 49 protected: |
| 46 FXJS_PerIsolateData() {} | 50 FXJS_PerIsolateData() {} |
| 47 }; | 51 }; |
| 48 | 52 |
| 49 extern const wchar_t kFXJSValueNameString[]; | 53 extern const wchar_t kFXJSValueNameString[]; |
| 50 extern const wchar_t kFXJSValueNameNumber[]; | 54 extern const wchar_t kFXJSValueNameNumber[]; |
| 51 extern const wchar_t kFXJSValueNameBoolean[]; | 55 extern const wchar_t kFXJSValueNameBoolean[]; |
| 52 extern const wchar_t kFXJSValueNameDate[]; | 56 extern const wchar_t kFXJSValueNameDate[]; |
| 53 extern const wchar_t kFXJSValueNameObject[]; | 57 extern const wchar_t kFXJSValueNameObject[]; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); | 217 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); |
| 214 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, | 218 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate, |
| 215 v8::Local<v8::Value> pValue); | 219 v8::Local<v8::Value> pValue); |
| 216 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, | 220 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate, |
| 217 v8::Local<v8::Value> pValue); | 221 v8::Local<v8::Value> pValue); |
| 218 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, | 222 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate, |
| 219 v8::Local<v8::Value> pValue); | 223 v8::Local<v8::Value> pValue); |
| 220 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); | 224 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom); |
| 221 | 225 |
| 222 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ | 226 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ |
| OLD | NEW |