Remove dead code found by Scythe.
[pdfium.git] / fpdfsdk / include / jsapi / fxjs_v8.h
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 // PDFium wrapper around V8 APIs. PDFium code should include this file rather
8 // than including V8 headers directly.
9
10 #ifndef FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
11 #define FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_
12
13 #include <v8.h>
14 #include "../../../core/include/fxcrt/fx_string.h"  // For CFX_WideString
15
16 typedef v8::Value                       JSValue;
17 typedef v8::Local<v8::Object>   JSObject;
18 typedef v8::Local<v8::Object>   JSFXObject;
19
20 enum FXJSOBJTYPE
21 {
22         JS_DYNAMIC = 0,
23         JS_STATIC = 1,
24 };
25
26 enum FXJSVALUETYPE
27 {
28         VT_unknown,
29         VT_string,
30         VT_number,
31         VT_boolean,
32         VT_date,
33         VT_object,
34         VT_fxobject,
35         VT_null,
36         VT_undefined
37 };
38
39 struct FXJSErr
40 {
41         const wchar_t* message;
42     const wchar_t* srcline;
43     unsigned linnum;
44 };
45
46 /* --------------------------------------------- API --------------------------------------------- */
47
48 typedef v8::Isolate IJS_Runtime;
49 class IFXJS_Context;
50 class IFXJS_Runtime;
51
52 typedef void (*LP_CONSTRUCTOR)(IFXJS_Context* cc, v8::Local<v8::Object> obj, v8::Local<v8::Object> global);
53 typedef void (*LP_DESTRUCTOR)(v8::Local<v8::Object> obj);
54
55
56 int                                                             JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor);
57 int                                                             JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall);
58 int                                                             JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut);
59 int                                                             JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallback pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterCallback pPropPut, v8::NamedPropertyDeleterCallback pPropDel);
60 int                                                             JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Local<v8::Value> pDefault);
61 int                                                             JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall);
62 int                                                             JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Local<v8::Value> pDefault);
63
64 void                                                    JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Global<v8::Context>& v8PersistentContext);
65 void                                                    JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Global<v8::Context>& v8PersistentContext);
66 void                                                    JS_Initial(unsigned int embedderDataSlot);
67 void                                                    JS_Release();
68 int                                                             JS_Parse(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror);
69 int                                                             JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror);
70 v8::Local<v8::Object>                   JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID);
71 v8::Local<v8::Object>                   JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID);
72 void                                                    JS_SetThisObj(IJS_Runtime* pJSRuntime, int nThisObjID);
73 v8::Local<v8::Object>                   JS_GetThisObj(IJS_Runtime * pJSRuntime);
74 int                                                             JS_GetObjDefnID(v8::Local<v8::Object> pObj);
75 IJS_Runtime*                                    JS_GetRuntime(v8::Local<v8::Object> pObj);
76 int                                                             JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName);
77 void                                                    JS_Error(v8::Isolate* isolate, const CFX_WideString& message);
78 unsigned                                                JS_CalcHash(const wchar_t* main, unsigned nLen);
79 unsigned                                                JS_CalcHash(const wchar_t* main);
80 const wchar_t*                                  JS_GetTypeof(v8::Local<v8::Value> pObj);
81 void                                                    JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Local<v8::Object> pObj, void* p);
82 void*                                                   JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Local<v8::Object> pObj);
83 void                                                    JS_SetPrivate(v8::Local<v8::Object> pObj, void* p);
84 void*                                                   JS_GetPrivate(v8::Local<v8::Object> pObj);
85 void                                                    JS_FreePrivate(void* p);
86 void                                                    JS_FreePrivate(v8::Local<v8::Object> pObj);
87 v8::Local<v8::Value>                    JS_GetObjectValue(v8::Local<v8::Object> pObj);
88 v8::Local<v8::Value>                    JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Local<v8::Object> pObj,const wchar_t* PropertyName);
89 v8::Local<v8::Array>                    JS_GetObjectElementNames(IJS_Runtime* pJSRuntime, v8::Local<v8::Object> pObj);
90 void                                                    JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, const wchar_t* sValue);
91 void                                                    JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, int nValue);
92 void                                                    JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, float fValue);
93 void                                                    JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, double dValue);
94 void                                                    JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, bool bValue);
95 void                                                    JS_PutObjectObject(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName, v8::Local<v8::Object> pPut);
96 void                                                    JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj, const wchar_t* PropertyName);
97 unsigned                                                JS_PutArrayElement(IJS_Runtime* pJSRuntime, v8::Local<v8::Array> pArray,unsigned index,v8::Local<v8::Value> pValue,FXJSVALUETYPE eType);
98 v8::Local<v8::Value>                    JS_GetArrayElement(IJS_Runtime* pJSRuntime, v8::Local<v8::Array> pArray,unsigned index);
99 unsigned                                                JS_GetArrayLength(v8::Local<v8::Array> pArray);
100 v8::Local<v8::Value>                    JS_GetListValue(IJS_Runtime* pJSRuntime, v8::Local<v8::Value> pList, int index);
101
102
103 v8::Local<v8::Array>                    JS_NewArray(IJS_Runtime* pJSRuntime);
104 v8::Local<v8::Value>                    JS_NewNumber(IJS_Runtime* pJSRuntime,int number);
105 v8::Local<v8::Value>                    JS_NewNumber(IJS_Runtime* pJSRuntime,double number);
106 v8::Local<v8::Value>                    JS_NewNumber(IJS_Runtime* pJSRuntime,float number);
107 v8::Local<v8::Value>                    JS_NewBoolean(IJS_Runtime* pJSRuntime,bool b);
108 v8::Local<v8::Value>                    JS_NewObject(IJS_Runtime* pJSRuntime,v8::Local<v8::Object> pObj);
109 v8::Local<v8::Value>                    JS_NewObject2(IJS_Runtime* pJSRuntime,v8::Local<v8::Array> pObj);
110 v8::Local<v8::Value>                    JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string);
111 v8::Local<v8::Value>                    JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen);
112 v8::Local<v8::Value>                    JS_NewNull();
113 v8::Local<v8::Value>                    JS_NewDate(IJS_Runtime* pJSRuntime,double d);
114 v8::Local<v8::Value>                    JS_NewValue(IJS_Runtime* pJSRuntime);
115
116
117 int                                                             JS_ToInt32(IJS_Runtime* pJSRuntime, v8::Local<v8::Value> pValue);
118 bool                                                    JS_ToBoolean(IJS_Runtime* pJSRuntime, v8::Local<v8::Value> pValue);
119 double                                                  JS_ToNumber(IJS_Runtime* pJSRuntime, v8::Local<v8::Value> pValue);
120 v8::Local<v8::Object>                   JS_ToObject(IJS_Runtime* pJSRuntime, v8::Local<v8::Value> pValue);
121 CFX_WideString                                  JS_ToString(IJS_Runtime* pJSRuntime, v8::Local<v8::Value> pValue);
122 v8::Local<v8::Array>                    JS_ToArray(IJS_Runtime* pJSRuntime, v8::Local<v8::Value> pValue);
123 void                                                    JS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom);
124
125 double                                                  JS_GetDateTime();
126 int                                                             JS_GetYearFromTime(double dt);
127 int                                                             JS_GetMonthFromTime(double dt);
128 int                                                             JS_GetDayFromTime(double dt);
129 int                                                             JS_GetHourFromTime(double dt);
130 int                                                             JS_GetMinFromTime(double dt);
131 int                                                             JS_GetSecFromTime(double dt);
132 double                                                  JS_DateParse(const wchar_t* string);
133 double                                                  JS_MakeDay(int nYear, int nMonth, int nDay);
134 double                                                  JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
135 double                                                  JS_MakeDate(double day, double time);
136 bool                                                    JS_PortIsNan(double d);
137 double                                                  JS_LocalTime(double d);
138
139 #endif  // FPDFSDK_INCLUDE_JSAPI_FXJS_V8_H_