From a7bec6431022d52eb407d66ff906d13218a06b4b Mon Sep 17 00:00:00 2001 From: mayo78 <75394229+mayo78@users.noreply.github.com> Date: Sat, 16 Nov 2024 12:13:06 -0500 Subject: [PATCH 1/2] Use @:structInit instead of seperate typedef. --- crowplexus/iris/Iris.hx | 4 ++-- crowplexus/iris/IrisConfig.hx | 21 ++------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/crowplexus/iris/Iris.hx b/crowplexus/iris/Iris.hx index d8de6fa..c491a35 100644 --- a/crowplexus/iris/Iris.hx +++ b/crowplexus/iris/Iris.hx @@ -190,11 +190,11 @@ class Iris { * will trace "Hello World!" to the standard output. * @param scriptCode the script to be parsed, e.g: */ - public function new(scriptCode: String, ?config: AutoIrisConfig): Void { + public function new(scriptCode: String, ?config: IrisConfig): Void { if (config == null) config = new IrisConfig("Iris", true, true, []); this.scriptCode = scriptCode; - this.config = IrisConfig.from(config); + this.config = config; this.config.name = fixScriptName(this.name); parser = new Parser(); diff --git a/crowplexus/iris/IrisConfig.hx b/crowplexus/iris/IrisConfig.hx index 82c8d44..1b3903c 100644 --- a/crowplexus/iris/IrisConfig.hx +++ b/crowplexus/iris/IrisConfig.hx @@ -1,18 +1,8 @@ package crowplexus.iris; -abstract OneOfTwo(Dynamic) from T1 from T2 to T1 to T2 {} - -typedef RawIrisConfig = { - var name: String; - var ?autoRun: Bool; - var ?autoPreset: Bool; - var ?localBlocklist: Array; -}; - -typedef AutoIrisConfig = OneOfTwo; - +@:structInit class IrisConfig { - public var name: String = null; + public var name: String; public var autoRun: Bool = true; public var autoPreset: Bool = true; @:unreflective public var localBlocklist: Array = []; @@ -32,11 +22,4 @@ class IrisConfig { if (localBlocklist != null) this.localBlocklist = localBlocklist; } - - public static function from(d: AutoIrisConfig): IrisConfig { - if (d != null && Std.isOfType(d, IrisConfig)) - return d; - var d: RawIrisConfig = cast d; - return new IrisConfig(d.name, d.autoRun, d.autoPreset, d.localBlocklist); - } } From ae384ee4f4c63f40373f341b64e3452ce89c5114 Mon Sep 17 00:00:00 2001 From: mayo78 <75394229+mayo78@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:35:27 -0500 Subject: [PATCH 2/2] Re-add removed stuff but deprecated (Could use better message?) --- crowplexus/iris/IrisConfig.hx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crowplexus/iris/IrisConfig.hx b/crowplexus/iris/IrisConfig.hx index 1b3903c..654f996 100644 --- a/crowplexus/iris/IrisConfig.hx +++ b/crowplexus/iris/IrisConfig.hx @@ -22,4 +22,12 @@ class IrisConfig { if (localBlocklist != null) this.localBlocklist = localBlocklist; } + + @:deprecated('IrisConfig.from is deprecated! It\'s not needed anymore!') + public static function from(d: IrisConfig): IrisConfig { + return d; + } } + +@:deprecated('RawIrisConfig is deprecated! Use IrisConfig instead! (IrisConfig supports structInit, only the type needs to be changed)') +class RawIrisConfig extends IrisConfig {}