Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 19b8e2c701f11bf66b595306d89127a960159172..3c503d0c06ed3ff52370ac92c889821b3755aa1d 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -6281,17 +6281,33 @@ class V8_EXPORT EmbedderHeapTracer { |
}; |
/** |
- * Callback to the embedder used in SnapshotCreator to handle internal fields. |
- */ |
-typedef StartupData (*SerializeInternalFieldsCallback)(Local<Object> holder, |
- int index); |
+ * Callback and supporting data used in SnapshotCreator to implement embedder |
+ * logic to serialize internal fields. |
+ */ |
+struct SerializeInternalFieldsCallback { |
+ typedef StartupData (*CallbackFunction)(Local<Object> holder, int index, |
+ void* data); |
+ SerializeInternalFieldsCallback(CallbackFunction function = nullptr, |
+ void* data_arg = nullptr) |
+ : callback(function), data(data_arg) {} |
+ CallbackFunction callback; |
+ void* data; |
+}; |
/** |
- * Callback to the embedder used to deserialize internal fields. |
+ * Callback and supporting data used to implement embedder logic to deserialize |
+ * internal fields. |
*/ |
-typedef void (*DeserializeInternalFieldsCallback)(Local<Object> holder, |
- int index, |
- StartupData payload); |
+struct DeserializeInternalFieldsCallback { |
+ typedef void (*CallbackFunction)(Local<Object> holder, int index, |
+ StartupData payload, void* data); |
+ DeserializeInternalFieldsCallback(CallbackFunction function = nullptr, |
+ void* data_arg = nullptr) |
+ : callback(function), data(data_arg) {} |
+ void (*callback)(Local<Object> holder, int index, StartupData payload, |
+ void* data); |
+ void* data; |
+}; |
/** |
* Isolate represents an isolated instance of the V8 engine. V8 isolates have |
@@ -7688,7 +7704,8 @@ class V8_EXPORT SnapshotCreator { |
* \returns the index of the context in the snapshot blob. |
*/ |
size_t AddContext(Local<Context> context, |
- SerializeInternalFieldsCallback callback = nullptr); |
+ SerializeInternalFieldsCallback callback = |
+ SerializeInternalFieldsCallback()); |
/** |
* Add a template to be included in the snapshot blob. |
@@ -8028,7 +8045,8 @@ class V8_EXPORT Context { |
static MaybeLocal<Context> FromSnapshot( |
Isolate* isolate, size_t context_snapshot_index, |
- DeserializeInternalFieldsCallback internal_fields_deserializer = nullptr, |
+ DeserializeInternalFieldsCallback internal_fields_deserializer = |
+ DeserializeInternalFieldsCallback(), |
ExtensionConfiguration* extensions = nullptr, |
MaybeLocal<Value> global_object = MaybeLocal<Value>()); |