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

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

Issue 2154503002: Remove type info from CJS_Value, interrogate v8 instead (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: nit 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>
11 11
12 #include "core/fxcrt/include/fx_basic.h" 12 #include "core/fxcrt/include/fx_basic.h"
13 #include "fxjs/include/fxjs_v8.h" 13 #include "fxjs/include/fxjs_v8.h"
14 14
15 class CJS_Array; 15 class CJS_Array;
16 class CJS_Date; 16 class CJS_Date;
17 class CJS_Document; 17 class CJS_Document;
18 class CJS_Object; 18 class CJS_Object;
19 class CJS_Runtime; 19 class CJS_Runtime;
20 20
21 class CJS_Value { 21 class CJS_Value {
22 public: 22 public:
23 enum Type { 23 enum Type {
24 VT_unknown, 24 VT_unknown,
25 VT_string, 25 VT_string,
26 VT_number, 26 VT_number,
27 VT_boolean, 27 VT_boolean,
28 VT_date, 28 VT_date,
29 VT_object, 29 VT_object,
30 VT_fxobject,
31 VT_null, 30 VT_null,
32 VT_undefined 31 VT_undefined
33 }; 32 };
34 33
35 CJS_Value(CJS_Runtime* pRuntime); 34 CJS_Value(CJS_Runtime* pRuntime);
36 CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue, Type t); 35 CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue);
37 CJS_Value(CJS_Runtime* pRuntime, const int& iValue); 36 CJS_Value(CJS_Runtime* pRuntime, const int& iValue);
38 CJS_Value(CJS_Runtime* pRuntime, const double& dValue); 37 CJS_Value(CJS_Runtime* pRuntime, const double& dValue);
39 CJS_Value(CJS_Runtime* pRuntime, const float& fValue); 38 CJS_Value(CJS_Runtime* pRuntime, const float& fValue);
40 CJS_Value(CJS_Runtime* pRuntime, const bool& bValue); 39 CJS_Value(CJS_Runtime* pRuntime, const bool& bValue);
41 CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Object>); 40 CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj);
42 CJS_Value(CJS_Runtime* pRuntime, CJS_Object*);
43 CJS_Value(CJS_Runtime* pRuntime, CJS_Document*);
44 CJS_Value(CJS_Runtime* pRuntime, const FX_CHAR* pStr); 41 CJS_Value(CJS_Runtime* pRuntime, const FX_CHAR* pStr);
45 CJS_Value(CJS_Runtime* pRuntime, const FX_WCHAR* pWstr); 42 CJS_Value(CJS_Runtime* pRuntime, const FX_WCHAR* pWstr);
46 CJS_Value(CJS_Runtime* pRuntime, CJS_Array& array); 43 CJS_Value(CJS_Runtime* pRuntime, CJS_Array& array);
47 44
48 ~CJS_Value(); 45 ~CJS_Value();
49 CJS_Value(const CJS_Value& other); 46 CJS_Value(const CJS_Value& other);
50 47
51 void SetNull(); 48 void SetNull();
52 void Attach(v8::Local<v8::Value> pValue, Type t); 49 void Attach(v8::Local<v8::Value> pValue);
53 void Attach(CJS_Value* pValue); 50 void Attach(CJS_Value* pValue);
54 void Detach(); 51 void Detach();
55 52
56 Type GetType() const; 53 static Type GetValueType(v8::Local<v8::Value> value);
54 Type GetType() const { return GetValueType(m_pValue); }
57 int ToInt() const; 55 int ToInt() const;
58 bool ToBool() const; 56 bool ToBool() const;
59 double ToDouble() const; 57 double ToDouble() const;
60 float ToFloat() const; 58 float ToFloat() const;
61 CJS_Object* ToCJSObject() const; 59 CJS_Object* ToCJSObject() const;
62 CFX_WideString ToCFXWideString() const; 60 CFX_WideString ToCFXWideString() const;
63 CFX_ByteString ToCFXByteString() const; 61 CFX_ByteString ToCFXByteString() const;
64 v8::Local<v8::Object> ToV8Object() const; 62 v8::Local<v8::Object> ToV8Object() const;
65 v8::Local<v8::Array> ToV8Array() const; 63 v8::Local<v8::Array> ToV8Array() const;
66 v8::Local<v8::Value> ToV8Value() const; 64 v8::Local<v8::Value> ToV8Value() const;
67 65
68 // Replace the current |m_pValue| with a v8::Number if possible 66 // Replace the current |m_pValue| with a v8::Number if possible
69 // to make one from the current |m_pValue|, updating |m_eType| 67 // to make one from the current |m_pValue|.
70 // as appropriate to indicate the result.
71 void MaybeCoerceToNumber(); 68 void MaybeCoerceToNumber();
72 69
73 void operator=(int iValue); 70 void operator=(int iValue);
74 void operator=(bool bValue); 71 void operator=(bool bValue);
75 void operator=(double val); 72 void operator=(double val);
76 void operator=(float val); 73 void operator=(float val);
77 void operator=(CJS_Object* val); 74 void operator=(CJS_Object* val);
78 void operator=(CJS_Document* val);
79 void operator=(v8::Local<v8::Object> val); 75 void operator=(v8::Local<v8::Object> val);
80 void operator=(CJS_Array& val); 76 void operator=(CJS_Array& val);
81 void operator=(CJS_Date& val); 77 void operator=(CJS_Date& val);
82 void operator=(const FX_WCHAR* pWstr); 78 void operator=(const FX_WCHAR* pWstr);
83 void operator=(const FX_CHAR* pStr); 79 void operator=(const FX_CHAR* pStr);
84 void operator=(CJS_Value value); 80 void operator=(CJS_Value value);
85 81
86 FX_BOOL IsArrayObject() const; 82 FX_BOOL IsArrayObject() const;
87 FX_BOOL IsDateObject() const; 83 FX_BOOL IsDateObject() const;
88 FX_BOOL ConvertToArray(CJS_Array&) const; 84 FX_BOOL ConvertToArray(CJS_Array&) const;
89 FX_BOOL ConvertToDate(CJS_Date&) const; 85 FX_BOOL ConvertToDate(CJS_Date&) const;
90 86
91 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; } 87 CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime; }
92 88
93 protected: 89 protected:
94 Type m_eType;
95 v8::Local<v8::Value> m_pValue; 90 v8::Local<v8::Value> m_pValue;
96 CJS_Runtime* m_pJSRuntime; 91 CJS_Runtime* m_pJSRuntime;
97 }; 92 };
98 93
99 class CJS_PropValue : public CJS_Value { 94 class CJS_PropValue : public CJS_Value {
100 public: 95 public:
101 CJS_PropValue(const CJS_Value&); 96 CJS_PropValue(const CJS_Value&);
102 CJS_PropValue(CJS_Runtime* pRuntime); 97 CJS_PropValue(CJS_Runtime* pRuntime);
103 ~CJS_PropValue(); 98 ~CJS_PropValue();
104 99
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // names as wchar_t string literals corresponding to each positional argument. 218 // names as wchar_t string literals corresponding to each positional argument.
224 // The result will always contain |nKeywords| value, with unspecified ones 219 // The result will always contain |nKeywords| value, with unspecified ones
225 // being set to type VT_unknown. 220 // being set to type VT_unknown.
226 std::vector<CJS_Value> JS_ExpandKeywordParams( 221 std::vector<CJS_Value> JS_ExpandKeywordParams(
227 CJS_Runtime* pRuntime, 222 CJS_Runtime* pRuntime,
228 const std::vector<CJS_Value>& originals, 223 const std::vector<CJS_Value>& originals,
229 size_t nKeywords, 224 size_t nKeywords,
230 ...); 225 ...);
231 226
232 #endif // FPDFSDK_JAVASCRIPT_JS_VALUE_H_ 227 #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