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

Side by Side Diff: fpdfsdk/src/javascript/JS_Value.h

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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/src/javascript/JS_Runtime_Stub.cpp ('k') | fpdfsdk/src/javascript/JS_Value.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #ifndef FPDFSDK_SRC_JAVASCRIPT_JS_VALUE_H_
8 #define FPDFSDK_SRC_JAVASCRIPT_JS_VALUE_H_
9
10 #include <vector>
11
12 #include "core/include/fxcrt/fx_basic.h"
13 #include "fpdfsdk/include/jsapi/fxjs_v8.h"
14
15 class CJS_Array;
16 class CJS_Date;
17 class CJS_Document;
18 class CJS_Object;
19 class CJS_Runtime;
20
21 class CJS_Value {
22 public:
23 enum Type {
24 VT_unknown,
25 VT_string,
26 VT_number,
27 VT_boolean,
28 VT_date,
29 VT_object,
30 VT_fxobject,
31 VT_null,
32 VT_undefined
33 };
34
35 CJS_Value(CJS_Runtime* pRuntime);
36 CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue, Type t);
37 CJS_Value(CJS_Runtime* pRuntime, const int& iValue);
38 CJS_Value(CJS_Runtime* pRuntime, const double& dValue);
39 CJS_Value(CJS_Runtime* pRuntime, const float& fValue);
40 CJS_Value(CJS_Runtime* pRuntime, const bool& bValue);
41 CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Object>);
42 CJS_Value(CJS_Runtime* pRuntime, CJS_Object*);
43 CJS_Value(CJS_Runtime* pRuntime, CJS_Document*);
44 CJS_Value(CJS_Runtime* pRuntime, const FX_CHAR* pStr);
45 CJS_Value(CJS_Runtime* pRuntime, const FX_WCHAR* pWstr);
46 CJS_Value(CJS_Runtime* pRuntime, CJS_Array& array);
47
48 ~CJS_Value();
49
50 void SetNull();
51 void Attach(v8::Local<v8::Value> pValue, Type t);
52 void Attach(CJS_Value* pValue);
53 void Detach();
54
55 Type GetType() const;
56 int ToInt() const;
57 bool ToBool() const;
58 double ToDouble() const;
59 float ToFloat() const;
60 CJS_Object* ToCJSObject() const;
61 CFX_WideString ToCFXWideString() const;
62 CFX_ByteString ToCFXByteString() const;
63 v8::Local<v8::Object> ToV8Object() const;
64 v8::Local<v8::Array> ToV8Array() const;
65 v8::Local<v8::Value> ToV8Value() const;
66
67 // Replace the current |m_pValue| with a v8::Number if possible
68 // to make one from the current |m_pValue|, updating |m_eType|
69 // as appropriate to indicate the result.
70 void MaybeCoerceToNumber();
71
72 void operator=(int iValue);
73 void operator=(bool bValue);
74 void operator=(double val);
75 void operator=(float val);
76 void operator=(CJS_Object* val);
77 void operator=(CJS_Document* val);
78 void operator=(v8::Local<v8::Object> val);
79 void operator=(CJS_Array& val);
80 void operator=(CJS_Date& val);
81 void operator=(const FX_WCHAR* pWstr);
82 void operator=(const FX_CHAR* pStr);
83 void operator=(CJS_Value value);
84
85 FX_BOOL IsArrayObject() const;
86 FX_BOOL IsDateObject() const;
87 FX_BOOL ConvertToArray(CJS_Array&) const;
88 FX_BOOL ConvertToDate(CJS_Date&) const;
89
90 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; }
91
92 protected:
93 Type m_eType;
94 v8::Local<v8::Value> m_pValue;
95 CJS_Runtime* m_pJSRuntime;
96 };
97
98 class CJS_PropValue : public CJS_Value {
99 public:
100 CJS_PropValue(const CJS_Value&);
101 CJS_PropValue(CJS_Runtime* pRuntime);
102 ~CJS_PropValue();
103
104 FX_BOOL IsSetting() const { return m_bIsSetting; }
105 FX_BOOL IsGetting() const { return !m_bIsSetting; }
106
107 void operator<<(int val);
108 void operator>>(int&) const;
109 void operator<<(bool val);
110 void operator>>(bool&) const;
111 void operator<<(double val);
112 void operator>>(double&) const;
113 void operator<<(CJS_Object* pObj);
114 void operator>>(CJS_Object*& ppObj) const;
115 void operator<<(CJS_Document* pJsDoc);
116 void operator>>(CJS_Document*& ppJsDoc) const;
117 void operator<<(CFX_ByteString);
118 void operator>>(CFX_ByteString&) const;
119 void operator<<(CFX_WideString);
120 void operator>>(CFX_WideString&) const;
121 void operator<<(const FX_WCHAR* c_string);
122 void operator<<(v8::Local<v8::Object>);
123 void operator>>(v8::Local<v8::Object>&) const;
124 void operator>>(CJS_Array& array) const;
125 void operator<<(CJS_Array& array);
126 void operator<<(CJS_Date& date);
127 void operator>>(CJS_Date& date) const;
128 operator v8::Local<v8::Value>() const;
129 void StartSetting();
130 void StartGetting();
131
132 private:
133 FX_BOOL m_bIsSetting;
134 };
135
136 class CJS_Array {
137 public:
138 CJS_Array(CJS_Runtime* pRuntime);
139 virtual ~CJS_Array();
140
141 void Attach(v8::Local<v8::Array> pArray);
142 void GetElement(unsigned index, CJS_Value& value);
143 void SetElement(unsigned index, CJS_Value value);
144 int GetLength();
145 FX_BOOL IsAttached();
146 operator v8::Local<v8::Array>();
147
148 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; }
149
150 private:
151 v8::Local<v8::Array> m_pArray;
152 CJS_Runtime* m_pJSRuntime;
153 };
154
155 class CJS_Date {
156 friend class CJS_Value;
157
158 public:
159 CJS_Date(CJS_Runtime* pRuntime);
160 CJS_Date(CJS_Runtime* pRuntime, double dMsec_time);
161 CJS_Date(CJS_Runtime* pRuntime,
162 int year,
163 int mon,
164 int day,
165 int hour,
166 int min,
167 int sec);
168 virtual ~CJS_Date();
169 void Attach(v8::Local<v8::Value> pDate);
170
171 int GetYear();
172 void SetYear(int iYear);
173
174 int GetMonth();
175 void SetMonth(int iMonth);
176
177 int GetDay();
178 void SetDay(int iDay);
179
180 int GetHours();
181 void SetHours(int iHours);
182
183 int GetMinutes();
184 void SetMinutes(int minutes);
185
186 int GetSeconds();
187 void SetSeconds(int seconds);
188
189 operator v8::Local<v8::Value>();
190 operator double() const;
191
192 CFX_WideString ToString() const;
193
194 static double
195 MakeDate(int year, int mon, int mday, int hour, int min, int sec, int ms);
196
197 FX_BOOL IsValidDate();
198
199 protected:
200 v8::Local<v8::Value> m_pDate;
201 CJS_Runtime* m_pJSRuntime;
202 };
203
204 double JS_GetDateTime();
205 int JS_GetYearFromTime(double dt);
206 int JS_GetMonthFromTime(double dt);
207 int JS_GetDayFromTime(double dt);
208 int JS_GetHourFromTime(double dt);
209 int JS_GetMinFromTime(double dt);
210 int JS_GetSecFromTime(double dt);
211 double JS_DateParse(const wchar_t* str);
212 double JS_MakeDay(int nYear, int nMonth, int nDay);
213 double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
214 double JS_MakeDate(double day, double time);
215 bool JS_PortIsNan(double d);
216 double JS_LocalTime(double d);
217
218 // Some JS methods have the bizarre convention that they may also be called
219 // with a single argument which is an object containing the actual arguments
220 // as its properties. The varying arguments to this method are the property
221 // names as wchar_t string literals corresponding to each positional argument.
222 // The result will always contain |nKeywords| value, with unspecified ones
223 // being set to type VT_unknown.
224 std::vector<CJS_Value> JS_ExpandKeywordParams(
225 CJS_Runtime* pRuntime,
226 const std::vector<CJS_Value>& originals,
227 size_t nKeywords,
228 ...);
229
230 #endif // FPDFSDK_SRC_JAVASCRIPT_JS_VALUE_H_
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime_Stub.cpp ('k') | fpdfsdk/src/javascript/JS_Value.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698