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

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

Issue 2026993003: Remove FXJSE_Value_ToObject and call methods directly (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@context_cleanup_3
Patch Set: Created 4 years, 6 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
« xfa/fxjse/value.h ('K') | « xfa/fxjse/value.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 #include "xfa/fxjse/value.h" 7 #include "xfa/fxjse/value.h"
8 8
9 #include <math.h> 9 #include <math.h>
10 10
11 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
Tom Sepez 2016/06/01 20:17:58 illegal include, in theory due to layering.
11 #include "xfa/fxjse/class.h" 12 #include "xfa/fxjse/class.h"
12 #include "xfa/fxjse/context.h" 13 #include "xfa/fxjse/context.h"
13 14
14 FX_BOOL FXJSE_Value_IsUndefined(CFXJSE_Value* pValue) { 15 FX_BOOL FXJSE_Value_IsUndefined(CFXJSE_Value* pValue) {
15 return pValue && pValue->IsUndefined(); 16 return pValue && pValue->IsUndefined();
16 } 17 }
17 18
18 FX_BOOL FXJSE_Value_IsNull(CFXJSE_Value* pValue) { 19 FX_BOOL FXJSE_Value_IsNull(CFXJSE_Value* pValue) {
19 return pValue && pValue->IsNull(); 20 return pValue && pValue->IsNull();
20 } 21 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 58
58 void FXJSE_Value_ToUTF8String(CFXJSE_Value* pValue, 59 void FXJSE_Value_ToUTF8String(CFXJSE_Value* pValue,
59 CFX_ByteString& szStrOutput) { 60 CFX_ByteString& szStrOutput) {
60 pValue->ToString(szStrOutput); 61 pValue->ToString(szStrOutput);
61 } 62 }
62 63
63 int32_t FXJSE_Value_ToInteger(CFXJSE_Value* pValue) { 64 int32_t FXJSE_Value_ToInteger(CFXJSE_Value* pValue) {
64 return pValue->ToInteger(); 65 return pValue->ToInteger();
65 } 66 }
66 67
67 CFXJSE_HostObject* FXJSE_Value_ToObject(CFXJSE_Value* pValue,
68 CFXJSE_Class* pClass) {
69 return pValue->ToObject(pClass);
70 }
71
72 void FXJSE_Value_SetUndefined(CFXJSE_Value* pValue) { 68 void FXJSE_Value_SetUndefined(CFXJSE_Value* pValue) {
73 pValue->SetUndefined(); 69 pValue->SetUndefined();
74 } 70 }
75 71
76 void FXJSE_Value_SetNull(CFXJSE_Value* pValue) { 72 void FXJSE_Value_SetNull(CFXJSE_Value* pValue) {
77 pValue->SetNull(); 73 pValue->SetNull();
78 } 74 }
79 75
80 void FXJSE_Value_SetBoolean(CFXJSE_Value* pValue, FX_BOOL bBoolean) { 76 void FXJSE_Value_SetBoolean(CFXJSE_Value* pValue, FX_BOOL bBoolean) {
81 pValue->SetBoolean(bBoolean); 77 pValue->SetBoolean(bBoolean);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 hError.As<v8::Object>()->Set( 187 hError.As<v8::Object>()->Set(
192 v8::String::NewFromUtf8(pIsolate, "name"), 188 v8::String::NewFromUtf8(pIsolate, "name"),
193 v8::String::NewFromUtf8(pIsolate, utf8Name.c_str(), 189 v8::String::NewFromUtf8(pIsolate, utf8Name.c_str(),
194 v8::String::kNormalString, 190 v8::String::kNormalString,
195 utf8Name.GetLength())); 191 utf8Name.GetLength()));
196 } 192 }
197 } 193 }
198 pIsolate->ThrowException(hError); 194 pIsolate->ThrowException(hError);
199 } 195 }
200 196
201 CFXJSE_HostObject* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const { 197 CFXJSE_HostObject* CFXJSE_Value::ToHostObject(CFXJSE_Class* lpClass) const {
202 ASSERT(!m_hValue.IsEmpty()); 198 ASSERT(!m_hValue.IsEmpty());
203 199
204 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate); 200 CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
205 v8::Local<v8::Value> pValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue); 201 v8::Local<v8::Value> pValue = v8::Local<v8::Value>::New(m_pIsolate, m_hValue);
206 ASSERT(!pValue.IsEmpty()); 202 ASSERT(!pValue.IsEmpty());
207 203
208 if (!pValue->IsObject()) 204 if (!pValue->IsObject())
209 return nullptr; 205 return nullptr;
210 206
211 return FXJSE_RetrieveObjectBinding(pValue.As<v8::Object>(), lpClass); 207 return FXJSE_RetrieveObjectBinding(pValue.As<v8::Object>(), lpClass);
212 } 208 }
213 209
210 CXFA_Object* CFXJSE_Value::ToObject(CFXJSE_Class* lpClass) const {
211 return static_cast<CXFA_Object*>(ToHostObject(lpClass));
212 }
213
214 CXFA_Node* CFXJSE_Value::ToNode(CFXJSE_Class* lpClass) const {
215 return static_cast<CXFA_Node*>(ToHostObject(lpClass));
216 }
217
218 CXFA_FM2JSContext* CFXJSE_Value::ToJSContext(CFXJSE_Class* lpClass) const {
219 return static_cast<CXFA_FM2JSContext*>(ToHostObject(lpClass));
220 }
221
222 CXFA_ThisProxy* CFXJSE_Value::ToProxy(CFXJSE_Class* lpClass) const {
223 return static_cast<CXFA_ThisProxy*>(ToHostObject(lpClass));
224 }
225
214 V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) { 226 V8_INLINE static double FXJSE_ftod(FX_FLOAT fNumber) {
215 if (sizeof(FX_FLOAT) != 4) { 227 if (sizeof(FX_FLOAT) != 4) {
216 ASSERT(FALSE); 228 ASSERT(FALSE);
217 return fNumber; 229 return fNumber;
218 } 230 }
219 231
220 uint32_t nFloatBits = (uint32_t&)fNumber; 232 uint32_t nFloatBits = (uint32_t&)fNumber;
221 uint8_t nExponent = (uint8_t)(nFloatBits >> 16 >> 7); 233 uint8_t nExponent = (uint8_t)(nFloatBits >> 16 >> 7);
222 if (nExponent == 0 || nExponent == 255) 234 if (nExponent == 0 || nExponent == 255)
223 return fNumber; 235 return fNumber;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 if (lpRetValue) 506 if (lpRetValue)
495 lpRetValue->ForceSetValue(hReturnValue); 507 lpRetValue->ForceSetValue(hReturnValue);
496 508
497 if (lpLocalArgs) { 509 if (lpLocalArgs) {
498 for (uint32_t i = 0; i < nArgCount; i++) 510 for (uint32_t i = 0; i < nArgCount; i++)
499 lpLocalArgs[i].~Local(); 511 lpLocalArgs[i].~Local();
500 FX_Free(lpLocalArgs); 512 FX_Free(lpLocalArgs);
501 } 513 }
502 return bRetValue; 514 return bRetValue;
503 } 515 }
OLDNEW
« xfa/fxjse/value.h ('K') | « xfa/fxjse/value.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698