| 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_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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 48   ~CJS_Value(); | 48   ~CJS_Value(); | 
| 49 | 49 | 
| 50   void SetNull(CJS_Runtime* pRuntime); | 50   void SetNull(CJS_Runtime* pRuntime); | 
| 51   void SetValue(const CJS_Value& other); | 51   void SetValue(const CJS_Value& other); | 
| 52   void Attach(v8::Local<v8::Value> pValue); | 52   void Attach(v8::Local<v8::Value> pValue); | 
| 53   void Detach(); | 53   void Detach(); | 
| 54 | 54 | 
| 55   static Type GetValueType(v8::Local<v8::Value> value); | 55   static Type GetValueType(v8::Local<v8::Value> value); | 
| 56   Type GetType() const { return GetValueType(m_pValue); } | 56   Type GetType() const { return GetValueType(m_pValue); } | 
| 57 | 57 | 
| 58   int ToInt(v8::Isolate* pIsolate) const; | 58   int ToInt(CJS_Runtime* pRuntime) const; | 
| 59   bool ToBool(v8::Isolate* pIsolate) const; | 59   bool ToBool(CJS_Runtime* pRuntime) const; | 
| 60   double ToDouble(v8::Isolate* pIsolate) const; | 60   double ToDouble(CJS_Runtime* pRuntime) const; | 
| 61   float ToFloat(v8::Isolate* pIsolate) const; | 61   float ToFloat(CJS_Runtime* pRuntime) const; | 
| 62   CJS_Object* ToCJSObject(v8::Isolate* pIsolate) const; | 62   CJS_Object* ToCJSObject(CJS_Runtime* pRuntime) const; | 
| 63   CFX_WideString ToCFXWideString(v8::Isolate* pIsolate) const; | 63   CFX_WideString ToCFXWideString(CJS_Runtime* pRuntime) const; | 
| 64   CFX_ByteString ToCFXByteString(v8::Isolate* pIsolate) const; | 64   CFX_ByteString ToCFXByteString(CJS_Runtime* pRuntime) const; | 
| 65   v8::Local<v8::Object> ToV8Object(v8::Isolate* pIsolate) const; | 65   v8::Local<v8::Object> ToV8Object(CJS_Runtime* pRuntime) const; | 
| 66   v8::Local<v8::Array> ToV8Array(v8::Isolate* pIsolate) const; | 66   v8::Local<v8::Array> ToV8Array(CJS_Runtime* pRuntime) const; | 
| 67   v8::Local<v8::Value> ToV8Value(v8::Isolate* pIsolate) const; | 67   v8::Local<v8::Value> ToV8Value(CJS_Runtime* pRuntime) const; | 
| 68 | 68 | 
| 69   // Replace the current |m_pValue| with a v8::Number if possible | 69   // Replace the current |m_pValue| with a v8::Number if possible | 
| 70   // to make one from the current |m_pValue|. | 70   // to make one from the current |m_pValue|. | 
| 71   void MaybeCoerceToNumber(v8::Isolate* pIsolate); | 71   void MaybeCoerceToNumber(CJS_Runtime* pRuntime); | 
| 72 | 72 | 
| 73   bool IsArrayObject() const; | 73   bool IsArrayObject() const; | 
| 74   bool IsDateObject() const; | 74   bool IsDateObject() const; | 
| 75   bool ConvertToArray(v8::Isolate* pIsolate, CJS_Array&) const; | 75   bool ConvertToArray(CJS_Runtime* pRuntime, CJS_Array&) const; | 
| 76   bool ConvertToDate(v8::Isolate* pIsolate, CJS_Date&) const; | 76   bool ConvertToDate(CJS_Runtime* pRuntime, CJS_Date&) const; | 
| 77 | 77 | 
| 78  protected: | 78  protected: | 
| 79   v8::Local<v8::Value> m_pValue; | 79   v8::Local<v8::Value> m_pValue; | 
| 80 }; | 80 }; | 
| 81 | 81 | 
| 82 class CJS_PropValue { | 82 class CJS_PropValue { | 
| 83  public: | 83  public: | 
| 84   explicit CJS_PropValue(CJS_Runtime* pRuntime); | 84   explicit CJS_PropValue(CJS_Runtime* pRuntime); | 
| 85   CJS_PropValue(CJS_Runtime* pRuntime, const CJS_Value&); | 85   CJS_PropValue(CJS_Runtime* pRuntime, const CJS_Value&); | 
| 86   ~CJS_PropValue(); | 86   ~CJS_PropValue(); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 120   CJS_Runtime* const m_pJSRuntime; | 120   CJS_Runtime* const m_pJSRuntime; | 
| 121 }; | 121 }; | 
| 122 | 122 | 
| 123 class CJS_Array { | 123 class CJS_Array { | 
| 124  public: | 124  public: | 
| 125   CJS_Array(); | 125   CJS_Array(); | 
| 126   CJS_Array(const CJS_Array& other); | 126   CJS_Array(const CJS_Array& other); | 
| 127   virtual ~CJS_Array(); | 127   virtual ~CJS_Array(); | 
| 128 | 128 | 
| 129   void Attach(v8::Local<v8::Array> pArray); | 129   void Attach(v8::Local<v8::Array> pArray); | 
| 130   void GetElement(v8::Isolate* pIsolate, | 130   void GetElement(CJS_Runtime* pRuntime, | 
| 131                   unsigned index, | 131                   unsigned index, | 
| 132                   CJS_Value& value) const; | 132                   CJS_Value& value) const; | 
| 133   void SetElement(v8::Isolate* pIsolate, | 133   void SetElement(CJS_Runtime* pRuntime, | 
| 134                   unsigned index, | 134                   unsigned index, | 
| 135                   const CJS_Value& value); | 135                   const CJS_Value& value); | 
| 136   int GetLength() const; | 136   int GetLength(CJS_Runtime* pRuntime) const; | 
| 137 | 137 | 
| 138   v8::Local<v8::Array> ToV8Array(v8::Isolate* pIsolate) const; | 138   v8::Local<v8::Array> ToV8Array(CJS_Runtime* pRuntime) const; | 
| 139 | 139 | 
| 140  private: | 140  private: | 
| 141   mutable v8::Local<v8::Array> m_pArray; | 141   mutable v8::Local<v8::Array> m_pArray; | 
| 142 }; | 142 }; | 
| 143 | 143 | 
| 144 class CJS_Date { | 144 class CJS_Date { | 
| 145  public: | 145  public: | 
| 146   CJS_Date(); | 146   CJS_Date(); | 
| 147   CJS_Date(v8::Isolate* pIsolate, double dMsec_time); | 147   CJS_Date(CJS_Runtime* pRuntime, double dMsec_time); | 
| 148   CJS_Date(v8::Isolate* pIsolate, | 148   CJS_Date(CJS_Runtime* pRuntime, | 
| 149            int year, | 149            int year, | 
| 150            int mon, | 150            int mon, | 
| 151            int day, | 151            int day, | 
| 152            int hour, | 152            int hour, | 
| 153            int min, | 153            int min, | 
| 154            int sec); | 154            int sec); | 
| 155   virtual ~CJS_Date(); | 155   virtual ~CJS_Date(); | 
| 156 | 156 | 
| 157   void Attach(v8::Local<v8::Date> pDate); | 157   void Attach(v8::Local<v8::Date> pDate); | 
| 158   bool IsValidDate(v8::Isolate* pIsolate) const; | 158   bool IsValidDate(CJS_Runtime* pRuntime) const; | 
| 159 | 159 | 
| 160   int GetYear(v8::Isolate* pIsolate) const; | 160   int GetYear(CJS_Runtime* pRuntime) const; | 
| 161   void SetYear(v8::Isolate* pIsolate, int iYear); | 161   void SetYear(CJS_Runtime* pRuntime, int iYear); | 
| 162 | 162 | 
| 163   int GetMonth(v8::Isolate* pIsolate) const; | 163   int GetMonth(CJS_Runtime* pRuntime) const; | 
| 164   void SetMonth(v8::Isolate* pIsolate, int iMonth); | 164   void SetMonth(CJS_Runtime* pRuntime, int iMonth); | 
| 165 | 165 | 
| 166   int GetDay(v8::Isolate* pIsolate) const; | 166   int GetDay(CJS_Runtime* pRuntime) const; | 
| 167   void SetDay(v8::Isolate* pIsolate, int iDay); | 167   void SetDay(CJS_Runtime* pRuntime, int iDay); | 
| 168 | 168 | 
| 169   int GetHours(v8::Isolate* pIsolate) const; | 169   int GetHours(CJS_Runtime* pRuntime) const; | 
| 170   void SetHours(v8::Isolate* pIsolate, int iHours); | 170   void SetHours(CJS_Runtime* pRuntime, int iHours); | 
| 171 | 171 | 
| 172   int GetMinutes(v8::Isolate* pIsolate) const; | 172   int GetMinutes(CJS_Runtime* pRuntime) const; | 
| 173   void SetMinutes(v8::Isolate* pIsolate, int minutes); | 173   void SetMinutes(CJS_Runtime* pRuntime, int minutes); | 
| 174 | 174 | 
| 175   int GetSeconds(v8::Isolate* pIsolate) const; | 175   int GetSeconds(CJS_Runtime* pRuntime) const; | 
| 176   void SetSeconds(v8::Isolate* pIsolate, int seconds); | 176   void SetSeconds(CJS_Runtime* pRuntime, int seconds); | 
| 177 | 177 | 
| 178   v8::Local<v8::Date> ToV8Date(v8::Isolate* pIsolate) const; | 178   v8::Local<v8::Date> ToV8Date(CJS_Runtime* pRuntime) const; | 
| 179   double ToDouble(v8::Isolate* pIsolate) const; | 179   double ToDouble(CJS_Runtime* pRuntime) const; | 
| 180   CFX_WideString ToString(v8::Isolate* pIsolate) const; | 180   CFX_WideString ToString(CJS_Runtime* pRuntime) const; | 
| 181 | 181 | 
| 182  protected: | 182  protected: | 
| 183   v8::Local<v8::Date> m_pDate; | 183   v8::Local<v8::Date> m_pDate; | 
| 184 }; | 184 }; | 
| 185 | 185 | 
| 186 double JS_GetDateTime(); | 186 double JS_GetDateTime(); | 
| 187 int JS_GetYearFromTime(double dt); | 187 int JS_GetYearFromTime(double dt); | 
| 188 int JS_GetMonthFromTime(double dt); | 188 int JS_GetMonthFromTime(double dt); | 
| 189 int JS_GetDayFromTime(double dt); | 189 int JS_GetDayFromTime(double dt); | 
| 190 int JS_GetHourFromTime(double dt); | 190 int JS_GetHourFromTime(double dt); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 203 // names as wchar_t string literals corresponding to each positional argument. | 203 // names as wchar_t string literals corresponding to each positional argument. | 
| 204 // The result will always contain |nKeywords| value, with unspecified ones | 204 // The result will always contain |nKeywords| value, with unspecified ones | 
| 205 // being set to type VT_unknown. | 205 // being set to type VT_unknown. | 
| 206 std::vector<CJS_Value> JS_ExpandKeywordParams( | 206 std::vector<CJS_Value> JS_ExpandKeywordParams( | 
| 207     CJS_Runtime* pRuntime, | 207     CJS_Runtime* pRuntime, | 
| 208     const std::vector<CJS_Value>& originals, | 208     const std::vector<CJS_Value>& originals, | 
| 209     size_t nKeywords, | 209     size_t nKeywords, | 
| 210     ...); | 210     ...); | 
| 211 | 211 | 
| 212 #endif  // FPDFSDK_JAVASCRIPT_JS_VALUE_H_ | 212 #endif  // FPDFSDK_JAVASCRIPT_JS_VALUE_H_ | 
| OLD | NEW | 
|---|