diff options
author | 2023-07-14 19:37:22 -0700 | |
---|---|---|
committer | 2023-07-14 19:37:22 -0700 | |
commit | c39c11e1011b682c2c4e48594c7d6110cfc3343c (patch) | |
tree | 8808ca4cd6684949423f28f3cd4d90aedb605cb7 /src/bun.js/bindings/ZigGeneratedClasses.h | |
parent | 25512104265aa568ca98e5bd89a977203ee261a6 (diff) | |
download | bun-c39c11e1011b682c2c4e48594c7d6110cfc3343c.tar.gz bun-c39c11e1011b682c2c4e48594c7d6110cfc3343c.tar.zst bun-c39c11e1011b682c2c4e48594c7d6110cfc3343c.zip |
structured clone (#3637)
* copy `SerializedScriptValue`
* format
* make `SerializedScriptValue` compile
* add `transfer` option
* tests
* serialize/deserialize blobs
* tests for blobs
* serialize/deserialize file blobs
* more tests
* small cleanup
* format
* small changes + serialize offset
* slice helper
* map and set test
Diffstat (limited to 'src/bun.js/bindings/ZigGeneratedClasses.h')
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedClasses.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h index 1631f960e..f66c65e40 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.h +++ b/src/bun.js/bindings/ZigGeneratedClasses.h @@ -10,6 +10,7 @@ namespace Zig { #include "JSDOMWrapper.h" #include <wtf/NeverDestroyed.h> +#include "SerializedScriptValue.h" namespace WebCore { using namespace Zig; @@ -1998,4 +1999,27 @@ public: void finishCreation(JSC::VM&); }; +class StructuredCloneableSerialize { +public: + void (*cppWriteBytes)(CloneSerializer*, const uint8_t*, uint32_t); + + std::function<void(void*, JSC::JSGlobalObject*, void*, void (*)(CloneSerializer*, const uint8_t*, uint32_t))> zigFunction; + + uint8_t tag; + + // the type from zig + void* impl; + + static std::optional<StructuredCloneableSerialize> fromJS(JSC::JSValue); + void write(CloneSerializer* serializer, JSC::JSGlobalObject* globalObject) + { + zigFunction(impl, globalObject, serializer, cppWriteBytes); + } +}; + +class StructuredCloneableDeserialize { +public: + static std::optional<JSC::EncodedJSValue> fromTagDeserialize(uint8_t tag, JSC::JSGlobalObject*, const uint8_t*, const uint8_t*); +}; + } |