aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/modules/TTYModule.h
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-08-02 16:27:36 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-02 16:27:36 -0700
commitc2a77cf7ec9de9eadf938046bdf78e58561c8a6d (patch)
tree0f90f1b323061455875333c9f40592b303585973 /src/bun.js/modules/TTYModule.h
parent7656b4b17e91f15b58eeab8f45b78c416ec6a045 (diff)
downloadbun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.tar.gz
bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.tar.zst
bun-c2a77cf7ec9de9eadf938046bdf78e58561c8a6d.zip
Rewrite built-in modules to use CommonJS over ESM (#3814)
* stfdsafsd sadffdsa stuff finish commonjs stuff asdf not done but work not done but work not done yet but this is how far i am remove files lol update built files uncomment everything in events lol export default stuff * afdsafsd * its not perfect but almost done * okay * cool * remove temp file * finish rebase * revert settings.json * a * ch-ch-ch-ch-changes * okay * remove this check in release for now * sxdcfghnjm, * lkjhgf * fmt * filename can be null * Update NodeModuleModule.h * weee * fmt --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/modules/TTYModule.h')
-rw-r--r--src/bun.js/modules/TTYModule.h81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/bun.js/modules/TTYModule.h b/src/bun.js/modules/TTYModule.h
deleted file mode 100644
index 79bc8c871..000000000
--- a/src/bun.js/modules/TTYModule.h
+++ /dev/null
@@ -1,81 +0,0 @@
-#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<JSC::Identifier, 4> &exportNames,
- JSC::MarkedArgumentBuffer &exportValues) {
- JSC::VM &vm = lexicalGlobalObject->vm();
- GlobalObject *globalObject =
- reinterpret_cast<GlobalObject *>(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);
-
- 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);
-
- auto CommonJS =
- Identifier::fromUid(vm.symbolRegistry().symbolForKey("CommonJS"_s));
-
- exportNames.append(CommonJS);
- exportValues.append(jsNumber(0));
-
- tty->putDirect(vm, PropertyName(CommonJS), jsNumber(0), 0);
-}
-
-} // namespace Zig