mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
implement node:cluster (#11492)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: nektro <nektro@users.noreply.github.com> Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include "JavaScriptCore/JSString.h"
|
||||
#include "JavaScriptCore/JSType.h"
|
||||
#include "JavaScriptCore/Symbol.h"
|
||||
#include "wtf/Assertions.h"
|
||||
#include "wtf/text/ASCIIFastPath.h"
|
||||
#include "wtf/text/ASCIILiteral.h"
|
||||
#include "wtf/text/MakeString.h"
|
||||
#include "wtf/text/WTFString.h"
|
||||
@@ -67,6 +69,7 @@ static JSC::JSObject* createErrorPrototype(JSC::VM& vm, JSC::JSGlobalObject* glo
|
||||
extern "C" JSC::EncodedJSValue Bun__ERR_INVALID_ARG_TYPE(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue val_arg_name, JSC::EncodedJSValue val_expected_type, JSC::EncodedJSValue val_actual_value);
|
||||
extern "C" JSC::EncodedJSValue Bun__ERR_INVALID_ARG_TYPE_static(JSC::JSGlobalObject* globalObject, const ZigString* val_arg_name, const ZigString* val_expected_type, JSC::EncodedJSValue val_actual_value);
|
||||
extern "C" JSC::EncodedJSValue Bun__ERR_MISSING_ARGS(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue arg1, JSC::EncodedJSValue arg2, JSC::EncodedJSValue arg3);
|
||||
extern "C" JSC::EncodedJSValue Bun__ERR_MISSING_ARGS_static(JSC::JSGlobalObject* globalObject, const ZigString* arg1, const ZigString* arg2, const ZigString* arg3);
|
||||
extern "C" JSC::EncodedJSValue Bun__ERR_IPC_CHANNEL_CLOSED(JSC::JSGlobalObject* globalObject);
|
||||
|
||||
// clang-format on
|
||||
@@ -317,6 +320,41 @@ extern "C" JSC::EncodedJSValue Bun__ERR_MISSING_ARGS(JSC::JSGlobalObject* global
|
||||
auto message = makeString("The \""_s, name1, "\", \""_s, name2, "\", and \""_s, name3, "\" arguments must be specified"_s);
|
||||
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_MISSING_ARGS, message));
|
||||
}
|
||||
extern "C" JSC::EncodedJSValue Bun__ERR_MISSING_ARGS_static(JSC::JSGlobalObject* globalObject, const ZigString* arg1, const ZigString* arg2, const ZigString* arg3)
|
||||
{
|
||||
JSC::VM& vm = globalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
if (arg1 == 0) {
|
||||
JSC::throwTypeError(globalObject, scope, "requires at least 1 argument"_s);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto name1 = std::span<const unsigned char>(arg1->ptr, arg1->len);
|
||||
ASSERT(WTF::charactersAreAllASCII(name1));
|
||||
|
||||
if (arg2 == nullptr) {
|
||||
// 1 arg name passed
|
||||
auto message = makeString("The \""_s, name1, "\" argument must be specified"_s);
|
||||
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_MISSING_ARGS, message));
|
||||
}
|
||||
|
||||
auto name2 = std::span<const unsigned char>(arg2->ptr, arg2->len);
|
||||
ASSERT(WTF::charactersAreAllASCII(name2));
|
||||
|
||||
if (arg3 == nullptr) {
|
||||
// 2 arg names passed
|
||||
auto message = makeString("The \""_s, name1, "\" and \""_s, name2, "\" arguments must be specified"_s);
|
||||
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_MISSING_ARGS, message));
|
||||
}
|
||||
|
||||
auto name3 = std::span<const unsigned char>(arg3->ptr, arg3->len);
|
||||
ASSERT(WTF::charactersAreAllASCII(name3));
|
||||
|
||||
// 3 arg names passed
|
||||
auto message = makeString("The \""_s, name1, "\", \""_s, name2, "\", and \""_s, name3, "\" arguments must be specified"_s);
|
||||
return JSC::JSValue::encode(createError(globalObject, ErrorCode::ERR_MISSING_ARGS, message));
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(jsFunction_ERR_IPC_CHANNEL_CLOSED, (JSC::JSGlobalObject * globalObject, JSC::CallFrame*))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user