summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/JS_Value.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-06 11:33:46 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-06 11:33:46 -0700
commit3745841a4c4ab915c98865c1dd71f9debc3e2f99 (patch)
tree9d43ea977a9f50faa40391f38264f6695527555c /fpdfsdk/src/javascript/JS_Value.h
parent1b1dd8a6907f4631044b1c03698170853af594a9 (diff)
downloadpdfium-3745841a4c4ab915c98865c1dd71f9debc3e2f99.tar.xz
Merge to XFA: Make the vast majority of JS headers private to src/javascript.
(cherry picked from commit 5b3d0208723f21c50b9922bdc500c9d78c359a25) Original Review URL: https://codereview.chromium.org/1389783002 . New changes to fix IWYU in: fpdfsdk/include/fpdfxfa/fpdfxfa_app.h xfa/include/fxfa/fxfa.h xfa/include/fxfa/fxfa_objectacc.h R=thestig@chromium.org Review URL: https://codereview.chromium.org/1388023003 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Value.h')
-rw-r--r--fpdfsdk/src/javascript/JS_Value.h218
1 files changed, 218 insertions, 0 deletions
diff --git a/fpdfsdk/src/javascript/JS_Value.h b/fpdfsdk/src/javascript/JS_Value.h
new file mode 100644
index 0000000000..fdcc66279f
--- /dev/null
+++ b/fpdfsdk/src/javascript/JS_Value.h
@@ -0,0 +1,218 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FPDFSDK_SRC_JAVASCRIPT_JS_VALUE_H_
+#define FPDFSDK_SRC_JAVASCRIPT_JS_VALUE_H_
+
+#include "../../../core/include/fxcrt/fx_basic.h"
+#include "../../include/jsapi/fxjs_v8.h"
+
+class CJS_Array;
+class CJS_Date;
+class CJS_Document;
+class CJS_Object;
+
+class CJS_Value {
+ public:
+ enum Type {
+ VT_unknown,
+ VT_string,
+ VT_number,
+ VT_boolean,
+ VT_date,
+ VT_object,
+ VT_fxobject,
+ VT_null,
+ VT_undefined
+ };
+
+ CJS_Value(v8::Isolate* isolate);
+ CJS_Value(v8::Isolate* isolate, v8::Local<v8::Value> pValue, Type t);
+ CJS_Value(v8::Isolate* isolate, const int& iValue);
+ CJS_Value(v8::Isolate* isolate, const double& dValue);
+ CJS_Value(v8::Isolate* isolate, const float& fValue);
+ CJS_Value(v8::Isolate* isolate, const bool& bValue);
+ CJS_Value(v8::Isolate* isolate, v8::Local<v8::Object>);
+ CJS_Value(v8::Isolate* isolate, CJS_Object*);
+ CJS_Value(v8::Isolate* isolate, CJS_Document*);
+ CJS_Value(v8::Isolate* isolate, const FX_CHAR* pStr);
+ CJS_Value(v8::Isolate* isolate, const FX_WCHAR* pWstr);
+ CJS_Value(v8::Isolate* isolate, CJS_Array& array);
+
+ ~CJS_Value();
+
+ void SetNull();
+ void Attach(v8::Local<v8::Value> pValue, Type t);
+ void Attach(CJS_Value* pValue);
+ void Detach();
+
+ Type GetType() const;
+ int ToInt() const;
+ bool ToBool() const;
+ double ToDouble() const;
+ float ToFloat() const;
+ CJS_Object* ToCJSObject() const;
+ CFX_WideString ToCFXWideString() const;
+ CFX_ByteString ToCFXByteString() const;
+ v8::Local<v8::Object> ToV8Object() const;
+ v8::Local<v8::Array> ToV8Array() const;
+ v8::Local<v8::Value> ToV8Value() const;
+
+ void operator=(int iValue);
+ void operator=(bool bValue);
+ void operator=(double);
+ void operator=(float);
+ void operator=(CJS_Object*);
+ void operator=(CJS_Document*);
+ void operator=(v8::Local<v8::Object>);
+ void operator=(CJS_Array&);
+ void operator=(CJS_Date&);
+ void operator=(const FX_WCHAR* pWstr);
+ void operator=(const FX_CHAR* pStr);
+ void operator=(CJS_Value value);
+
+ FX_BOOL IsArrayObject() const;
+ FX_BOOL IsDateObject() const;
+ FX_BOOL ConvertToArray(CJS_Array&) const;
+ FX_BOOL ConvertToDate(CJS_Date&) const;
+
+ v8::Isolate* GetIsolate() { return m_isolate; }
+
+ protected:
+ Type m_eType;
+ v8::Local<v8::Value> m_pValue;
+ v8::Isolate* m_isolate;
+};
+
+class CJS_Parameters : public CFX_ArrayTemplate<CJS_Value> {
+ public:
+ void push_back(const CJS_Value& newElement) {
+ CFX_ArrayTemplate<CJS_Value>::Add(newElement);
+ }
+ int size() const { return CFX_ArrayTemplate<CJS_Value>::GetSize(); }
+};
+
+class CJS_PropValue : public CJS_Value {
+ public:
+ CJS_PropValue(const CJS_Value&);
+ CJS_PropValue(v8::Isolate* isolate);
+ ~CJS_PropValue();
+
+ public:
+ FX_BOOL IsSetting();
+ FX_BOOL IsGetting();
+ void operator<<(int);
+ void operator>>(int&) const;
+ void operator<<(bool);
+ void operator>>(bool&) const;
+ void operator<<(double);
+ void operator>>(double&) const;
+ void operator<<(CJS_Object* pObj);
+ void operator>>(CJS_Object*& ppObj) const;
+ void operator<<(CJS_Document* pJsDoc);
+ void operator>>(CJS_Document*& ppJsDoc) const;
+ void operator<<(CFX_ByteString);
+ void operator>>(CFX_ByteString&) const;
+ void operator<<(CFX_WideString);
+ void operator>>(CFX_WideString&) const;
+ void operator<<(const FX_WCHAR* c_string);
+ void operator<<(v8::Local<v8::Object>);
+ void operator>>(v8::Local<v8::Object>&) const;
+ void operator>>(CJS_Array& array) const;
+ void operator<<(CJS_Array& array);
+ void operator<<(CJS_Date& date);
+ void operator>>(CJS_Date& date) const;
+ operator v8::Local<v8::Value>() const;
+ void StartSetting();
+ void StartGetting();
+
+ private:
+ FX_BOOL m_bIsSetting;
+};
+
+class CJS_Array {
+ public:
+ CJS_Array(v8::Isolate* isolate);
+ virtual ~CJS_Array();
+
+ void Attach(v8::Local<v8::Array> pArray);
+ void GetElement(unsigned index, CJS_Value& value);
+ void SetElement(unsigned index, CJS_Value value);
+ int GetLength();
+ FX_BOOL IsAttached();
+ operator v8::Local<v8::Array>();
+
+ v8::Isolate* GetIsolate() { return m_isolate; }
+
+ private:
+ v8::Local<v8::Array> m_pArray;
+ v8::Isolate* m_isolate;
+};
+
+class CJS_Date {
+ friend class CJS_Value;
+
+ public:
+ CJS_Date(v8::Isolate* isolate);
+ CJS_Date(v8::Isolate* isolate, double dMsec_time);
+ CJS_Date(v8::Isolate* isolate,
+ int year,
+ int mon,
+ int day,
+ int hour,
+ int min,
+ int sec);
+ virtual ~CJS_Date();
+ void Attach(v8::Local<v8::Value> pDate);
+
+ int GetYear();
+ void SetYear(int iYear);
+
+ int GetMonth();
+ void SetMonth(int iMonth);
+
+ int GetDay();
+ void SetDay(int iDay);
+
+ int GetHours();
+ void SetHours(int iHours);
+
+ int GetMinutes();
+ void SetMinutes(int minutes);
+
+ int GetSeconds();
+ void SetSeconds(int seconds);
+
+ operator v8::Local<v8::Value>();
+ operator double() const;
+
+ CFX_WideString ToString() const;
+
+ static double
+ MakeDate(int year, int mon, int mday, int hour, int min, int sec, int ms);
+
+ FX_BOOL IsValidDate();
+
+ protected:
+ v8::Local<v8::Value> m_pDate;
+ v8::Isolate* m_isolate;
+};
+
+double JS_GetDateTime();
+int JS_GetYearFromTime(double dt);
+int JS_GetMonthFromTime(double dt);
+int JS_GetDayFromTime(double dt);
+int JS_GetHourFromTime(double dt);
+int JS_GetMinFromTime(double dt);
+int JS_GetSecFromTime(double dt);
+double JS_DateParse(const wchar_t* string);
+double JS_MakeDay(int nYear, int nMonth, int nDay);
+double JS_MakeTime(int nHour, int nMin, int nSec, int nMs);
+double JS_MakeDate(double day, double time);
+bool JS_PortIsNan(double d);
+double JS_LocalTime(double d);
+
+#endif // FPDFSDK_SRC_JAVASCRIPT_JS_VALUE_H_