ci: run clang-format on .h files too (#14597)

Co-authored-by: nektro <nektro@users.noreply.github.com>
This commit is contained in:
Meghan Denny
2024-10-15 16:54:49 -07:00
committed by GitHub
parent 409e674526
commit 06e733cc64
50 changed files with 1788 additions and 1740 deletions

View File

@@ -1,6 +1,11 @@
# https://clang.llvm.org/docs/ClangFormat.html
set(CLANG_FORMAT_SOURCES ${BUN_C_SOURCES} ${BUN_CXX_SOURCES})
file(GLOB BUN_H_SOURCES LIST_DIRECTORIES false ${CONFIGURE_DEPENDS}
${CWD}/src/bun.js/bindings/*.h
${CWD}/src/bun.js/modules/*.h
)
set(CLANG_FORMAT_SOURCES ${BUN_C_SOURCES} ${BUN_CXX_SOURCES} ${BUN_H_SOURCES})
register_command(
TARGET

View File

@@ -17,4 +17,4 @@ enum class BufferEncodingType {
};
}
}

View File

@@ -199,4 +199,4 @@ namespace WebCore {
using JSVMClientData = WebCore::JSVMClientData;
using JSHeapData = WebCore::JSHeapData;
}
}

View File

@@ -12,4 +12,4 @@ public:
bool isHTMLAllCollection(JSC::VM&, JSC::JSValue) override { return false; }
};
}
}

View File

@@ -106,4 +106,4 @@ class GlobalObject;
namespace Bun {
JSC::JSValue runVirtualModule(Zig::GlobalObject*, BunString* specifier, bool& wasModuleMock);
JSC::Structure* createModuleMockStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype);
}
}

View File

@@ -53,4 +53,4 @@ public:
private:
MessagePortChannelProviderImpl* m_messagePortChannelProvider;
};
}
}

View File

@@ -6,4 +6,4 @@ namespace WebCore {
class CachedScript {
};
}
}

View File

@@ -44,4 +44,4 @@ private:
void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
};
}
}

View File

@@ -13,4 +13,4 @@ public:
}
};
}
}

View File

@@ -41,4 +41,4 @@ protected:
bool m_isCleanupTask;
};
}
}

View File

@@ -18,4 +18,4 @@ ALWAYS_INLINE GCDeferralContext::~GCDeferralContext()
m_vm.heap.collectIfNecessaryOrDefer();
}
} // namespace JSC
} // namespace JSC

View File

@@ -414,4 +414,4 @@ template<typename T>
struct IsIDLArrayBufferViewAllowShared : public std::integral_constant<bool, std::is_base_of<IDLAllowSharedAdaptor<IDLArrayBufferView>, T>::value> {
};
} // namespace WebCore
} // namespace WebCore

View File

@@ -10,4 +10,4 @@ JSC_DECLARE_HOST_FUNCTION(jsDollarCpp);
JSC_DECLARE_HOST_FUNCTION(jsDollarZig);
} // namespace JS2Native
} // namespace Bun
} // namespace Bun

View File

@@ -69,4 +69,4 @@ public:
bool tombstoned { false };
};
} // namespace Zig
} // namespace Zig

View File

@@ -26,4 +26,4 @@ public:
HashSet<Ref<JSC::DeferredWorkTimer::TicketData>> m_pendingTicketsOther;
};
}
}

View File

@@ -2,4 +2,4 @@ namespace Bun {
JSC::JSValue createJSCTestingHelpers(Zig::GlobalObject* global);
}
}

View File

@@ -8,4 +8,4 @@
namespace WebCore {
}
}

View File

@@ -35,4 +35,4 @@ JSClass* toJSDOMGlobalObject(JSC::VM& vm, JSC::JSValue value)
return nullptr;
}
}
}

View File

@@ -12,4 +12,4 @@ namespace Bun {
JSC::JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject);
}
}

View File

@@ -37,4 +37,4 @@ public:
bool isEmpty();
void drain(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
};
}
}

View File

@@ -71,4 +71,4 @@ private:
JSC::WriteBarrier<JSC::JSFunction> m_wrappedFn;
};
}
}

View File

@@ -2,7 +2,7 @@
#include "ZigGlobalObject.h"
namespace Bun {
JSC::JSValue createAsyncHooksBinding(Zig::GlobalObject*);
}
}

View File

@@ -4,4 +4,4 @@ namespace Bun {
JSC::JSValue createNodeFetchInternalBinding(Zig::GlobalObject*);
}
}

View File

@@ -1,11 +1,11 @@
#include "config.h"
namespace Bun {
JSC_DECLARE_HOST_FUNCTION(jsHTTPAssignHeaders);
JSC_DECLARE_HOST_FUNCTION(jsHTTPGetHeader);
JSC_DECLARE_HOST_FUNCTION(jsHTTPSetHeader);
JSC::JSValue createNodeHTTPInternalBinding(Zig::GlobalObject*);
}
}

View File

@@ -2,7 +2,7 @@
#include "ZigGlobalObject.h"
namespace Bun {
JSC::JSValue createNodeTLSBinding(Zig::GlobalObject*);
}
}

View File

@@ -5,4 +5,4 @@ namespace Bun {
JSC::JSValue createNodeURLBinding(Zig::GlobalObject*);
} // namespace Bun
} // namespace Bun

View File

@@ -2,7 +2,7 @@
#include "ZigGlobalObject.h"
namespace Bun {
JSC::JSValue createNodePathBinding(Zig::GlobalObject* globalObject);
} // namespace Bun

View File

@@ -15,4 +15,4 @@ JSC::JSValue createNodeTTYWrapObject(JSC::JSGlobalObject* globalObject);
JSC_DECLARE_HOST_FUNCTION(Process_functionInternalGetWindowSize);
}
}

View File

@@ -10,4 +10,4 @@ JSC_DECLARE_HOST_FUNCTION(jsGetErrorMap);
JSC::JSObject* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
} // namespace ProcessBindingUV
} // namespace Bun
} // namespace Bun

View File

@@ -206,4 +206,4 @@ public:
ScriptExecutionContext* executionContext(JSC::JSGlobalObject*);
}
}

View File

@@ -14,4 +14,4 @@ enum SinkID : uint8_t {
static constexpr unsigned numberOfSinkIDs
= 7;
}
}

View File

@@ -31,4 +31,4 @@ public:
JSC::Strong<JSC::Unknown> m_cell;
};
}
}

View File

@@ -3,4 +3,4 @@ namespace Bun {
JSC::JSValue createUndiciInternalBinding(Zig::GlobalObject* globalObject);
}
}

View File

@@ -4,4 +4,4 @@ namespace Bun {
JSC::Structure* createUtilInspectOptionsStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
}
}

View File

@@ -15,4 +15,4 @@ Inspector::InspectorDebuggerAgent* debuggerAgent(JSC::JSGlobalObject* globalObje
return nullptr;
}
}
}

View File

@@ -1,5 +1,5 @@
#pragma once
namespace Bun {
bool isBuiltinModule(const String &namePossiblyWithNodePrefix);
} // namespace Bun
bool isBuiltinModule(const String& namePossiblyWithNodePrefix);
} // namespace Bun

View File

@@ -100,4 +100,4 @@ public:
#endif
};
} // namespace Zig
} // namespace Zig

View File

@@ -12,4 +12,4 @@ class VM;
namespace Bun {
String base64URLEncodeToString(Vector<uint8_t> data);
size_t toISOString(JSC::VM& vm, double date, char buffer[64]);
}
}

View File

@@ -9,46 +9,44 @@ using namespace WebCore;
namespace Zig {
inline void generateNativeModule_AbortControllerModule(
JSC::JSGlobalObject *lexicalGlobalObject, JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4> &exportNames,
JSC::MarkedArgumentBuffer &exportValues) {
JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4>& exportNames,
JSC::MarkedArgumentBuffer& exportValues)
{
Zig::GlobalObject *globalObject =
reinterpret_cast<Zig::GlobalObject *>(lexicalGlobalObject);
JSC::VM &vm = globalObject->vm();
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
JSC::VM& vm = globalObject->vm();
auto *abortController =
WebCore::JSAbortController::getConstructor(vm, globalObject).getObject();
JSValue abortSignal =
WebCore::JSAbortSignal::getConstructor(vm, globalObject);
auto* abortController = WebCore::JSAbortController::getConstructor(vm, globalObject).getObject();
JSValue abortSignal = WebCore::JSAbortSignal::getConstructor(vm, globalObject);
const auto controllerIdent = Identifier::fromString(vm, "AbortController"_s);
const auto signalIdent = Identifier::fromString(vm, "AbortSignal"_s);
const Identifier esModuleMarker = builtinNames(vm).__esModulePublicName();
const auto controllerIdent = Identifier::fromString(vm, "AbortController"_s);
const auto signalIdent = Identifier::fromString(vm, "AbortSignal"_s);
const Identifier esModuleMarker = builtinNames(vm).__esModulePublicName();
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(abortController);
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(abortController);
exportNames.append(signalIdent);
exportValues.append(abortSignal);
exportNames.append(signalIdent);
exportValues.append(abortSignal);
exportNames.append(controllerIdent);
exportValues.append(abortController);
exportNames.append(controllerIdent);
exportValues.append(abortController);
exportNames.append(esModuleMarker);
exportValues.append(jsBoolean(true));
exportNames.append(esModuleMarker);
exportValues.append(jsBoolean(true));
// https://github.com/mysticatea/abort-controller/blob/a935d38e09eb95d6b633a8c42fcceec9969e7b05/dist/abort-controller.js#L125
abortController->putDirect(
vm, signalIdent, abortSignal,
static_cast<unsigned>(PropertyAttribute::DontDelete));
// https://github.com/mysticatea/abort-controller/blob/a935d38e09eb95d6b633a8c42fcceec9969e7b05/dist/abort-controller.js#L125
abortController->putDirect(
vm, signalIdent, abortSignal,
static_cast<unsigned>(PropertyAttribute::DontDelete));
abortController->putDirect(
vm, controllerIdent, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));
abortController->putDirect(
vm, controllerIdent, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));
abortController->putDirect(
vm, vm.propertyNames->defaultKeyword, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));
abortController->putDirect(
vm, vm.propertyNames->defaultKeyword, abortController,
static_cast<unsigned>(PropertyAttribute::DontDelete));
}
} // namespace Zig

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
namespace Zig {
void generateNativeModule_BunObject(JSC::JSGlobalObject *lexicalGlobalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4> &exportNames,
JSC::MarkedArgumentBuffer &exportValues);
void generateNativeModule_BunObject(JSC::JSGlobalObject* lexicalGlobalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4>& exportNames,
JSC::MarkedArgumentBuffer& exportValues);
} // namespace Zig
} // namespace Zig

View File

@@ -1,17 +1,18 @@
namespace Zig {
void generateNativeModule_BunTest(
JSC::JSGlobalObject *lexicalGlobalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4> &exportNames,
JSC::MarkedArgumentBuffer &exportValues) {
JSC::VM &vm = lexicalGlobalObject->vm();
auto globalObject = jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
JSC::JSGlobalObject* lexicalGlobalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4>& exportNames,
JSC::MarkedArgumentBuffer& exportValues)
{
JSC::VM& vm = lexicalGlobalObject->vm();
auto globalObject = jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
JSObject *object = globalObject->lazyPreloadTestModuleObject();
JSObject* object = globalObject->lazyPreloadTestModuleObject();
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(object);
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(object);
}
} // namespace Zig
} // namespace Zig

View File

@@ -16,219 +16,218 @@ using namespace JSC;
// TODO: Add DOMJIT fast path
JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isUtf8,
(JSC::JSGlobalObject * lexicalGlobalObject,
JSC::CallFrame *callframe)) {
auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
(JSC::JSGlobalObject * lexicalGlobalObject,
JSC::CallFrame* callframe))
{
auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
auto buffer = callframe->argument(0);
auto *bufferView = JSC::jsDynamicCast<JSC::JSArrayBufferView *>(buffer);
const char *ptr = nullptr;
size_t byteLength = 0;
if (bufferView) {
if (UNLIKELY(bufferView->isDetached())) {
throwTypeError(lexicalGlobalObject, throwScope,
"ArrayBufferView is detached"_s);
return {};
auto buffer = callframe->argument(0);
auto* bufferView = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(buffer);
const char* ptr = nullptr;
size_t byteLength = 0;
if (bufferView) {
if (UNLIKELY(bufferView->isDetached())) {
throwTypeError(lexicalGlobalObject, throwScope,
"ArrayBufferView is detached"_s);
return {};
}
byteLength = bufferView->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char*>(bufferView->vector());
} else if (auto* arrayBuffer = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(buffer)) {
auto* impl = arrayBuffer->impl();
if (!impl) {
return JSValue::encode(jsBoolean(true));
}
if (UNLIKELY(impl->isDetached())) {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject,
"Cannot validate on a detached buffer"_s);
}
byteLength = impl->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char*>(impl->data());
} else {
Bun::throwError(lexicalGlobalObject, throwScope,
Bun::ErrorCode::ERR_INVALID_ARG_TYPE,
"First argument must be an ArrayBufferView"_s);
return {};
}
byteLength = bufferView->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char *>(bufferView->vector());
} else if (auto *arrayBuffer =
JSC::jsDynamicCast<JSC::JSArrayBuffer *>(buffer)) {
auto *impl = arrayBuffer->impl();
if (!impl) {
return JSValue::encode(jsBoolean(true));
}
if (UNLIKELY(impl->isDetached())) {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject,
"Cannot validate on a detached buffer"_s);
}
byteLength = impl->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char *>(impl->data());
} else {
Bun::throwError(lexicalGlobalObject, throwScope,
Bun::ErrorCode::ERR_INVALID_ARG_TYPE,
"First argument must be an ArrayBufferView"_s);
return {};
}
RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(
simdutf::validate_utf8(ptr, byteLength))));
RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(simdutf::validate_utf8(ptr, byteLength))));
}
// TODO: Add DOMJIT fast path
JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_isAscii,
(JSC::JSGlobalObject * lexicalGlobalObject,
JSC::CallFrame *callframe)) {
auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
(JSC::JSGlobalObject * lexicalGlobalObject,
JSC::CallFrame* callframe))
{
auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm());
auto buffer = callframe->argument(0);
auto *bufferView = JSC::jsDynamicCast<JSC::JSArrayBufferView *>(buffer);
const char *ptr = nullptr;
size_t byteLength = 0;
if (bufferView) {
auto buffer = callframe->argument(0);
auto* bufferView = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(buffer);
const char* ptr = nullptr;
size_t byteLength = 0;
if (bufferView) {
if (UNLIKELY(bufferView->isDetached())) {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject,
"Cannot validate on a detached buffer"_s);
if (UNLIKELY(bufferView->isDetached())) {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject,
"Cannot validate on a detached buffer"_s);
}
byteLength = bufferView->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char*>(bufferView->vector());
} else if (auto* arrayBuffer = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(buffer)) {
auto* impl = arrayBuffer->impl();
if (UNLIKELY(impl->isDetached())) {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject,
"Cannot validate on a detached buffer"_s);
}
if (!impl) {
return JSValue::encode(jsBoolean(true));
}
byteLength = impl->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char*>(impl->data());
} else {
Bun::throwError(lexicalGlobalObject, throwScope,
Bun::ErrorCode::ERR_INVALID_ARG_TYPE,
"First argument must be an ArrayBufferView"_s);
return {};
}
byteLength = bufferView->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char *>(bufferView->vector());
} else if (auto *arrayBuffer =
JSC::jsDynamicCast<JSC::JSArrayBuffer *>(buffer)) {
auto *impl = arrayBuffer->impl();
if (UNLIKELY(impl->isDetached())) {
return Bun::ERR::INVALID_STATE(throwScope, lexicalGlobalObject,
"Cannot validate on a detached buffer"_s);
}
if (!impl) {
return JSValue::encode(jsBoolean(true));
}
byteLength = impl->byteLength();
if (byteLength == 0) {
return JSValue::encode(jsBoolean(true));
}
ptr = reinterpret_cast<const char *>(impl->data());
} else {
Bun::throwError(lexicalGlobalObject, throwScope,
Bun::ErrorCode::ERR_INVALID_ARG_TYPE,
"First argument must be an ArrayBufferView"_s);
return {};
}
RELEASE_AND_RETURN(
throwScope,
JSValue::encode(jsBoolean(simdutf::validate_ascii(ptr, byteLength))));
RELEASE_AND_RETURN(
throwScope,
JSValue::encode(jsBoolean(simdutf::validate_ascii(ptr, byteLength))));
}
BUN_DECLARE_HOST_FUNCTION(jsFunctionResolveObjectURL);
JSC_DEFINE_HOST_FUNCTION(jsFunctionNotImplemented,
(JSGlobalObject * globalObject,
CallFrame *callFrame)) {
VM &vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
(JSGlobalObject * globalObject,
CallFrame* callFrame))
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
throwException(globalObject, scope,
createError(globalObject, "Not implemented"_s));
return {};
throwException(globalObject, scope,
createError(globalObject, "Not implemented"_s));
return {};
}
JSC_DEFINE_CUSTOM_GETTER(jsGetter_INSPECT_MAX_BYTES, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, PropertyName propertyName))
{
auto globalObject = reinterpret_cast<Zig::GlobalObject *>(lexicalGlobalObject);
return JSValue::encode(jsNumber(globalObject->INSPECT_MAX_BYTES));
auto globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
return JSValue::encode(jsNumber(globalObject->INSPECT_MAX_BYTES));
}
JSC_DEFINE_CUSTOM_SETTER(jsSetter_INSPECT_MAX_BYTES, (JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, PropertyName propertyName))
{
auto globalObject = reinterpret_cast<Zig::GlobalObject *>(lexicalGlobalObject);
auto &vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
auto val = JSValue::decode(value);
Bun::V::validateNumber(scope, globalObject, val, jsString(vm, String("INSPECT_MAX_BYTES"_s)), jsNumber(0), jsUndefined());
RETURN_IF_EXCEPTION(scope, {});
globalObject->INSPECT_MAX_BYTES = val.asNumber();
return JSValue::encode(jsUndefined());
auto globalObject = reinterpret_cast<Zig::GlobalObject*>(lexicalGlobalObject);
auto& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
auto val = JSValue::decode(value);
Bun::V::validateNumber(scope, globalObject, val, jsString(vm, String("INSPECT_MAX_BYTES"_s)), jsNumber(0), jsUndefined());
RETURN_IF_EXCEPTION(scope, {});
globalObject->INSPECT_MAX_BYTES = val.asNumber();
return JSValue::encode(jsUndefined());
}
DEFINE_NATIVE_MODULE(NodeBuffer) {
INIT_NATIVE_MODULE(12);
DEFINE_NATIVE_MODULE(NodeBuffer)
{
INIT_NATIVE_MODULE(12);
put(JSC::Identifier::fromString(vm, "Buffer"_s),
globalObject->JSBufferConstructor());
put(JSC::Identifier::fromString(vm, "Buffer"_s),
globalObject->JSBufferConstructor());
auto *slowBuffer = JSC::JSFunction::create(
vm, globalObject, 0, "SlowBuffer"_s, WebCore::constructSlowBuffer,
ImplementationVisibility::Public, NoIntrinsic,
WebCore::constructSlowBuffer);
slowBuffer->putDirect(
vm, vm.propertyNames->prototype, globalObject->JSBufferPrototype(),
JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum |
JSC::PropertyAttribute::DontDelete);
put(JSC::Identifier::fromString(vm, "SlowBuffer"_s), slowBuffer);
auto blobIdent = JSC::Identifier::fromString(vm, "Blob"_s);
auto* slowBuffer = JSC::JSFunction::create(
vm, globalObject, 0, "SlowBuffer"_s, WebCore::constructSlowBuffer,
ImplementationVisibility::Public, NoIntrinsic,
WebCore::constructSlowBuffer);
slowBuffer->putDirect(
vm, vm.propertyNames->prototype, globalObject->JSBufferPrototype(),
JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
put(JSC::Identifier::fromString(vm, "SlowBuffer"_s), slowBuffer);
auto blobIdent = JSC::Identifier::fromString(vm, "Blob"_s);
JSValue blobValue = globalObject->JSBlobConstructor();
put(blobIdent, blobValue);
JSValue blobValue = globalObject->JSBlobConstructor();
put(blobIdent, blobValue);
put(JSC::Identifier::fromString(vm, "File"_s),
globalObject->JSDOMFileConstructor());
put(JSC::Identifier::fromString(vm, "File"_s),
globalObject->JSDOMFileConstructor());
{
auto name = Identifier::fromString(vm, "INSPECT_MAX_BYTES"_s);
auto value = JSC::CustomGetterSetter::create(vm, jsGetter_INSPECT_MAX_BYTES, jsSetter_INSPECT_MAX_BYTES);
auto attributes = PropertyAttribute::DontDelete | PropertyAttribute::CustomAccessor;
defaultObject->putDirectCustomAccessor(vm, name, value, (unsigned)attributes);
exportNames.append(name);
exportValues.append(value);
__NATIVE_MODULE_ASSERT_INCR;
}
{
auto name = Identifier::fromString(vm, "INSPECT_MAX_BYTES"_s);
auto value = JSC::CustomGetterSetter::create(vm, jsGetter_INSPECT_MAX_BYTES, jsSetter_INSPECT_MAX_BYTES);
auto attributes = PropertyAttribute::DontDelete | PropertyAttribute::CustomAccessor;
defaultObject->putDirectCustomAccessor(vm, name, value, (unsigned)attributes);
exportNames.append(name);
exportValues.append(value);
__NATIVE_MODULE_ASSERT_INCR;
}
put(JSC::Identifier::fromString(vm, "kMaxLength"_s), JSC::jsNumber(Bun::Buffer::kMaxLength));
put(JSC::Identifier::fromString(vm, "kStringMaxLength"_s), JSC::jsNumber(Bun::Buffer::kStringMaxLength));
put(JSC::Identifier::fromString(vm, "kMaxLength"_s), JSC::jsNumber(Bun::Buffer::kMaxLength));
put(JSC::Identifier::fromString(vm, "kStringMaxLength"_s), JSC::jsNumber(Bun::Buffer::kStringMaxLength));
JSC::JSObject *constants = JSC::constructEmptyObject(lexicalGlobalObject, globalObject->objectPrototype(), 2);
constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_LENGTH));
constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_STRING_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_STRING_LENGTH));
JSC::JSObject* constants = JSC::constructEmptyObject(lexicalGlobalObject, globalObject->objectPrototype(), 2);
constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_LENGTH));
constants->putDirect(vm, JSC::Identifier::fromString(vm, "MAX_STRING_LENGTH"_s), JSC::jsNumber(Bun::Buffer::MAX_STRING_LENGTH));
put(JSC::Identifier::fromString(vm, "constants"_s), constants);
put(JSC::Identifier::fromString(vm, "constants"_s), constants);
JSC::Identifier atobI = JSC::Identifier::fromString(vm, "atob"_s);
JSC::JSValue atobV = lexicalGlobalObject->get(globalObject, PropertyName(atobI));
JSC::Identifier atobI = JSC::Identifier::fromString(vm, "atob"_s);
JSC::JSValue atobV = lexicalGlobalObject->get(globalObject, PropertyName(atobI));
JSC::Identifier btoaI = JSC::Identifier::fromString(vm, "btoa"_s);
JSC::JSValue btoaV = lexicalGlobalObject->get(globalObject, PropertyName(btoaI));
JSC::Identifier btoaI = JSC::Identifier::fromString(vm, "btoa"_s);
JSC::JSValue btoaV = lexicalGlobalObject->get(globalObject, PropertyName(btoaI));
put(atobI, atobV);
put(btoaI, btoaV);
put(atobI, atobV);
put(btoaI, btoaV);
auto *transcode = InternalFunction::createFunctionThatMasqueradesAsUndefined(
vm, globalObject, 1, "transcode"_s, jsFunctionNotImplemented);
auto* transcode = InternalFunction::createFunctionThatMasqueradesAsUndefined(
vm, globalObject, 1, "transcode"_s, jsFunctionNotImplemented);
put(JSC::Identifier::fromString(vm, "transcode"_s), transcode);
put(JSC::Identifier::fromString(vm, "transcode"_s), transcode);
auto *resolveObjectURL =
InternalFunction::createFunctionThatMasqueradesAsUndefined(
vm, globalObject, 1, "resolveObjectURL"_s,
jsFunctionResolveObjectURL);
auto* resolveObjectURL = InternalFunction::createFunctionThatMasqueradesAsUndefined(
vm, globalObject, 1, "resolveObjectURL"_s,
jsFunctionResolveObjectURL);
put(JSC::Identifier::fromString(vm, "resolveObjectURL"_s), resolveObjectURL);
put(JSC::Identifier::fromString(vm, "resolveObjectURL"_s), resolveObjectURL);
put(JSC::Identifier::fromString(vm, "isAscii"_s),
JSC::JSFunction::create(vm, globalObject, 1, "isAscii"_s,
jsBufferConstructorFunction_isAscii,
ImplementationVisibility::Public, NoIntrinsic,
jsBufferConstructorFunction_isUtf8));
put(JSC::Identifier::fromString(vm, "isAscii"_s),
JSC::JSFunction::create(vm, globalObject, 1, "isAscii"_s,
jsBufferConstructorFunction_isAscii,
ImplementationVisibility::Public, NoIntrinsic,
jsBufferConstructorFunction_isUtf8));
put(JSC::Identifier::fromString(vm, "isUtf8"_s),
JSC::JSFunction::create(vm, globalObject, 1, "isUtf8"_s,
jsBufferConstructorFunction_isUtf8,
ImplementationVisibility::Public, NoIntrinsic,
jsBufferConstructorFunction_isUtf8));
put(JSC::Identifier::fromString(vm, "isUtf8"_s),
JSC::JSFunction::create(vm, globalObject, 1, "isUtf8"_s,
jsBufferConstructorFunction_isUtf8,
ImplementationVisibility::Public, NoIntrinsic,
jsBufferConstructorFunction_isUtf8));
}
} // namespace Zig

File diff suppressed because it is too large Load Diff

View File

@@ -6,69 +6,72 @@
namespace Zig {
JSC_DEFINE_HOST_FUNCTION(jsFunctionProcessModuleCommonJS,
(JSGlobalObject * globalObject,
CallFrame *callFrame)) {
(JSGlobalObject * globalObject,
CallFrame* callFrame))
{
return JSValue::encode(
reinterpret_cast<Zig::GlobalObject *>(globalObject)->processObject());
return JSValue::encode(
reinterpret_cast<Zig::GlobalObject*>(globalObject)->processObject());
}
JSC_DEFINE_CUSTOM_GETTER(jsFunctionProcessModuleCommonJSGetter,
(JSGlobalObject * globalObject,
JSC::EncodedJSValue thisValue,
PropertyName propertyName)) {
(JSGlobalObject * globalObject,
JSC::EncodedJSValue thisValue,
PropertyName propertyName))
{
return JSValue::encode(reinterpret_cast<Zig::GlobalObject *>(globalObject)
->processObject()
->get(globalObject, propertyName));
return JSValue::encode(reinterpret_cast<Zig::GlobalObject*>(globalObject)
->processObject()
->get(globalObject, propertyName));
}
JSC_DEFINE_CUSTOM_SETTER(jsFunctionProcessModuleCommonJSSetter,
(JSGlobalObject * globalObject,
JSC::EncodedJSValue thisValue,
JSC::EncodedJSValue encodedValue,
PropertyName propertyName)) {
VM &vm = globalObject->vm();
(JSGlobalObject * globalObject,
JSC::EncodedJSValue thisValue,
JSC::EncodedJSValue encodedValue,
PropertyName propertyName))
{
VM& vm = globalObject->vm();
return reinterpret_cast<Zig::GlobalObject *>(globalObject)
->processObject()
->putDirect(vm, propertyName, JSValue::decode(encodedValue), 0);
return reinterpret_cast<Zig::GlobalObject*>(globalObject)
->processObject()
->putDirect(vm, propertyName, JSValue::decode(encodedValue), 0);
}
DEFINE_NATIVE_MODULE(NodeProcess) {
JSC::VM &vm = lexicalGlobalObject->vm();
GlobalObject *globalObject =
reinterpret_cast<GlobalObject *>(lexicalGlobalObject);
DEFINE_NATIVE_MODULE(NodeProcess)
{
JSC::VM& vm = lexicalGlobalObject->vm();
GlobalObject* globalObject = reinterpret_cast<GlobalObject*>(lexicalGlobalObject);
JSC::JSObject *process = globalObject->processObject();
auto scope = DECLARE_THROW_SCOPE(vm);
if (!process->staticPropertiesReified()) {
process->reifyAllStaticProperties(globalObject);
if (scope.exception())
return;
}
PropertyNameArray properties(vm, PropertyNameMode::Strings,
PrivateSymbolMode::Exclude);
process->getPropertyNames(globalObject, properties,
DontEnumPropertiesMode::Exclude);
if (scope.exception())
return;
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(process);
for (auto &entry : properties) {
exportNames.append(entry);
auto catchScope = DECLARE_CATCH_SCOPE(vm);
JSValue result = process->get(globalObject, entry);
if (catchScope.exception()) {
result = jsUndefined();
catchScope.clearException();
JSC::JSObject* process = globalObject->processObject();
auto scope = DECLARE_THROW_SCOPE(vm);
if (!process->staticPropertiesReified()) {
process->reifyAllStaticProperties(globalObject);
if (scope.exception())
return;
}
exportValues.append(result);
}
PropertyNameArray properties(vm, PropertyNameMode::Strings,
PrivateSymbolMode::Exclude);
process->getPropertyNames(globalObject, properties,
DontEnumPropertiesMode::Exclude);
if (scope.exception())
return;
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(process);
for (auto& entry : properties) {
exportNames.append(entry);
auto catchScope = DECLARE_CATCH_SCOPE(vm);
JSValue result = process->get(globalObject, entry);
if (catchScope.exception()) {
result = jsUndefined();
catchScope.clearException();
}
exportValues.append(result);
}
}
} // namespace Zig

View File

@@ -4,13 +4,14 @@
namespace Zig {
DEFINE_NATIVE_MODULE(NodeStringDecoder) {
INIT_NATIVE_MODULE(1);
DEFINE_NATIVE_MODULE(NodeStringDecoder)
{
INIT_NATIVE_MODULE(1);
put(JSC::Identifier::fromString(vm, "StringDecoder"_s),
globalObject->JSStringDecoder());
put(JSC::Identifier::fromString(vm, "StringDecoder"_s),
globalObject->JSStringDecoder());
RETURN_NATIVE_MODULE();
RETURN_NATIVE_MODULE();
}
} // namespace Zig

View File

@@ -13,19 +13,20 @@ using namespace WebCore;
JSC_DECLARE_HOST_FUNCTION(jsFunctionTty_isatty);
JSC_DECLARE_HOST_FUNCTION(jsFunctionNotImplementedYet);
DEFINE_NATIVE_MODULE(NodeTTY) {
INIT_NATIVE_MODULE(3);
DEFINE_NATIVE_MODULE(NodeTTY)
{
INIT_NATIVE_MODULE(3);
auto *notimpl = JSFunction::create(vm, globalObject, 0, "notimpl"_s,
jsFunctionNotImplementedYet,
ImplementationVisibility::Public,
NoIntrinsic, jsFunctionNotImplementedYet);
auto* notimpl = JSFunction::create(vm, globalObject, 0, "notimpl"_s,
jsFunctionNotImplementedYet,
ImplementationVisibility::Public,
NoIntrinsic, jsFunctionNotImplementedYet);
putNativeFn(Identifier::fromString(vm, "isatty"_s), jsFunctionTty_isatty);
put(Identifier::fromString(vm, "ReadStream"_s), notimpl);
put(Identifier::fromString(vm, "WriteStream"_s), notimpl);
putNativeFn(Identifier::fromString(vm, "isatty"_s), jsFunctionTty_isatty);
put(Identifier::fromString(vm, "ReadStream"_s), notimpl);
put(Identifier::fromString(vm, "WriteStream"_s), notimpl);
RETURN_NATIVE_MODULE();
RETURN_NATIVE_MODULE();
}
} // namespace Zig

View File

@@ -18,491 +18,523 @@
using namespace JSC;
#define GET_FIRST_VALUE \
if (callframe->argumentCount() < 1) \
return JSValue::encode(jsBoolean(false)); \
JSValue value = callframe->uncheckedArgument(0);
#define GET_FIRST_VALUE \
if (callframe->argumentCount() < 1) \
return JSValue::encode(jsBoolean(false)); \
JSValue value = callframe->uncheckedArgument(0);
#define GET_FIRST_CELL \
if (callframe->argumentCount() < 1) \
return JSValue::encode(jsBoolean(false)); \
JSValue value = callframe->uncheckedArgument(0); \
if (!value.isCell()) \
return JSValue::encode(jsBoolean(false)); \
JSCell *cell = value.asCell();
#define GET_FIRST_CELL \
if (callframe->argumentCount() < 1) \
return JSValue::encode(jsBoolean(false)); \
JSValue value = callframe->uncheckedArgument(0); \
if (!value.isCell()) \
return JSValue::encode(jsBoolean(false)); \
JSCell* cell = value.asCell();
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsExternal,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
return JSValue::encode(jsBoolean(value.inherits<Bun::NapiExternal>()));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
return JSValue::encode(jsBoolean(value.inherits<Bun::NapiExternal>()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsDate, (JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSDateType));
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsDate, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSDateType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsArgumentsObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
if (!value.isCell())
return JSValue::encode(jsBoolean(false));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
if (!value.isCell())
return JSValue::encode(jsBoolean(false));
auto type = value.asCell()->type();
switch (type) {
case DirectArgumentsType:
case ScopedArgumentsType:
case ClonedArgumentsType:
return JSValue::encode(jsBoolean(true));
default:
return JSValue::encode(jsBoolean(false));
}
__builtin_unreachable();
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigIntObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(
jsBoolean(globalObject->bigIntObjectStructure() == cell->structure()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBooleanObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
return JSValue::encode(
jsBoolean(value.isCell() && value.asCell()->type() == BooleanObjectType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNumberObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
return JSValue::encode(
jsBoolean(value.isCell() && value.asCell()->type() == NumberObjectType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsStringObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
return JSValue::encode(jsBoolean(
value.isCell() && (value.asCell()->type() == StringObjectType ||
value.asCell()->type() == DerivedStringObjectType)));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSymbolObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(
jsBoolean(globalObject->symbolObjectStructure() == cell->structure()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNativeError,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
if (value.isCell()) {
if (value.inherits<JSC::ErrorInstance>() ||
value.asCell()->type() == ErrorInstanceType)
return JSValue::encode(jsBoolean(true));
VM &vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject *object = value.toObject(globalObject);
// node util.isError relies on toString
// https://github.com/nodejs/node/blob/cf8c6994e0f764af02da4fa70bc5962142181bf3/doc/api/util.md#L2923
PropertySlot slot(object, PropertySlot::InternalMethodType::VMInquiry, &vm);
if (object->getPropertySlot(globalObject,
vm.propertyNames->toStringTagSymbol, slot)) {
EXCEPTION_ASSERT(!scope.exception());
if (slot.isValue()) {
JSValue value =
slot.getValue(globalObject, vm.propertyNames->toStringTagSymbol);
if (value.isString()) {
String tag = asString(value)->value(globalObject);
if (UNLIKELY(scope.exception()))
scope.clearException();
if (tag == "Error"_s)
return JSValue::encode(jsBoolean(true));
}
}
auto type = value.asCell()->type();
switch (type) {
case DirectArgumentsType:
case ScopedArgumentsType:
case ClonedArgumentsType:
return JSValue::encode(jsBoolean(true));
default:
return JSValue::encode(jsBoolean(false));
}
JSValue proto = object->getPrototype(vm, globalObject);
if (proto.isCell() && (proto.inherits<JSC::ErrorInstance>() ||
proto.asCell()->type() == ErrorInstanceType ||
proto.inherits<JSC::ErrorPrototype>()))
return JSValue::encode(jsBoolean(true));
}
__builtin_unreachable();
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigIntObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(
jsBoolean(globalObject->bigIntObjectStructure() == cell->structure()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBooleanObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
return JSValue::encode(
jsBoolean(value.isCell() && value.asCell()->type() == BooleanObjectType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNumberObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
return JSValue::encode(
jsBoolean(value.isCell() && value.asCell()->type() == NumberObjectType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsStringObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
return JSValue::encode(jsBoolean(
value.isCell() && (value.asCell()->type() == StringObjectType || value.asCell()->type() == DerivedStringObjectType)));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSymbolObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(false));
return JSValue::encode(
jsBoolean(globalObject->symbolObjectStructure() == cell->structure()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNativeError,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
if (value.isCell()) {
if (value.inherits<JSC::ErrorInstance>() || value.asCell()->type() == ErrorInstanceType)
return JSValue::encode(jsBoolean(true));
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSObject* object = value.toObject(globalObject);
// node util.isError relies on toString
// https://github.com/nodejs/node/blob/cf8c6994e0f764af02da4fa70bc5962142181bf3/doc/api/util.md#L2923
PropertySlot slot(object, PropertySlot::InternalMethodType::VMInquiry, &vm);
if (object->getPropertySlot(globalObject,
vm.propertyNames->toStringTagSymbol, slot)) {
EXCEPTION_ASSERT(!scope.exception());
if (slot.isValue()) {
JSValue value = slot.getValue(globalObject, vm.propertyNames->toStringTagSymbol);
if (value.isString()) {
String tag = asString(value)->value(globalObject);
if (UNLIKELY(scope.exception()))
scope.clearException();
if (tag == "Error"_s)
return JSValue::encode(jsBoolean(true));
}
}
}
JSValue proto = object->getPrototype(vm, globalObject);
if (proto.isCell() && (proto.inherits<JSC::ErrorInstance>() || proto.asCell()->type() == ErrorInstanceType || proto.inherits<JSC::ErrorPrototype>()))
return JSValue::encode(jsBoolean(true));
}
return JSValue::encode(jsBoolean(false));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsRegExp,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
return JSValue::encode(
jsBoolean(value.isCell() && value.asCell()->type() == RegExpObjectType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
return JSValue::encode(
jsBoolean(value.isCell() && value.asCell()->type() == RegExpObjectType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsAsyncFunction,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
auto *function = jsDynamicCast<JSFunction *>(value);
if (!function)
return JSValue::encode(jsBoolean(false));
auto* function = jsDynamicCast<JSFunction*>(value);
if (!function)
return JSValue::encode(jsBoolean(false));
auto *executable = function->jsExecutable();
if (!executable)
return JSValue::encode(jsBoolean(false));
auto* executable = function->jsExecutable();
if (!executable)
return JSValue::encode(jsBoolean(false));
if (executable->isAsyncGenerator()) {
return JSValue::encode(jsBoolean(true));
}
if (executable->isAsyncGenerator()) {
return JSValue::encode(jsBoolean(true));
}
auto &vm = globalObject->vm();
auto proto = function->getPrototype(vm, globalObject);
if (!proto.isCell()) {
return JSValue::encode(jsBoolean(false));
}
auto& vm = globalObject->vm();
auto proto = function->getPrototype(vm, globalObject);
if (!proto.isCell()) {
return JSValue::encode(jsBoolean(false));
}
auto *protoCell = proto.asCell();
return JSValue::encode(
jsBoolean(protoCell->inherits<AsyncFunctionPrototype>()));
auto* protoCell = proto.asCell();
return JSValue::encode(
jsBoolean(protoCell->inherits<AsyncFunctionPrototype>()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsGeneratorFunction,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_VALUE
auto *function = jsDynamicCast<JSFunction *>(value);
if (!function)
return JSValue::encode(jsBoolean(false));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_VALUE
auto* function = jsDynamicCast<JSFunction*>(value);
if (!function)
return JSValue::encode(jsBoolean(false));
auto *executable = function->jsExecutable();
if (!executable)
return JSValue::encode(jsBoolean(false));
auto* executable = function->jsExecutable();
if (!executable)
return JSValue::encode(jsBoolean(false));
return JSValue::encode(
jsBoolean(executable->isGenerator() || executable->isAsyncGenerator()));
return JSValue::encode(
jsBoolean(executable->isGenerator() || executable->isAsyncGenerator()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsGeneratorObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSGeneratorType ||
cell->type() == JSAsyncGeneratorType));
return JSValue::encode(jsBoolean(cell->type() == JSGeneratorType || cell->type() == JSAsyncGeneratorType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsPromise,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSPromiseType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSPromiseType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsMap, (JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSMapType));
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsMap, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSMapType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSet, (JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSSetType));
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSet, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSSetType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsMapIterator,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSMapIteratorType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSMapIteratorType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSetIterator,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSSetIteratorType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSSetIteratorType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsWeakMap,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSWeakMapType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSWeakMapType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsWeakSet,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSWeakSetType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == JSWeakSetType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsArrayBuffer,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
auto *arrayBuffer = jsDynamicCast<JSArrayBuffer *>(cell);
if (!arrayBuffer)
return JSValue::encode(jsBoolean(false));
return JSValue::encode(jsBoolean(!arrayBuffer->isShared()));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
auto* arrayBuffer = jsDynamicCast<JSArrayBuffer*>(cell);
if (!arrayBuffer)
return JSValue::encode(jsBoolean(false));
return JSValue::encode(jsBoolean(!arrayBuffer->isShared()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsDataView,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == DataViewType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == DataViewType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsSharedArrayBuffer,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
auto *arrayBuffer = jsDynamicCast<JSArrayBuffer *>(cell);
if (!arrayBuffer)
return JSValue::encode(jsBoolean(false));
return JSValue::encode(jsBoolean(arrayBuffer->isShared()));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
auto* arrayBuffer = jsDynamicCast<JSArrayBuffer*>(cell);
if (!arrayBuffer)
return JSValue::encode(jsBoolean(false));
return JSValue::encode(jsBoolean(arrayBuffer->isShared()));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsProxy, (JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == GlobalProxyType ||
cell->type() == ProxyObjectType));
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsProxy, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == GlobalProxyType || cell->type() == ProxyObjectType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsModuleNamespaceObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == ModuleNamespaceObjectType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == ModuleNamespaceObjectType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsAnyArrayBuffer,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
auto *arrayBuffer = jsDynamicCast<JSArrayBuffer *>(cell);
return JSValue::encode(jsBoolean(arrayBuffer != nullptr));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
auto* arrayBuffer = jsDynamicCast<JSArrayBuffer*>(cell);
return JSValue::encode(jsBoolean(arrayBuffer != nullptr));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBoxedPrimitive,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
switch (cell->type()) {
case JSC::BooleanObjectType:
case JSC::NumberObjectType:
case JSC::StringObjectType:
case JSC::DerivedStringObjectType:
return JSValue::encode(jsBoolean(true));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
switch (cell->type()) {
case JSC::BooleanObjectType:
case JSC::NumberObjectType:
case JSC::StringObjectType:
case JSC::DerivedStringObjectType:
return JSValue::encode(jsBoolean(true));
default: {
if (cell->structure() == globalObject->symbolObjectStructure())
return JSValue::encode(jsBoolean(true));
default: {
if (cell->structure() == globalObject->symbolObjectStructure())
return JSValue::encode(jsBoolean(true));
if (cell->structure() == globalObject->bigIntObjectStructure())
return JSValue::encode(jsBoolean(true));
}
}
if (cell->structure() == globalObject->bigIntObjectStructure())
return JSValue::encode(jsBoolean(true));
}
}
return JSValue::encode(jsBoolean(false));
return JSValue::encode(jsBoolean(false));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsArrayBufferView,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(
jsBoolean(cell->type() >= Int8ArrayType && cell->type() <= DataViewType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(
jsBoolean(cell->type() >= Int8ArrayType && cell->type() <= DataViewType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsTypedArray,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() >= Int8ArrayType &&
cell->type() <= BigUint64ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() >= Int8ArrayType && cell->type() <= BigUint64ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint8Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint8ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint8ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint8ClampedArray,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint8ClampedArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint8ClampedArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint16Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint16ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint16ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsUint32Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint32ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Uint32ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsInt8Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Int8ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Int8ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsInt16Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Int16ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Int16ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsInt32Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Int32ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Int32ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsFloat16Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Float16ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Float16ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsFloat32Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Float32ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Float32ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsFloat64Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Float64ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == Float64ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigInt64Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == BigInt64ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == BigInt64ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsBigUint64Array,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == BigUint64ArrayType));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->type() == BigUint64ArrayType));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsKeyObject,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
if (!cell->isObject()) {
return JSValue::encode(jsBoolean(false));
}
auto* object = cell->getObject();
auto& vm = globalObject->vm();
const auto& names = WebCore::builtinNames(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
if (auto val = object->getIfPropertyExists(globalObject,
names.bunNativePtrPrivateName())) {
if (val.isCell() && val.inherits<WebCore::JSCryptoKey>())
return JSValue::encode(jsBoolean(true));
}
if (scope.exception()) {
scope.clearException();
}
if (!cell->isObject()) {
return JSValue::encode(jsBoolean(false));
}
auto *object = cell->getObject();
auto &vm = globalObject->vm();
const auto &names = WebCore::builtinNames(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
if (auto val = object->getIfPropertyExists(globalObject,
names.bunNativePtrPrivateName())) {
if (val.isCell() && val.inherits<WebCore::JSCryptoKey>())
return JSValue::encode(jsBoolean(true));
}
if (scope.exception()) {
scope.clearException();
}
return JSValue::encode(jsBoolean(false));
}
JSC_DEFINE_HOST_FUNCTION(jsFunctionIsCryptoKey,
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame *callframe)) {
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->inherits<WebCore::JSCryptoKey>()));
(JSC::JSGlobalObject * globalObject,
JSC::CallFrame* callframe))
{
GET_FIRST_CELL
return JSValue::encode(jsBoolean(cell->inherits<WebCore::JSCryptoKey>()));
}
namespace Zig {
DEFINE_NATIVE_MODULE(NodeUtilTypes) {
INIT_NATIVE_MODULE(43);
DEFINE_NATIVE_MODULE(NodeUtilTypes)
{
INIT_NATIVE_MODULE(43);
putNativeFn(Identifier::fromString(vm, "isExternal"_s), jsFunctionIsExternal);
putNativeFn(Identifier::fromString(vm, "isDate"_s), jsFunctionIsDate);
putNativeFn(Identifier::fromString(vm, "isArgumentsObject"_s),
jsFunctionIsArgumentsObject);
putNativeFn(Identifier::fromString(vm, "isBigIntObject"_s),
jsFunctionIsBigIntObject);
putNativeFn(Identifier::fromString(vm, "isBooleanObject"_s),
jsFunctionIsBooleanObject);
putNativeFn(Identifier::fromString(vm, "isNumberObject"_s),
jsFunctionIsNumberObject);
putNativeFn(Identifier::fromString(vm, "isStringObject"_s),
jsFunctionIsStringObject);
putNativeFn(Identifier::fromString(vm, "isSymbolObject"_s),
jsFunctionIsSymbolObject);
putNativeFn(Identifier::fromString(vm, "isNativeError"_s),
jsFunctionIsNativeError);
putNativeFn(Identifier::fromString(vm, "isRegExp"_s), jsFunctionIsRegExp);
putNativeFn(Identifier::fromString(vm, "isAsyncFunction"_s),
jsFunctionIsAsyncFunction);
putNativeFn(Identifier::fromString(vm, "isGeneratorFunction"_s),
jsFunctionIsGeneratorFunction);
putNativeFn(Identifier::fromString(vm, "isGeneratorObject"_s),
jsFunctionIsGeneratorObject);
putNativeFn(Identifier::fromString(vm, "isPromise"_s), jsFunctionIsPromise);
putNativeFn(Identifier::fromString(vm, "isMap"_s), jsFunctionIsMap);
putNativeFn(Identifier::fromString(vm, "isSet"_s), jsFunctionIsSet);
putNativeFn(Identifier::fromString(vm, "isMapIterator"_s),
jsFunctionIsMapIterator);
putNativeFn(Identifier::fromString(vm, "isSetIterator"_s),
jsFunctionIsSetIterator);
putNativeFn(Identifier::fromString(vm, "isWeakMap"_s), jsFunctionIsWeakMap);
putNativeFn(Identifier::fromString(vm, "isWeakSet"_s), jsFunctionIsWeakSet);
putNativeFn(Identifier::fromString(vm, "isArrayBuffer"_s),
jsFunctionIsArrayBuffer);
putNativeFn(Identifier::fromString(vm, "isDataView"_s), jsFunctionIsDataView);
putNativeFn(Identifier::fromString(vm, "isSharedArrayBuffer"_s),
jsFunctionIsSharedArrayBuffer);
putNativeFn(Identifier::fromString(vm, "isProxy"_s), jsFunctionIsProxy);
putNativeFn(Identifier::fromString(vm, "isModuleNamespaceObject"_s),
jsFunctionIsModuleNamespaceObject);
putNativeFn(Identifier::fromString(vm, "isAnyArrayBuffer"_s),
jsFunctionIsAnyArrayBuffer);
putNativeFn(Identifier::fromString(vm, "isBoxedPrimitive"_s),
jsFunctionIsBoxedPrimitive);
putNativeFn(Identifier::fromString(vm, "isArrayBufferView"_s),
jsFunctionIsArrayBufferView);
putNativeFn(Identifier::fromString(vm, "isTypedArray"_s),
jsFunctionIsTypedArray);
putNativeFn(Identifier::fromString(vm, "isUint8Array"_s),
jsFunctionIsUint8Array);
putNativeFn(Identifier::fromString(vm, "isUint8ClampedArray"_s),
jsFunctionIsUint8ClampedArray);
putNativeFn(Identifier::fromString(vm, "isUint16Array"_s),
jsFunctionIsUint16Array);
putNativeFn(Identifier::fromString(vm, "isUint32Array"_s),
jsFunctionIsUint32Array);
putNativeFn(Identifier::fromString(vm, "isInt8Array"_s),
jsFunctionIsInt8Array);
putNativeFn(Identifier::fromString(vm, "isInt16Array"_s),
jsFunctionIsInt16Array);
putNativeFn(Identifier::fromString(vm, "isInt32Array"_s),
jsFunctionIsInt32Array);
putNativeFn(Identifier::fromString(vm, "isFloat16Array"_s),
jsFunctionIsFloat16Array);
putNativeFn(Identifier::fromString(vm, "isFloat32Array"_s),
jsFunctionIsFloat32Array);
putNativeFn(Identifier::fromString(vm, "isFloat64Array"_s),
jsFunctionIsFloat64Array);
putNativeFn(Identifier::fromString(vm, "isBigInt64Array"_s),
jsFunctionIsBigInt64Array);
putNativeFn(Identifier::fromString(vm, "isBigUint64Array"_s),
jsFunctionIsBigUint64Array);
putNativeFn(Identifier::fromString(vm, "isKeyObject"_s),
jsFunctionIsKeyObject);
putNativeFn(Identifier::fromString(vm, "isCryptoKey"_s),
jsFunctionIsCryptoKey);
putNativeFn(Identifier::fromString(vm, "isExternal"_s), jsFunctionIsExternal);
putNativeFn(Identifier::fromString(vm, "isDate"_s), jsFunctionIsDate);
putNativeFn(Identifier::fromString(vm, "isArgumentsObject"_s),
jsFunctionIsArgumentsObject);
putNativeFn(Identifier::fromString(vm, "isBigIntObject"_s),
jsFunctionIsBigIntObject);
putNativeFn(Identifier::fromString(vm, "isBooleanObject"_s),
jsFunctionIsBooleanObject);
putNativeFn(Identifier::fromString(vm, "isNumberObject"_s),
jsFunctionIsNumberObject);
putNativeFn(Identifier::fromString(vm, "isStringObject"_s),
jsFunctionIsStringObject);
putNativeFn(Identifier::fromString(vm, "isSymbolObject"_s),
jsFunctionIsSymbolObject);
putNativeFn(Identifier::fromString(vm, "isNativeError"_s),
jsFunctionIsNativeError);
putNativeFn(Identifier::fromString(vm, "isRegExp"_s), jsFunctionIsRegExp);
putNativeFn(Identifier::fromString(vm, "isAsyncFunction"_s),
jsFunctionIsAsyncFunction);
putNativeFn(Identifier::fromString(vm, "isGeneratorFunction"_s),
jsFunctionIsGeneratorFunction);
putNativeFn(Identifier::fromString(vm, "isGeneratorObject"_s),
jsFunctionIsGeneratorObject);
putNativeFn(Identifier::fromString(vm, "isPromise"_s), jsFunctionIsPromise);
putNativeFn(Identifier::fromString(vm, "isMap"_s), jsFunctionIsMap);
putNativeFn(Identifier::fromString(vm, "isSet"_s), jsFunctionIsSet);
putNativeFn(Identifier::fromString(vm, "isMapIterator"_s),
jsFunctionIsMapIterator);
putNativeFn(Identifier::fromString(vm, "isSetIterator"_s),
jsFunctionIsSetIterator);
putNativeFn(Identifier::fromString(vm, "isWeakMap"_s), jsFunctionIsWeakMap);
putNativeFn(Identifier::fromString(vm, "isWeakSet"_s), jsFunctionIsWeakSet);
putNativeFn(Identifier::fromString(vm, "isArrayBuffer"_s),
jsFunctionIsArrayBuffer);
putNativeFn(Identifier::fromString(vm, "isDataView"_s), jsFunctionIsDataView);
putNativeFn(Identifier::fromString(vm, "isSharedArrayBuffer"_s),
jsFunctionIsSharedArrayBuffer);
putNativeFn(Identifier::fromString(vm, "isProxy"_s), jsFunctionIsProxy);
putNativeFn(Identifier::fromString(vm, "isModuleNamespaceObject"_s),
jsFunctionIsModuleNamespaceObject);
putNativeFn(Identifier::fromString(vm, "isAnyArrayBuffer"_s),
jsFunctionIsAnyArrayBuffer);
putNativeFn(Identifier::fromString(vm, "isBoxedPrimitive"_s),
jsFunctionIsBoxedPrimitive);
putNativeFn(Identifier::fromString(vm, "isArrayBufferView"_s),
jsFunctionIsArrayBufferView);
putNativeFn(Identifier::fromString(vm, "isTypedArray"_s),
jsFunctionIsTypedArray);
putNativeFn(Identifier::fromString(vm, "isUint8Array"_s),
jsFunctionIsUint8Array);
putNativeFn(Identifier::fromString(vm, "isUint8ClampedArray"_s),
jsFunctionIsUint8ClampedArray);
putNativeFn(Identifier::fromString(vm, "isUint16Array"_s),
jsFunctionIsUint16Array);
putNativeFn(Identifier::fromString(vm, "isUint32Array"_s),
jsFunctionIsUint32Array);
putNativeFn(Identifier::fromString(vm, "isInt8Array"_s),
jsFunctionIsInt8Array);
putNativeFn(Identifier::fromString(vm, "isInt16Array"_s),
jsFunctionIsInt16Array);
putNativeFn(Identifier::fromString(vm, "isInt32Array"_s),
jsFunctionIsInt32Array);
putNativeFn(Identifier::fromString(vm, "isFloat16Array"_s),
jsFunctionIsFloat16Array);
putNativeFn(Identifier::fromString(vm, "isFloat32Array"_s),
jsFunctionIsFloat32Array);
putNativeFn(Identifier::fromString(vm, "isFloat64Array"_s),
jsFunctionIsFloat64Array);
putNativeFn(Identifier::fromString(vm, "isBigInt64Array"_s),
jsFunctionIsBigInt64Array);
putNativeFn(Identifier::fromString(vm, "isBigUint64Array"_s),
jsFunctionIsBigUint64Array);
putNativeFn(Identifier::fromString(vm, "isKeyObject"_s),
jsFunctionIsKeyObject);
putNativeFn(Identifier::fromString(vm, "isCryptoKey"_s),
jsFunctionIsCryptoKey);
RETURN_NATIVE_MODULE();
RETURN_NATIVE_MODULE();
}
} // namespace Zig

View File

@@ -5,15 +5,15 @@
namespace Zig {
JSC::SyntheticSourceProvider::SyntheticSourceGenerator
generateObjectModuleSourceCode(JSC::JSGlobalObject *globalObject,
JSC::JSObject *object);
generateObjectModuleSourceCode(JSC::JSGlobalObject* globalObject,
JSC::JSObject* object);
JSC::SyntheticSourceProvider::SyntheticSourceGenerator
generateObjectModuleSourceCodeForJSON(JSC::JSGlobalObject *globalObject,
JSC::JSObject *object);
generateObjectModuleSourceCodeForJSON(JSC::JSGlobalObject* globalObject,
JSC::JSObject* object);
JSC::SyntheticSourceProvider::SyntheticSourceGenerator
generateJSValueModuleSourceCode(JSC::JSGlobalObject *globalObject,
JSC::JSValue value);
generateJSValueModuleSourceCode(JSC::JSGlobalObject* globalObject,
JSC::JSValue value);
} // namespace Zig
} // namespace Zig

View File

@@ -4,17 +4,18 @@ using namespace WebCore;
namespace Zig {
inline void
generateNativeModule_UTF8Validate(JSC::JSGlobalObject *globalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4> &exportNames,
JSC::MarkedArgumentBuffer &exportValues) {
auto &vm = globalObject->vm();
generateNativeModule_UTF8Validate(JSC::JSGlobalObject* globalObject,
JSC::Identifier moduleKey,
Vector<JSC::Identifier, 4>& exportNames,
JSC::MarkedArgumentBuffer& exportValues)
{
auto& vm = globalObject->vm();
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(JSC::JSFunction::create(
vm, globalObject, 1, "utf8Validate"_s, jsBufferConstructorFunction_isUtf8,
ImplementationVisibility::Public, NoIntrinsic,
jsBufferConstructorFunction_isUtf8));
exportNames.append(vm.propertyNames->defaultKeyword);
exportValues.append(JSC::JSFunction::create(
vm, globalObject, 1, "utf8Validate"_s, jsBufferConstructorFunction_isUtf8,
ImplementationVisibility::Public, NoIntrinsic,
jsBufferConstructorFunction_isUtf8));
}
} // namespace Zig