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

Side by Side Diff: xfa/fxjse/value.h

Issue 2013963005: Replace FXJSE_HCONTEXT with CFXJSE_Context* (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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 | « xfa/fxjse/include/fxjse.h ('k') | no next file » | 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 XFA_FXJSE_VALUE_H_ 7 #ifndef XFA_FXJSE_VALUE_H_
8 #define XFA_FXJSE_VALUE_H_ 8 #define XFA_FXJSE_VALUE_H_
9 9
10 #include "xfa/fxjse/scope_inline.h" 10 #include "xfa/fxjse/scope_inline.h"
11 11
12 class CFXJSE_Value { 12 class CFXJSE_Value {
13 public: 13 public:
14 CFXJSE_Value(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} 14 CFXJSE_Value(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {}
15 15
16 protected:
17 CFXJSE_Value();
18 CFXJSE_Value(const CFXJSE_Value&);
19 CFXJSE_Value& operator=(const CFXJSE_Value&);
20
21 public:
22 V8_INLINE FX_BOOL IsUndefined() const { 16 V8_INLINE FX_BOOL IsUndefined() const {
23 if (m_hValue.IsEmpty()) { 17 if (m_hValue.IsEmpty()) {
24 return FALSE; 18 return FALSE;
25 } 19 }
26 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 20 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
27 v8::Local<v8::Value> hValue = 21 v8::Local<v8::Value> hValue =
28 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 22 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
29 return hValue->IsUndefined(); 23 return hValue->IsUndefined();
30 } 24 }
31 V8_INLINE FX_BOOL IsNull() const { 25 V8_INLINE FX_BOOL IsNull() const {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 V8_INLINE FX_BOOL IsDate() const { 97 V8_INLINE FX_BOOL IsDate() const {
104 if (m_hValue.IsEmpty()) { 98 if (m_hValue.IsEmpty()) {
105 return FALSE; 99 return FALSE;
106 } 100 }
107 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 101 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
108 v8::Local<v8::Value> hValue = 102 v8::Local<v8::Value> hValue =
109 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 103 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
110 return hValue->IsDate(); 104 return hValue->IsDate();
111 } 105 }
112 106
113 public:
114 V8_INLINE FX_BOOL ToBoolean() const { 107 V8_INLINE FX_BOOL ToBoolean() const {
115 ASSERT(!m_hValue.IsEmpty()); 108 ASSERT(!m_hValue.IsEmpty());
116 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 109 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
117 v8::Local<v8::Value> hValue = 110 v8::Local<v8::Value> hValue =
118 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 111 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
119 return static_cast<FX_BOOL>(hValue->BooleanValue()); 112 return static_cast<FX_BOOL>(hValue->BooleanValue());
120 } 113 }
121 V8_INLINE FX_FLOAT ToFloat() const { 114 V8_INLINE FX_FLOAT ToFloat() const {
122 ASSERT(!m_hValue.IsEmpty()); 115 ASSERT(!m_hValue.IsEmpty());
123 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 116 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
(...skipping 19 matching lines...) Expand all
143 ASSERT(!m_hValue.IsEmpty()); 136 ASSERT(!m_hValue.IsEmpty());
144 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 137 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
145 v8::Local<v8::Value> hValue = 138 v8::Local<v8::Value> hValue =
146 v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 139 v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
147 v8::Local<v8::String> hString = hValue->ToString(); 140 v8::Local<v8::String> hString = hValue->ToString();
148 v8::String::Utf8Value hStringVal(hString); 141 v8::String::Utf8Value hStringVal(hString);
149 szStrOutput = *hStringVal; 142 szStrOutput = *hStringVal;
150 } 143 }
151 void* ToObject(CFXJSE_Class* lpClass) const; 144 void* ToObject(CFXJSE_Class* lpClass) const;
152 145
153 public:
154 V8_INLINE void SetUndefined() { 146 V8_INLINE void SetUndefined() {
155 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 147 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
156 v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate); 148 v8::Local<v8::Value> hValue = v8::Undefined(m_pIsolate);
157 m_hValue.Reset(m_pIsolate, hValue); 149 m_hValue.Reset(m_pIsolate, hValue);
158 } 150 }
159 V8_INLINE void SetNull() { 151 V8_INLINE void SetNull() {
160 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate); 152 CFXJSE_ScopeUtil_IsolateHandle scope(m_pIsolate);
161 v8::Local<v8::Value> hValue = v8::Null(m_pIsolate); 153 v8::Local<v8::Value> hValue = v8::Null(m_pIsolate);
162 m_hValue.Reset(m_pIsolate, hValue); 154 m_hValue.Reset(m_pIsolate, hValue);
163 } 155 }
(...skipping 23 matching lines...) Expand all
187 V8_INLINE void SetFloat(FX_FLOAT fFloat); 179 V8_INLINE void SetFloat(FX_FLOAT fFloat);
188 V8_INLINE void SetJSObject() { 180 V8_INLINE void SetJSObject() {
189 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 181 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
190 v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate); 182 v8::Local<v8::Value> hValue = v8::Object::New(m_pIsolate);
191 m_hValue.Reset(m_pIsolate, hValue); 183 m_hValue.Reset(m_pIsolate, hValue);
192 } 184 }
193 void SetHostObject(void* lpObject, CFXJSE_Class* lpClass); 185 void SetHostObject(void* lpObject, CFXJSE_Class* lpClass);
194 void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues); 186 void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues);
195 void SetDate(double dDouble); 187 void SetDate(double dDouble);
196 188
197 public:
198 FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName, 189 FX_BOOL GetObjectProperty(const CFX_ByteStringC& szPropName,
199 CFXJSE_Value* lpPropValue); 190 CFXJSE_Value* lpPropValue);
200 FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName, 191 FX_BOOL SetObjectProperty(const CFX_ByteStringC& szPropName,
201 CFXJSE_Value* lpPropValue); 192 CFXJSE_Value* lpPropValue);
202 FX_BOOL GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); 193 FX_BOOL GetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue);
203 FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue); 194 FX_BOOL SetObjectProperty(uint32_t uPropIdx, CFXJSE_Value* lpPropValue);
204 FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName); 195 FX_BOOL DeleteObjectProperty(const CFX_ByteStringC& szPropName);
205 FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName, 196 FX_BOOL HasObjectOwnProperty(const CFX_ByteStringC& szPropName,
206 FX_BOOL bUseTypeGetter); 197 FX_BOOL bUseTypeGetter);
207 FX_BOOL SetObjectOwnProperty(const CFX_ByteStringC& szPropName, 198 FX_BOOL SetObjectOwnProperty(const CFX_ByteStringC& szPropName,
208 CFXJSE_Value* lpPropValue); 199 CFXJSE_Value* lpPropValue);
209 FX_BOOL SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis); 200 FX_BOOL SetFunctionBind(CFXJSE_Value* lpOldFunction, CFXJSE_Value* lpNewThis);
210 FX_BOOL Call(CFXJSE_Value* lpReceiver, 201 FX_BOOL Call(CFXJSE_Value* lpReceiver,
211 CFXJSE_Value* lpRetValue, 202 CFXJSE_Value* lpRetValue,
212 uint32_t nArgCount, 203 uint32_t nArgCount,
213 FXJSE_HVALUE* lpArgs); 204 FXJSE_HVALUE* lpArgs);
214 205
215 public:
216 V8_INLINE v8::Isolate* GetIsolate() const { return m_pIsolate; } 206 V8_INLINE v8::Isolate* GetIsolate() const { return m_pIsolate; }
217 V8_INLINE const v8::Global<v8::Value>& DirectGetValue() const { 207 V8_INLINE const v8::Global<v8::Value>& DirectGetValue() const {
218 return m_hValue; 208 return m_hValue;
219 } 209 }
220 V8_INLINE void ForceSetValue(v8::Local<v8::Value> hValue) { 210 V8_INLINE void ForceSetValue(v8::Local<v8::Value> hValue) {
221 m_hValue.Reset(m_pIsolate, hValue); 211 m_hValue.Reset(m_pIsolate, hValue);
222 } 212 }
223 V8_INLINE void Assign(const CFXJSE_Value* lpValue) { 213 V8_INLINE void Assign(const CFXJSE_Value* lpValue) {
224 if (lpValue) { 214 if (lpValue) {
225 m_hValue.Reset(m_pIsolate, lpValue->m_hValue); 215 m_hValue.Reset(m_pIsolate, lpValue->m_hValue);
226 } else { 216 } else {
227 m_hValue.Reset(); 217 m_hValue.Reset();
228 } 218 }
229 } 219 }
230 220
231 public:
232 static CFXJSE_Value* Create(v8::Isolate* pIsolate); 221 static CFXJSE_Value* Create(v8::Isolate* pIsolate);
233 222
234 protected: 223 private:
224 friend class CFXJSE_Class;
225 friend class CFXJSE_Context;
226
227 CFXJSE_Value();
228 CFXJSE_Value(const CFXJSE_Value&);
229 CFXJSE_Value& operator=(const CFXJSE_Value&);
230
235 v8::Isolate* m_pIsolate; 231 v8::Isolate* m_pIsolate;
236 v8::Global<v8::Value> m_hValue; 232 v8::Global<v8::Value> m_hValue;
237 friend class CFXJSE_Context;
238 friend class CFXJSE_Class;
239 }; 233 };
240 234
241 #endif // XFA_FXJSE_VALUE_H_ 235 #endif // XFA_FXJSE_VALUE_H_
OLDNEW
« no previous file with comments | « xfa/fxjse/include/fxjse.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698