Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: fpdfsdk/include/jsapi/fxjs_v8.h

Issue 1347833002: Ensure functions in FXJS_V8 are prefixed by FXJS_. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nits, format. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/javascript/JS_Value.h ('k') | fpdfsdk/src/javascript/Consts.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ 10 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
11 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ 11 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_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 enum FXJSOBJTYPE { 16 enum FXJSOBJTYPE {
17 JS_DYNAMIC = 0, 17 FXJS_DYNAMIC = 0,
18 JS_STATIC = 1, 18 FXJS_STATIC = 1,
19 };
20
21 enum FXJSVALUETYPE {
22 VT_unknown,
23 VT_string,
24 VT_number,
25 VT_boolean,
26 VT_date,
27 VT_object,
28 VT_fxobject,
29 VT_null,
30 VT_undefined
31 }; 19 };
32 20
33 struct FXJSErr { 21 struct FXJSErr {
34 const wchar_t* message; 22 const wchar_t* message;
35 const wchar_t* srcline; 23 const wchar_t* srcline;
36 unsigned linnum; 24 unsigned linnum;
37 }; 25 };
38 26
39 extern const wchar_t kFXJSValueNameString[]; 27 extern const wchar_t kFXJSValueNameString[];
40 extern const wchar_t kFXJSValueNameNumber[]; 28 extern const wchar_t kFXJSValueNameNumber[];
41 extern const wchar_t kFXJSValueNameBoolean[]; 29 extern const wchar_t kFXJSValueNameBoolean[];
42 extern const wchar_t kFXJSValueNameDate[]; 30 extern const wchar_t kFXJSValueNameDate[];
43 extern const wchar_t kFXJSValueNameObject[]; 31 extern const wchar_t kFXJSValueNameObject[];
44 extern const wchar_t kFXJSValueNameFxobj[]; 32 extern const wchar_t kFXJSValueNameFxobj[];
45 extern const wchar_t kFXJSValueNameNull[]; 33 extern const wchar_t kFXJSValueNameNull[];
46 extern const wchar_t kFXJSValueNameUndefined[]; 34 extern const wchar_t kFXJSValueNameUndefined[];
47 35
48 // FXJS_V8 places no interpretation on these two classes; it merely 36 // FXJS_V8 places no interpretation on these two classes; it merely
49 // passes them on to the caller-provided LP_CONSTRUCTORs. 37 // passes them on to the caller-provided FXJS_CONSTRUCTORs.
50 class IFXJS_Context; 38 class IFXJS_Context;
51 class IFXJS_Runtime; 39 class IFXJS_Runtime;
52 40
53 class JS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 41 class FXJS_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
54 void* Allocate(size_t length) override; 42 void* Allocate(size_t length) override;
55 void* AllocateUninitialized(size_t length) override; 43 void* AllocateUninitialized(size_t length) override;
56 void Free(void* data, size_t length) override; 44 void Free(void* data, size_t length) override;
57 }; 45 };
58 46
59 typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, 47 using FXJS_CONSTRUCTOR = void (*)(IFXJS_Context* cc,
60 v8::Local<v8::Object> obj, 48 v8::Local<v8::Object> obj,
61 v8::Local<v8::Object> global); 49 v8::Local<v8::Object> global);
62 typedef void (*LP_DESTRUCTOR)(v8::Local<v8::Object> obj); 50 using FXJS_DESTRUCTOR = void (*)(v8::Local<v8::Object> obj);
51
52 // Call before making FXJS_PrepareIsolate call.
53 void FXJS_Initialize(unsigned int embedderDataSlot);
54 void FXJS_Release();
55
56 // Call before making FXJS_Define* calls. Resources allocated here are cleared
57 // as part of FXJS_ReleaseRuntime().
58 void FXJS_PrepareIsolate(v8::Isolate* pIsolate);
63 59
64 // Call before making JS_PrepareIsolate call. 60 // Call before making JS_PrepareIsolate call.
65 void JS_Initialize(unsigned int embedderDataSlot); 61 void JS_Initialize(unsigned int embedderDataSlot);
66 void JS_Release(); 62 void JS_Release();
67 63
68 // Call before making JS_Define* calls. Resources allocated here are cleared 64 // Call before making JS_Define* calls. Resources allocated here are cleared
69 // as part of JS_ReleaseRuntime(). 65 // as part of JS_ReleaseRuntime().
70 void JS_PrepareIsolate(v8::Isolate* pIsolate); 66 void JS_PrepareIsolate(v8::Isolate* pIsolate);
71 67
72 // Always returns a valid, newly-created objDefnID. 68 // Always returns a valid, newly-created objDefnID.
73 int JS_DefineObj(v8::Isolate* pIsolate, 69 int FXJS_DefineObj(v8::Isolate* pIsolate,
74 const wchar_t* sObjName, 70 const wchar_t* sObjName,
75 FXJSOBJTYPE eObjType, 71 FXJSOBJTYPE eObjType,
76 LP_CONSTRUCTOR pConstructor, 72 FXJS_CONSTRUCTOR pConstructor,
77 LP_DESTRUCTOR pDestructor); 73 FXJS_DESTRUCTOR pDestructor);
78 74
79 void JS_DefineObjMethod(v8::Isolate* pIsolate, 75 void FXJS_DefineObjMethod(v8::Isolate* pIsolate,
80 int nObjDefnID,
81 const wchar_t* sMethodName,
82 v8::FunctionCallback pMethodCall);
83 void JS_DefineObjProperty(v8::Isolate* pIsolate,
84 int nObjDefnID, 76 int nObjDefnID,
85 const wchar_t* sPropName, 77 const wchar_t* sMethodName,
86 v8::AccessorGetterCallback pPropGet, 78 v8::FunctionCallback pMethodCall);
87 v8::AccessorSetterCallback pPropPut); 79 void FXJS_DefineObjProperty(v8::Isolate* pIsolate,
88 void JS_DefineObjAllProperties(v8::Isolate* pIsolate, 80 int nObjDefnID,
89 int nObjDefnID, 81 const wchar_t* sPropName,
90 v8::NamedPropertyQueryCallback pPropQurey, 82 v8::AccessorGetterCallback pPropGet,
91 v8::NamedPropertyGetterCallback pPropGet, 83 v8::AccessorSetterCallback pPropPut);
92 v8::NamedPropertySetterCallback pPropPut, 84 void FXJS_DefineObjAllProperties(v8::Isolate* pIsolate,
93 v8::NamedPropertyDeleterCallback pPropDel); 85 int nObjDefnID,
94 void JS_DefineObjConst(v8::Isolate* pIsolate, 86 v8::NamedPropertyQueryCallback pPropQurey,
95 int nObjDefnID, 87 v8::NamedPropertyGetterCallback pPropGet,
96 const wchar_t* sConstName, 88 v8::NamedPropertySetterCallback pPropPut,
97 v8::Local<v8::Value> pDefault); 89 v8::NamedPropertyDeleterCallback pPropDel);
98 void JS_DefineGlobalMethod(v8::Isolate* pIsolate, 90 void FXJS_DefineObjConst(v8::Isolate* pIsolate,
99 const wchar_t* sMethodName, 91 int nObjDefnID,
100 v8::FunctionCallback pMethodCall); 92 const wchar_t* sConstName,
101 void JS_DefineGlobalConst(v8::Isolate* pIsolate, 93 v8::Local<v8::Value> pDefault);
102 const wchar_t* sConstName, 94 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate,
103 v8::Local<v8::Value> pDefault); 95 const wchar_t* sMethodName,
96 v8::FunctionCallback pMethodCall);
97 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate,
98 const wchar_t* sConstName,
99 v8::Local<v8::Value> pDefault);
104 100
105 // Called after JS_Define* calls made. 101 // Called after FXJS_Define* calls made.
106 void JS_InitializeRuntime(v8::Isolate* pIsolate, 102 void FXJS_InitializeRuntime(v8::Isolate* pIsolate,
107 IFXJS_Runtime* pFXRuntime, 103 IFXJS_Runtime* pFXRuntime,
108 IFXJS_Context* context, 104 IFXJS_Context* context,
109 v8::Global<v8::Context>& v8PersistentContext); 105 v8::Global<v8::Context>& v8PersistentContext);
110 void JS_ReleaseRuntime(v8::Isolate* pIsolate, 106 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
111 v8::Global<v8::Context>& v8PersistentContext); 107 v8::Global<v8::Context>& v8PersistentContext);
112 108
113 // Called after JS_InitializeRuntime call made. 109 // Called after FXJS_InitializeRuntime call made.
114 int JS_Execute(v8::Isolate* pIsolate, 110 int FXJS_Execute(v8::Isolate* pIsolate,
115 IFXJS_Context* pJSContext, 111 IFXJS_Context* pJSContext,
116 const wchar_t* script, 112 const wchar_t* script,
117 long length, 113 long length,
118 FXJSErr* perror); 114 FXJSErr* perror);
119 115
120 v8::Local<v8::Object> JS_NewFxDynamicObj(v8::Isolate* pIsolate, 116 v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate,
121 IFXJS_Context* pJSContext, 117 IFXJS_Context* pJSContext,
122 int nObjDefnID); 118 int nObjDefnID);
123 v8::Local<v8::Object> JS_GetStaticObj(v8::Isolate* pIsolate, int nObjDefnID); 119 v8::Local<v8::Object> FXJS_GetStaticObj(v8::Isolate* pIsolate, int nObjDefnID);
124 v8::Local<v8::Object> JS_GetThisObj(v8::Isolate* pIsolate); 120 v8::Local<v8::Object> FXJS_GetThisObj(v8::Isolate* pIsolate);
125 int JS_GetObjDefnID(v8::Local<v8::Object> pObj); 121 int FXJS_GetObjDefnID(v8::Local<v8::Object> pObj);
126 v8::Isolate* JS_GetRuntime(v8::Local<v8::Object> pObj); 122 v8::Isolate* FXJS_GetRuntime(v8::Local<v8::Object> pObj);
127 int JS_GetObjDefnID(v8::Isolate* pIsolate, const wchar_t* pObjName); 123 int FXJS_GetObjDefnID(v8::Isolate* pIsolate, const wchar_t* pObjName);
128 void JS_Error(v8::Isolate* isolate, const CFX_WideString& message); 124 void FXJS_Error(v8::Isolate* isolate, const CFX_WideString& message);
129 unsigned JS_CalcHash(const wchar_t* main, unsigned nLen); 125 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj);
130 unsigned JS_CalcHash(const wchar_t* main); 126 void FXJS_SetPrivate(v8::Isolate* pIsolate,
131 const wchar_t* JS_GetTypeof(v8::Local<v8::Value> pObj); 127 v8::Local<v8::Object> pObj,
132 void JS_SetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj, void* p); 128 void* p);
133 void* JS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj); 129 void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj);
134 void JS_SetPrivate(v8::Local<v8::Object> pObj, void* p); 130 void FXJS_SetPrivate(v8::Local<v8::Object> pObj, void* p);
135 void* JS_GetPrivate(v8::Local<v8::Object> pObj); 131 void* FXJS_GetPrivate(v8::Local<v8::Object> pObj);
136 void JS_FreePrivate(void* p); 132 void FXJS_FreePrivate(void* p);
137 void JS_FreePrivate(v8::Local<v8::Object> pObj); 133 void FXJS_FreePrivate(v8::Local<v8::Object> pObj);
138 v8::Local<v8::Value> JS_GetObjectValue(v8::Local<v8::Object> pObj); 134 v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
139 v8::Local<v8::Value> JS_GetObjectElement(v8::Isolate* pIsolate, 135 const wchar_t* PropertyName,
140 v8::Local<v8::Object> pObj, 136 int Len = -1);
141 const wchar_t* PropertyName); 137 v8::Local<v8::Value> FXJS_GetObjectValue(v8::Local<v8::Object> pObj);
142 v8::Local<v8::Array> JS_GetObjectElementNames(v8::Isolate* pIsolate, 138 v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate,
143 v8::Local<v8::Object> pObj); 139 v8::Local<v8::Object> pObj,
144 void JS_PutObjectString(v8::Isolate* pIsolate, 140 const wchar_t* PropertyName);
141 v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate,
142 v8::Local<v8::Object> pObj);
143 void FXJS_PutObjectString(v8::Isolate* pIsolate,
144 v8::Local<v8::Object> pObj,
145 const wchar_t* PropertyName,
146 const wchar_t* sValue);
147 void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
148 v8::Local<v8::Object> pObj,
149 const wchar_t* PropertyName,
150 int nValue);
151 void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
152 v8::Local<v8::Object> pObj,
153 const wchar_t* PropertyName,
154 float fValue);
155 void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
156 v8::Local<v8::Object> pObj,
157 const wchar_t* PropertyName,
158 double dValue);
159 void FXJS_PutObjectBoolean(v8::Isolate* pIsolate,
160 v8::Local<v8::Object> pObj,
161 const wchar_t* PropertyName,
162 bool bValue);
163 void FXJS_PutObjectObject(v8::Isolate* pIsolate,
164 v8::Local<v8::Object> pObj,
165 const wchar_t* PropertyName,
166 v8::Local<v8::Object> pPut);
167 void FXJS_PutObjectNull(v8::Isolate* pIsolate,
145 v8::Local<v8::Object> pObj, 168 v8::Local<v8::Object> pObj,
146 const wchar_t* PropertyName, 169 const wchar_t* PropertyName);
147 const wchar_t* sValue); 170 unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate,
148 void JS_PutObjectNumber(v8::Isolate* pIsolate, 171 v8::Local<v8::Array> pArray,
149 v8::Local<v8::Object> pObj, 172 unsigned index,
150 const wchar_t* PropertyName, 173 v8::Local<v8::Value> pValue);
151 int nValue); 174 v8::Local<v8::Value> FXJS_GetArrayElement(v8::Isolate* pIsolate,
152 void JS_PutObjectNumber(v8::Isolate* pIsolate, 175 v8::Local<v8::Array> pArray,
153 v8::Local<v8::Object> pObj, 176 unsigned index);
154 const wchar_t* PropertyName, 177 unsigned FXJS_GetArrayLength(v8::Local<v8::Array> pArray);
155 float fValue); 178 v8::Local<v8::Value> FXJS_GetListValue(v8::Isolate* pIsolate,
156 void JS_PutObjectNumber(v8::Isolate* pIsolate, 179 v8::Local<v8::Value> pList,
157 v8::Local<v8::Object> pObj, 180 int index);
158 const wchar_t* PropertyName,
159 double dValue);
160 void JS_PutObjectBoolean(v8::Isolate* pIsolate,
161 v8::Local<v8::Object> pObj,
162 const wchar_t* PropertyName,
163 bool bValue);
164 void JS_PutObjectObject(v8::Isolate* pIsolate,
165 v8::Local<v8::Object> pObj,
166 const wchar_t* PropertyName,
167 v8::Local<v8::Object> pPut);
168 void JS_PutObjectNull(v8::Isolate* pIsolate,
169 v8::Local<v8::Object> pObj,
170 const wchar_t* PropertyName);
171 unsigned JS_PutArrayElement(v8::Isolate* pIsolate,
172 v8::Local<v8::Array> pArray,
173 unsigned index,
174 v8::Local<v8::Value> pValue,
175 FXJSVALUETYPE eType);
176 v8::Local<v8::Value> JS_GetArrayElement(v8::Isolate* pIsolate,
177 v8::Local<v8::Array> pArray,
178 unsigned index);
179 unsigned JS_GetArrayLength(v8::Local<v8::Array> pArray);
180 v8::Local<v8::Value> JS_GetListValue(v8::Isolate* pIsolate,
181 v8::Local<v8::Value> pList,
182 int index);
183 181
184 v8::Local<v8::Array> JS_NewArray(v8::Isolate* pIsolate); 182 v8::Local<v8::Array> FXJS_NewArray(v8::Isolate* pIsolate);
185 v8::Local<v8::Value> JS_NewNumber(v8::Isolate* pIsolate, int number); 183 v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, int number);
186 v8::Local<v8::Value> JS_NewNumber(v8::Isolate* pIsolate, double number); 184 v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, double number);
187 v8::Local<v8::Value> JS_NewNumber(v8::Isolate* pIsolate, float number); 185 v8::Local<v8::Value> FXJS_NewNumber(v8::Isolate* pIsolate, float number);
188 v8::Local<v8::Value> JS_NewBoolean(v8::Isolate* pIsolate, bool b); 186 v8::Local<v8::Value> FXJS_NewBoolean(v8::Isolate* pIsolate, bool b);
189 v8::Local<v8::Value> JS_NewObject(v8::Isolate* pIsolate, 187 v8::Local<v8::Value> FXJS_NewObject(v8::Isolate* pIsolate,
190 v8::Local<v8::Object> pObj); 188 v8::Local<v8::Object> pObj);
191 v8::Local<v8::Value> JS_NewObject2(v8::Isolate* pIsolate, 189 v8::Local<v8::Value> FXJS_NewObject2(v8::Isolate* pIsolate,
192 v8::Local<v8::Array> pObj); 190 v8::Local<v8::Array> pObj);
193 v8::Local<v8::Value> JS_NewString(v8::Isolate* pIsolate, const wchar_t* string); 191 v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate,
194 v8::Local<v8::Value> JS_NewString(v8::Isolate* pIsolate, 192 const wchar_t* string);
195 const wchar_t* string, 193 v8::Local<v8::Value> FXJS_NewString(v8::Isolate* pIsolate,
196 unsigned nLen); 194 const wchar_t* string,
197 v8::Local<v8::Value> JS_NewNull(); 195 unsigned nLen);
198 v8::Local<v8::Value> JS_NewDate(v8::Isolate* pIsolate, double d); 196 v8::Local<v8::Value> FXJS_NewNull();
199 v8::Local<v8::Value> JS_NewValue(v8::Isolate* pIsolate); 197 v8::Local<v8::Value> FXJS_NewDate(v8::Isolate* pIsolate, double d);
198 v8::Local<v8::Value> FXJS_NewValue(v8::Isolate* pIsolate);
200 199
201 int JS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); 200 int FXJS_ToInt32(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
202 bool JS_ToBoolean(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); 201 bool FXJS_ToBoolean(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
203 double JS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); 202 double FXJS_ToNumber(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue);
204 v8::Local<v8::Object> JS_ToObject(v8::Isolate* pIsolate, 203 v8::Local<v8::Object> FXJS_ToObject(v8::Isolate* pIsolate,
204 v8::Local<v8::Value> pValue);
205 CFX_WideString FXJS_ToString(v8::Isolate* pIsolate,
206 v8::Local<v8::Value> pValue);
207 v8::Local<v8::Array> FXJS_ToArray(v8::Isolate* pIsolate,
205 v8::Local<v8::Value> pValue); 208 v8::Local<v8::Value> pValue);
206 CFX_WideString JS_ToString(v8::Isolate* pIsolate, v8::Local<v8::Value> pValue); 209 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
207 v8::Local<v8::Array> JS_ToArray(v8::Isolate* pIsolate,
208 v8::Local<v8::Value> pValue);
209 void JS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
210
211 double JS_GetDateTime();
212 int JS_GetYearFromTime(double dt);
213 int JS_GetMonthFromTime(double dt);
214 int JS_GetDayFromTime(double dt);
215 int JS_GetHourFromTime(double dt);
216 int JS_GetMinFromTime(double dt);
217 int JS_GetSecFromTime(double dt);
218 double JS_DateParse(const wchar_t* string);
219 double JS_MakeDay(int nYear, int nMonth, int nDay);
220 double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
221 double JS_MakeDate(double day, double time);
222 bool JS_PortIsNan(double d);
223 double JS_LocalTime(double d);
224 210
225 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_ 211 #endif // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/javascript/JS_Value.h ('k') | fpdfsdk/src/javascript/Consts.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698