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 // PDFium wrapper around V8 APIs. PDFium code should include this file rather | 7 // PDFium wrapper around V8 APIs. PDFium code should include this file rather |
8 // than including V8 headers directly. | 8 // than including V8 headers directly. |
9 | 9 |
10 #ifndef FXJSAPI_H | 10 #ifndef FXJSAPI_H |
11 #define FXJSAPI_H | 11 #define FXJSAPI_H |
12 | 12 |
13 #include <v8.h> | 13 #include <v8.h> |
14 #include "../../../core/include/fxcrt/fx_string.h" // For CFX_WideString | 14 #include "../../../core/include/fxcrt/fx_string.h" // For CFX_WideString |
15 | 15 |
16 typedef v8::Value JSValue; | 16 typedef v8::Value JSValue; |
17 typedef v8::Handle<v8::Object>» JSObject; | 17 typedef v8::Local<v8::Object>» JSObject; |
18 typedef v8::Handle<v8::Object>» JSFXObject; | 18 typedef v8::Local<v8::Object>» JSFXObject; |
19 | 19 |
20 enum FXJSOBJTYPE | 20 enum FXJSOBJTYPE |
21 { | 21 { |
22 JS_DYNAMIC = 0, | 22 JS_DYNAMIC = 0, |
23 JS_STATIC = 1, | 23 JS_STATIC = 1, |
24 }; | 24 }; |
25 | 25 |
26 enum FXJSVALUETYPE | 26 enum FXJSVALUETYPE |
27 { | 27 { |
28 VT_unknown, | 28 VT_unknown, |
(...skipping 13 matching lines...) Expand all Loading... |
42 const wchar_t* srcline; | 42 const wchar_t* srcline; |
43 unsigned linnum; | 43 unsigned linnum; |
44 }; | 44 }; |
45 | 45 |
46 /* --------------------------------------------- API ---------------------------
------------------ */ | 46 /* --------------------------------------------- API ---------------------------
------------------ */ |
47 | 47 |
48 typedef v8::Isolate IJS_Runtime; | 48 typedef v8::Isolate IJS_Runtime; |
49 class IFXJS_Context; | 49 class IFXJS_Context; |
50 class IFXJS_Runtime; | 50 class IFXJS_Runtime; |
51 | 51 |
52 typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, v8::Handle<v8::Object> obj, v8
::Handle<v8::Object> global); | 52 typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, v8::Local<v8::Object> obj, v8:
:Local<v8::Object> global); |
53 typedef void (*LP_DESTRUCTOR)(v8::Handle<v8::Object> obj); | 53 typedef void (*LP_DESTRUCTOR)(v8::Local<v8::Object> obj); |
54 | 54 |
55 | 55 |
56 int JS_DefineObj(IJS
_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUC
TOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew); | 56 int JS_DefineObj(IJS
_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUC
TOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew); |
57 int JS_DefineObjMeth
od(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::Func
tionCallback pMethodCall); | 57 int JS_DefineObjMeth
od(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::Func
tionCallback pMethodCall); |
58 int JS_DefineObjProp
erty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::Acce
ssorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut); | 58 int JS_DefineObjProp
erty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::Acce
ssorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut); |
59 int JS_DefineObjAllP
roperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallbac
k pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterC
allback pPropPut, v8::NamedPropertyDeleterCallback pPropDel); | 59 int JS_DefineObjAllP
roperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallbac
k pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterC
allback pPropPut, v8::NamedPropertyDeleterCallback pPropDel); |
60 int» » » » » » » » JS_DefineObjCons
t(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Handle
<v8::Value> pDefault); | 60 int» » » » » » » » JS_DefineObjCons
t(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Local<
v8::Value> pDefault); |
61 int JS_DefineGlobalM
ethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback
pMethodCall); | 61 int JS_DefineGlobalM
ethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback
pMethodCall); |
62 int» » » » » » » » JS_DefineGlobalC
onst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Handle<v8::Value> p
Default); | 62 int» » » » » » » » JS_DefineGlobalC
onst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Local<v8::Value> pD
efault); |
63 | 63 |
64 void» » » » » » » JS_InitialRuntime(IJS_Ru
ntime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Persist
ent<v8::Context>& v8PersistentContext); | 64 void» » » » » » » JS_InitialRuntime(IJS_Ru
ntime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Global<
v8::Context>& v8PersistentContext); |
65 void» » » » » » » JS_ReleaseRuntime(IJS_Ru
ntime* pJSRuntime, v8::Persistent<v8::Context>& v8PersistentContext); | 65 void» » » » » » » JS_ReleaseRuntime(IJS_Ru
ntime* pJSRuntime, v8::Global<v8::Context>& v8PersistentContext); |
66 void JS_Initial(); | 66 void JS_Initial(); |
67 void JS_Release(); | 67 void JS_Release(); |
68 int JS_Parse(IJS_Run
time* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length,
FXJSErr* perror); | 68 int JS_Parse(IJS_Run
time* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length,
FXJSErr* perror); |
69 int JS_Execute(IJS_R
untime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long lengt
h, FXJSErr* perror); | 69 int JS_Execute(IJS_R
untime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long lengt
h, FXJSErr* perror); |
70 v8::Handle<v8::Object>» » » JS_NewFxDynamicObj(IJS_Runtime* pJSRunti
me, IFXJS_Context* pJSContext, int nObjDefnID); | 70 v8::Local<v8::Object>» » » JS_NewFxDynamicObj(IJS_Runtime* pJSRunti
me, IFXJS_Context* pJSContext, int nObjDefnID); |
71 v8::Handle<v8::Object>» » » JS_GetStaticObj(IJS_Runtime* pJSRuntime,
int nObjDefnID); | 71 v8::Local<v8::Object>» » » JS_GetStaticObj(IJS_Runtime* pJSRuntime,
int nObjDefnID); |
72 void JS_SetThisObj(IJS_Runtim
e* pJSRuntime, int nThisObjID); | 72 void JS_SetThisObj(IJS_Runtim
e* pJSRuntime, int nThisObjID); |
73 v8::Handle<v8::Object>» » » JS_GetThisObj(IJS_Runtime * pJSRuntime); | 73 v8::Local<v8::Object>» » » JS_GetThisObj(IJS_Runtime * pJSRuntime); |
74 int» » » » » » » » JS_GetObjDefnID(
v8::Handle<v8::Object> pObj); | 74 int» » » » » » » » JS_GetObjDefnID(
v8::Local<v8::Object> pObj); |
75 IJS_Runtime*» » » » » JS_GetRuntime(v8::Handle<v8::Obj
ect> pObj); | 75 IJS_Runtime*» » » » » JS_GetRuntime(v8::Local<v8::Obje
ct> pObj); |
76 int JS_GetObjDefnID(
IJS_Runtime * pJSRuntime, const wchar_t* pObjName); | 76 int JS_GetObjDefnID(
IJS_Runtime * pJSRuntime, const wchar_t* pObjName); |
77 void JS_Error(v8::Isolate* is
olate, const CFX_WideString& message); | 77 void JS_Error(v8::Isolate* is
olate, const CFX_WideString& message); |
78 unsigned JS_CalcHash(const wchar_
t* main, unsigned nLen); | 78 unsigned JS_CalcHash(const wchar_
t* main, unsigned nLen); |
79 unsigned JS_CalcHash(const wchar_
t* main); | 79 unsigned JS_CalcHash(const wchar_
t* main); |
80 const wchar_t*» » » » » JS_GetTypeof(v8::Handle<v8::Valu
e> pObj); | 80 const wchar_t*» » » » » JS_GetTypeof(v8::Local<v8::Value
> pObj); |
81 void» » » » » » » JS_SetPrivate(IJS_Runtim
e* pJSRuntime, v8::Handle<v8::Object> pObj, void* p); | 81 void» » » » » » » JS_SetPrivate(IJS_Runtim
e* pJSRuntime, v8::Local<v8::Object> pObj, void* p); |
82 void*» » » » » » » JS_GetPrivate(IJS_Runtim
e* pJSRuntime, v8::Handle<v8::Object> pObj); | 82 void*» » » » » » » JS_GetPrivate(IJS_Runtim
e* pJSRuntime, v8::Local<v8::Object> pObj); |
83 void» » » » » » » JS_SetPrivate(v8::Handle
<v8::Object> pObj, void* p); | 83 void» » » » » » » JS_SetPrivate(v8::Local<
v8::Object> pObj, void* p); |
84 void*» » » » » » » JS_GetPrivate(v8::Handle
<v8::Object> pObj); | 84 void*» » » » » » » JS_GetPrivate(v8::Local<
v8::Object> pObj); |
85 void» » » » » » » JS_FreePrivate(v8::Handl
e<v8::Object> pObj); | 85 void» » » » » » » JS_FreePrivate(void* p); |
86 v8::Handle<v8::Value>» » » JS_GetObjectValue(v8::Handle<v8::Object>
pObj); | 86 void» » » » » » » JS_FreePrivate(v8::Local
<v8::Object> pObj); |
87 v8::Handle<v8::Value>» » » JS_GetObjectElement(IJS_Runtime* pJSRunt
ime, v8::Handle<v8::Object> pObj,const wchar_t* PropertyName); | 87 v8::Local<v8::Value>» » » JS_GetObjectValue(v8::Local<v8::Object>
pObj); |
88 v8::Handle<v8::Array>» » » JS_GetObjectElementNames(v8::Handle<v8::
Object> pObj); | 88 v8::Local<v8::Value>» » » JS_GetObjectElement(IJS_Runtime* pJSRunt
ime, v8::Local<v8::Object> pObj,const wchar_t* PropertyName); |
89 void» » » » » » » JS_PutObjectString(IJS_R
untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, con
st wchar_t* sValue); | 89 v8::Local<v8::Array>» » » JS_GetObjectElementNames(IJS_Runtime* pJ
SRuntime, v8::Local<v8::Object> pObj); |
90 void» » » » » » » JS_PutObjectNumber(IJS_R
untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, int
nValue); | 90 void» » » » » » » JS_PutObjectString(IJS_R
untime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, cons
t wchar_t* sValue); |
91 void» » » » » » » JS_PutObjectNumber(IJS_R
untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, flo
at fValue); | 91 void» » » » » » » JS_PutObjectNumber(IJS_R
untime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, int
nValue); |
92 void» » » » » » » JS_PutObjectNumber(IJS_R
untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, dou
ble dValue); | 92 void» » » » » » » JS_PutObjectNumber(IJS_R
untime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, floa
t fValue); |
93 void» » » » » » » JS_PutObjectBoolean(IJS_
Runtime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, bo
ol bValue); | 93 void» » » » » » » JS_PutObjectNumber(IJS_R
untime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, doub
le dValue); |
94 void» » » » » » » JS_PutObjectObject(IJS_R
untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, v8:
:Handle<v8::Object> pPut); | 94 void» » » » » » » JS_PutObjectBoolean(IJS_
Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, boo
l bValue); |
95 void» » » » » » » JS_PutObjectNull(IJS_Run
time* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName); | 95 void» » » » » » » JS_PutObjectObject(IJS_R
untime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, v8::
Local<v8::Object> pPut); |
96 unsigned» » » » » » JS_PutArrayElement(v8::H
andle<v8::Array> pArray,unsigned index,v8::Handle<v8::Value> pValue,FXJSVALUETYP
E eType); | 96 void» » » » » » » JS_PutObjectNull(IJS_Run
time* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName); |
97 v8::Handle<v8::Value>» » » JS_GetArrayElemnet(v8::Handle<v8::Array>
pArray,unsigned index); | 97 unsigned» » » » » » JS_PutArrayElement(IJS_R
untime* pJSRuntime, v8::Local<v8::Array> pArray,unsigned index,v8::Local<v8::Val
ue> pValue,FXJSVALUETYPE eType); |
98 unsigned» » » » » » JS_GetArrayLength(v8::Ha
ndle<v8::Array> pArray); | 98 v8::Local<v8::Value>» » » JS_GetArrayElement(IJS_Runtime* pJSRunti
me, v8::Local<v8::Array> pArray,unsigned index); |
99 v8::Handle<v8::Value>» » » JS_GetListValue(v8::Handle<v8::Value> pL
ist, int index); | 99 unsigned» » » » » » JS_GetArrayLength(v8::Lo
cal<v8::Array> pArray); |
| 100 v8::Local<v8::Value>» » » JS_GetListValue(IJS_Runtime* pJSRuntime,
v8::Local<v8::Value> pList, int index); |
100 | 101 |
101 | 102 |
102 v8::Handle<v8::Array>» » » JS_NewArray(IJS_Runtime* pJSRuntime); | 103 v8::Local<v8::Array>» » » JS_NewArray(IJS_Runtime* pJSRuntime); |
103 v8::Handle<v8::Value>» » » JS_NewNumber(IJS_Runtime* pJSRuntime,int
number); | 104 v8::Local<v8::Value>» » » JS_NewNumber(IJS_Runtime* pJSRuntime,int
number); |
104 v8::Handle<v8::Value>» » » JS_NewNumber(IJS_Runtime* pJSRuntime,dou
ble number); | 105 v8::Local<v8::Value>» » » JS_NewNumber(IJS_Runtime* pJSRuntime,dou
ble number); |
105 v8::Handle<v8::Value>» » » JS_NewNumber(IJS_Runtime* pJSRuntime,flo
at number); | 106 v8::Local<v8::Value>» » » JS_NewNumber(IJS_Runtime* pJSRuntime,flo
at number); |
106 v8::Handle<v8::Value>» » » JS_NewBoolean(IJS_Runtime* pJSRuntime,bo
ol b); | 107 v8::Local<v8::Value>» » » JS_NewBoolean(IJS_Runtime* pJSRuntime,bo
ol b); |
107 v8::Handle<v8::Value>» » » JS_NewObject(IJS_Runtime* pJSRuntime,v8:
:Handle<v8::Object> pObj); | 108 v8::Local<v8::Value>» » » JS_NewObject(IJS_Runtime* pJSRuntime,v8:
:Local<v8::Object> pObj); |
108 v8::Handle<v8::Value>» » » JS_NewObject2(IJS_Runtime* pJSRuntime,v8
::Handle<v8::Array> pObj); | 109 v8::Local<v8::Value>» » » JS_NewObject2(IJS_Runtime* pJSRuntime,v8
::Local<v8::Array> pObj); |
109 v8::Handle<v8::Value>» » » JS_NewString(IJS_Runtime* pJSRuntime,con
st wchar_t* string); | 110 v8::Local<v8::Value>» » » JS_NewString(IJS_Runtime* pJSRuntime,con
st wchar_t* string); |
110 v8::Handle<v8::Value>» » » JS_NewString(IJS_Runtime* pJSRuntime,con
st wchar_t* string, unsigned nLen); | 111 v8::Local<v8::Value>» » » JS_NewString(IJS_Runtime* pJSRuntime,con
st wchar_t* string, unsigned nLen); |
111 v8::Handle<v8::Value>» » » JS_NewNull(); | 112 v8::Local<v8::Value>» » » JS_NewNull(); |
112 v8::Handle<v8::Value>» » » JS_NewDate(IJS_Runtime* pJSRuntime,doubl
e d); | 113 v8::Local<v8::Value>» » » JS_NewDate(IJS_Runtime* pJSRuntime,doubl
e d); |
113 v8::Handle<v8::Value>» » » JS_NewValue(IJS_Runtime* pJSRuntime); | 114 v8::Local<v8::Value>» » » JS_NewValue(IJS_Runtime* pJSRuntime); |
114 | 115 |
115 | 116 |
116 int» » » » » » » » JS_ToInt32(v8::H
andle<v8::Value> pValue); | 117 int» » » » » » » » JS_ToInt32(IJS_R
untime* pJSRuntime, v8::Local<v8::Value> pValue); |
117 bool» » » » » » » JS_ToBoolean(v8::Handle<
v8::Value> pValue); | 118 bool» » » » » » » JS_ToBoolean(IJS_Runtime
* pJSRuntime, v8::Local<v8::Value> pValue); |
118 double» » » » » » » JS_ToNumber(v8::Handle<v
8::Value> pValue); | 119 double» » » » » » » JS_ToNumber(IJS_Runtime*
pJSRuntime, v8::Local<v8::Value> pValue); |
119 v8::Handle<v8::Object>» » » JS_ToObject(v8::Handle<v8::Value> pValue
); | 120 v8::Local<v8::Object>» » » JS_ToObject(IJS_Runtime* pJSRuntime, v8:
:Local<v8::Value> pValue); |
120 CFX_WideString» » » » » JS_ToString(v8::Handle<v8::Value
> pValue); | 121 CFX_WideString» » » » » JS_ToString(IJS_Runtime* pJSRunt
ime, v8::Local<v8::Value> pValue); |
121 v8::Handle<v8::Array>» » » JS_ToArray(v8::Handle<v8::Value> pValue)
; | 122 v8::Local<v8::Array>» » » JS_ToArray(IJS_Runtime* pJSRuntime, v8::
Local<v8::Value> pValue); |
122 void» » » » » » » JS_ValueCopy(v8::Handle<
v8::Value>& pTo, v8::Handle<v8::Value> pFrom); | 123 void» » » » » » » JS_ValueCopy(v8::Local<v
8::Value>& pTo, v8::Local<v8::Value> pFrom); |
123 | 124 |
124 double JS_GetDateTime(); | 125 double JS_GetDateTime(); |
125 int JS_GetYearFromTi
me(double dt); | 126 int JS_GetYearFromTi
me(double dt); |
126 int JS_GetMonthFromT
ime(double dt); | 127 int JS_GetMonthFromT
ime(double dt); |
127 int JS_GetDayFromTim
e(double dt); | 128 int JS_GetDayFromTim
e(double dt); |
128 int JS_GetHourFromTi
me(double dt); | 129 int JS_GetHourFromTi
me(double dt); |
129 int JS_GetMinFromTim
e(double dt); | 130 int JS_GetMinFromTim
e(double dt); |
130 int JS_GetSecFromTim
e(double dt); | 131 int JS_GetSecFromTim
e(double dt); |
131 double JS_DateParse(const wchar
_t* string); | 132 double JS_DateParse(const wchar
_t* string); |
132 double JS_MakeDay(int nYear, in
t nMonth, int nDay); | 133 double JS_MakeDay(int nYear, in
t nMonth, int nDay); |
133 double JS_MakeTime(int nHour, i
nt nMin, int nSec, int nMs); | 134 double JS_MakeTime(int nHour, i
nt nMin, int nSec, int nMs); |
134 double JS_MakeDate(double day,
double time); | 135 double JS_MakeDate(double day,
double time); |
135 bool JS_PortIsNan(double d); | 136 bool JS_PortIsNan(double d); |
136 double JS_LocalTime(double d); | 137 double JS_LocalTime(double d); |
137 | 138 |
138 #endif //FXJSAPI_H | 139 #endif //FXJSAPI_H |
OLD | NEW |