summaryrefslogtreecommitdiff
path: root/xfa/fxjse/util_inline.h
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-27 17:45:00 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-27 17:45:00 -0700
commit3a005f22703b9303a306bf34cbd17c3729f763aa (patch)
tree9f640eaedbcbdf5b24641f33da1a110241feca82 /xfa/fxjse/util_inline.h
parent2f109ab836682cb465270ed303d27955db97d98f (diff)
downloadpdfium-3a005f22703b9303a306bf34cbd17c3729f763aa.tar.xz
Workaround dubious casting between CXFA_Object and void* in FXJSE
This is just a crock to get things working until we fix the underlying issue. When there's single-inheritance, it may often work in practice to C-style (reinterpret) cast a Derived* ptr to void* and then back to a Base* ptr. One place where this blows up is if Derived has virtual functions but Base does not, in which case the world will be offset by the size of a vtable ptr. Because of the use of void* types in FXJSE, the above was happening when setting a CXFA_ThisProxy (Derived, virtual) to be a global object (void*). This would then be cast back to a CFXA_Object (Base, non-virtual) and chaos is ensured. Not sure how far back this goes. Along the way, pick up some tidying which was necessary for simplicity while tracking this down. BUG=613607 Review-Url: https://codereview.chromium.org/2015143005
Diffstat (limited to 'xfa/fxjse/util_inline.h')
-rw-r--r--xfa/fxjse/util_inline.h51
1 files changed, 0 insertions, 51 deletions
diff --git a/xfa/fxjse/util_inline.h b/xfa/fxjse/util_inline.h
deleted file mode 100644
index e61dc6aa80..0000000000
--- a/xfa/fxjse/util_inline.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// 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_