diff options
author | 2022-06-22 23:21:48 -0700 | |
---|---|---|
committer | 2022-06-22 23:21:48 -0700 | |
commit | 729d445b6885f69dd2c6355f38707bd42851c791 (patch) | |
tree | f87a7c408929ea3f57bbb7ace380cf869da83c0e /src/bun.js/bindings/ZigConsoleClient.h | |
parent | 25f820c6bf1d8ec6d444ef579cc036b8c0607b75 (diff) | |
download | bun-jarred/rename.tar.gz bun-jarred/rename.tar.zst bun-jarred/rename.zip |
change the directory structurejarred/rename
Diffstat (limited to 'src/bun.js/bindings/ZigConsoleClient.h')
-rw-r--r-- | src/bun.js/bindings/ZigConsoleClient.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/bun.js/bindings/ZigConsoleClient.h b/src/bun.js/bindings/ZigConsoleClient.h new file mode 100644 index 000000000..684e928fd --- /dev/null +++ b/src/bun.js/bindings/ZigConsoleClient.h @@ -0,0 +1,70 @@ +#pragma once + +#include "JavaScriptCore/ConsoleClient.h" +#include "wtf/Vector.h" +#include "wtf/text/WTFString.h" + +namespace Inspector { +class InspectorConsoleAgent; +class InspectorDebuggerAgent; +class InspectorScriptProfilerAgent; +} // namespace Inspector +namespace Zig { +using InspectorConsoleAgent = Inspector::InspectorConsoleAgent; +using InspectorDebuggerAgent = Inspector::InspectorDebuggerAgent; +using InspectorScriptProfilerAgent = Inspector::InspectorScriptProfilerAgent; +using namespace JSC; + +class ConsoleClient final : public JSC::ConsoleClient { + WTF_MAKE_FAST_ALLOCATED; + +public: + ~ConsoleClient() final {} + ConsoleClient(void* client) + : JSC::ConsoleClient() + { + m_client = client; + } + + static bool logToSystemConsole(); + static void setLogToSystemConsole(bool); + + void setDebuggerAgent(InspectorDebuggerAgent* agent) { m_debuggerAgent = agent; } + void setPersistentScriptProfilerAgent(InspectorScriptProfilerAgent* agent) + { + m_scriptProfilerAgent = agent; + } + + void* m_client; + +private: + void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::JSGlobalObject*, + Ref<Inspector::ScriptArguments>&&); + void count(JSC::JSGlobalObject*, const String& label); + void countReset(JSC::JSGlobalObject*, const String& label); + void profile(JSC::JSGlobalObject*, const String& title); + void profileEnd(JSC::JSGlobalObject*, const String& title); + void takeHeapSnapshot(JSC::JSGlobalObject*, const String& title); + void time(JSC::JSGlobalObject*, const String& label); + void timeLog(JSC::JSGlobalObject*, const String& label, Ref<Inspector::ScriptArguments>&&); + void timeEnd(JSC::JSGlobalObject*, const String& label); + void timeStamp(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + void record(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + void recordEnd(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + void screenshot(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&); + + void warnUnimplemented(const String& method); + void internalAddMessage(MessageType, MessageLevel, JSC::JSGlobalObject*, + Ref<Inspector::ScriptArguments>&&); + + void startConsoleProfile(); + void stopConsoleProfile(); + + Inspector::InspectorConsoleAgent* m_consoleAgent; + Inspector::InspectorDebuggerAgent* m_debuggerAgent { nullptr }; + Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent { nullptr }; + Vector<String> m_profiles; + bool m_profileRestoreBreakpointActiveValue { false }; +}; + +} // namespace Zig |