// Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef XFA_FXJSE_UTIL_INLINE_H_ #define XFA_FXJSE_UTIL_INLINE_H_ #include "xfa/fxjse/context.h" static V8_INLINE v8::Local FXJSE_GetGlobalObjectFromContext( const v8::Local& hContext) { return hContext->Global()->GetPrototype().As(); } static V8_INLINE void FXJSE_UpdateObjectBinding(v8::Local& hObject, void* lpNewBinding) { ASSERT(!hObject.IsEmpty()); ASSERT(hObject->InternalFieldCount() > 0); hObject->SetAlignedPointerInInternalField(0, lpNewBinding); } static V8_INLINE void* FXJSE_RetrieveObjectBinding( const v8::Local& hJSObject) { ASSERT(!hJSObject.IsEmpty()); if (!hJSObject->IsObject()) { return NULL; } v8::Local hObject = hJSObject; if (hObject->InternalFieldCount() == 0) { v8::Local hProtoObject = hObject->GetPrototype(); if (hProtoObject.IsEmpty() || !hProtoObject->IsObject()) { return NULL; } hObject = hProtoObject.As(); if (hObject->InternalFieldCount() == 0) { return NULL; } } return hObject->GetAlignedPointerFromInternalField(0); } #endif // XFA_FXJSE_UTIL_INLINE_H_