mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
module pr 2 (#18266)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "ModuleLoader.h"
|
||||
#include "napi.h"
|
||||
|
||||
#include "BunProcess.h"
|
||||
@@ -465,9 +466,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionDlopen, (JSC::JSGlobalObject * globalOb
|
||||
while (charCount > 0 && (messageBuffer[charCount - 1] == L'\r' || messageBuffer[charCount - 1] == L'\n' || messageBuffer[charCount - 1] == L' '))
|
||||
charCount--;
|
||||
|
||||
// Create a span of the wide characters
|
||||
auto wideCharSpan = std::span<const UChar>(reinterpret_cast<const UChar*>(messageBuffer), charCount);
|
||||
errorBuilder.append(WTF::StringView(wideCharSpan));
|
||||
errorBuilder.append(WTF::StringView(messageBuffer, charCount, false));
|
||||
} else {
|
||||
errorBuilder.append("error code "_s);
|
||||
errorBuilder.append(WTF::String::number(errorId));
|
||||
@@ -2641,12 +2640,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_availableMemory, (JSGlobalObject * globalObject
|
||||
|
||||
inline JSValue processBindingUtil(Zig::GlobalObject* globalObject, JSC::VM& vm)
|
||||
{
|
||||
auto& builtinNames = WebCore::builtinNames(vm);
|
||||
auto fn = globalObject->getDirect(vm, builtinNames.requireNativeModulePrivateName());
|
||||
auto callData = JSC::getCallData(fn);
|
||||
JSC::MarkedArgumentBuffer args;
|
||||
args.append(jsString(vm, String("util/types"_s)));
|
||||
return JSC::profiledCall(globalObject, ProfilingReason::API, fn, callData, globalObject, args);
|
||||
return globalObject->internalModuleRegistry()->requireId(globalObject, vm, InternalModuleRegistry::NodeUtilTypes);
|
||||
}
|
||||
|
||||
inline JSValue processBindingConfig(Zig::GlobalObject* globalObject, JSC::VM& vm)
|
||||
@@ -3303,7 +3297,7 @@ JSC_DEFINE_CUSTOM_GETTER(processTitle, (JSC::JSGlobalObject * globalObject, JSC:
|
||||
#if !OS(WINDOWS)
|
||||
ZigString str;
|
||||
Bun__Process__getTitle(globalObject, &str);
|
||||
return JSValue::encode(Zig::toJSStringValue(str, globalObject));
|
||||
return JSValue::encode(Zig::toJSString(str, globalObject));
|
||||
#else
|
||||
auto& vm = JSC::getVM(globalObject);
|
||||
char title[1024];
|
||||
@@ -3452,6 +3446,29 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionKill, (JSC::JSGlobalObject * globalObje
|
||||
return JSValue::encode(jsBoolean(true));
|
||||
}
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(Process_functionLoadBuiltinModule, (JSGlobalObject * globalObject, CallFrame* callFrame))
|
||||
{
|
||||
auto* zigGlobalObject = jsCast<Zig::GlobalObject*>(globalObject);
|
||||
VM& vm = zigGlobalObject->vm();
|
||||
auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
JSValue id = callFrame->argument(0);
|
||||
if (!id.isString()) {
|
||||
return Bun::ERR::INVALID_ARG_TYPE(scope, globalObject, "moduleName"_s, "string"_s, id);
|
||||
}
|
||||
|
||||
String idWtfStr = id.toWTFString(zigGlobalObject);
|
||||
RETURN_IF_EXCEPTION(scope, {});
|
||||
BunString idStr = Bun::toString(idWtfStr);
|
||||
|
||||
JSValue fetchResult = Bun::resolveAndFetchBuiltinModule(zigGlobalObject, &idStr);
|
||||
if (fetchResult) {
|
||||
RELEASE_AND_RETURN(scope, JSC::JSValue::encode(fetchResult));
|
||||
}
|
||||
|
||||
RELEASE_AND_RETURN(scope, JSValue::encode(jsUndefined()));
|
||||
}
|
||||
|
||||
extern "C" void Process__emitMessageEvent(Zig::GlobalObject* global, EncodedJSValue value)
|
||||
{
|
||||
auto* process = static_cast<Process*>(global->processObject());
|
||||
@@ -3557,6 +3574,7 @@ extern "C" void Process__emitErrorEvent(Zig::GlobalObject* global, EncodedJSValu
|
||||
_stopProfilerIdleNotifier Process_stubEmptyFunction Function 0
|
||||
_tickCallback Process_stubEmptyFunction Function 0
|
||||
_kill Process_functionReallyKill Function 2
|
||||
getBuiltinModule Process_functionLoadBuiltinModule Function 1
|
||||
|
||||
#if !OS(WINDOWS)
|
||||
getegid Process_functiongetegid Function 0
|
||||
|
||||
Reference in New Issue
Block a user