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
fxv8.h
Go to the documentation of this file.
1// Copyright 2020 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_FXV8_H_
8#define FXJS_FXV8_H_
9
10#include <stddef.h>
11
12#include <vector>
13
14#include "core/fxcrt/fx_string.h"
15#include "third_party/base/containers/span.h"
16#include "v8/include/v8-forward.h"
17
18// The fxv8 functions soften up the interface to the V8 API. In particular,
19// PDFium uses size_t for sizes and indices, but V8 mostly uses ints, so
20// these routines perform checked conversions.
21
22namespace fxv8 {
23
24// These first check for empty locals.
26bool IsNull(v8::Local<v8::Value> value);
28bool IsString(v8::Local<v8::Value> value);
29bool IsNumber(v8::Local<v8::Value> value);
31bool IsObject(v8::Local<v8::Value> value);
32bool IsArray(v8::Local<v8::Value> value);
33bool IsDate(v8::Local<v8::Value> value);
35
36v8::Local<v8::Value> NewNullHelper(v8::Isolate* pIsolate);
37v8::Local<v8::Value> NewUndefinedHelper(v8::Isolate* pIsolate);
38v8::Local<v8::Number> NewNumberHelper(v8::Isolate* pIsolate, int number);
39v8::Local<v8::Number> NewNumberHelper(v8::Isolate* pIsolate, double number);
40v8::Local<v8::Number> NewNumberHelper(v8::Isolate* pIsolate, float number);
41v8::Local<v8::Boolean> NewBooleanHelper(v8::Isolate* pIsolate, bool b);
42v8::Local<v8::String> NewStringHelper(v8::Isolate* pIsolate,
43 ByteStringView str);
44v8::Local<v8::String> NewStringHelper(v8::Isolate* pIsolate,
45 WideStringView str);
46v8::Local<v8::Array> NewArrayHelper(v8::Isolate* pIsolate);
47v8::Local<v8::Array> NewArrayHelper(v8::Isolate* pIsolate,
49v8::Local<v8::Object> NewObjectHelper(v8::Isolate* pIsolate);
50v8::Local<v8::Date> NewDateHelper(v8::Isolate* pIsolate, double d);
51
52// Conversion to PDFium type without re-entry from known v8 type.
55
56// Conversion to PDFium type with possible re-entry for coercion.
73
80 v8::Local<v8::Object> pObj);
91 v8::Local<v8::Value> pPut);
95
102 size_t index);
104
105void ThrowExceptionHelper(v8::Isolate* pIsolate, ByteStringView str);
106void ThrowExceptionHelper(v8::Isolate* pIsolate, WideStringView str);
107
108} // namespace fxv8
109
110#endif // FXJS_FXV8_H_
v8::Local< v8::Number > NewNumber(double number)
Definition cfx_v8.cpp:67
v8::Local< v8::Number > NewNumber(float number)
Definition cfx_v8.cpp:71
v8::Local< v8::Boolean > NewBoolean(bool b)
Definition cfx_v8.cpp:75
v8::Local< v8::String > NewString(WideStringView str)
Definition cfx_v8.cpp:83
v8::Local< v8::Array > NewArray()
Definition cfx_v8.cpp:40
CFX_V8(v8::Isolate *pIsolate)
Definition cfx_v8.cpp:12
v8::Local< v8::Date > NewDate(double d)
Definition cfx_v8.cpp:98
v8::Local< v8::Value > NewNull()
Definition cfx_v8.cpp:90
void DisposeIsolate()
Definition cfx_v8.cpp:35
v8::Local< v8::Object > NewObject()
Definition cfx_v8.cpp:44
virtual ~CFX_V8()
v8::Local< v8::Number > NewNumber(int number)
Definition cfx_v8.cpp:63
v8::Local< v8::String > NewString(ByteStringView str)
Definition cfx_v8.cpp:79
v8::Local< v8::Value > NewUndefined()
Definition cfx_v8.cpp:94
Definition fxv8.h:22
v8::Local< v8::Number > NewNumberHelper(v8::Isolate *pIsolate, int number)
Definition fxv8.cpp:67
v8::Local< v8::Value > ReentrantGetArrayElementHelper(v8::Isolate *pIsolate, v8::Local< v8::Array > pArray, size_t index)
Definition fxv8.cpp:306
v8::Local< v8::Date > NewDateHelper(v8::Isolate *pIsolate, double d)
Definition fxv8.cpp:115
bool IsBoolean(v8::Local< v8::Value > value)
Definition fxv8.cpp:27
v8::Local< v8::Object > ReentrantToObjectHelper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:187
void ThrowExceptionHelper(v8::Isolate *pIsolate, WideStringView str)
Definition fxv8.cpp:333
v8::Local< v8::Value > NewUndefinedHelper(v8::Isolate *pIsolate)
Definition fxv8.cpp:63
bool IsArray(v8::Local< v8::Value > value)
Definition fxv8.cpp:47
bool IsUndefined(v8::Local< v8::Value > value)
Definition fxv8.cpp:19
double ReentrantToDoubleHelper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:151
v8::Local< v8::String > NewStringHelper(v8::Isolate *pIsolate, WideStringView str)
Definition fxv8.cpp:91
bool ReentrantSetObjectOwnPropertyHelper(v8::Isolate *pIsolate, v8::Local< v8::Object > pObj, ByteStringView bsUTF8PropertyName, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:257
bool ReentrantPutArrayElementHelper(v8::Isolate *pIsolate, v8::Local< v8::Array > pArray, size_t index, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:292
v8::Local< v8::String > NewStringHelper(v8::Isolate *pIsolate, ByteStringView str)
Definition fxv8.cpp:83
bool IsInteger(v8::Local< v8::Value > value)
Definition fxv8.cpp:39
void ThrowExceptionHelper(v8::Isolate *pIsolate, ByteStringView str)
Definition fxv8.cpp:329
bool ReentrantHasObjectOwnPropertyHelper(v8::Isolate *pIsolate, v8::Local< v8::Object > pObj, ByteStringView bsUTF8PropertyName)
Definition fxv8.cpp:244
v8::Local< v8::Boolean > NewBooleanHelper(v8::Isolate *pIsolate, bool b)
Definition fxv8.cpp:79
v8::Local< v8::Array > NewArrayHelper(v8::Isolate *pIsolate, pdfium::span< v8::Local< v8::Value > > values)
Definition fxv8.cpp:100
v8::Local< v8::Value > ReentrantGetObjectPropertyHelper(v8::Isolate *pIsolate, v8::Local< v8::Object > pObj, ByteStringView bsUTF8PropertyName)
Definition fxv8.cpp:207
WideString ReentrantToWideStringHelper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:159
void ReentrantDeleteObjectPropertyHelper(v8::Isolate *pIsolate, v8::Local< v8::Object > pObj, ByteStringView bsUTF8PropertyName)
Definition fxv8.cpp:283
bool IsNumber(v8::Local< v8::Value > value)
Definition fxv8.cpp:35
bool ReentrantPutObjectPropertyHelper(v8::Isolate *pIsolate, v8::Local< v8::Object > pObj, ByteStringView bsUTF8PropertyName, v8::Local< v8::Value > pPut)
Definition fxv8.cpp:270
bool IsObject(v8::Local< v8::Value > value)
Definition fxv8.cpp:43
bool IsString(v8::Local< v8::Value > value)
Definition fxv8.cpp:31
ByteString ReentrantToByteStringHelper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:173
ByteString ToByteString(v8::Isolate *pIsolate, v8::Local< v8::String > pValue)
Definition fxv8.cpp:126
v8::Local< v8::Object > NewObjectHelper(v8::Isolate *pIsolate)
Definition fxv8.cpp:111
bool IsDate(v8::Local< v8::Value > value)
Definition fxv8.cpp:51
v8::Local< v8::Array > NewArrayHelper(v8::Isolate *pIsolate)
Definition fxv8.cpp:96
bool ReentrantToBooleanHelper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:138
size_t GetArrayLengthHelper(v8::Local< v8::Array > pArray)
Definition fxv8.cpp:323
v8::Local< v8::Number > NewNumberHelper(v8::Isolate *pIsolate, double number)
Definition fxv8.cpp:71
WideString ToWideString(v8::Isolate *pIsolate, v8::Local< v8::String > pValue)
Definition fxv8.cpp:121
v8::Local< v8::Value > NewNullHelper(v8::Isolate *pIsolate)
Definition fxv8.cpp:59
bool IsNull(v8::Local< v8::Value > value)
Definition fxv8.cpp:23
v8::Local< v8::Number > NewNumberHelper(v8::Isolate *pIsolate, float number)
Definition fxv8.cpp:75
float ReentrantToFloatHelper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:146
int32_t ReentrantToInt32Helper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:131
v8::Local< v8::Array > ReentrantToArrayHelper(v8::Isolate *pIsolate, v8::Local< v8::Value > pValue)
Definition fxv8.cpp:197
std::vector< WideString > ReentrantGetObjectPropertyNamesHelper(v8::Isolate *pIsolate, v8::Local< v8::Object > pObj)
Definition fxv8.cpp:224
bool IsFunction(v8::Local< v8::Value > value)
Definition fxv8.cpp:55
void operator()(v8::Isolate *ptr)
Definition cfx_v8.cpp:130