summaryrefslogtreecommitdiff
path: root/xfa/fxjse/util_inline.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 14:14:16 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 14:14:16 -0400
commit1770c021cf998ff1b33855b1397f6ea8ff9f7cd7 (patch)
tree285e39abd4b5872d8cd632b9e331b0667fdc3eae /xfa/fxjse/util_inline.h
parentf766ad219f66543654520f6a1955836f519e26d1 (diff)
downloadpdfium-1770c021cf998ff1b33855b1397f6ea8ff9f7cd7.tar.xz
Move xfa/src up to xfa/.
This CL moves the xfa/src files up to the xfa/ directory and fixes the includes, include guards, and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1803723002 .
Diffstat (limited to 'xfa/fxjse/util_inline.h')
-rw-r--r--xfa/fxjse/util_inline.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/xfa/fxjse/util_inline.h b/xfa/fxjse/util_inline.h
new file mode 100644
index 0000000000..e61dc6aa80
--- /dev/null
+++ b/xfa/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_FXJSE_UTIL_INLINE_H_
+#define XFA_FXJSE_UTIL_INLINE_H_
+
+#include "xfa/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_FXJSE_UTIL_INLINE_H_