blob: afcb5c0ee7d2ca51767ceda7c14ec57cbfed94cf (
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
30
31
32
33
34
|
#include "../bindings/JSStringDecoder.h"
#include "../bindings/ZigGlobalObject.h"
#include "JavaScriptCore/JSGlobalObject.h"
namespace Zig {
inline JSValue
generateStringDecoderSourceCode(JSC::JSGlobalObject *lexicalGlobalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4> &exportNames,
JSC::MarkedArgumentBuffer &exportValues) {
JSC::VM &vm = lexicalGlobalObject->vm();
GlobalObject *globalObject =
reinterpret_cast<GlobalObject *>(lexicalGlobalObject);
exportNames.append(JSC::Identifier::fromString(vm, "StringDecoder"_s));
exportValues.append(globalObject->JSStringDecoder());
JSC::JSObject *defaultObject = constructEmptyObject(globalObject);
defaultObject->putDirect(vm,
PropertyName(Identifier::fromUid(
vm.symbolRegistry().symbolForKey("CommonJS"_s))),
jsNumber(0), 0);
for (size_t i = 0; i < exportNames.size(); i++) {
defaultObject->putDirect(vm, exportNames[i], exportValues.at(i), 0);
}
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(defaultObject);
return {};
}
} // namespace Zig
|