Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: xfa/fxjse/context.cpp

Issue 2015143005: Workaround dubious casting between CXFA_Object and void* in FXJSE (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Revert typecheck, actually fix code. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fxjse/context.h ('k') | xfa/fxjse/include/fxjse.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxjse/context.cpp
diff --git a/xfa/fxjse/context.cpp b/xfa/fxjse/context.cpp
index 333b2abe57d3ff7a6055af5a719cc4e38bed3002..49d0b44338d17f0a54e2dc872cd15c479561389c 100644
--- a/xfa/fxjse/context.cpp
+++ b/xfa/fxjse/context.cpp
@@ -8,9 +8,48 @@
#include "xfa/fxjse/class.h"
#include "xfa/fxjse/scope_inline.h"
-#include "xfa/fxjse/util_inline.h"
#include "xfa/fxjse/value.h"
+v8::Local<v8::Object> FXJSE_GetGlobalObjectFromContext(
+ const v8::Local<v8::Context>& hContext) {
+ return hContext->Global()->GetPrototype().As<v8::Object>();
+}
+
+void FXJSE_UpdateObjectBinding(v8::Local<v8::Object>& hObject,
+ void* lpNewBinding) {
+ ASSERT(!hObject.IsEmpty());
+ ASSERT(hObject->InternalFieldCount() > 0);
+ hObject->SetAlignedPointerInInternalField(0, lpNewBinding);
+}
+
+void* FXJSE_RetrieveObjectBinding(const v8::Local<v8::Object>& hJSObject,
+ CFXJSE_Class* lpClass) {
+ 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);
+}
+
CFXJSE_Context* FXJSE_Context_Create(
v8::Isolate* pIsolate,
const FXJSE_CLASS_DESCRIPTOR* lpGlobalClass,
« no previous file with comments | « xfa/fxjse/context.h ('k') | xfa/fxjse/include/fxjse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698