mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: paperdave <paperdave@users.noreply.github.com> Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
#pragma once
|
|
#include "root.h"
|
|
#include "ZigGlobalObject.h"
|
|
|
|
namespace Bake {
|
|
|
|
struct DevServer; // DevServer.zig
|
|
struct Route; // DevServer.zig
|
|
struct BunVirtualMachine;
|
|
|
|
class GlobalObject : public Zig::GlobalObject {
|
|
public:
|
|
using Base = Zig::GlobalObject;
|
|
|
|
/// Null if in production
|
|
DevServer* m_devServer;
|
|
|
|
template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
|
|
{
|
|
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
|
|
return nullptr;
|
|
return WebCore::subspaceForImpl<GlobalObject, WebCore::UseCustomHeapCellType::Yes>(
|
|
vm,
|
|
[](auto& spaces) { return spaces.m_clientSubspaceForBakeGlobalScope.get(); },
|
|
[](auto& spaces, auto&& space) { spaces.m_clientSubspaceForBakeGlobalScope = std::forward<decltype(space)>(space); },
|
|
[](auto& spaces) { return spaces.m_subspaceForBakeGlobalScope.get(); },
|
|
[](auto& spaces, auto&& space) { spaces.m_subspaceForBakeGlobalScope = std::forward<decltype(space)>(space); },
|
|
[](auto& server) -> JSC::HeapCellType& { return server.m_heapCellTypeForJSWorkerGlobalScope; });
|
|
}
|
|
|
|
static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;
|
|
static GlobalObject* create(JSC::VM& vm, JSC::Structure* structure, const JSC::GlobalObjectMethodTable* methodTable);
|
|
|
|
ALWAYS_INLINE bool isProduction() const { return !m_devServer; }
|
|
|
|
void finishCreation(JSC::VM& vm);
|
|
|
|
GlobalObject(JSC::VM& vm, JSC::Structure* structure, const JSC::GlobalObjectMethodTable* methodTable)
|
|
: Zig::GlobalObject(vm, structure, methodTable) { }
|
|
};
|
|
|
|
// Zig API
|
|
extern "C" void KitInitProcessIdentifier();
|
|
extern "C" GlobalObject* KitCreateDevGlobal(DevServer* owner, void* console);
|
|
|
|
}; // namespace Kit
|