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

Side by Side Diff: fxjs/fxjs_v8.h

Issue 2637503002: Tidy FXJS_V8, backfill tests. (Closed)
Patch Set: rebase Created 3 years, 11 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/javascript/global.cpp ('k') | fxjs/fxjs_v8.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 // 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
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 // Called after FXJS_Define* calls made. 170 // Called after FXJS_Define* calls made.
171 void InitializeEngine(); 171 void InitializeEngine();
172 void ReleaseEngine(); 172 void ReleaseEngine();
173 173
174 // Called after FXJS_InitializeEngine call made. 174 // Called after FXJS_InitializeEngine call made.
175 int Execute(const CFX_WideString& script, FXJSErr* perror); 175 int Execute(const CFX_WideString& script, FXJSErr* perror);
176 176
177 v8::Local<v8::Context> NewLocalContext(); 177 v8::Local<v8::Context> NewLocalContext();
178 v8::Local<v8::Context> GetPersistentContext(); 178 v8::Local<v8::Context> GetPersistentContext();
179 v8::Local<v8::Object> GetThisObj();
179 180
180 v8::Local<v8::Value> NewNull(); 181 v8::Local<v8::Value> NewNull();
181 v8::Local<v8::Array> NewArray(); 182 v8::Local<v8::Array> NewArray();
182 v8::Local<v8::Value> NewNumber(int number); 183 v8::Local<v8::Value> NewNumber(int number);
183 v8::Local<v8::Value> NewNumber(double number); 184 v8::Local<v8::Value> NewNumber(double number);
184 v8::Local<v8::Value> NewNumber(float number); 185 v8::Local<v8::Value> NewNumber(float number);
185 v8::Local<v8::Value> NewBoolean(bool b); 186 v8::Local<v8::Value> NewBoolean(bool b);
186 v8::Local<v8::Value> NewString(const wchar_t* str); 187 v8::Local<v8::Value> NewString(const CFX_WideString& str);
187 v8::Local<v8::Date> NewDate(double d); 188 v8::Local<v8::Date> NewDate(double d);
188 v8::Local<v8::Object> NewFxDynamicObj(int nObjDefnID, bool bStatic = false); 189 v8::Local<v8::Object> NewFxDynamicObj(int nObjDefnID, bool bStatic = false);
189 190
190 v8::Local<v8::Object> GetThisObj();
191 int ToInt32(v8::Local<v8::Value> pValue); 191 int ToInt32(v8::Local<v8::Value> pValue);
192 bool ToBoolean(v8::Local<v8::Value> pValue); 192 bool ToBoolean(v8::Local<v8::Value> pValue);
193 double ToNumber(v8::Local<v8::Value> pValue); 193 double ToDouble(v8::Local<v8::Value> pValue);
194 CFX_WideString ToString(v8::Local<v8::Value> pValue); 194 CFX_WideString ToWideString(v8::Local<v8::Value> pValue);
195 v8::Local<v8::Object> ToObject(v8::Local<v8::Value> pValue); 195 v8::Local<v8::Object> ToObject(v8::Local<v8::Value> pValue);
196 v8::Local<v8::Array> ToArray(v8::Local<v8::Value> pValue); 196 v8::Local<v8::Array> ToArray(v8::Local<v8::Value> pValue);
197 197
198 // Arrays.
198 unsigned GetArrayLength(v8::Local<v8::Array> pArray); 199 unsigned GetArrayLength(v8::Local<v8::Array> pArray);
199 v8::Local<v8::Value> GetArrayElement(v8::Local<v8::Array> pArray, 200 v8::Local<v8::Value> GetArrayElement(v8::Local<v8::Array> pArray,
200 unsigned index); 201 unsigned index);
201 unsigned PutArrayElement(v8::Local<v8::Array> pArray, 202 unsigned PutArrayElement(v8::Local<v8::Array> pArray,
202 unsigned index, 203 unsigned index,
203 v8::Local<v8::Value> pValue); 204 v8::Local<v8::Value> pValue);
204 205
206 // Objects.
205 std::vector<CFX_WideString> GetObjectPropertyNames( 207 std::vector<CFX_WideString> GetObjectPropertyNames(
206 v8::Local<v8::Object> pObj); 208 v8::Local<v8::Object> pObj);
207 v8::Local<v8::Value> GetObjectProperty(v8::Local<v8::Object> pObj, 209 v8::Local<v8::Value> GetObjectProperty(v8::Local<v8::Object> pObj,
208 const CFX_WideString& PropertyName); 210 const CFX_WideString& PropertyName);
209 211 void PutObjectProperty(v8::Local<v8::Object> pObj,
210 void PutObjectString(v8::Local<v8::Object> pObj, 212 const CFX_WideString& PropertyName,
211 const CFX_WideString& wsPropertyName, 213 v8::Local<v8::Value> pValue);
212 const CFX_WideString& wsValue);
213 void PutObjectNumber(v8::Local<v8::Object> pObj,
214 const CFX_WideString& PropertyName,
215 int nValue);
216 void PutObjectNumber(v8::Local<v8::Object> pObj,
217 const CFX_WideString& PropertyName,
218 float fValue);
219 void PutObjectNumber(v8::Local<v8::Object> pObj,
220 const CFX_WideString& PropertyName,
221 double dValue);
222 void PutObjectBoolean(v8::Local<v8::Object> pObj,
223 const CFX_WideString& PropertyName,
224 bool bValue);
225 void PutObjectObject(v8::Local<v8::Object> pObj,
226 const CFX_WideString& PropertyName,
227 v8::Local<v8::Object> pPut);
228 void PutObjectNull(v8::Local<v8::Object> pObj,
229 const CFX_WideString& PropertyName);
230 214
231 // Native object binding. 215 // Native object binding.
232 void SetObjectPrivate(v8::Local<v8::Object> pObj, void* p); 216 void SetObjectPrivate(v8::Local<v8::Object> pObj, void* p);
233 void* GetObjectPrivate(v8::Local<v8::Object> pObj); 217 void* GetObjectPrivate(v8::Local<v8::Object> pObj);
234 static void FreeObjectPrivate(void* p); 218 static void FreeObjectPrivate(void* p);
235 static void FreeObjectPrivate(v8::Local<v8::Object> pObj); 219 static void FreeObjectPrivate(v8::Local<v8::Object> pObj);
236 220
237 void SetConstArray(const CFX_WideString& name, v8::Local<v8::Array> array); 221 void SetConstArray(const CFX_WideString& name, v8::Local<v8::Array> array);
238 v8::Local<v8::Array> GetConstArray(const CFX_WideString& name); 222 v8::Local<v8::Array> GetConstArray(const CFX_WideString& name);
239 223
240 v8::Local<v8::String> WSToJSString(const CFX_WideString& wsPropertyName); 224 v8::Local<v8::String> WSToJSString(const CFX_WideString& wsPropertyName);
241 void Error(const CFX_WideString& message); 225 void Error(const CFX_WideString& message);
242 226
243 protected: 227 protected:
244 CFXJS_Engine(); 228 CFXJS_Engine();
245 229
246 void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; } 230 void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; }
247 231
248 private: 232 private:
249 v8::Isolate* m_isolate; 233 v8::Isolate* m_isolate;
250 v8::Global<v8::Context> m_V8PersistentContext; 234 v8::Global<v8::Context> m_V8PersistentContext;
251 std::vector<v8::Global<v8::Object>*> m_StaticObjects; 235 std::vector<v8::Global<v8::Object>*> m_StaticObjects;
252 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays; 236 std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays;
253 }; 237 };
254 238
255 #endif // FXJS_FXJS_V8_H_ 239 #endif // FXJS_FXJS_V8_H_
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/global.cpp ('k') | fxjs/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698