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

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

Issue 2172813002: Tidy up JS_Value.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebse Created 4 years, 5 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/JS_Define.h ('k') | fpdfsdk/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
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 FPDFSDK_JAVASCRIPT_JS_VALUE_H_ 7 #ifndef FPDFSDK_JAVASCRIPT_JS_VALUE_H_
8 #define FPDFSDK_JAVASCRIPT_JS_VALUE_H_ 8 #define FPDFSDK_JAVASCRIPT_JS_VALUE_H_
9 9
10 #include <vector> 10 #include <vector>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Replace the current |m_pValue| with a v8::Number if possible 65 // Replace the current |m_pValue| with a v8::Number if possible
66 // to make one from the current |m_pValue|. 66 // to make one from the current |m_pValue|.
67 void MaybeCoerceToNumber(); 67 void MaybeCoerceToNumber();
68 68
69 void operator=(int iValue); 69 void operator=(int iValue);
70 void operator=(bool bValue); 70 void operator=(bool bValue);
71 void operator=(double val); 71 void operator=(double val);
72 void operator=(float val); 72 void operator=(float val);
73 void operator=(CJS_Object* val); 73 void operator=(CJS_Object* val);
74 void operator=(v8::Local<v8::Object> val); 74 void operator=(v8::Local<v8::Object> val);
75 void operator=(CJS_Array& val); 75 void operator=(const CJS_Array& val);
76 void operator=(CJS_Date& val); 76 void operator=(const CJS_Date& val);
77 void operator=(const CJS_Value& value);
78 void operator=(const FX_CHAR* pStr);
77 void operator=(const FX_WCHAR* pWstr); 79 void operator=(const FX_WCHAR* pWstr);
78 void operator=(const FX_CHAR* pStr);
79 void operator=(CJS_Value value);
80 80
81 FX_BOOL IsArrayObject() const; 81 FX_BOOL IsArrayObject() const;
82 FX_BOOL IsDateObject() const; 82 FX_BOOL IsDateObject() const;
83 FX_BOOL ConvertToArray(CJS_Array&) const; 83 FX_BOOL ConvertToArray(CJS_Array&) const;
84 FX_BOOL ConvertToDate(CJS_Date&) const; 84 FX_BOOL ConvertToDate(CJS_Date&) const;
85 85
86 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; } 86 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; }
87 87
88 protected: 88 protected:
89 v8::Local<v8::Value> m_pValue; 89 v8::Local<v8::Value> m_pValue;
90 CJS_Runtime* m_pJSRuntime; 90 CJS_Runtime* const m_pJSRuntime;
91 }; 91 };
92 92
93 class CJS_PropValue : public CJS_Value { 93 class CJS_PropValue : public CJS_Value {
94 public: 94 public:
95 explicit CJS_PropValue(CJS_Runtime* pRuntime);
95 CJS_PropValue(const CJS_Value&); 96 CJS_PropValue(const CJS_Value&);
96 CJS_PropValue(CJS_Runtime* pRuntime);
97 ~CJS_PropValue(); 97 ~CJS_PropValue();
98 98
99 FX_BOOL IsSetting() const { return m_bIsSetting; } 99 void StartSetting() { m_bIsSetting = true; }
100 FX_BOOL IsGetting() const { return !m_bIsSetting; } 100 void StartGetting() { m_bIsSetting = false; }
101 bool IsSetting() const { return m_bIsSetting; }
102 bool IsGetting() const { return !m_bIsSetting; }
101 103
102 void operator<<(int val); 104 void operator<<(int val);
103 void operator>>(int&) const; 105 void operator>>(int&) const;
104 void operator<<(bool val); 106 void operator<<(bool val);
105 void operator>>(bool&) const; 107 void operator>>(bool&) const;
106 void operator<<(double val); 108 void operator<<(double val);
107 void operator>>(double&) const; 109 void operator>>(double&) const;
108 void operator<<(CJS_Object* pObj); 110 void operator<<(CJS_Object* pObj);
109 void operator>>(CJS_Object*& ppObj) const; 111 void operator>>(CJS_Object*& ppObj) const;
110 void operator<<(CJS_Document* pJsDoc); 112 void operator<<(CJS_Document* pJsDoc);
111 void operator>>(CJS_Document*& ppJsDoc) const; 113 void operator>>(CJS_Document*& ppJsDoc) const;
112 void operator<<(CFX_ByteString); 114 void operator<<(CFX_ByteString);
113 void operator>>(CFX_ByteString&) const; 115 void operator>>(CFX_ByteString&) const;
114 void operator<<(CFX_WideString); 116 void operator<<(CFX_WideString);
115 void operator>>(CFX_WideString&) const; 117 void operator>>(CFX_WideString&) const;
116 void operator<<(const FX_WCHAR* c_string); 118 void operator<<(const FX_WCHAR* c_string);
117 void operator<<(v8::Local<v8::Object>); 119 void operator<<(v8::Local<v8::Object>);
118 void operator>>(v8::Local<v8::Object>&) const; 120 void operator>>(v8::Local<v8::Object>&) const;
119 void operator>>(CJS_Array& array) const; 121 void operator>>(CJS_Array& array) const;
120 void operator<<(CJS_Array& array); 122 void operator<<(CJS_Array& array);
121 void operator<<(CJS_Date& date); 123 void operator<<(CJS_Date& date);
122 void operator>>(CJS_Date& date) const; 124 void operator>>(CJS_Date& date) const;
123 operator v8::Local<v8::Value>() const;
124 void StartSetting();
125 void StartGetting();
126 125
127 private: 126 private:
128 FX_BOOL m_bIsSetting; 127 bool m_bIsSetting;
129 }; 128 };
130 129
131 class CJS_Array { 130 class CJS_Array {
132 public: 131 public:
133 CJS_Array(CJS_Runtime* pRuntime); 132 explicit CJS_Array(CJS_Runtime* pRuntime);
133 CJS_Array(const CJS_Array& other);
134 virtual ~CJS_Array(); 134 virtual ~CJS_Array();
135 CJS_Array(const CJS_Array& other);
136 135
137 void Attach(v8::Local<v8::Array> pArray); 136 void Attach(v8::Local<v8::Array> pArray);
138 void GetElement(unsigned index, CJS_Value& value); 137 void GetElement(unsigned index, CJS_Value& value) const;
139 void SetElement(unsigned index, CJS_Value value); 138 void SetElement(unsigned index, CJS_Value value);
140 int GetLength(); 139 int GetLength() const;
141 FX_BOOL IsAttached();
142 operator v8::Local<v8::Array>();
143 140
141 v8::Local<v8::Array> ToV8Array() const;
144 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; } 142 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; }
145 143
146 private: 144 private:
147 v8::Local<v8::Array> m_pArray; 145 mutable v8::Local<v8::Array> m_pArray;
Tom Sepez 2016/07/25 17:24:46 Note: mutable because some const get operations ma
148 CJS_Runtime* m_pJSRuntime; 146 CJS_Runtime* const m_pJSRuntime;
149 }; 147 };
150 148
151 class CJS_Date { 149 class CJS_Date {
152 friend class CJS_Value;
153
154 public: 150 public:
155 CJS_Date(CJS_Runtime* pRuntime); 151 explicit CJS_Date(CJS_Runtime* pRuntime);
156 CJS_Date(CJS_Runtime* pRuntime, double dMsec_time); 152 CJS_Date(CJS_Runtime* pRuntime, double dMsec_time);
157 CJS_Date(CJS_Runtime* pRuntime, 153 CJS_Date(CJS_Runtime* pRuntime,
158 int year, 154 int year,
159 int mon, 155 int mon,
160 int day, 156 int day,
161 int hour, 157 int hour,
162 int min, 158 int min,
163 int sec); 159 int sec);
164 virtual ~CJS_Date(); 160 virtual ~CJS_Date();
161
165 void Attach(v8::Local<v8::Value> pDate); 162 void Attach(v8::Local<v8::Value> pDate);
163 bool IsValidDate() const;
166 164
167 int GetYear(); 165 int GetYear() const;
168 void SetYear(int iYear); 166 void SetYear(int iYear);
169 167
170 int GetMonth(); 168 int GetMonth() const;
171 void SetMonth(int iMonth); 169 void SetMonth(int iMonth);
172 170
173 int GetDay(); 171 int GetDay() const;
174 void SetDay(int iDay); 172 void SetDay(int iDay);
175 173
176 int GetHours(); 174 int GetHours() const;
177 void SetHours(int iHours); 175 void SetHours(int iHours);
178 176
179 int GetMinutes(); 177 int GetMinutes() const;
180 void SetMinutes(int minutes); 178 void SetMinutes(int minutes);
181 179
182 int GetSeconds(); 180 int GetSeconds() const;
183 void SetSeconds(int seconds); 181 void SetSeconds(int seconds);
184 182
185 operator v8::Local<v8::Value>(); 183 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; }
186 operator double() const; 184 v8::Local<v8::Value> ToV8Value() const { return m_pDate; }
187 185 double ToDouble() const;
188 CFX_WideString ToString() const; 186 CFX_WideString ToString() const;
189 187
190 static double
191 MakeDate(int year, int mon, int mday, int hour, int min, int sec, int ms);
192
193 FX_BOOL IsValidDate();
194
195 protected: 188 protected:
196 v8::Local<v8::Value> m_pDate; 189 v8::Local<v8::Value> m_pDate;
197 CJS_Runtime* m_pJSRuntime; 190 CJS_Runtime* const m_pJSRuntime;
198 }; 191 };
199 192
200 double JS_GetDateTime(); 193 double JS_GetDateTime();
201 int JS_GetYearFromTime(double dt); 194 int JS_GetYearFromTime(double dt);
202 int JS_GetMonthFromTime(double dt); 195 int JS_GetMonthFromTime(double dt);
203 int JS_GetDayFromTime(double dt); 196 int JS_GetDayFromTime(double dt);
204 int JS_GetHourFromTime(double dt); 197 int JS_GetHourFromTime(double dt);
205 int JS_GetMinFromTime(double dt); 198 int JS_GetMinFromTime(double dt);
206 int JS_GetSecFromTime(double dt); 199 int JS_GetSecFromTime(double dt);
207 double JS_DateParse(const CFX_WideString& str); 200 double JS_DateParse(const CFX_WideString& str);
208 double JS_MakeDay(int nYear, int nMonth, int nDay); 201 double JS_MakeDay(int nYear, int nMonth, int nDay);
209 double JS_MakeTime(int nHour, int nMin, int nSec, int nMs); 202 double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
210 double JS_MakeDate(double day, double time); 203 double JS_MakeDate(double day, double time);
211 bool JS_PortIsNan(double d); 204 bool JS_PortIsNan(double d);
212 double JS_LocalTime(double d); 205 double JS_LocalTime(double d);
213 206
214 // Some JS methods have the bizarre convention that they may also be called 207 // Some JS methods have the bizarre convention that they may also be called
215 // with a single argument which is an object containing the actual arguments 208 // with a single argument which is an object containing the actual arguments
216 // as its properties. The varying arguments to this method are the property 209 // as its properties. The varying arguments to this method are the property
217 // names as wchar_t string literals corresponding to each positional argument. 210 // names as wchar_t string literals corresponding to each positional argument.
218 // The result will always contain |nKeywords| value, with unspecified ones 211 // The result will always contain |nKeywords| value, with unspecified ones
219 // being set to type VT_unknown. 212 // being set to type VT_unknown.
220 std::vector<CJS_Value> JS_ExpandKeywordParams( 213 std::vector<CJS_Value> JS_ExpandKeywordParams(
221 CJS_Runtime* pRuntime, 214 CJS_Runtime* pRuntime,
222 const std::vector<CJS_Value>& originals, 215 const std::vector<CJS_Value>& originals,
223 size_t nKeywords, 216 size_t nKeywords,
224 ...); 217 ...);
225 218
226 #endif // FPDFSDK_JAVASCRIPT_JS_VALUE_H_ 219 #endif // FPDFSDK_JAVASCRIPT_JS_VALUE_H_
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/JS_Define.h ('k') | fpdfsdk/javascript/JS_Value.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698