#include "fxjs/cfxjs_engine.h"
#include <memory>
#include <utility>
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/cfx_v8_array_buffer_allocator.h"
#include "fxjs/cjs_object.h"
#include "fxjs/fxv8.h"
#include "fxjs/xfa/cfxjse_runtimedata.h"
#include "v8/include/v8-context.h"
#include "v8/include/v8-exception.h"
#include "v8/include/v8-isolate.h"
#include "v8/include/v8-message.h"
#include "v8/include/v8-primitive.h"
#include "v8/include/v8-script.h"
#include "v8/include/v8-util.h"
namespace {
unsigned int g_embedderDataSlot = …;
v8::Isolate* g_isolate = …;
size_t g_isolate_ref_count = …;
CFX_V8ArrayBufferAllocator* g_arrayBufferAllocator = …;
v8::Global<v8::ObjectTemplate>* g_DefaultGlobalObjectTemplate = …;
const wchar_t kPerObjectDataTag[] = …;
const wchar_t kPerIsolateDataTag[] = …;
void* GetAlignedPointerForPerObjectDataTag() { … }
std::pair<int, int> GetLineAndColumnFromError(v8::Local<v8::Message> message,
v8::Local<v8::Context> context) { … }
}
void CFXJS_PerObjectData::SetNewDataInObject(FXJSOBJTYPE eObjType,
uint32_t nObjDefnID,
v8::Local<v8::Object> pObj) { … }
CFXJS_PerObjectData* CFXJS_PerObjectData::GetFromObject(
v8::Local<v8::Object> pObj) { … }
bool CFXJS_PerObjectData::HasInternalFields(v8::Local<v8::Object> pObj) { … }
CFXJS_PerObjectData* CFXJS_PerObjectData::ExtractFromObject(
v8::Local<v8::Object> pObj) { … }
CFXJS_PerObjectData::CFXJS_PerObjectData(FXJSOBJTYPE eObjType,
uint32_t nObjDefnID)
: … { … }
CFXJS_PerObjectData::~CFXJS_PerObjectData() = default;
class V8TemplateMapTraits final
: public v8::StdMapTraits<CFXJS_PerObjectData*, v8::Object> { … };
class V8TemplateMap { … };
class CFXJS_ObjDefinition { … };
static v8::Local<v8::ObjectTemplate> GetGlobalObjectTemplate(
v8::Isolate* pIsolate) { … }
void V8TemplateMapTraits::Dispose(v8::Isolate* isolate,
v8::Global<v8::Object> value,
WeakCallbackDataType* key) { … }
void V8TemplateMapTraits::DisposeWeak(
const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { … }
V8TemplateMapTraits::MapType* V8TemplateMapTraits::MapFromWeakCallbackInfo(
const v8::WeakCallbackInfo<WeakCallbackDataType>& info) { … }
void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate* pIsolate) { … }
void FXJS_Release() { … }
bool FXJS_GetIsolate(v8::Isolate** pResultIsolate) { … }
size_t FXJS_GlobalIsolateRefCount() { … }
void CFXJS_PerIsolateData::SetUp(v8::Isolate* pIsolate) { … }
CFXJS_PerIsolateData* CFXJS_PerIsolateData::Get(v8::Isolate* pIsolate) { … }
CFXJS_PerIsolateData::CFXJS_PerIsolateData(v8::Isolate* pIsolate)
: … { … }
CFXJS_PerIsolateData::~CFXJS_PerIsolateData() = default;
uint32_t CFXJS_PerIsolateData::CurrentMaxObjDefinitionID() const { … }
CFXJS_ObjDefinition* CFXJS_PerIsolateData::ObjDefinitionForID(
uint32_t id) const { … }
uint32_t CFXJS_PerIsolateData::AssignIDForObjDefinition(
std::unique_ptr<CFXJS_ObjDefinition> pDefn) { … }
CFXJS_Engine::CFXJS_Engine() : … { … }
CFXJS_Engine::CFXJS_Engine(v8::Isolate* pIsolate) : … { … }
CFXJS_Engine::~CFXJS_Engine() = default;
uint32_t CFXJS_Engine::GetObjDefnID(v8::Local<v8::Object> pObj) { … }
void CFXJS_Engine::SetBinding(v8::Local<v8::Object> pObj,
std::unique_ptr<CFXJS_PerObjectData::Binding> p) { … }
void CFXJS_Engine::FreePerObjectData(v8::Local<v8::Object> pObj) { … }
uint32_t CFXJS_Engine::DefineObj(const char* sObjName,
FXJSOBJTYPE eObjType,
CFXJS_Engine::Constructor pConstructor,
CFXJS_Engine::Destructor pDestructor) { … }
void CFXJS_Engine::DefineObjMethod(uint32_t nObjDefnID,
const char* sMethodName,
v8::FunctionCallback pMethodCall) { … }
void CFXJS_Engine::DefineObjProperty(uint32_t nObjDefnID,
const char* sPropName,
v8::AccessorNameGetterCallback pPropGet,
v8::AccessorNameSetterCallback pPropPut) { … }
void CFXJS_Engine::DefineObjAllProperties(
uint32_t nObjDefnID,
v8::NamedPropertyQueryCallback pPropQurey,
v8::NamedPropertyGetterCallback pPropGet,
v8::NamedPropertySetterCallback pPropPut,
v8::NamedPropertyDeleterCallback pPropDel,
v8::NamedPropertyEnumeratorCallback pPropEnum) { … }
void CFXJS_Engine::DefineObjConst(uint32_t nObjDefnID,
const char* sConstName,
v8::Local<v8::Value> pDefault) { … }
void CFXJS_Engine::DefineGlobalMethod(const char* sMethodName,
v8::FunctionCallback pMethodCall) { … }
void CFXJS_Engine::DefineGlobalConst(const wchar_t* sConstName,
v8::FunctionCallback pConstGetter) { … }
void CFXJS_Engine::InitializeEngine() { … }
void CFXJS_Engine::ReleaseEngine() { … }
std::optional<IJS_Runtime::JS_Error> CFXJS_Engine::Execute(
const WideString& script) { … }
v8::Local<v8::Object> CFXJS_Engine::NewFXJSBoundObject(uint32_t nObjDefnID,
FXJSOBJTYPE type) { … }
v8::Local<v8::Object> CFXJS_Engine::GetThisObj() { … }
void CFXJS_Engine::Error(const WideString& message) { … }
v8::Local<v8::Context> CFXJS_Engine::GetV8Context() { … }
CFXJS_PerObjectData::Binding* CFXJS_Engine::GetBinding(
v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj) { … }
v8::Local<v8::Array> CFXJS_Engine::GetConstArray(const WideString& name) { … }
void CFXJS_Engine::SetConstArray(const WideString& name,
v8::Local<v8::Array> array) { … }