blob: 0f255d7c89602541f22c9bdad0892d68d0315d6f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "blob.h"
#include "ZigGeneratedClasses.h"
extern "C" JSC::EncodedJSValue Blob__create(JSC::JSGlobalObject* globalObject, void* impl);
extern "C" void* Blob__setAsFile(void* impl, BunString* filename);
namespace WebCore {
JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WebCore::Blob& impl)
{
BunString filename = Bun::toString(impl.fileName());
impl.m_impl = Blob__setAsFile(impl.impl(), &filename);
return JSC::JSValue::decode(Blob__create(lexicalGlobalObject, Blob__dupe(impl.impl())));
}
JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, Ref<WebCore::Blob>&& impl)
{
auto fileNameStr = impl->fileName();
BunString filename = Bun::toString(fileNameStr);
EncodedJSValue encoded = Blob__create(lexicalGlobalObject, impl->impl());
JSBlob* blob = jsCast<JSBlob*>(JSC::JSValue::decode(encoded));
Blob__setAsFile(blob->wrapped(), &filename);
return JSC::JSValue::decode(encoded);
}
}
|