aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/modules/ProcessModule.h
blob: 2c82d6b3d3422ae0a71d64d80941b1c15590964a (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
35
36
37
38
39
#include "../bindings/ZigGlobalObject.h"
#include "JavaScriptCore/JSGlobalObject.h"

namespace Zig {

inline void generateProcessSourceCode(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);

    JSC::JSObject* process = globalObject->processObject();

    auto exportFromProcess = [&] (const String& string) {
        auto identifier = JSC::Identifier::fromString(vm, string);
        exportNames.append(identifier);
        exportValues.append(process->getDirect(vm, identifier));
    };

    exportFromProcess("arch"_s);
    exportFromProcess("argv"_s);
    exportFromProcess("browser"_s);
    exportFromProcess("chdir"_s);
    exportFromProcess("cwd"_s);
    exportFromProcess("dlopen"_s);
    exportFromProcess("exitCode"_s);
    exportFromProcess("exit"_s);
    exportFromProcess("hrtime"_s);
    exportFromProcess("pid"_s);
    exportFromProcess("ppid"_s);
    exportFromProcess("nextTick"_s);
    exportFromProcess("revision"_s);
    exportFromProcess("title"_s);
    exportFromProcess("version"_s);
    exportFromProcess("versions"_s);
    exportFromProcess("platform"_s);

    exportFromProcess("isBun"_s);
}

}