From 532bc4f2bc940c50b9b18749eee29eb95b03fa44 Mon Sep 17 00:00:00 2001 From: Anton Kuzin Date: Thu, 23 Oct 2025 20:24:00 +0300 Subject: [PATCH] Override the CallPassingArgs method and make it do nothing. --- src/kOS.Safe/Encapsulation/KOSDelegate.cs | 2 +- src/kOS.Safe/Encapsulation/NoDelegate.cs | 21 +++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/kOS.Safe/Encapsulation/KOSDelegate.cs b/src/kOS.Safe/Encapsulation/KOSDelegate.cs index 7c65b15380..ab9f8bb712 100644 --- a/src/kOS.Safe/Encapsulation/KOSDelegate.cs +++ b/src/kOS.Safe/Encapsulation/KOSDelegate.cs @@ -62,7 +62,7 @@ public List GetMergedArgs(List args) return merged; } - public Structure CallPassingArgs(params Structure[] args) + public virtual Structure CallPassingArgs(params Structure[] args) { if (Cpu == null) throw new KOSCannotCallException(); diff --git a/src/kOS.Safe/Encapsulation/NoDelegate.cs b/src/kOS.Safe/Encapsulation/NoDelegate.cs index 585532cd7f..ce6a92e13f 100644 --- a/src/kOS.Safe/Encapsulation/NoDelegate.cs +++ b/src/kOS.Safe/Encapsulation/NoDelegate.cs @@ -1,16 +1,10 @@ -using System; -using System.Collections.Generic; using kOS.Safe.Execution; -using kOS.Safe.Exceptions; -using kOS.Safe.Compilation; namespace kOS.Safe.Encapsulation { /// - /// A UserDelegate that cannot actually ever executesany user code. - /// Instead, when OpcodeCall() is executed for it, it will merely - /// crash with an exception. The idea is to give scripts something - /// they can use to "unset" a callback hook. + /// A UserDelegate that cannot actually ever execute any user code. + /// The idea is to give scripts something they can use to "unset" a callback hook. /// [kOS.Safe.Utilities.KOSNomenclature("NoDelegate")] public class NoDelegate : UserDelegate @@ -32,15 +26,10 @@ public override KOSDelegate Clone() { return new NoDelegate(Cpu); } - - public override void PushUnderArgs() - { - // force it to do nothing. - } - - public override Structure CallWithArgsPushedAlready() + + public override Structure CallPassingArgs(params Structure[] args) { - throw new KOSCannotCallException(); + return new KOSPassThruReturn(); } public override string ToString()