pdfium/fxjs/cjs_object.cpp
Clemens Backes 02ed40c030 Avoid calls to deprecated GetIsolate methods
Use the stored isolate instead.

After this landed https://crrev.com/c/6613837 will advance the
deprecation of the methods in the V8 API.

Bug: 427885584

R=tsepez@chromium.org

Change-Id: I7ce29779f5de501ef56c60d5cfdd91772e056d8e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/133910
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2025-07-22 11:17:25 -07:00

50 lines
1.7 KiB
C++

// Copyright 2014 The PDFium Authors
// 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
#include "fxjs/cjs_object.h"
#include "fxjs/cfxjs_engine.h"
// static
void CJS_Object::DefineConsts(CFXJS_Engine* pEngine,
uint32_t nObjDefnID,
pdfium::span<const JSConstSpec> consts) {
for (const auto& item : consts) {
pEngine->DefineObjConst(
nObjDefnID, item.pName,
item.eType == JSConstSpec::Number
? pEngine->NewNumber(item.number).As<v8::Value>()
: pEngine->NewString(item.pStr).As<v8::Value>());
}
}
// static
void CJS_Object::DefineProps(CFXJS_Engine* pEngine,
uint32_t nObjDefnID,
pdfium::span<const JSPropertySpec> props) {
for (const auto& item : props) {
pEngine->DefineObjProperty(nObjDefnID, item.pName, item.pPropGet,
item.pPropPut);
}
}
// static
void CJS_Object::DefineMethods(CFXJS_Engine* pEngine,
uint32_t nObjDefnID,
pdfium::span<const JSMethodSpec> methods) {
for (const auto& item : methods) {
pEngine->DefineObjMethod(nObjDefnID, item.pName, item.pMethodCall);
}
}
CJS_Object::CJS_Object(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
: v8_object_(pRuntime->GetIsolate(), pObject), runtime_(pRuntime) {}
CJS_Object::CJS_Object(v8::Local<v8::Object> object, v8::Isolate* isolate)
: v8_object_(isolate, object) {}
CJS_Object::~CJS_Object() = default;