| OLD | NEW |
| 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_INCLUDE_JAVASCRIPT_JS_VALUE_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_VALUE_H_ |
| 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_VALUE_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_VALUE_H_ |
| 9 | 9 |
| 10 #include "../../../core/include/fxcrt/fx_basic.h" | 10 #include "../../../core/include/fxcrt/fx_basic.h" |
| 11 #include "../jsapi/fxjs_v8.h" | 11 #include "../jsapi/fxjs_v8.h" |
| 12 | 12 |
| 13 class CJS_Array; | 13 class CJS_Array; |
| 14 class CJS_Date; | 14 class CJS_Date; |
| 15 class CJS_Document; | 15 class CJS_Document; |
| 16 class CJS_Object; | 16 class CJS_Object; |
| 17 | 17 |
| 18 class CJS_Value { | 18 class CJS_Value { |
| 19 public: | 19 public: |
| 20 enum Type { |
| 21 VT_unknown, |
| 22 VT_string, |
| 23 VT_number, |
| 24 VT_boolean, |
| 25 VT_date, |
| 26 VT_object, |
| 27 VT_fxobject, |
| 28 VT_null, |
| 29 VT_undefined |
| 30 }; |
| 31 |
| 20 CJS_Value(v8::Isolate* isolate); | 32 CJS_Value(v8::Isolate* isolate); |
| 21 CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue, FXJSVALUETYPE t); | 33 CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue, Type t); |
| 22 CJS_Value(v8::Isolate* isolate, const int& iValue); | 34 CJS_Value(v8::Isolate* isolate, const int& iValue); |
| 23 CJS_Value(v8::Isolate* isolate, const double& dValue); | 35 CJS_Value(v8::Isolate* isolate, const double& dValue); |
| 24 CJS_Value(v8::Isolate* isolate, const float& fValue); | 36 CJS_Value(v8::Isolate* isolate, const float& fValue); |
| 25 CJS_Value(v8::Isolate* isolate, const bool& bValue); | 37 CJS_Value(v8::Isolate* isolate, const bool& bValue); |
| 26 CJS_Value(v8::Isolate* isolate, v8::Local<v8::Object>); | 38 CJS_Value(v8::Isolate* isolate, v8::Local<v8::Object>); |
| 27 CJS_Value(v8::Isolate* isolate, CJS_Object*); | 39 CJS_Value(v8::Isolate* isolate, CJS_Object*); |
| 28 CJS_Value(v8::Isolate* isolate, CJS_Document*); | 40 CJS_Value(v8::Isolate* isolate, CJS_Document*); |
| 29 CJS_Value(v8::Isolate* isolate, const FX_CHAR* pStr); | 41 CJS_Value(v8::Isolate* isolate, const FX_CHAR* pStr); |
| 30 CJS_Value(v8::Isolate* isolate, const FX_WCHAR* pWstr); | 42 CJS_Value(v8::Isolate* isolate, const FX_WCHAR* pWstr); |
| 31 CJS_Value(v8::Isolate* isolate, CJS_Array& array); | 43 CJS_Value(v8::Isolate* isolate, CJS_Array& array); |
| 32 | 44 |
| 33 ~CJS_Value(); | 45 ~CJS_Value(); |
| 34 | 46 |
| 35 void SetNull(); | 47 void SetNull(); |
| 36 void Attach(v8::Local<v8::Value> pValue, FXJSVALUETYPE t); | 48 void Attach(v8::Local<v8::Value> pValue, Type t); |
| 37 void Attach(CJS_Value* pValue); | 49 void Attach(CJS_Value* pValue); |
| 38 void Detach(); | 50 void Detach(); |
| 39 | 51 |
| 52 Type GetType() const; |
| 40 int ToInt() const; | 53 int ToInt() const; |
| 41 bool ToBool() const; | 54 bool ToBool() const; |
| 42 double ToDouble() const; | 55 double ToDouble() const; |
| 43 float ToFloat() const; | 56 float ToFloat() const; |
| 44 CJS_Object* ToCJSObject() const; | 57 CJS_Object* ToCJSObject() const; |
| 45 CFX_WideString ToCFXWideString() const; | 58 CFX_WideString ToCFXWideString() const; |
| 46 CFX_ByteString ToCFXByteString() const; | 59 CFX_ByteString ToCFXByteString() const; |
| 47 v8::Local<v8::Object> ToV8Object() const; | 60 v8::Local<v8::Object> ToV8Object() const; |
| 48 v8::Local<v8::Array> ToV8Array() const; | 61 v8::Local<v8::Array> ToV8Array() const; |
| 49 v8::Local<v8::Value> ToV8Value() const; | 62 v8::Local<v8::Value> ToV8Value() const; |
| 50 | 63 |
| 51 void operator=(int iValue); | 64 void operator=(int iValue); |
| 52 void operator=(bool bValue); | 65 void operator=(bool bValue); |
| 53 void operator=(double); | 66 void operator=(double); |
| 54 void operator=(float); | 67 void operator=(float); |
| 55 void operator=(CJS_Object*); | 68 void operator=(CJS_Object*); |
| 56 void operator=(CJS_Document*); | 69 void operator=(CJS_Document*); |
| 57 void operator=(v8::Local<v8::Object>); | 70 void operator=(v8::Local<v8::Object>); |
| 58 void operator=(CJS_Array&); | 71 void operator=(CJS_Array&); |
| 59 void operator=(CJS_Date&); | 72 void operator=(CJS_Date&); |
| 60 void operator=(const FX_WCHAR* pWstr); | 73 void operator=(const FX_WCHAR* pWstr); |
| 61 void operator=(const FX_CHAR* pStr); | 74 void operator=(const FX_CHAR* pStr); |
| 62 void operator=(CJS_Value value); | 75 void operator=(CJS_Value value); |
| 63 | 76 |
| 64 FX_BOOL IsArrayObject() const; | 77 FX_BOOL IsArrayObject() const; |
| 65 FX_BOOL IsDateObject() const; | 78 FX_BOOL IsDateObject() const; |
| 66 FXJSVALUETYPE GetType() const; | |
| 67 | |
| 68 FX_BOOL ConvertToArray(CJS_Array&) const; | 79 FX_BOOL ConvertToArray(CJS_Array&) const; |
| 69 FX_BOOL ConvertToDate(CJS_Date&) const; | 80 FX_BOOL ConvertToDate(CJS_Date&) const; |
| 70 | 81 |
| 71 v8::Isolate* GetIsolate() { return m_isolate; } | 82 v8::Isolate* GetIsolate() { return m_isolate; } |
| 72 | 83 |
| 73 protected: | 84 protected: |
| 85 Type m_eType; |
| 74 v8::Local<v8::Value> m_pValue; | 86 v8::Local<v8::Value> m_pValue; |
| 75 FXJSVALUETYPE m_eType; | |
| 76 v8::Isolate* m_isolate; | 87 v8::Isolate* m_isolate; |
| 77 }; | 88 }; |
| 78 | 89 |
| 79 class CJS_Parameters : public CFX_ArrayTemplate<CJS_Value> { | 90 class CJS_Parameters : public CFX_ArrayTemplate<CJS_Value> { |
| 80 public: | 91 public: |
| 81 void push_back(const CJS_Value& newElement) { | 92 void push_back(const CJS_Value& newElement) { |
| 82 CFX_ArrayTemplate<CJS_Value>::Add(newElement); | 93 CFX_ArrayTemplate<CJS_Value>::Add(newElement); |
| 83 } | 94 } |
| 84 int size() const { return CFX_ArrayTemplate<CJS_Value>::GetSize(); } | 95 int size() const { return CFX_ArrayTemplate<CJS_Value>::GetSize(); } |
| 85 }; | 96 }; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 static double | 194 static double |
| 184 MakeDate(int year, int mon, int mday, int hour, int min, int sec, int ms); | 195 MakeDate(int year, int mon, int mday, int hour, int min, int sec, int ms); |
| 185 | 196 |
| 186 FX_BOOL IsValidDate(); | 197 FX_BOOL IsValidDate(); |
| 187 | 198 |
| 188 protected: | 199 protected: |
| 189 v8::Local<v8::Value> m_pDate; | 200 v8::Local<v8::Value> m_pDate; |
| 190 v8::Isolate* m_isolate; | 201 v8::Isolate* m_isolate; |
| 191 }; | 202 }; |
| 192 | 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* string); |
| 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 |
| 193 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_VALUE_H_ | 218 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_VALUE_H_ |
| OLD | NEW |