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 #include "xfa/fxjse/class.h" | 7 #include "xfa/fxjse/class.h" |
8 | 8 |
9 #include "xfa/fxjse/cfxjse_arguments.h" | 9 #include "xfa/fxjse/cfxjse_arguments.h" |
10 #include "xfa/fxjse/context.h" | 10 #include "xfa/fxjse/context.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 176 } |
177 | 177 |
178 CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const { | 178 CFX_ByteString CFXJSE_Arguments::GetUTF8String(int32_t index) const { |
179 const CFXJSE_ArgumentsImpl* lpArguments = | 179 const CFXJSE_ArgumentsImpl* lpArguments = |
180 reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); | 180 reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); |
181 v8::Local<v8::String> hString = (*lpArguments->m_pInfo)[index]->ToString(); | 181 v8::Local<v8::String> hString = (*lpArguments->m_pInfo)[index]->ToString(); |
182 v8::String::Utf8Value szStringVal(hString); | 182 v8::String::Utf8Value szStringVal(hString); |
183 return CFX_ByteString(*szStringVal); | 183 return CFX_ByteString(*szStringVal); |
184 } | 184 } |
185 | 185 |
186 void* CFXJSE_Arguments::GetObject(int32_t index, FXJSE_HCLASS hClass) const { | 186 void* CFXJSE_Arguments::GetObject(int32_t index) const { |
187 const CFXJSE_ArgumentsImpl* lpArguments = | 187 const CFXJSE_ArgumentsImpl* lpArguments = |
188 reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); | 188 reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); |
189 v8::Local<v8::Value> hValue = (*lpArguments->m_pInfo)[index]; | 189 v8::Local<v8::Value> hValue = (*lpArguments->m_pInfo)[index]; |
190 ASSERT(!hValue.IsEmpty()); | 190 ASSERT(!hValue.IsEmpty()); |
191 if (!hValue->IsObject()) { | 191 if (!hValue->IsObject()) { |
192 return NULL; | 192 return NULL; |
193 } | 193 } |
194 CFXJSE_Class* lpClass = reinterpret_cast<CFXJSE_Class*>(hClass); | 194 return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>()); |
195 return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), lpClass); | |
196 } | 195 } |
197 | 196 |
198 FXJSE_HVALUE CFXJSE_Arguments::GetReturnValue() { | 197 FXJSE_HVALUE CFXJSE_Arguments::GetReturnValue() { |
199 const CFXJSE_ArgumentsImpl* lpArguments = | 198 const CFXJSE_ArgumentsImpl* lpArguments = |
200 reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); | 199 reinterpret_cast<const CFXJSE_ArgumentsImpl* const>(this); |
201 return reinterpret_cast<FXJSE_HVALUE>(lpArguments->m_pRetValue); | 200 return reinterpret_cast<FXJSE_HVALUE>(lpArguments->m_pRetValue); |
202 } | 201 } |
203 static void FXJSE_Context_GlobalObjToString( | 202 static void FXJSE_Context_GlobalObjToString( |
204 const v8::FunctionCallbackInfo<v8::Value>& info) { | 203 const v8::FunctionCallbackInfo<v8::Value>& info) { |
205 const FXJSE_CLASS* lpClass = | 204 const FXJSE_CLASS* lpClass = |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 308 } |
310 | 309 |
311 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, | 310 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, |
312 const CFX_ByteStringC& szName) { | 311 const CFX_ByteStringC& szName) { |
313 for (const auto& pClass : pContext->m_rgClasses) { | 312 for (const auto& pClass : pContext->m_rgClasses) { |
314 if (pClass->m_szClassName == szName) | 313 if (pClass->m_szClassName == szName) |
315 return pClass.get(); | 314 return pClass.get(); |
316 } | 315 } |
317 return nullptr; | 316 return nullptr; |
318 } | 317 } |
OLD | NEW |