Commit e677c91f authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[include][cleanup] Replace typedef by using

The rest of the code base was already migrated last year in
https://crrev.com/c/1631409. In the API we have to be more careful to
not break embedders. According to the standard there is no semantic
difference between typedef and using ([decl.typedef#2]):
  A typedef-name can also be introduced by an alias-declaration. The
  identifier following the using keyword becomes a typedef-name and the
  optional attribute-specifier-seq following the identifier appertains
  to that typedef-name. Such a typedef-name has the same semantics as if
  it were introduced by the typedef specifier.

Thus this CL replaces all typedefs in include/v8.h by the equivalent
using declaration. This improves readability, especially for function
pointer types.

R=ulan@chromium.org
CC=leszeks@chromium.org

Bug: v8:11074
Change-Id: Id917b6aa5c8cd289c60bda5da1e3667e747936e7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2563880
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71719}
parent 9d7de198
......@@ -436,7 +436,7 @@ static const int kEmbedderFieldsInWeakCallback = 2;
template <typename T>
class WeakCallbackInfo {
public:
typedef void (*Callback)(const WeakCallbackInfo<T>& data);
using Callback = void (*)(const WeakCallbackInfo<T>& data);
WeakCallbackInfo(Isolate* isolate, T* parameter,
void* embedder_fields[kEmbedderFieldsInWeakCallback],
......@@ -630,7 +630,7 @@ template <class T> class PersistentBase {
template<class T>
class NonCopyablePersistentTraits {
public:
typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent;
using NonCopyablePersistent = Persistent<T, NonCopyablePersistentTraits<T>>;
static const bool kResetInDestructor = false;
template<class S, class M>
V8_INLINE static void Copy(const Persistent<S, M>& source,
......@@ -647,7 +647,7 @@ class NonCopyablePersistentTraits {
*/
template<class T>
struct CopyablePersistentTraits {
typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent;
using CopyablePersistent = Persistent<T, CopyablePersistentTraits<T>>;
static const bool kResetInDestructor = true;
template<class S, class M>
static V8_INLINE void Copy(const Persistent<S, M>& source,
......@@ -809,7 +809,7 @@ class Global : public PersistentBase<T> {
/*
* For compatibility with Chromium's base::Bind (base::Passed).
*/
typedef void MoveOnlyTypeForCPP03;
using MoveOnlyTypeForCPP03 = void;
Global(const Global&) = delete;
void operator=(const Global&) = delete;
......@@ -1629,11 +1629,10 @@ class V8_EXPORT Module : public Data {
*/
int GetIdentityHash() const;
V8_DEPRECATE_SOON("Use ResolveModuleCallback")
typedef MaybeLocal<Module> (*ResolveCallback)(Local<Context> context,
Local<String> specifier,
Local<Module> referrer);
typedef MaybeLocal<Module> (*ResolveModuleCallback)(
using ResolveCallback V8_DEPRECATE_SOON("Use ResolveModuleCallback") =
MaybeLocal<Module> (*)(Local<Context> context, Local<String> specifier,
Local<Module> referrer);
using ResolveModuleCallback = MaybeLocal<Module> (*)(
Local<Context> context, Local<String> specifier,
Local<FixedArray> import_assertions, Local<Module> referrer);
......@@ -1709,8 +1708,8 @@ class V8_EXPORT Module : public Data {
* exception was thrown) and return an empy MaybeLocal to indicate falure
* (where an exception was thrown).
*/
typedef MaybeLocal<Value> (*SyntheticModuleEvaluationSteps)(
Local<Context> context, Local<Module> module);
using SyntheticModuleEvaluationSteps =
MaybeLocal<Value> (*)(Local<Context> context, Local<Module> module);
/**
* Creates a new SyntheticModule with the specified export names, where
......@@ -3758,23 +3757,17 @@ enum PropertyAttribute {
* setting|getting a particular property. See Object and ObjectTemplate's
* method SetAccessor.
*/
typedef void (*AccessorGetterCallback)(
Local<String> property,
const PropertyCallbackInfo<Value>& info);
typedef void (*AccessorNameGetterCallback)(
Local<Name> property,
const PropertyCallbackInfo<Value>& info);
typedef void (*AccessorSetterCallback)(
Local<String> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info);
typedef void (*AccessorNameSetterCallback)(
Local<Name> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info);
using AccessorGetterCallback =
void (*)(Local<String> property, const PropertyCallbackInfo<Value>& info);
using AccessorNameGetterCallback =
void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
using AccessorSetterCallback = void (*)(Local<String> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info);
using AccessorNameSetterCallback =
void (*)(Local<Name> property, Local<Value> value,
const PropertyCallbackInfo<void>& info);
/**
* Access control specifications.
......@@ -4626,8 +4619,7 @@ class PropertyCallbackInfo {
internal::Address* args_;
};
typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
enum class ConstructorBehavior { kThrow, kAllow };
......@@ -6344,8 +6336,8 @@ class V8_EXPORT Template : public Data {
*
* See also `ObjectTemplate::SetHandler`.
*/
typedef void (*GenericNamedPropertyGetterCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
using GenericNamedPropertyGetterCallback =
void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
/**
* Interceptor for set requests on an object.
......@@ -6368,9 +6360,9 @@ typedef void (*GenericNamedPropertyGetterCallback)(
* See also
* `ObjectTemplate::SetHandler.`
*/
typedef void (*GenericNamedPropertySetterCallback)(
Local<Name> property, Local<Value> value,
const PropertyCallbackInfo<Value>& info);
using GenericNamedPropertySetterCallback =
void (*)(Local<Name> property, Local<Value> value,
const PropertyCallbackInfo<Value>& info);
/**
* Intercepts all requests that query the attributes of the
......@@ -6393,8 +6385,8 @@ typedef void (*GenericNamedPropertySetterCallback)(
* See also
* `ObjectTemplate::SetHandler.`
*/
typedef void (*GenericNamedPropertyQueryCallback)(
Local<Name> property, const PropertyCallbackInfo<Integer>& info);
using GenericNamedPropertyQueryCallback =
void (*)(Local<Name> property, const PropertyCallbackInfo<Integer>& info);
/**
* Interceptor for delete requests on an object.
......@@ -6417,8 +6409,8 @@ typedef void (*GenericNamedPropertyQueryCallback)(
*
* See also `ObjectTemplate::SetHandler.`
*/
typedef void (*GenericNamedPropertyDeleterCallback)(
Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
using GenericNamedPropertyDeleterCallback =
void (*)(Local<Name> property, const PropertyCallbackInfo<Boolean>& info);
/**
* Returns an array containing the names of the properties the named
......@@ -6426,8 +6418,8 @@ typedef void (*GenericNamedPropertyDeleterCallback)(
*
* Note: The values in the array must be of type v8::Name.
*/
typedef void (*GenericNamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
using GenericNamedPropertyEnumeratorCallback =
void (*)(const PropertyCallbackInfo<Array>& info);
/**
* Interceptor for defineProperty requests on an object.
......@@ -6449,9 +6441,9 @@ typedef void (*GenericNamedPropertyEnumeratorCallback)(
*
* See also `ObjectTemplate::SetHandler`.
*/
typedef void (*GenericNamedPropertyDefinerCallback)(
Local<Name> property, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);
using GenericNamedPropertyDefinerCallback =
void (*)(Local<Name> property, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);
/**
* Interceptor for getOwnPropertyDescriptor requests on an object.
......@@ -6472,37 +6464,33 @@ typedef void (*GenericNamedPropertyDefinerCallback)(
*
* See also `ObjectTemplate::SetHandler`.
*/
typedef void (*GenericNamedPropertyDescriptorCallback)(
Local<Name> property, const PropertyCallbackInfo<Value>& info);
using GenericNamedPropertyDescriptorCallback =
void (*)(Local<Name> property, const PropertyCallbackInfo<Value>& info);
/**
* See `v8::GenericNamedPropertyGetterCallback`.
*/
typedef void (*IndexedPropertyGetterCallback)(
uint32_t index,
const PropertyCallbackInfo<Value>& info);
using IndexedPropertyGetterCallback =
void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
/**
* See `v8::GenericNamedPropertySetterCallback`.
*/
typedef void (*IndexedPropertySetterCallback)(
uint32_t index,
Local<Value> value,
const PropertyCallbackInfo<Value>& info);
using IndexedPropertySetterCallback =
void (*)(uint32_t index, Local<Value> value,
const PropertyCallbackInfo<Value>& info);
/**
* See `v8::GenericNamedPropertyQueryCallback`.
*/
typedef void (*IndexedPropertyQueryCallback)(
uint32_t index,
const PropertyCallbackInfo<Integer>& info);
using IndexedPropertyQueryCallback =
void (*)(uint32_t index, const PropertyCallbackInfo<Integer>& info);
/**
* See `v8::GenericNamedPropertyDeleterCallback`.
*/
typedef void (*IndexedPropertyDeleterCallback)(
uint32_t index,
const PropertyCallbackInfo<Boolean>& info);
using IndexedPropertyDeleterCallback =
void (*)(uint32_t index, const PropertyCallbackInfo<Boolean>& info);
/**
* Returns an array containing the indices of the properties the indexed
......@@ -6510,21 +6498,21 @@ typedef void (*IndexedPropertyDeleterCallback)(
*
* Note: The values in the array must be uint32_t.
*/
typedef void (*IndexedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
using IndexedPropertyEnumeratorCallback =
void (*)(const PropertyCallbackInfo<Array>& info);
/**
* See `v8::GenericNamedPropertyDefinerCallback`.
*/
typedef void (*IndexedPropertyDefinerCallback)(
uint32_t index, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);
using IndexedPropertyDefinerCallback =
void (*)(uint32_t index, const PropertyDescriptor& desc,
const PropertyCallbackInfo<Value>& info);
/**
* See `v8::GenericNamedPropertyDescriptorCallback`.
*/
typedef void (*IndexedPropertyDescriptorCallback)(
uint32_t index, const PropertyCallbackInfo<Value>& info);
using IndexedPropertyDescriptorCallback =
void (*)(uint32_t index, const PropertyCallbackInfo<Value>& info);
/**
* Access type specification.
......@@ -6542,9 +6530,9 @@ enum AccessType {
* Returns true if the given context should be allowed to access the given
* object.
*/
typedef bool (*AccessCheckCallback)(Local<Context> accessing_context,
Local<Object> accessed_object,
Local<Value> data);
using AccessCheckCallback = bool (*)(Local<Context> accessing_context,
Local<Object> accessed_object,
Local<Value> data);
/**
* A FunctionTemplate is used to create functions at runtime. There
......@@ -7348,19 +7336,18 @@ class V8_EXPORT ResourceConstraints {
// --- Exceptions ---
using FatalErrorCallback = void (*)(const char* location, const char* message);
typedef void (*FatalErrorCallback)(const char* location, const char* message);
using OOMErrorCallback = void (*)(const char* location, bool is_heap_oom);
typedef void (*OOMErrorCallback)(const char* location, bool is_heap_oom);
using DcheckErrorCallback = void (*)(const char* file, int line,
const char* message);
typedef void (*DcheckErrorCallback)(const char* file, int line,
const char* message);
typedef void (*MessageCallback)(Local<Message> message, Local<Value> data);
using MessageCallback = void (*)(Local<Message> message, Local<Value> data);
// --- Tracing ---
typedef void (*LogEventCallback)(const char* name, int event);
using LogEventCallback = void (*)(const char* name, int event);
/**
* Create new error objects by calling the corresponding error object
......@@ -7394,14 +7381,12 @@ class V8_EXPORT Exception {
// --- Counters Callbacks ---
typedef int* (*CounterLookupCallback)(const char* name);
using CounterLookupCallback = int* (*)(const char* name);
typedef void* (*CreateHistogramCallback)(const char* name,
int min,
int max,
size_t buckets);
using CreateHistogramCallback = void* (*)(const char* name, int min, int max,
size_t buckets);
typedef void (*AddHistogramSampleCallback)(void* histogram, int sample);
using AddHistogramSampleCallback = void (*)(void* histogram, int sample);
// --- Crashkeys Callback ---
enum class CrashKeyId {
......@@ -7412,11 +7397,11 @@ enum class CrashKeyId {
kDumpType,
};
typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value);
using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value);
// --- Enter/Leave Script Callback ---
typedef void (*BeforeCallEnteredCallback)(Isolate*);
typedef void (*CallCompletedCallback)(Isolate*);
using BeforeCallEnteredCallback = void (*)(Isolate*);
using CallCompletedCallback = void (*)(Isolate*);
/**
* HostImportModuleDynamicallyCallback is called when we require the
......@@ -7438,7 +7423,7 @@ typedef void (*CallCompletedCallback)(Isolate*);
* fails (e.g. due to stack overflow), the embedder must propagate
* that exception by returning an empty MaybeLocal.
*/
typedef MaybeLocal<Promise> (*HostImportModuleDynamicallyCallback)(
using HostImportModuleDynamicallyCallback = MaybeLocal<Promise> (*)(
Local<Context> context, Local<ScriptOrModule> referrer,
Local<String> specifier);
......@@ -7452,9 +7437,9 @@ typedef MaybeLocal<Promise> (*HostImportModuleDynamicallyCallback)(
* The embedder should use v8::Object::CreateDataProperty to add properties on
* the meta object.
*/
typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
Local<Module> module,
Local<Object> meta);
using HostInitializeImportMetaObjectCallback = void (*)(Local<Context> context,
Local<Module> module,
Local<Object> meta);
/**
* PrepareStackTraceCallback is called when the stack property of an error is
......@@ -7463,9 +7448,9 @@ typedef void (*HostInitializeImportMetaObjectCallback)(Local<Context> context,
* |sites| is an array of call sites, specified in
* https://v8.dev/docs/stack-trace-api
*/
typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
Local<Value> error,
Local<Array> sites);
using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
Local<Value> error,
Local<Array> sites);
/**
* PromiseHook with type kInit is called when a new promise is
......@@ -7485,8 +7470,8 @@ typedef MaybeLocal<Value> (*PrepareStackTraceCallback)(Local<Context> context,
*/
enum class PromiseHookType { kInit, kResolve, kBefore, kAfter };
typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise,
Local<Value> parent);
using PromiseHook = void (*)(PromiseHookType type, Local<Promise> promise,
Local<Value> parent);
// --- Promise Reject Callback ---
enum PromiseRejectEvent {
......@@ -7512,11 +7497,11 @@ class PromiseRejectMessage {
Local<Value> value_;
};
typedef void (*PromiseRejectCallback)(PromiseRejectMessage message);
using PromiseRejectCallback = void (*)(PromiseRejectMessage message);
// --- Microtasks Callbacks ---
typedef void (*MicrotasksCompletedCallbackWithData)(Isolate*, void*);
typedef void (*MicrotaskCallback)(void* data);
using MicrotasksCompletedCallbackWithData = void (*)(Isolate*, void*);
using MicrotaskCallback = void (*)(void* data);
/**
* Policy for running microtasks:
......@@ -7654,9 +7639,8 @@ class V8_EXPORT V8_NODISCARD MicrotasksScope {
};
// --- Failed Access Check Callback ---
typedef void (*FailedAccessCheckCallback)(Local<Object> target,
AccessType type,
Local<Value> data);
using FailedAccessCheckCallback = void (*)(Local<Object> target,
AccessType type, Local<Value> data);
// --- AllowCodeGenerationFromStrings callbacks ---
......@@ -7664,8 +7648,8 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
* Callback to check if code generation from strings is allowed. See
* Context::AllowCodeGenerationFromStrings.
*/
typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context,
Local<String> source);
using AllowCodeGenerationFromStringsCallback = bool (*)(Local<Context> context,
Local<String> source);
struct ModifyCodeGenerationFromStringsResult {
// If true, proceed with the codegen algorithm. Otherwise, block it.
......@@ -7680,36 +7664,36 @@ struct ModifyCodeGenerationFromStringsResult {
* Callback to check if codegen is allowed from a source object, and convert
* the source to string if necessary. See: ModifyCodeGenerationFromStrings.
*/
typedef ModifyCodeGenerationFromStringsResult (
*ModifyCodeGenerationFromStringsCallback)(Local<Context> context,
using ModifyCodeGenerationFromStringsCallback =
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
Local<Value> source);
typedef ModifyCodeGenerationFromStringsResult (
*ModifyCodeGenerationFromStringsCallback2)(Local<Context> context,
Local<Value> source,
bool is_code_like);
using ModifyCodeGenerationFromStringsCallback2 =
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
Local<Value> source,
bool is_code_like);
// --- WebAssembly compilation callbacks ---
typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&);
using ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&);
typedef bool (*AllowWasmCodeGenerationCallback)(Local<Context> context,
Local<String> source);
using AllowWasmCodeGenerationCallback = bool (*)(Local<Context> context,
Local<String> source);
// --- Callback for APIs defined on v8-supported objects, but implemented
// by the embedder. Example: WebAssembly.{compile|instantiate}Streaming ---
typedef void (*ApiImplementationCallback)(const FunctionCallbackInfo<Value>&);
using ApiImplementationCallback = void (*)(const FunctionCallbackInfo<Value>&);
// --- Callback for WebAssembly.compileStreaming ---
typedef void (*WasmStreamingCallback)(const FunctionCallbackInfo<Value>&);
using WasmStreamingCallback = void (*)(const FunctionCallbackInfo<Value>&);
// --- Callback for checking if WebAssembly threads are enabled ---
typedef bool (*WasmThreadsEnabledCallback)(Local<Context> context);
using WasmThreadsEnabledCallback = bool (*)(Local<Context> context);
// --- Callback for loading source map file for Wasm profiling support
typedef Local<String> (*WasmLoadSourceMapCallback)(Isolate* isolate,
const char* name);
using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
const char* name);
// --- Callback for checking if WebAssembly Simd is enabled ---
typedef bool (*WasmSimdEnabledCallback)(Local<Context> context);
using WasmSimdEnabledCallback = bool (*)(Local<Context> context);
// --- Garbage Collection Callbacks ---
......@@ -7753,9 +7737,9 @@ enum GCCallbackFlags {
kGCCallbackScheduleIdleGarbageCollection = 1 << 6,
};
typedef void (*GCCallback)(GCType type, GCCallbackFlags flags);
using GCCallback = void (*)(GCType type, GCCallbackFlags flags);
typedef void (*InterruptCallback)(Isolate* isolate, void* data);
using InterruptCallback = void (*)(Isolate* isolate, void* data);
/**
* This callback is invoked when the heap size is close to the heap limit and
......@@ -7764,8 +7748,8 @@ typedef void (*InterruptCallback)(Isolate* isolate, void* data);
* than the current_heap_limit. The initial heap limit is the limit that was
* set after heap setup.
*/
typedef size_t (*NearHeapLimitCallback)(void* data, size_t current_heap_limit,
size_t initial_heap_limit);
using NearHeapLimitCallback = size_t (*)(void* data, size_t current_heap_limit,
size_t initial_heap_limit);
/**
* Collection of shared per-process V8 memory information.
......@@ -8019,14 +8003,14 @@ enum JitCodeEventOptions {
*
* \param event code add, move or removal event.
*/
typedef void (*JitCodeEventHandler)(const JitCodeEvent* event);
using JitCodeEventHandler = void (*)(const JitCodeEvent* event);
/**
* Callback function passed to SetUnhandledExceptionCallback.
*/
#if defined(V8_OS_WIN)
typedef int (*UnhandledExceptionCallback)(
_EXCEPTION_POINTERS* exception_pointers);
using UnhandledExceptionCallback =
int (*)(_EXCEPTION_POINTERS* exception_pointers);
#endif
/**
......@@ -8253,8 +8237,8 @@ class V8_EXPORT EmbedderHeapTracer {
* serialized verbatim.
*/
struct SerializeInternalFieldsCallback {
typedef StartupData (*CallbackFunction)(Local<Object> holder, int index,
void* data);
using CallbackFunction = StartupData (*)(Local<Object> holder, int index,
void* data);
SerializeInternalFieldsCallback(CallbackFunction function = nullptr,
void* data_arg = nullptr)
: callback(function), data(data_arg) {}
......@@ -8263,15 +8247,15 @@ struct SerializeInternalFieldsCallback {
};
// Note that these fields are called "internal fields" in the API and called
// "embedder fields" within V8.
typedef SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback;
using SerializeEmbedderFieldsCallback = SerializeInternalFieldsCallback;
/**
* Callback and supporting data used to implement embedder logic to deserialize
* internal fields.
*/
struct DeserializeInternalFieldsCallback {
typedef void (*CallbackFunction)(Local<Object> holder, int index,
StartupData payload, void* data);
using CallbackFunction = void (*)(Local<Object> holder, int index,
StartupData payload, void* data);
DeserializeInternalFieldsCallback(CallbackFunction function = nullptr,
void* data_arg = nullptr)
: callback(function), data(data_arg) {}
......@@ -8279,7 +8263,7 @@ struct DeserializeInternalFieldsCallback {
void* data);
void* data;
};
typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback;
using DeserializeEmbedderFieldsCallback = DeserializeInternalFieldsCallback;
/**
* Controls how the default MeasureMemoryDelegate reports the result of
......@@ -8686,8 +8670,8 @@ class V8_EXPORT Isolate {
kMessageWarning,
};
typedef void (*UseCounterCallback)(Isolate* isolate,
UseCounterFeature feature);
using UseCounterCallback = void (*)(Isolate* isolate,
UseCounterFeature feature);
/**
* Allocates a new isolate but does not initialize it. Does not change the
......@@ -8753,7 +8737,7 @@ class V8_EXPORT Isolate {
* - the custom callback set returns true.
* Otherwise, the custom callback will not be called and V8 will not abort.
*/
typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*);
using AbortOnUncaughtExceptionCallback = bool (*)(Isolate*);
void SetAbortOnUncaughtExceptionCallback(
AbortOnUncaughtExceptionCallback callback);
......@@ -9002,10 +8986,10 @@ class V8_EXPORT Isolate {
*/
Local<Value> ThrowException(Local<Value> exception);
typedef void (*GCCallback)(Isolate* isolate, GCType type,
GCCallbackFlags flags);
typedef void (*GCCallbackWithData)(Isolate* isolate, GCType type,
GCCallbackFlags flags, void* data);
using GCCallback = void (*)(Isolate* isolate, GCType type,
GCCallbackFlags flags);
using GCCallbackWithData = void (*)(Isolate* isolate, GCType type,
GCCallbackFlags flags, void* data);
/**
* Enables the host application to receive a notification before a
......@@ -9108,12 +9092,12 @@ class V8_EXPORT Isolate {
* This callback may schedule exceptions, *unless* |event| is equal to
* |kTerminatedExecution|.
*/
typedef void (*AtomicsWaitCallback)(AtomicsWaitEvent event,
Local<SharedArrayBuffer> array_buffer,
size_t offset_in_bytes, int64_t value,
double timeout_in_ms,
AtomicsWaitWakeHandle* stop_handle,
void* data);
using AtomicsWaitCallback = void (*)(AtomicsWaitEvent event,
Local<SharedArrayBuffer> array_buffer,
size_t offset_in_bytes, int64_t value,
double timeout_in_ms,
AtomicsWaitWakeHandle* stop_handle,
void* data);
/**
* Set a new |AtomicsWaitCallback|. This overrides an earlier
......@@ -9145,7 +9129,7 @@ class V8_EXPORT Isolate {
void* data = nullptr);
void RemoveGCEpilogueCallback(GCCallback callback);
typedef size_t (*GetExternallyAllocatedMemoryInBytesCallback)();
using GetExternallyAllocatedMemoryInBytesCallback = size_t (*)();
/**
* Set the callback that tells V8 how much memory is currently allocated
......@@ -9746,7 +9730,7 @@ class V8_EXPORT StartupData {
* EntropySource is used as a callback function when v8 needs a source
* of entropy.
*/
typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
using EntropySource = bool (*)(unsigned char* buffer, size_t length);
/**
* ReturnAddressLocationResolver is used as a callback function when v8 is
......@@ -9761,9 +9745,8 @@ typedef bool (*EntropySource)(unsigned char* buffer, size_t length);
*
* \note The resolver function must not cause garbage collection.
*/
typedef uintptr_t (*ReturnAddressLocationResolver)(
uintptr_t return_addr_location);
using ReturnAddressLocationResolver =
uintptr_t (*)(uintptr_t return_addr_location);
/**
* Container class for static utility functions.
......@@ -10648,8 +10631,8 @@ class V8_EXPORT Context {
* context, call the specified callback, and throw an exception.
* To unset abort, pass nullptr as callback.
*/
typedef void (*AbortScriptExecutionCallback)(Isolate* isolate,
Local<Context> context);
using AbortScriptExecutionCallback = void (*)(Isolate* isolate,
Local<Context> context);
void SetAbortScriptExecution(AbortScriptExecutionCallback callback);
/**
......@@ -10985,7 +10968,7 @@ void Persistent<T, M>::Copy(const Persistent<S, M2>& that) {
template <class T>
bool PersistentBase<T>::IsWeak() const {
typedef internal::Internals I;
using I = internal::Internals;
if (this->IsEmpty()) return false;
return I::GetNodeState(reinterpret_cast<internal::Address*>(this->val_)) ==
I::kNodeStateIsWeakValue;
......@@ -11026,7 +11009,7 @@ template <typename P>
V8_INLINE void PersistentBase<T>::SetWeak(
P* parameter, typename WeakCallbackInfo<P>::Callback callback,
WeakCallbackType type) {
typedef typename WeakCallbackInfo<void>::Callback Callback;
using Callback = WeakCallbackInfo<void>::Callback;
#if (__GNUC__ >= 8) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
......@@ -11058,7 +11041,7 @@ void PersistentBase<T>::AnnotateStrongRetainer(const char* label) {
template <class T>
void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
typedef internal::Internals I;
using I = internal::Internals;
if (this->IsEmpty()) return;
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
......@@ -11068,7 +11051,7 @@ void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) {
template <class T>
uint16_t PersistentBase<T>::WrapperClassId() const {
typedef internal::Internals I;
using I = internal::Internals;
if (this->IsEmpty()) return 0;
internal::Address* obj = reinterpret_cast<internal::Address*>(this->val_);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
......@@ -11266,7 +11249,7 @@ TracedReference<T>& TracedReference<T>::operator=(const TracedReference& rhs) {
}
void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
typedef internal::Internals I;
using I = internal::Internals;
if (IsEmpty()) return;
internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
......@@ -11274,7 +11257,7 @@ void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
}
uint16_t TracedReferenceBase::WrapperClassId() const {
typedef internal::Internals I;
using I = internal::Internals;
if (IsEmpty()) return 0;
internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
......@@ -11334,7 +11317,7 @@ void ReturnValue<T>::Set(double i) {
template<typename T>
void ReturnValue<T>::Set(int32_t i) {
static_assert(std::is_base_of<T, Integer>::value, "type check");
typedef internal::Internals I;
using I = internal::Internals;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
return;
......@@ -11357,7 +11340,7 @@ void ReturnValue<T>::Set(uint32_t i) {
template<typename T>
void ReturnValue<T>::Set(bool value) {
static_assert(std::is_base_of<T, Boolean>::value, "type check");
typedef internal::Internals I;
using I = internal::Internals;
int root_index;
if (value) {
root_index = I::kTrueValueRootIndex;
......@@ -11370,21 +11353,21 @@ void ReturnValue<T>::Set(bool value) {
template<typename T>
void ReturnValue<T>::SetNull() {
static_assert(std::is_base_of<T, Primitive>::value, "type check");
typedef internal::Internals I;
using I = internal::Internals;
*value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetUndefined() {
static_assert(std::is_base_of<T, Primitive>::value, "type check");
typedef internal::Internals I;
using I = internal::Internals;
*value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetEmptyString() {
static_assert(std::is_base_of<T, String>::value, "type check");
typedef internal::Internals I;
using I = internal::Internals;
*value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex);
}
......@@ -11396,7 +11379,7 @@ Isolate* ReturnValue<T>::GetIsolate() const {
template <typename T>
Local<Value> ReturnValue<T>::Get() const {
typedef internal::Internals I;
using I = internal::Internals;
if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex))
return Local<Value>(*Undefined(GetIsolate()));
return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_));
......@@ -11603,8 +11586,8 @@ AccessorSignature* AccessorSignature::Cast(Data* data) {
Local<Value> Object::GetInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<A*>(this);
// Fast path: If the object is a plain JSObject, which is the common case, we
// know where to find the internal fields and can return the value directly.
......@@ -11631,8 +11614,8 @@ Local<Value> Object::GetInternalField(int index) {
void* Object::GetAlignedPointerFromInternalField(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<A*>(this);
// Fast path: If the object is a plain JSObject, which is the common case, we
// know where to find the internal fields and can return the value directly.
......@@ -11661,8 +11644,8 @@ String* String::Cast(v8::Data* data) {
}
Local<String> String::Empty(Isolate* isolate) {
typedef internal::Address S;
typedef internal::Internals I;
using S = internal::Address;
using I = internal::Internals;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
return Local<String>(reinterpret_cast<String*>(slot));
......@@ -11670,8 +11653,8 @@ Local<String> String::Empty(Isolate* isolate) {
String::ExternalStringResource* String::GetExternalStringResource() const {
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<const A*>(this);
ExternalStringResource* result;
......@@ -11693,8 +11676,8 @@ String::ExternalStringResource* String::GetExternalStringResource() const {
String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
String::Encoding* encoding_out) const {
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<const A*>(this);
int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask;
*encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
......@@ -11725,8 +11708,8 @@ bool Value::IsUndefined() const {
}
bool Value::QuickIsUndefined() const {
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<const A*>(this);
if (!I::HasHeapObjectTag(obj)) return false;
if (I::GetInstanceType(obj) != I::kOddballType) return false;
......@@ -11743,8 +11726,8 @@ bool Value::IsNull() const {
}
bool Value::QuickIsNull() const {
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<const A*>(this);
if (!I::HasHeapObjectTag(obj)) return false;
if (I::GetInstanceType(obj) != I::kOddballType) return false;
......@@ -11760,8 +11743,8 @@ bool Value::IsNullOrUndefined() const {
}
bool Value::QuickIsNullOrUndefined() const {
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<const A*>(this);
if (!I::HasHeapObjectTag(obj)) return false;
if (I::GetInstanceType(obj) != I::kOddballType) return false;
......@@ -11778,8 +11761,8 @@ bool Value::IsString() const {
}
bool Value::QuickIsString() const {
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A obj = *reinterpret_cast<const A*>(this);
if (!I::HasHeapObjectTag(obj)) return false;
return (I::GetInstanceType(obj) < I::kFirstNonstringType);
......@@ -12170,7 +12153,7 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
template <typename T>
bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
typedef internal::Internals I;
using I = internal::Internals;
if (args_[kShouldThrowOnErrorIndex] !=
I::IntToSmi(I::kInferShouldThrowMode)) {
return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(I::kDontThrow);
......@@ -12180,8 +12163,8 @@ bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
}
Local<Primitive> Undefined(Isolate* isolate) {
typedef internal::Address S;
typedef internal::Internals I;
using S = internal::Address;
using I = internal::Internals;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
......@@ -12189,8 +12172,8 @@ Local<Primitive> Undefined(Isolate* isolate) {
Local<Primitive> Null(Isolate* isolate) {
typedef internal::Address S;
typedef internal::Internals I;
using S = internal::Address;
using I = internal::Internals;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
......@@ -12198,8 +12181,8 @@ Local<Primitive> Null(Isolate* isolate) {
Local<Boolean> True(Isolate* isolate) {
typedef internal::Address S;
typedef internal::Internals I;
using S = internal::Address;
using I = internal::Internals;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
......@@ -12207,8 +12190,8 @@ Local<Boolean> True(Isolate* isolate) {
Local<Boolean> False(Isolate* isolate) {
typedef internal::Address S;
typedef internal::Internals I;
using S = internal::Address;
using I = internal::Internals;
I::CheckInitialized(isolate);
S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
......@@ -12216,19 +12199,19 @@ Local<Boolean> False(Isolate* isolate) {
void Isolate::SetData(uint32_t slot, void* data) {
typedef internal::Internals I;
using I = internal::Internals;
I::SetEmbedderData(this, slot, data);
}
void* Isolate::GetData(uint32_t slot) {
typedef internal::Internals I;
using I = internal::Internals;
return I::GetEmbedderData(this, slot);
}
uint32_t Isolate::GetNumberOfDataSlots() {
typedef internal::Internals I;
using I = internal::Internals;
return I::kNumIsolateDataSlots;
}
......@@ -12241,8 +12224,8 @@ MaybeLocal<T> Isolate::GetDataFromSnapshotOnce(size_t index) {
Local<Value> Context::GetEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A ctx = *reinterpret_cast<const A*>(this);
A embedder_data =
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
......@@ -12267,8 +12250,8 @@ Local<Value> Context::GetEmbedderData(int index) {
void* Context::GetAlignedPointerFromEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS
typedef internal::Address A;
typedef internal::Internals I;
using A = internal::Address;
using I = internal::Internals;
A ctx = *reinterpret_cast<const A*>(this);
A embedder_data =
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment