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

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

Issue 453133004: clang-format all code (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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
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 #ifndef FXJSAPI_H 7 #ifndef FXJSAPI_H
8 #define FXJSAPI_H 8 #define FXJSAPI_H
9 9
10 #include <v8.h> 10 #include <v8.h>
11 11
12 enum FXJSOBJTYPE 12 enum FXJSOBJTYPE {
13 { 13 JS_DYNAMIC = 0,
14 » JS_DYNAMIC = 0, 14 JS_STATIC = 1,
15 » JS_STATIC = 1,
16 }; 15 };
17 16
18 enum FXJSVALUETYPE 17 enum FXJSVALUETYPE {
19 { 18 VT_unknown,
20 » VT_unknown, 19 VT_string,
21 » VT_string, 20 VT_number,
22 » VT_number, 21 VT_boolean,
23 » VT_boolean, 22 VT_date,
24 » VT_date, 23 VT_object,
25 » VT_object, 24 VT_fxobject,
26 » VT_fxobject, 25 VT_null,
27 » VT_null, 26 VT_undefined
28 » VT_undefined
29 }; 27 };
30 28
31 struct FXJSErr 29 struct FXJSErr {
32 { 30 const wchar_t* message;
33 » const wchar_t* message;» 31 const wchar_t* srcline;
34 const wchar_t* srcline;» 32 unsigned linnum;
35 unsigned linnum;
36 }; 33 };
37 34
38 /* --------------------------------------------- API --------------------------- ------------------ */ 35 /* --------------------------------------------- API
36 * --------------------------------------------- */
39 37
40 typedef v8::Isolate IJS_Runtime; 38 typedef v8::Isolate IJS_Runtime;
41 class IFXJS_Context; 39 class IFXJS_Context;
42 class IFXJS_Runtime; 40 class IFXJS_Runtime;
43 41
44
45 #ifndef JSCRIPT_ARGS 42 #ifndef JSCRIPT_ARGS
46 #define JSCRIPT_ARGS 43 #define JSCRIPT_ARGS
47 44
48 #define JS_PROPGET_ARGS»» » v8::Local<v8::String> property,const v8: :PropertyCallbackInfo<v8::Value>& info 45 #define JS_PROPGET_ARGS \
49 #define JS_PROPPUT_ARGS»» » v8::Local<v8::String> property,v8::Local <v8::Value> value,const v8::PropertyCallbackInfo<void>& info 46 v8::Local<v8::String> property, \
50 #define JS_METHOD_ARGS» » » const v8::FunctionCallbackInfo<v8::Value >& info 47 const v8::PropertyCallbackInfo<v8::Value>& info
51 #define JS_CONSTRUCTOR_ARGS» » IFXJS_Context* cc, v8::Handle<v8::Object > obj, v8::Handle<v8::Object> global 48 #define JS_PROPPUT_ARGS \
52 #define JS_DESTRUCTOR_ARGS» » v8::Handle<v8::Object> obj 49 v8::Local<v8::String> property, v8::Local<v8::Value> value, \
53 50 const v8::PropertyCallbackInfo<void>& info
54 #define JS_PROPQUERY_ARGS» » v8::Local<v8::String> property,const v8: :PropertyCallbackInfo<v8::Integer>& info 51 #define JS_METHOD_ARGS const v8::FunctionCallbackInfo<v8::Value>& info
55 #define JS_NAMED_PROPGET_ARGS» JS_PROPGET_ARGS»» » » » 52 #define JS_CONSTRUCTOR_ARGS \
56 #define JS_NAMED_PROPPUT_ARGS» v8::Local<v8::String> property,v8::Local<v8::Val ue> value,const v8::PropertyCallbackInfo<v8::Value>& info 53 IFXJS_Context* cc, v8::Handle<v8::Object> obj, v8::Handle<v8::Object> global
57 #define JS_PROPDEL_ARGS»» » v8::Local<v8::String> property,const v8: :PropertyCallbackInfo<v8::Boolean>& info 54 #define JS_DESTRUCTOR_ARGS v8::Handle<v8::Object> obj
55
56 #define JS_PROPQUERY_ARGS \
57 v8::Local<v8::String> property, \
58 const v8::PropertyCallbackInfo<v8::Integer>& info
59 #define JS_NAMED_PROPGET_ARGS JS_PROPGET_ARGS
60 #define JS_NAMED_PROPPUT_ARGS \
61 v8::Local<v8::String> property, v8::Local<v8::Value> value, \
62 const v8::PropertyCallbackInfo<v8::Value>& info
63 #define JS_PROPDEL_ARGS \
64 v8::Local<v8::String> property, \
65 const v8::PropertyCallbackInfo<v8::Boolean>& info
58 66
59 typedef unsigned (*LP_CONSTRUCTOR)(JS_CONSTRUCTOR_ARGS); 67 typedef unsigned (*LP_CONSTRUCTOR)(JS_CONSTRUCTOR_ARGS);
60 typedef unsigned (*LP_DESTRUCTOR)(JS_DESTRUCTOR_ARGS); 68 typedef unsigned (*LP_DESTRUCTOR)(JS_DESTRUCTOR_ARGS);
61 69
62 #endif 70 #endif
63 71
64 int JS_DefineObj(IJS _Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUC TOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew); 72 int JS_DefineObj(IJS_Runtime* pJSRuntime,
65 int JS_DefineObjMeth od(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::Func tionCallback pMethodCall, unsigned nParamNum); 73 const wchar_t* sObjName,
66 int JS_DefineObjProp erty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::Acce ssorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut); 74 FXJSOBJTYPE eObjType,
67 int JS_DefineObjAllP roperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallbac k pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterC allback pPropPut, v8::NamedPropertyDeleterCallback pPropDel); 75 LP_CONSTRUCTOR pConstructor,
68 int JS_DefineObjCons t(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Handle <v8::Value> pDefault); 76 LP_DESTRUCTOR pDestructor,
69 int JS_DefineGlobalM ethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall, unsigned nParamNum); 77 unsigned bApplyNew);
70 int JS_DefineGlobalC onst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Handle<v8::Value> p Default); 78 int JS_DefineObjMethod(IJS_Runtime* pJSRuntime,
71 79 int nObjDefnID,
72 void JS_InitialRuntime(IJS_Ru ntime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Persist ent<v8::Context>& v8PersistentContext); 80 const wchar_t* sMethodName,
73 void JS_ReleaseRuntime(IJS_Ru ntime* pJSRuntime, v8::Persistent<v8::Context>& v8PersistentContext); 81 v8::FunctionCallback pMethodCall,
74 void JS_Initial(); 82 unsigned nParamNum);
75 void JS_Release(); 83 int JS_DefineObjProperty(IJS_Runtime* pJSRuntime,
76 int JS_Parse(IJS_Run time* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror); 84 int nObjDefnID,
77 int JS_Execute(IJS_R untime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long lengt h, FXJSErr* perror); 85 const wchar_t* sPropName,
78 v8::Handle<v8::Object> JS_NewFxDynamicObj(IJS_Runtime* pJSRunti me, IFXJS_Context* pJSContext, int nObjDefnID); 86 v8::AccessorGetterCallback pPropGet,
79 v8::Handle<v8::Object> JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID); 87 v8::AccessorSetterCallback pPropPut);
80 void JS_SetThisObj(IJS_Runtim e* pJSRuntime, int nThisObjID); 88 int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime,
81 v8::Handle<v8::Object> JS_GetThisObj(IJS_Runtime * pJSRuntime); 89 int nObjDefnID,
82 int JS_GetObjDefnID( v8::Handle<v8::Object> pObj); 90 v8::NamedPropertyQueryCallback pPropQurey,
83 IJS_Runtime* JS_GetRuntime(v8::Handle<v8::Obj ect> pObj); 91 v8::NamedPropertyGetterCallback pPropGet,
84 int JS_GetObjDefnID( IJS_Runtime * pJSRuntime, const wchar_t* pObjName); 92 v8::NamedPropertySetterCallback pPropPut,
85 void JS_Error(v8::Value * pEr ror,const wchar_t * main,const wchar_t * sub); 93 v8::NamedPropertyDeleterCallback pPropDel);
86 unsigned JS_CalcHash(const wchar_ t* main, unsigned nLen); 94 int JS_DefineObjConst(IJS_Runtime* pJSRuntime,
87 unsigned JS_CalcHash(const wchar_ t* main); 95 int nObjDefnID,
88 const wchar_t* JS_GetTypeof(v8::Handle<v8::Valu e> pObj); 96 const wchar_t* sConstName,
89 const wchar_t* JS_GetClassname(v8::Handle<v8::O bject> pObj); 97 v8::Handle<v8::Value> pDefault);
90 void JS_SetPrivate(IJS_Runtim e* pJSRuntime, v8::Handle<v8::Object> pObj, void* p); 98 int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime,
91 void* JS_GetPrivate(IJS_Runtim e* pJSRuntime, v8::Handle<v8::Object> pObj); 99 const wchar_t* sMethodName,
92 void JS_SetPrivate(v8::Handle <v8::Object> pObj, void* p); 100 v8::FunctionCallback pMethodCall,
93 void* JS_GetPrivate(v8::Handle <v8::Object> pObj); 101 unsigned nParamNum);
94 void JS_FreePrivate(v8::Handl e<v8::Object> pObj); 102 int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime,
95 v8::Handle<v8::Value> JS_GetObjectValue(v8::Handle<v8::Object> pObj); 103 const wchar_t* sConstName,
96 v8::Handle<v8::Value> JS_GetObjectElement(IJS_Runtime* pJSRunt ime, v8::Handle<v8::Object> pObj,const wchar_t* PropertyName); 104 v8::Handle<v8::Value> pDefault);
97 v8::Handle<v8::Array> JS_GetObjectElementNames(v8::Handle<v8:: Object> pObj); 105
98 void JS_PutObjectString(IJS_R untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, con st wchar_t* sValue); 106 void JS_InitialRuntime(IJS_Runtime* pJSRuntime,
99 void JS_PutObjectNumber(IJS_R untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, int nValue); 107 IFXJS_Runtime* pFXRuntime,
100 void JS_PutObjectNumber(IJS_R untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, flo at fValue); 108 IFXJS_Context* context,
101 void JS_PutObjectNumber(IJS_R untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, dou ble dValue); 109 v8::Persistent<v8::Context>& v8PersistentContext);
102 void JS_PutObjectBoolean(IJS_ Runtime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, bo ol bValue); 110 void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime,
103 void JS_PutObjectObject(IJS_R untime* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName, v8: :Handle<v8::Object> pPut); 111 v8::Persistent<v8::Context>& v8PersistentContext);
104 void JS_PutObjectNull(IJS_Run time* pJSRuntime,v8::Handle<v8::Object> pObj, const wchar_t* PropertyName); 112 void JS_Initial();
105 unsigned JS_PutArrayElement(v8::H andle<v8::Array> pArray,unsigned index,v8::Handle<v8::Value> pValue,FXJSVALUETYP E eType); 113 void JS_Release();
106 v8::Handle<v8::Value> JS_GetArrayElemnet(v8::Handle<v8::Array> pArray,unsigned index); 114 int JS_Parse(IJS_Runtime* pJSRuntime,
107 unsigned JS_GetArrayLength(v8::Ha ndle<v8::Array> pArray); 115 IFXJS_Context* pJSContext,
108 v8::Handle<v8::Value> JS_GetListValue(v8::Handle<v8::Value> pL ist, int index); 116 const wchar_t* script,
109 117 long length,
110 118 FXJSErr* perror);
111 v8::Handle<v8::Array> JS_NewArray(IJS_Runtime* pJSRuntime); 119 int JS_Execute(IJS_Runtime* pJSRuntime,
112 v8::Handle<v8::Value> JS_NewNumber(IJS_Runtime* pJSRuntime,int number); 120 IFXJS_Context* pJSContext,
113 v8::Handle<v8::Value> JS_NewNumber(IJS_Runtime* pJSRuntime,dou ble number); 121 const wchar_t* script,
114 v8::Handle<v8::Value> JS_NewNumber(IJS_Runtime* pJSRuntime,flo at number); 122 long length,
115 v8::Handle<v8::Value> JS_NewBoolean(IJS_Runtime* pJSRuntime,bo ol b); 123 FXJSErr* perror);
116 v8::Handle<v8::Value> JS_NewObject(IJS_Runtime* pJSRuntime,v8: :Handle<v8::Object> pObj); 124 v8::Handle<v8::Object> JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime,
117 v8::Handle<v8::Value> JS_NewObject2(IJS_Runtime* pJSRuntime,v8 ::Handle<v8::Array> pObj); 125 IFXJS_Context* pJSContext,
118 v8::Handle<v8::Value> JS_NewString(IJS_Runtime* pJSRuntime,con st wchar_t* string); 126 int nObjDefnID);
119 v8::Handle<v8::Value> JS_NewString(IJS_Runtime* pJSRuntime,con st wchar_t* string, unsigned nLen); 127 v8::Handle<v8::Object> JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID);
120 v8::Handle<v8::Value> JS_NewNull(); 128 void JS_SetThisObj(IJS_Runtime* pJSRuntime, int nThisObjID);
121 v8::Handle<v8::Value> JS_NewDate(IJS_Runtime* pJSRuntime,doubl e d); 129 v8::Handle<v8::Object> JS_GetThisObj(IJS_Runtime* pJSRuntime);
122 v8::Handle<v8::Value> JS_NewValue(IJS_Runtime* pJSRuntime); 130 int JS_GetObjDefnID(v8::Handle<v8::Object> pObj);
123 131 IJS_Runtime* JS_GetRuntime(v8::Handle<v8::Object> pObj);
124 132 int JS_GetObjDefnID(IJS_Runtime* pJSRuntime, const wchar_t* pObjName);
125 int JS_ToInt32(v8::H andle<v8::Value> pValue); 133 void JS_Error(v8::Value* pError, const wchar_t* main, const wchar_t* sub);
126 bool JS_ToBoolean(v8::Handle< v8::Value> pValue); 134 unsigned JS_CalcHash(const wchar_t* main, unsigned nLen);
127 double JS_ToNumber(v8::Handle<v 8::Value> pValue); 135 unsigned JS_CalcHash(const wchar_t* main);
128 v8::Handle<v8::Object> JS_ToObject(v8::Handle<v8::Value> pValue ); 136 const wchar_t* JS_GetTypeof(v8::Handle<v8::Value> pObj);
129 CFX_WideString JS_ToString(v8::Handle<v8::Value > pValue); 137 const wchar_t* JS_GetClassname(v8::Handle<v8::Object> pObj);
130 v8::Handle<v8::Array> JS_ToArray(v8::Handle<v8::Value> pValue) ; 138 void JS_SetPrivate(IJS_Runtime* pJSRuntime,
131 void JS_ValueCopy(v8::Handle< v8::Value>& pTo, v8::Handle<v8::Value> pFrom); 139 v8::Handle<v8::Object> pObj,
132 140 void* p);
133 double JS_GetDateTime(); 141 void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Handle<v8::Object> pObj);
134 int JS_GetYearFromTi me(double dt); 142 void JS_SetPrivate(v8::Handle<v8::Object> pObj, void* p);
135 int JS_GetMonthFromT ime(double dt); 143 void* JS_GetPrivate(v8::Handle<v8::Object> pObj);
136 int JS_GetDayFromTim e(double dt); 144 void JS_FreePrivate(v8::Handle<v8::Object> pObj);
137 int JS_GetHourFromTi me(double dt); 145 v8::Handle<v8::Value> JS_GetObjectValue(v8::Handle<v8::Object> pObj);
138 int JS_GetMinFromTim e(double dt); 146 v8::Handle<v8::Value> JS_GetObjectElement(IJS_Runtime* pJSRuntime,
139 int JS_GetSecFromTim e(double dt); 147 v8::Handle<v8::Object> pObj,
140 double JS_DateParse(const wchar _t* string); 148 const wchar_t* PropertyName);
141 double JS_MakeDay(int nYear, in t nMonth, int nDay); 149 v8::Handle<v8::Array> JS_GetObjectElementNames(v8::Handle<v8::Object> pObj);
142 double JS_MakeTime(int nHour, i nt nMin, int nSec, int nMs); 150 void JS_PutObjectString(IJS_Runtime* pJSRuntime,
143 double JS_MakeDate(double day, double time); 151 v8::Handle<v8::Object> pObj,
144 bool JS_PortIsNan(double d); 152 const wchar_t* PropertyName,
145 double JS_LocalTime(double d); 153 const wchar_t* sValue);
146 154 void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,
147 #endif //FXJSAPI_H 155 v8::Handle<v8::Object> pObj,
156 const wchar_t* PropertyName,
157 int nValue);
158 void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,
159 v8::Handle<v8::Object> pObj,
160 const wchar_t* PropertyName,
161 float fValue);
162 void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,
163 v8::Handle<v8::Object> pObj,
164 const wchar_t* PropertyName,
165 double dValue);
166 void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,
167 v8::Handle<v8::Object> pObj,
168 const wchar_t* PropertyName,
169 bool bValue);
170 void JS_PutObjectObject(IJS_Runtime* pJSRuntime,
171 v8::Handle<v8::Object> pObj,
172 const wchar_t* PropertyName,
173 v8::Handle<v8::Object> pPut);
174 void JS_PutObjectNull(IJS_Runtime* pJSRuntime,
175 v8::Handle<v8::Object> pObj,
176 const wchar_t* PropertyName);
177 unsigned JS_PutArrayElement(v8::Handle<v8::Array> pArray,
178 unsigned index,
179 v8::Handle<v8::Value> pValue,
180 FXJSVALUETYPE eType);
181 v8::Handle<v8::Value> JS_GetArrayElemnet(v8::Handle<v8::Array> pArray,
182 unsigned index);
183 unsigned JS_GetArrayLength(v8::Handle<v8::Array> pArray);
184 v8::Handle<v8::Value> JS_GetListValue(v8::Handle<v8::Value> pList, int index);
185
186 v8::Handle<v8::Array> JS_NewArray(IJS_Runtime* pJSRuntime);
187 v8::Handle<v8::Value> JS_NewNumber(IJS_Runtime* pJSRuntime, int number);
188 v8::Handle<v8::Value> JS_NewNumber(IJS_Runtime* pJSRuntime, double number);
189 v8::Handle<v8::Value> JS_NewNumber(IJS_Runtime* pJSRuntime, float number);
190 v8::Handle<v8::Value> JS_NewBoolean(IJS_Runtime* pJSRuntime, bool b);
191 v8::Handle<v8::Value> JS_NewObject(IJS_Runtime* pJSRuntime,
192 v8::Handle<v8::Object> pObj);
193 v8::Handle<v8::Value> JS_NewObject2(IJS_Runtime* pJSRuntime,
194 v8::Handle<v8::Array> pObj);
195 v8::Handle<v8::Value> JS_NewString(IJS_Runtime* pJSRuntime,
196 const wchar_t* string);
197 v8::Handle<v8::Value> JS_NewString(IJS_Runtime* pJSRuntime,
198 const wchar_t* string,
199 unsigned nLen);
200 v8::Handle<v8::Value> JS_NewNull();
201 v8::Handle<v8::Value> JS_NewDate(IJS_Runtime* pJSRuntime, double d);
202 v8::Handle<v8::Value> JS_NewValue(IJS_Runtime* pJSRuntime);
203
204 int JS_ToInt32(v8::Handle<v8::Value> pValue);
205 bool JS_ToBoolean(v8::Handle<v8::Value> pValue);
206 double JS_ToNumber(v8::Handle<v8::Value> pValue);
207 v8::Handle<v8::Object> JS_ToObject(v8::Handle<v8::Value> pValue);
208 CFX_WideString JS_ToString(v8::Handle<v8::Value> pValue);
209 v8::Handle<v8::Array> JS_ToArray(v8::Handle<v8::Value> pValue);
210 void JS_ValueCopy(v8::Handle<v8::Value>& pTo, v8::Handle<v8::Value> pFrom);
211
212 double JS_GetDateTime();
213 int JS_GetYearFromTime(double dt);
214 int JS_GetMonthFromTime(double dt);
215 int JS_GetDayFromTime(double dt);
216 int JS_GetHourFromTime(double dt);
217 int JS_GetMinFromTime(double dt);
218 int JS_GetSecFromTime(double dt);
219 double JS_DateParse(const wchar_t* string);
220 double JS_MakeDay(int nYear, int nMonth, int nDay);
221 double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
222 double JS_MakeDate(double day, double time);
223 bool JS_PortIsNan(double d);
224 double JS_LocalTime(double d);
225
226 #endif // FXJSAPI_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698