Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cjs_object.h
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef FXJS_CJS_OBJECT_H_
8#define FXJS_CJS_OBJECT_H_
9
10#include "core/fxcrt/unowned_ptr.h"
11#include "fxjs/cjs_runtime.h"
12#include "third_party/base/containers/span.h"
13
14class CFXJS_Engine;
15
17 enum Type { Number = 0, String = 1 };
18
19 const char* pName;
21 double number;
22 const char* pStr;
23};
24
30
35
37 public:
38 static void DefineConsts(CFXJS_Engine* pEngine,
39 uint32_t nObjDefnID,
40 pdfium::span<const JSConstSpec> consts);
41 static void DefineProps(CFXJS_Engine* pEngine,
42 uint32_t nObjDefnID,
43 pdfium::span<const JSPropertySpec> consts);
44 static void DefineMethods(CFXJS_Engine* pEngine,
45 uint32_t nObjDefnID,
46 pdfium::span<const JSMethodSpec> consts);
47
48 CJS_Object(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
49 virtual ~CJS_Object();
50
52 return m_pV8Object.Get(GetRuntime()->GetIsolate());
53 }
54 CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); }
55
56 private:
57 v8::Global<v8::Object> m_pV8Object;
58 ObservedPtr<CJS_Runtime> m_pRuntime;
59};
60
61#endif // FXJS_CJS_OBJECT_H_
bool FXJS_GetIsolate(v8::Isolate **pResultIsolate)
size_t FXJS_GlobalIsolateRefCount()
void FXJS_Initialize(unsigned int embedderDataSlot, v8::Isolate *pIsolate)
static v8::Local< v8::ObjectTemplate > GetGlobalObjectTemplate(v8::Isolate *pIsolate)
void FXJS_Release()
FXJSOBJTYPE
@ FXJSOBJTYPE_DYNAMIC
@ FXJSOBJTYPE_STATIC
@ FXJSOBJTYPE_GLOBAL
void DefineObjMethod(uint32_t nObjDefnID, const char *sMethodName, v8::FunctionCallback pMethodCall)
void DefineObjProperty(uint32_t nObjDefnID, const char *sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut)
v8::Local< v8::Context > GetV8Context()
void DefineObjConst(uint32_t nObjDefnID, const char *sConstName, v8::Local< v8::Value > pDefault)
~CFXJS_Engine() override
v8::Local< v8::Object > GetThisObj()
void DefineObjAllProperties(uint32_t nObjDefnID, v8::GenericNamedPropertyQueryCallback pPropQurey, v8::GenericNamedPropertyGetterCallback pPropGet, v8::GenericNamedPropertySetterCallback pPropPut, v8::GenericNamedPropertyDeleterCallback pPropDel, v8::GenericNamedPropertyEnumeratorCallback pPropEnum)
absl::optional< IJS_Runtime::JS_Error > Execute(const WideString &script)
void SetConstArray(const WideString &name, v8::Local< v8::Array > array)
v8::Local< v8::Array > GetConstArray(const WideString &name)
uint32_t DefineObj(const char *sObjName, FXJSOBJTYPE eObjType, Constructor pConstructor, Destructor pDestructor)
CFXJS_Engine(v8::Isolate *pIsolate)
void Error(const WideString &message)
v8::Local< v8::Object > NewFXJSBoundObject(uint32_t nObjDefnID, FXJSOBJTYPE type)
void InitializeEngine()
void DefineGlobalConst(const wchar_t *sConstName, v8::FunctionCallback pConstGetter)
void DefineGlobalMethod(const char *sMethodName, v8::FunctionCallback pMethodCall)
void RunConstructor(CFXJS_Engine *pEngine, v8::Local< v8::Object > obj, v8::Local< v8::Object > proxy)
const char * GetObjName() const
void DefineAllProperties(v8::GenericNamedPropertyQueryCallback pPropQurey, v8::GenericNamedPropertyGetterCallback pPropGet, v8::GenericNamedPropertySetterCallback pPropPut, v8::GenericNamedPropertyDeleterCallback pPropDel, v8::GenericNamedPropertyEnumeratorCallback pPropEnum)
void DefineConst(const char *sConstName, v8::Local< v8::Value > pDefault)
static void CallHandler(const v8::FunctionCallbackInfo< v8::Value > &info)
v8::Isolate * GetIsolate() const
void DefineMethod(v8::Local< v8::String > sMethodName, v8::FunctionCallback pMethodCall)
void RunDestructor(v8::Local< v8::Object > obj)
CFXJS_ObjDefinition(v8::Isolate *isolate, const char *sObjName, FXJSOBJTYPE eObjType, CFXJS_Engine::Constructor pConstructor, CFXJS_Engine::Destructor pDestructor)
FXJSOBJTYPE GetObjType() const
v8::Local< v8::ObjectTemplate > GetInstanceTemplate()
void DefineProperty(v8::Local< v8::String > sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut)
v8::Local< v8::Signature > GetSignature()
void SetPrivate(std::unique_ptr< CJS_Object > p)
~CFXJS_PerObjectData()=default
static void SetNewDataInObject(uint32_t nObjDefnID, v8::Local< v8::Object > pObj)
CJS_Object * GetPrivate()
static CFXJS_PerObjectData * GetFromObject(v8::Local< v8::Object > pObj)
uint32_t GetObjDefnID() const
static void DefineProps(CFXJS_Engine *pEngine, uint32_t nObjDefnID, pdfium::span< const JSPropertySpec > consts)
static void DefineConsts(CFXJS_Engine *pEngine, uint32_t nObjDefnID, pdfium::span< const JSConstSpec > consts)
virtual ~CJS_Object()
CJS_Runtime * GetRuntime() const
Definition cjs_object.h:54
CJS_Object(v8::Local< v8::Object > pObject, CJS_Runtime *pRuntime)
v8::Local< v8::Object > ToV8Object()
Definition cjs_object.h:51
static void DefineMethods(CFXJS_Engine *pEngine, uint32_t nObjDefnID, pdfium::span< const JSMethodSpec > consts)
uint32_t CurrentMaxObjDefinitionID() const
CFXJS_ObjDefinition * ObjDefinitionForID(uint32_t id) const
uint32_t AssignIDForObjDefinition(std::unique_ptr< CFXJS_ObjDefinition > pDefn)
static void OnWeakCallback(const v8::WeakCallbackInfo< WeakCallbackDataType > &data)
static void DisposeCallbackData(WeakCallbackDataType *callbackData)
static void Dispose(v8::Isolate *isolate, v8::Global< v8::Object > value, WeakCallbackDataType *key)
static WeakCallbackDataType * KeyFromWeakCallbackInfo(const v8::WeakCallbackInfo< WeakCallbackDataType > &data)
static MapType * MapFromWeakCallbackInfo(const v8::WeakCallbackInfo< WeakCallbackDataType > &)
static WeakCallbackDataType * WeakCallbackParameter(MapType *map, WeakCallbackDataType *key, v8::Local< v8::Object > value)
static const v8::PersistentContainerCallbackType kCallbackType
static void DisposeWeak(const v8::WeakCallbackInfo< WeakCallbackDataType > &data)
MapType * GetMap()
~V8TemplateMap()=default
V8TemplateMap(v8::Isolate *isolate)
void SetAndMakeWeak(v8::Local< v8::Object > handle)
Definition fxv8.h:22
void ThrowExceptionHelper(v8::Isolate *pIsolate, WideStringView str)
Definition fxv8.cpp:333
#define CHECK(cvref)
const char * pName
Definition cjs_object.h:19
double number
Definition cjs_object.h:21
const char * pStr
Definition cjs_object.h:22
v8::FunctionCallback pMethodCall
Definition cjs_object.h:33
const char * pName
Definition cjs_object.h:32
v8::AccessorGetterCallback pPropGet
Definition cjs_object.h:27
const char * pName
Definition cjs_object.h:26
v8::AccessorSetterCallback pPropPut
Definition cjs_object.h:28