#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 ion> Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-09-05simple benchmarkbenchmarkGravatar Fred K. Schott 6-0/+1427
2021-09-05[ci] yarn formatGravatar jasikpark 1-2/+3
2021-09-05Update `yarn.lock` with @octokit dep updates\n\n `--frozen-lockfile` was ↵Gravatar Caleb Jasik 1-13/+25
complaining that the lockfile needed updates.
2021-09-05docs: set +/- prefix to non-selectable (#1316)Gravatar Sam Chen 1-0/+4
2021-09-05docs: add a link to next article (#1308)Gravatar Sam Chen 2-2/+20
2021-09-05[ci] collect statsGravatar FredKSchott 1-0/+1
2021-09-04📘DOC: Fix URL normalization for the Left Sidebar in docs (#1299)Gravatar Caleb Jasik 2-2/+14
* Fix URL normalization for the Left Sidebar in docs * Move the fix into `util.ts` as suggested by @FredKSchott
2021-09-04examples: Fix with-tailwindcss example #1256 (#1312)Gravatar kreako 2-1/+1
2021-09-04[ci] collect statsGravatar FredKSchott 2-1/+2
2021-09-03docs: add a period (#1306)Gravatar Sam Chen 1-1/+1