| 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 _JS_VALUE_H_ | 7 #ifndef _JS_VALUE_H_ |
| 8 #define _JS_VALUE_H_ | 8 #define _JS_VALUE_H_ |
| 9 | 9 |
| 10 #include "../jsapi/fxjs_v8.h" | 10 #include "../jsapi/fxjs_v8.h" |
| 11 #include "../../../core/include/fxcrt/fx_basic.h" | 11 #include "../../../core/include/fxcrt/fx_basic.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 { | 19 { |
| 20 public: | 20 public: |
| 21 CJS_Value(v8::Isolate* isolate); | 21 CJS_Value(v8::Isolate* isolate); |
| 22 » CJS_Value(v8::Isolate* isolate, v8::Handle<v8::Value> pValue,FXJSVALUETY
PE t); | 22 » CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue,FXJSVALUETYP
E t); |
| 23 CJS_Value(v8::Isolate* isolate, const int &iValue); | 23 CJS_Value(v8::Isolate* isolate, const int &iValue); |
| 24 CJS_Value(v8::Isolate* isolate, const double &dValue); | 24 CJS_Value(v8::Isolate* isolate, const double &dValue); |
| 25 CJS_Value(v8::Isolate* isolate, const float &fValue); | 25 CJS_Value(v8::Isolate* isolate, const float &fValue); |
| 26 CJS_Value(v8::Isolate* isolate, const bool &bValue); | 26 CJS_Value(v8::Isolate* isolate, const bool &bValue); |
| 27 CJS_Value(v8::Isolate* isolate, JSFXObject); | 27 CJS_Value(v8::Isolate* isolate, JSFXObject); |
| 28 CJS_Value(v8::Isolate* isolate, CJS_Object*); | 28 CJS_Value(v8::Isolate* isolate, CJS_Object*); |
| 29 CJS_Value(v8::Isolate* isolate, CJS_Document*); | 29 CJS_Value(v8::Isolate* isolate, CJS_Document*); |
| 30 CJS_Value(v8::Isolate* isolate, FX_LPCSTR pStr); | 30 CJS_Value(v8::Isolate* isolate, FX_LPCSTR pStr); |
| 31 CJS_Value(v8::Isolate* isolate, FX_LPCWSTR pWstr); | 31 CJS_Value(v8::Isolate* isolate, FX_LPCWSTR pWstr); |
| 32 CJS_Value(v8::Isolate* isolate, CJS_Array& array); | 32 CJS_Value(v8::Isolate* isolate, CJS_Array& array); |
| 33 | 33 |
| 34 ~CJS_Value(); | 34 ~CJS_Value(); |
| 35 | 35 |
| 36 void SetNull(); | 36 void SetNull(); |
| 37 void Attach(v8::Handle<v8::Value> pValue,FXJSVALUETYPE t); | 37 void Attach(v8::Local<v8::Value> pValue,FXJSVALUETYPE t); |
| 38 void Attach(CJS_Value *pValue); | 38 void Attach(CJS_Value *pValue); |
| 39 void Detach(); | 39 void Detach(); |
| 40 | 40 |
| 41 | 41 |
| 42 int ToInt() const; | 42 int ToInt() const; |
| 43 bool ToBool() const; | 43 bool ToBool() const; |
| 44 double ToDouble() const; | 44 double ToDouble() const; |
| 45 float ToFloat() const; | 45 float ToFloat() const; |
| 46 CJS_Object* ToCJSObject() const; | 46 CJS_Object* ToCJSObject() const; |
| 47 CFX_WideString ToCFXWideString() const; | 47 CFX_WideString ToCFXWideString() const; |
| 48 CFX_ByteString ToCFXByteString() const; | 48 CFX_ByteString ToCFXByteString() const; |
| 49 » v8::Handle<v8::Object> ToV8Object() const; | 49 » v8::Local<v8::Object> ToV8Object() const; |
| 50 » v8::Handle<v8::Array> ToV8Array() const; | 50 » v8::Local<v8::Array> ToV8Array() const; |
| 51 » v8::Handle<v8::Value> ToV8Value() const; | 51 » v8::Local<v8::Value> ToV8Value() const; |
| 52 | 52 |
| 53 void operator = (int iValue); | 53 void operator = (int iValue); |
| 54 void operator = (bool bValue); | 54 void operator = (bool bValue); |
| 55 void operator = (double); | 55 void operator = (double); |
| 56 void operator = (float); | 56 void operator = (float); |
| 57 void operator = (CJS_Object*); | 57 void operator = (CJS_Object*); |
| 58 void operator = (CJS_Document*); | 58 void operator = (CJS_Document*); |
| 59 » void operator = (v8::Handle<v8::Object>); | 59 » void operator = (v8::Local<v8::Object>); |
| 60 void operator = (CJS_Array &); | 60 void operator = (CJS_Array &); |
| 61 void operator = (CJS_Date &); | 61 void operator = (CJS_Date &); |
| 62 void operator = (FX_LPCWSTR pWstr); | 62 void operator = (FX_LPCWSTR pWstr); |
| 63 void operator = (FX_LPCSTR pStr); | 63 void operator = (FX_LPCSTR pStr); |
| 64 void operator = (CJS_Value value); | 64 void operator = (CJS_Value value); |
| 65 | 65 |
| 66 FX_BOOL IsArrayObject() const; | 66 FX_BOOL IsArrayObject() const; |
| 67 FX_BOOL IsDateObject() const; | 67 FX_BOOL IsDateObject() const; |
| 68 FXJSVALUETYPE GetType() const; | 68 FXJSVALUETYPE GetType() const; |
| 69 | 69 |
| 70 FX_BOOL ConvertToArray(CJS_Array &) const; | 70 FX_BOOL ConvertToArray(CJS_Array &) const; |
| 71 FX_BOOL ConvertToDate(CJS_Date &) const; | 71 FX_BOOL ConvertToDate(CJS_Date &) const; |
| 72 | 72 |
| 73 v8::Isolate* GetIsolate() {return m_isolate;} | 73 v8::Isolate* GetIsolate() {return m_isolate;} |
| 74 protected: | 74 protected: |
| 75 » v8::Handle<v8::Value> m_pValue; | 75 » v8::Local<v8::Value> m_pValue; |
| 76 FXJSVALUETYPE m_eType; | 76 FXJSVALUETYPE m_eType; |
| 77 v8::Isolate* m_isolate; | 77 v8::Isolate* m_isolate; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class CJS_Parameters : public CFX_ArrayTemplate<CJS_Value> | 80 class CJS_Parameters : public CFX_ArrayTemplate<CJS_Value> |
| 81 { | 81 { |
| 82 public: | 82 public: |
| 83 void push_back(const CJS_Value& newElement) { | 83 void push_back(const CJS_Value& newElement) { |
| 84 CFX_ArrayTemplate<CJS_Value>::Add(newElement); | 84 CFX_ArrayTemplate<CJS_Value>::Add(newElement); |
| 85 } | 85 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 111 void operator>>(CFX_ByteString&) const; | 111 void operator>>(CFX_ByteString&) const; |
| 112 void operator<<(CFX_WideString); | 112 void operator<<(CFX_WideString); |
| 113 void operator>>(CFX_WideString&) const; | 113 void operator>>(CFX_WideString&) const; |
| 114 void operator<<(FX_LPCWSTR c_string); | 114 void operator<<(FX_LPCWSTR c_string); |
| 115 void operator<<(JSFXObject); | 115 void operator<<(JSFXObject); |
| 116 void operator>>(JSFXObject&) const; | 116 void operator>>(JSFXObject&) const; |
| 117 void operator>>(CJS_Array& array) const; | 117 void operator>>(CJS_Array& array) const; |
| 118 void operator<<(CJS_Array& array); | 118 void operator<<(CJS_Array& array); |
| 119 void operator<<(CJS_Date& date); | 119 void operator<<(CJS_Date& date); |
| 120 void operator>>(CJS_Date& date) const; | 120 void operator>>(CJS_Date& date) const; |
| 121 » operator v8::Handle<v8::Value>() const; | 121 » operator v8::Local<v8::Value>() const; |
| 122 void StartSetting(); | 122 void StartSetting(); |
| 123 void StartGetting(); | 123 void StartGetting(); |
| 124 private: | 124 private: |
| 125 FX_BOOL m_bIsSetting; | 125 FX_BOOL m_bIsSetting; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class CJS_Array | 128 class CJS_Array |
| 129 { | 129 { |
| 130 public: | 130 public: |
| 131 CJS_Array(v8::Isolate* isolate); | 131 CJS_Array(v8::Isolate* isolate); |
| 132 virtual ~CJS_Array(); | 132 virtual ~CJS_Array(); |
| 133 | 133 |
| 134 » void Attach(v8::Handle<v8::Array> pArray); | 134 » void Attach(v8::Local<v8::Array> pArray); |
| 135 void GetElement(unsigned index,CJS_Value &value); | 135 void GetElement(unsigned index,CJS_Value &value); |
| 136 void SetElement(unsigned index,CJS_Value value); | 136 void SetElement(unsigned index,CJS_Value value); |
| 137 int GetLength(); | 137 int GetLength(); |
| 138 FX_BOOL IsAttached(); | 138 FX_BOOL IsAttached(); |
| 139 » operator v8::Handle<v8::Array>(); | 139 » operator v8::Local<v8::Array>(); |
| 140 | 140 |
| 141 v8::Isolate* GetIsolate() {return m_isolate;} | 141 v8::Isolate* GetIsolate() {return m_isolate;} |
| 142 private: | 142 private: |
| 143 » v8::Handle<v8::Array> m_pArray; | 143 » v8::Local<v8::Array> m_pArray; |
| 144 v8::Isolate* m_isolate; | 144 v8::Isolate* m_isolate; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 class CJS_Date | 147 class CJS_Date |
| 148 { | 148 { |
| 149 friend class CJS_Value; | 149 friend class CJS_Value; |
| 150 public: | 150 public: |
| 151 CJS_Date(v8::Isolate* isolate); | 151 CJS_Date(v8::Isolate* isolate); |
| 152 CJS_Date(v8::Isolate* isolate,double dMsec_time); | 152 CJS_Date(v8::Isolate* isolate,double dMsec_time); |
| 153 CJS_Date(v8::Isolate* isolate,int year, int mon, int day,int hour, int m
in, int sec); | 153 CJS_Date(v8::Isolate* isolate,int year, int mon, int day,int hour, int m
in, int sec); |
| 154 virtual ~CJS_Date(); | 154 virtual ~CJS_Date(); |
| 155 » void Attach(v8::Handle<v8::Value> pDate); | 155 » void Attach(v8::Local<v8::Value> pDate); |
| 156 | 156 |
| 157 int GetYear(); | 157 int GetYear(); |
| 158 void SetYear(int iYear); | 158 void SetYear(int iYear); |
| 159 | 159 |
| 160 int GetMonth(); | 160 int GetMonth(); |
| 161 void SetMonth(int iMonth); | 161 void SetMonth(int iMonth); |
| 162 | 162 |
| 163 int GetDay(); | 163 int GetDay(); |
| 164 void SetDay(int iDay); | 164 void SetDay(int iDay); |
| 165 | 165 |
| 166 int GetHours(); | 166 int GetHours(); |
| 167 void SetHours(int iHours); | 167 void SetHours(int iHours); |
| 168 | 168 |
| 169 int GetMinutes(); | 169 int GetMinutes(); |
| 170 void SetMinutes(int minutes); | 170 void SetMinutes(int minutes); |
| 171 | 171 |
| 172 int GetSeconds(); | 172 int GetSeconds(); |
| 173 void SetSeconds(int seconds); | 173 void SetSeconds(int seconds); |
| 174 | 174 |
| 175 » operator v8::Handle<v8::Value>(); | 175 » operator v8::Local<v8::Value>(); |
| 176 operator double() const; | 176 operator double() const; |
| 177 | 177 |
| 178 CFX_WideString ToString() const; | 178 CFX_WideString ToString() const; |
| 179 | 179 |
| 180 static double MakeDate(int year, int mon, int mday,int hour, int min,
int sec,int ms); | 180 static double MakeDate(int year, int mon, int mday,int hour, int min,
int sec,int ms); |
| 181 | 181 |
| 182 FX_BOOL IsValidDate(); | 182 FX_BOOL IsValidDate(); |
| 183 | 183 |
| 184 protected: | 184 protected: |
| 185 » v8::Handle<v8::Value> m_pDate; | 185 » v8::Local<v8::Value> m_pDate; |
| 186 v8::Isolate* m_isolate; | 186 v8::Isolate* m_isolate; |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 #endif //_JS_VALUE_H_ | 189 #endif //_JS_VALUE_H_ |
| 190 | 190 |
| OLD | NEW |