aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings
diff options
context:
space:
mode:
authorGravatar Ciro Spaciari <ciro.spaciari@gmail.com> 2023-05-14 14:18:56 -0300
committerGravatar GitHub <noreply@github.com> 2023-05-14 10:18:56 -0700
commitbf9e40d5b49f1ed16ea9abed4e231456dcda99c0 (patch)
treea803971285c5f4329bbee4ef025151baaf91c817 /src/bun.js/bindings
parent2a66229b0f9aabf96891afe3063e07ec877527ca (diff)
downloadbun-bf9e40d5b49f1ed16ea9abed4e231456dcda99c0.tar.gz
bun-bf9e40d5b49f1ed16ea9abed4e231456dcda99c0.tar.zst
bun-bf9e40d5b49f1ed16ea9abed4e231456dcda99c0.zip
feat(Timer.refresh) add refresh support on Timer (#2874)
* add refresh support on Timer * fix this return * add refresh setTimeout tests * fix tests and add setInterval test * use setCached for arguments and callback --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Diffstat (limited to 'src/bun.js/bindings')
-rw-r--r--src/bun.js/bindings/JSSink.cpp2
-rw-r--r--src/bun.js/bindings/JSSink.h2
-rw-r--r--src/bun.js/bindings/JSSinkLookupTable.h2
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp79
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h7
-rw-r--r--src/bun.js/bindings/generated_classes.zig47
6 files changed, 136 insertions, 3 deletions
diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp
index 31e648b8a..2fb03963e 100644
--- a/src/bun.js/bindings/JSSink.cpp
+++ b/src/bun.js/bindings/JSSink.cpp
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2023-04-27T21:24:10.276Z
+// Generated by 'make generate-sink' at 2023-05-14T13:28:43.914Z
// To regenerate this file, run:
//
// make generate-sink
diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h
index 29c5b2a09..9726f68e9 100644
--- a/src/bun.js/bindings/JSSink.h
+++ b/src/bun.js/bindings/JSSink.h
@@ -1,6 +1,6 @@
// AUTO-GENERATED FILE. DO NOT EDIT.
-// Generated by 'make generate-sink' at 2023-04-27T21:24:10.274Z
+// Generated by 'make generate-sink' at 2023-05-14T13:28:43.910Z
//
#pragma once
diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h
index 2f92be340..e4ed81629 100644
--- a/src/bun.js/bindings/JSSinkLookupTable.h
+++ b/src/bun.js/bindings/JSSinkLookupTable.h
@@ -1,4 +1,4 @@
-// Automatically generated from src/bun.js/bindings/JSSink.cpp using /home/will/dev/bun-test-universe/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT!
+// Automatically generated from src/bun.js/bindings/JSSink.cpp using /home/cirospaciari/Repos/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT!
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index 137d94fe2..a8ec4c6b5 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -13556,6 +13556,9 @@ JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__hasRefCallback);
extern "C" EncodedJSValue TimeoutPrototype__doRef(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__refCallback);
+extern "C" EncodedJSValue TimeoutPrototype__doRefresh(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
+JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__refreshCallback);
+
extern "C" EncodedJSValue TimeoutPrototype__doUnref(void* ptr, JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame);
JSC_DECLARE_HOST_FUNCTION(TimeoutPrototype__unrefCallback);
@@ -13564,6 +13567,7 @@ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTimeoutPrototype, JSTimeoutPrototype::Base
static const HashTableValue JSTimeoutPrototypeTableValues[] = {
{ "hasRef"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__hasRefCallback, 0 } },
{ "ref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__refCallback, 0 } },
+ { "refresh"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__refreshCallback, 0 } },
{ "unref"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | PropertyAttribute::DontDelete), NoIntrinsic, { HashTableValue::NativeFunctionType, TimeoutPrototype__unrefCallback, 0 } }
};
@@ -13617,6 +13621,22 @@ JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__refCallback, (JSGlobalObject * lexica
return TimeoutPrototype__doRef(thisObject->wrapped(), lexicalGlobalObject, callFrame);
}
+JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__refreshCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ JSTimeout* thisObject = jsDynamicCast<JSTimeout*>(callFrame->thisValue());
+
+ if (UNLIKELY(!thisObject)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ }
+
+ JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
+
+ return TimeoutPrototype__doRefresh(thisObject->wrapped(), lexicalGlobalObject, callFrame);
+}
+
JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__unrefCallback, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
{
auto& vm = lexicalGlobalObject->vm();
@@ -13633,6 +13653,32 @@ JSC_DEFINE_HOST_FUNCTION(TimeoutPrototype__unrefCallback, (JSGlobalObject * lexi
return TimeoutPrototype__doUnref(thisObject->wrapped(), lexicalGlobalObject, callFrame);
}
+extern "C" void TimeoutPrototype__argumentsSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSTimeout*>(JSValue::decode(thisValue));
+ thisObject->m_arguments.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue TimeoutPrototype__argumentsGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSTimeout*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_arguments.get());
+}
+
+extern "C" void TimeoutPrototype__callbackSetCachedValue(JSC::EncodedJSValue thisValue, JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
+{
+ auto& vm = globalObject->vm();
+ auto* thisObject = jsCast<JSTimeout*>(JSValue::decode(thisValue));
+ thisObject->m_callback.set(vm, thisObject, JSValue::decode(value));
+}
+
+extern "C" EncodedJSValue TimeoutPrototype__callbackGetCachedValue(JSC::EncodedJSValue thisValue)
+{
+ auto* thisObject = jsCast<JSTimeout*>(JSValue::decode(thisValue));
+ return JSValue::encode(thisObject->m_callback.get());
+}
+
void JSTimeoutPrototype::finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
{
Base::finishCreation(vm);
@@ -13717,6 +13763,39 @@ extern "C" EncodedJSValue Timeout__create(Zig::GlobalObject* globalObject, void*
return JSValue::encode(instance);
}
+
+template<typename Visitor>
+void JSTimeout::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ JSTimeout* thisObject = jsCast<JSTimeout*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+ visitor.append(thisObject->m_arguments);
+ visitor.append(thisObject->m_callback);
+}
+
+DEFINE_VISIT_CHILDREN(JSTimeout);
+
+template<typename Visitor>
+void JSTimeout::visitAdditionalChildren(Visitor& visitor)
+{
+ JSTimeout* thisObject = this;
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ visitor.append(thisObject->m_arguments);
+ visitor.append(thisObject->m_callback);
+}
+
+DEFINE_VISIT_ADDITIONAL_CHILDREN(JSTimeout);
+
+template<typename Visitor>
+void JSTimeout::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
+{
+ JSTimeout* thisObject = jsCast<JSTimeout*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ thisObject->visitAdditionalChildren<Visitor>(visitor);
+}
+
+DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSTimeout);
class JSTranspilerPrototype final : public JSC::JSNonFinalObject {
public:
using Base = JSC::JSNonFinalObject;
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index fc9be7501..02fef6d3c 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -1575,6 +1575,13 @@ public:
}
void finishCreation(JSC::VM&);
+
+ DECLARE_VISIT_CHILDREN;
+ template<typename Visitor> void visitAdditionalChildren(Visitor&);
+ DECLARE_VISIT_OUTPUT_CONSTRAINTS;
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_arguments;
+ mutable JSC::WriteBarrier<JSC::Unknown> m_callback;
};
class JSTranspiler final : public JSC::JSDestructibleObject {
diff --git a/src/bun.js/bindings/generated_classes.zig b/src/bun.js/bindings/generated_classes.zig
index a53d9bbe4..841e65b21 100644
--- a/src/bun.js/bindings/generated_classes.zig
+++ b/src/bun.js/bindings/generated_classes.zig
@@ -3988,6 +3988,50 @@ pub const JSTimeout = struct {
return Timeout__fromJS(value);
}
+ extern fn TimeoutPrototype__argumentsSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn TimeoutPrototype__argumentsGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Timeout.arguments` setter
+ /// This value will be visited by the garbage collector.
+ pub fn argumentsSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ TimeoutPrototype__argumentsSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Timeout.arguments` getter
+ /// This value will be visited by the garbage collector.
+ pub fn argumentsGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = TimeoutPrototype__argumentsGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
+ extern fn TimeoutPrototype__callbackSetCachedValue(JSC.JSValue, *JSC.JSGlobalObject, JSC.JSValue) void;
+
+ extern fn TimeoutPrototype__callbackGetCachedValue(JSC.JSValue) JSC.JSValue;
+
+ /// `Timeout.callback` setter
+ /// This value will be visited by the garbage collector.
+ pub fn callbackSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void {
+ JSC.markBinding(@src());
+ TimeoutPrototype__callbackSetCachedValue(thisValue, globalObject, value);
+ }
+
+ /// `Timeout.callback` getter
+ /// This value will be visited by the garbage collector.
+ pub fn callbackGetCached(thisValue: JSC.JSValue) ?JSC.JSValue {
+ JSC.markBinding(@src());
+ const result = TimeoutPrototype__callbackGetCachedValue(thisValue);
+ if (result == .zero)
+ return null;
+
+ return result;
+ }
+
/// Create a new instance of Timeout
pub fn toJS(this: *Timeout, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
JSC.markBinding(@src());
@@ -4030,10 +4074,13 @@ pub const JSTimeout = struct {
@compileLog("Expected Timeout.hasRef to be a callback but received " ++ @typeName(@TypeOf(Timeout.hasRef)));
if (@TypeOf(Timeout.doRef) != CallbackType)
@compileLog("Expected Timeout.doRef to be a callback but received " ++ @typeName(@TypeOf(Timeout.doRef)));
+ if (@TypeOf(Timeout.doRefresh) != CallbackType)
+ @compileLog("Expected Timeout.doRefresh to be a callback but received " ++ @typeName(@TypeOf(Timeout.doRefresh)));
if (@TypeOf(Timeout.doUnref) != CallbackType)
@compileLog("Expected Timeout.doUnref to be a callback but received " ++ @typeName(@TypeOf(Timeout.doUnref)));
if (!JSC.is_bindgen) {
@export(Timeout.doRef, .{ .name = "TimeoutPrototype__doRef" });
+ @export(Timeout.doRefresh, .{ .name = "TimeoutPrototype__doRefresh" });
@export(Timeout.doUnref, .{ .name = "TimeoutPrototype__doUnref" });
@export(Timeout.finalize, .{ .name = "TimeoutClass__finalize" });
@export(Timeout.hasRef, .{ .name = "TimeoutPrototype__hasRef" });