#include "../bindings/JSBuffer.h" #include "../bindings/ZigGlobalObject.h" #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/ObjectConstructor.h" namespace Zig { using namespace WebCore; JSC_DEFINE_HOST_FUNCTION(jsFunctionTty_isatty, (JSGlobalObject * globalObject, CallFrame *callFrame)) { VM &vm = globalObject->vm(); if (callFrame->argumentCount() < 1) { return JSValue::encode(jsBoolean(false)); } auto scope = DECLARE_CATCH_SCOPE(vm); int fd = callFrame->argument(0).toInt32(globalObject); RETURN_IF_EXCEPTION(scope, encodedJSValue()); return JSValue::encode(jsBoolean(isatty(fd))); } JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplementedYet, (JSGlobalObject * globalObject, CallFrame *callFrame)) { VM &vm = globalObject->vm(); auto throwScope = DECLARE_THROW_SCOPE(vm); throwException(globalObject, throwScope, createError(globalObject, "Not implemented yet"_s)); return JSValue::encode(jsUndefined()); } inline void generateTTYSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey, Vector &exportNames, JSC::MarkedArgumentBuffer &exportValues) { JSC::VM &vm = lexicalGlobalObject->vm(); GlobalObject *globalObject = reinterpret_cast(lexicalGlobalObject); auto *tty = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 3); auto *isattyFunction = JSFunction::create(vm, globalObject, 1, "isatty"_s, jsFunctionTty_isatty, ImplementationVisibility::Public); auto *notimpl = JSFunction::create(vm, globalObject, 0, "notimpl"_s, jsFunctionNotImplementedYet, ImplementationVisibility::Public, NoIntrinsic, jsFunctionNotImplementedYet); exportNames.append(JSC::Identifier::fromString(vm, "isatty"_s)); exportValues.append(isattyFunction); exportNames.append(JSC::Identifier::fromString(vm, "ReadStream"_s)); tty->putDirect(vm, JSC::Identifier::fromString(vm, "ReadStream"_s), notimpl); exportValues.append(notimpl); exportNames.append(JSC::Identifier::fromString(vm, "WriteStream"_s)); tty->putDirect(vm, JSC::Identifier::fromString(vm, "WriteStream"_s), notimpl); exportValues.append(notimpl); tty->putDirect(vm, PropertyName(Identifier::fromUid( vm.symbolRegistry().symbolForKey("CommonJS"_s))), jsNumber(0), 0); for (size_t i = 0; i < exportNames.size(); i++) { tty->putDirect(vm, exportNames[i], exportValues.at(i), 0); } exportNames.append(vm.propertyNames->defaultKeyword); exportValues.append(tty); } } // namespace Zig dave/remove-native-event'>dave/remove-native-event Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2023-05-21Fix assertion failureGravatar Jarred Sumner 1-1/+1
2023-05-21oopsieGravatar Jarred Sumner 1-1/+1
2023-05-21WS send with callback (#2986)Gravatar Ciro Spaciari 3-44/+39
2023-05-21[Bun.serve] Support `"nodebuffer"` binaryType in `ServerWebSocket`Gravatar Jarred Sumner 4-77/+122
2023-05-21[WebSocket] Implement `"nodebuffer"` binaryTypeGravatar Jarred Sumner 5-5/+125
2023-05-21[ws client] Make it a little more type safeGravatar Jarred Sumner 1-33/+51
2023-05-21[internal] Add more debug logs for uwsGravatar Jarred Sumner 2-3/+8
2023-05-21[internal] Add a 0 byte to EOF read files as a precautionGravatar Jarred Sumner 1-1/+5
2023-05-21[internal] Make AbortSIgnal usage slightly saferGravatar Jarred Sumner 3-6/+11
2023-05-21Add extra flag just to be sureGravatar Jarred Sumner 1-1/+1
2023-05-21[internal] Fix potential missing callbacks in AbortSignalGravatar Jarred Sumner 2-208/+2