| 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/src/fxjse/src/class.h" | 7 #include "xfa/src/fxjse/src/class.h" |
| 8 | 8 |
| 9 #include "xfa/src/fxjse/src/context.h" | 9 #include "xfa/src/fxjse/src/context.h" |
| 10 #include "xfa/src/fxjse/src/scope_inline.h" | 10 #include "xfa/src/fxjse/src/scope_inline.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 void FXJSE_DefineFunctions(FXJSE_HCONTEXT hContext, | 26 void FXJSE_DefineFunctions(FXJSE_HCONTEXT hContext, |
| 27 const FXJSE_FUNCTION* lpFunctions, | 27 const FXJSE_FUNCTION* lpFunctions, |
| 28 int nNum) { | 28 int nNum) { |
| 29 CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext); | 29 CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext); |
| 30 ASSERT(lpContext); | 30 ASSERT(lpContext); |
| 31 CFXJSE_ScopeUtil_IsolateHandleContext scope(lpContext); | 31 CFXJSE_ScopeUtil_IsolateHandleContext scope(lpContext); |
| 32 v8::Isolate* pIsolate = lpContext->GetRuntime(); | 32 v8::Isolate* pIsolate = lpContext->GetRuntime(); |
| 33 v8::Local<v8::Object> hGlobalObject = | 33 v8::Local<v8::Object> hGlobalObject = |
| 34 FXJSE_GetGlobalObjectFromContext(scope.GetLocalContext()); | 34 FXJSE_GetGlobalObjectFromContext(scope.GetLocalContext()); |
| 35 for (int32_t i = 0; i < nNum; i++) { | 35 for (int32_t i = 0; i < nNum; i++) { |
| 36 hGlobalObject->DefineOwnProperty( | 36 v8::Maybe<bool> maybe_success = hGlobalObject->DefineOwnProperty( |
| 37 scope.GetLocalContext(), | 37 scope.GetLocalContext(), |
| 38 v8::String::NewFromUtf8(pIsolate, lpFunctions[i].name), | 38 v8::String::NewFromUtf8(pIsolate, lpFunctions[i].name), |
| 39 v8::Function::New( | 39 v8::Function::New( |
| 40 pIsolate, FXJSE_V8FunctionCallback_Wrapper, | 40 pIsolate, FXJSE_V8FunctionCallback_Wrapper, |
| 41 v8::External::New(pIsolate, | 41 v8::External::New(pIsolate, |
| 42 const_cast<FXJSE_FUNCTION*>(lpFunctions + i))), | 42 const_cast<FXJSE_FUNCTION*>(lpFunctions + i))), |
| 43 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); | 43 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); |
| 44 if (!maybe_success.FromMaybe(false)) |
| 45 return; |
| 44 } | 46 } |
| 45 } | 47 } |
| 46 | 48 |
| 47 FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext, | 49 FXJSE_HCLASS FXJSE_DefineClass(FXJSE_HCONTEXT hContext, |
| 48 const FXJSE_CLASS* lpClass) { | 50 const FXJSE_CLASS* lpClass) { |
| 49 CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext); | 51 CFXJSE_Context* lpContext = reinterpret_cast<CFXJSE_Context*>(hContext); |
| 50 ASSERT(lpContext); | 52 ASSERT(lpContext); |
| 51 return reinterpret_cast<FXJSE_HCLASS>( | 53 return reinterpret_cast<FXJSE_HCLASS>( |
| 52 CFXJSE_Class::Create(lpContext, lpClass, FALSE)); | 54 CFXJSE_Class::Create(lpContext, lpClass, FALSE)); |
| 53 } | 55 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, | 339 CFXJSE_Class* CFXJSE_Class::GetClassFromContext(CFXJSE_Context* pContext, |
| 338 const CFX_ByteStringC& szName) { | 340 const CFX_ByteStringC& szName) { |
| 339 for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) { | 341 for (int count = pContext->m_rgClasses.GetSize(), i = 0; i < count; i++) { |
| 340 CFXJSE_Class* pClass = pContext->m_rgClasses[i]; | 342 CFXJSE_Class* pClass = pContext->m_rgClasses[i]; |
| 341 if (pClass->m_szClassName == szName) { | 343 if (pClass->m_szClassName == szName) { |
| 342 return pClass; | 344 return pClass; |
| 343 } | 345 } |
| 344 } | 346 } |
| 345 return NULL; | 347 return NULL; |
| 346 } | 348 } |
| OLD | NEW |