diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2016-03-08 15:03:11 -0500 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2016-03-08 15:03:11 -0500 |
commit | e2a774a4b841829ef089d0cbfd15a08895eecf0e (patch) | |
tree | 094545ac4603e5d2ed2c3138f9183cc4a7d4e67b /xfa/src/fxjse/util_inline.h | |
parent | 6cdf084fa40a62eb33185171622ad12d95c6009e (diff) | |
download | pdfium-e2a774a4b841829ef089d0cbfd15a08895eecf0e.tar.xz |
Remove xfa/src/fxjse/src and move code up a level.
This CL removes the xfa/src/fxjse/src and moves all of the .h and .cpp files
up to the, previously empty, xfa/src/fxjse directory.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1776643002 .
Diffstat (limited to 'xfa/src/fxjse/util_inline.h')
-rw-r--r-- | xfa/src/fxjse/util_inline.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/xfa/src/fxjse/util_inline.h b/xfa/src/fxjse/util_inline.h new file mode 100644 index 0000000000..c29c22e1f8 --- /dev/null +++ b/xfa/src/fxjse/util_inline.h @@ -0,0 +1,51 @@ +// 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_SRC_FXJSE_UTIL_INLINE_H_ +#define XFA_SRC_FXJSE_UTIL_INLINE_H_ + +#include "xfa/src/fxjse/context.h" + +static V8_INLINE v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext( + const v8::Local<v8::Context>& hContext) { + return hContext->Global()->GetPrototype().As<v8::Object>(); +} +static V8_INLINE void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject, + void* lpNewBinding) { + ASSERT(!hObject.IsEmpty()); + ASSERT(hObject->InternalFieldCount() > 0); + hObject->SetAlignedPointerInInternalField(0, lpNewBinding); +} +static V8_INLINE void* FXJSE_RetrieveObjectBinding( + const v8::Local<v8::Object>& hJSObject, + CFXJSE_Class* lpClass = NULL) { + ASSERT(!hJSObject.IsEmpty()); + if (!hJSObject->IsObject()) { + return NULL; + } + v8::Local<v8::Object> hObject = hJSObject; + if (hObject->InternalFieldCount() == 0) { + v8::Local<v8::Value> hProtoObject = hObject->GetPrototype(); + if (hProtoObject.IsEmpty() || !hProtoObject->IsObject()) { + return NULL; + } + hObject = hProtoObject.As<v8::Object>(); + if (hObject->InternalFieldCount() == 0) { + return NULL; + } + } + if (lpClass) { + v8::Local<v8::FunctionTemplate> hClass = + v8::Local<v8::FunctionTemplate>::New( + lpClass->GetContext()->GetRuntime(), lpClass->GetTemplate()); + if (!hClass->HasInstance(hObject)) { + return NULL; + } + } + return hObject->GetAlignedPointerFromInternalField(0); +} + +#endif // XFA_SRC_FXJSE_UTIL_INLINE_H_ |