From b273aa7a51571c24b4e9d56c9a7fcf6129d99654 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 9 Dec 2025 19:21:06 -0500 Subject: [PATCH 1/4] ReadOnly, WriteOnly added ReadOnly and WriteOnly params to meta functions that will override the setter and getter, respectively prelim pester tests for potato for safety pass --- lib/meta.ps1 | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/meta.ps1 b/lib/meta.ps1 index 9d79186..a6c1c08 100644 --- a/lib/meta.ps1 +++ b/lib/meta.ps1 @@ -1,6 +1,6 @@ function AddBoolMembers () { param( - [String[]]$PARAMS + [String[]]$PARAMS, [Switch]$readOnly, [Switch]$writeOnly ) [hashtable]$Signatures = @{} foreach ($param in $PARAMS) { @@ -10,13 +10,13 @@ function AddBoolMembers () { $Signatures['Setter'] = "param ( [bool]`$arg )`n`$this.Setter('{0}', `$arg)" ` -f $param - Addmember + Addmember -ReadOnly:$readOnly -WriteOnly:$writeOnly } } function AddFloatMembers () { param( - [String[]]$PARAMS, + [String[]]$PARAMS, [Switch]$readOnly, [Switch]$writeOnly, [int]$decimals = 2 ) [hashtable]$Signatures = @{} @@ -27,13 +27,13 @@ function AddFloatMembers () { $Signatures['Setter'] = "param ( [Single]`$arg )`n`$this.Setter('{0}', `$arg)" ` -f $param - Addmember + Addmember -ReadOnly:$readOnly -WriteOnly:$writeOnly } } function AddIntMembers () { param( - [String[]]$PARAMS + [String[]]$PARAMS, [Switch]$readOnly, [Switch]$writeOnly ) [hashtable]$Signatures = @{} foreach ($param in $PARAMS) { @@ -43,13 +43,13 @@ function AddIntMembers () { $Signatures['Setter'] = "param ( [Int]`$arg )`n`$this.Setter('{0}', `$arg)" ` -f $param - Addmember + Addmember -ReadOnly:$readOnly -WriteOnly:$writeOnly } } function AddStringMembers () { param( - [String[]]$PARAMS + [String[]]$PARAMS, [Switch]$readOnly, [Switch]$writeOnly ) [hashtable]$Signatures = @{} foreach ($param in $PARAMS) { @@ -59,7 +59,7 @@ function AddStringMembers () { $Signatures['Setter'] = "param ( [String]`$arg )`n`$this.Setter('{0}', `$arg)" ` -f $param - Addmember + Addmember -ReadOnly:$readOnly -WriteOnly:$writeOnly } } @@ -97,6 +97,24 @@ function AddChannelMembers () { } function Addmember { + param( + [Switch]$readOnly, [Switch]$writeOnly + ) + + if ($readOnly -and $writeOnly) { + throw "AddMember: cannot be both readOnly and writeOnly for '$param'" + } + + # Override signatures based on mode + if ($readOnly) { + $Signatures['Setter'] = "return Write-Warning (`"ERROR: `$(`$this.identifier()).{0} is read only`")" ` + -f $param + } + elseif ($writeOnly) { + $Signatures['Getter'] = "return Write-Warning (`"ERROR: `$(`$this.identifier()).{0} is write only`")" ` + -f $param + } + $AddMemberParams = @{ Name = $param MemberType = 'ScriptProperty' From 59f3168436299e228f9d7b13775d41a349053411 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 9 Dec 2025 19:37:58 -0500 Subject: [PATCH 2/4] device properties implemented here first because string pester tests can confirm the behavior works string pester tests for potato pass manual tests to confirm error behavior pass --- lib/io.ps1 | 51 +++------------------------------------------------ 1 file changed, 3 insertions(+), 48 deletions(-) diff --git a/lib/io.ps1 b/lib/io.ps1 index 07982b9..5bbe38e 100644 --- a/lib/io.ps1 +++ b/lib/io.ps1 @@ -99,53 +99,8 @@ class EqCell : IRemote { class IODevice : IRemote { IODevice ([int]$index, [Object]$remote) : base ($index, $remote) { + AddStringMembers -WriteOnly -PARAMS @('wdm', 'ks', 'mme') + AddStringMembers -ReadOnly -PARAMS @('name') + AddIntMembers -ReadOnly -PARAMS @('sr') } - - hidden $_name = $($this | Add-Member ScriptProperty 'name' ` - { - $this.Getter_String('name') - } ` - { - return Write-Warning ("ERROR: $($this.identifier()).name is read only") - } - ) - - hidden $_sr = $($this | Add-Member ScriptProperty 'sr' ` - { - [int]$this.Getter('sr') - } ` - { - return Write-Warning ("ERROR: $($this.identifier()).sr is read only") - } - ) - - hidden $_wdm = $($this | Add-Member ScriptProperty 'wdm' ` - { - return Write-Warning ("ERROR: $($this.identifier()).wdm is write only") - } ` - { - param([string]$arg) - return $this.Setter('wdm', $arg) - } - ) - - hidden $_ks = $($this | Add-Member ScriptProperty 'ks' ` - { - return Write-Warning ("ERROR: $($this.identifier()).ks is write only") - } ` - { - param([string]$arg) - return $this.Setter('ks', $arg) - } - ) - - hidden $_mme = $($this | Add-Member ScriptProperty 'mme' ` - { - return Write-Warning ("ERROR: $($this.identifier()).mme is write only") - } ` - { - param([string]$arg) - return $this.Setter('mme', $arg) - } - ) } \ No newline at end of file From 30da69469bd63ef73a0e7f0668fc2a80478b907b Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:08:19 -0500 Subject: [PATCH 3/4] asio, recorder.prefix string pester tests for potato pass manual test passes - bus.device.asio --- lib/bus.ps1 | 12 +----------- lib/recorder.ps1 | 11 +---------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/lib/bus.ps1 b/lib/bus.ps1 index 85ece7d..38e32e4 100644 --- a/lib/bus.ps1 +++ b/lib/bus.ps1 @@ -99,23 +99,13 @@ class VirtualBus : Bus { class BusDevice : IODevice { BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { if ($this.index -eq 0) { - $this.AddASIO() + AddStringMembers -PARAMS @('asio') -WriteOnly } } [string] identifier () { return 'Bus[' + $this.index + '].Device' } - - hidden [void] AddASIO () { - Add-Member -InputObject $this -MemberType ScriptProperty -Name 'asio' ` - -Value { - return Write-Warning ("ERROR: $($this.identifier()).asio is write only") - } -SecondValue { - param([string]$arg) - return $this.Setter('asio', $arg) - } -Force - } } function Make_Buses ([Object]$remote) { diff --git a/lib/recorder.ps1 b/lib/recorder.ps1 index b07c611..eef609b 100644 --- a/lib/recorder.ps1 +++ b/lib/recorder.ps1 @@ -25,6 +25,7 @@ class Recorder : IRemote { AddActionMembers -PARAMS @('replay', 'ff', 'rew') AddFloatMembers -PARAMS @('gain') AddIntMembers -PARAMS @('prerectime') + AddStringMembers -PARAMS @('prefix') -WriteOnly AddChannelMembers } @@ -117,16 +118,6 @@ class Recorder : IRemote { } ) - hidden $_prefix = $($this | Add-Member ScriptProperty 'prefix' ` - { - return Write-Warning ("ERROR: $($this.identifier()).prefix is write only") - } ` - { - param([string]$arg) - $this._prefix = $this.Setter('prefix', $arg) - } - ) - hidden $_filetype = $($this | Add-Member ScriptProperty 'filetype' ` { return Write-Warning ("ERROR: $($this.identifier()).filetype is write only") From 66b3fb355c3f0d2486e90935704b7d240402e4c4 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 9 Dec 2025 20:41:15 -0500 Subject: [PATCH 4/4] Update CHANGELOG.md pester tests pass for all kinds manual tests pass for all kinds - bus.device.asio --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a862c7c..0f6fa4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,9 +72,11 @@ Strip Gainlayers are now FloatArrayMember objects, see README for details ### Changed -- Device: explicit $arg types for consistency +- Meta functions can now take a -ReadOnly or -WriteOnly switch parameter - Meta: AddBoolMembers, AddIntMembers $arg types for consistency - Float getters/setters now default to two decimal places. +- Device: explicit $arg types for consistency +- Device members now added with meta functions - some vban.instream | vban.outstream commands now added with meta functions - on @@ -84,6 +86,7 @@ Strip Gainlayers are now FloatArrayMember objects, see README for details - Recorder.Armstrip|Armbus -> BoolArrayMember: now have .Get() - Cast Recorder getters to types for consistency +- Recorder.Prefix now added with AddStringMembers - Strip.Mono is now an alias for Strip.MC on virtual strips - Strip.AppMute|AppGain can now take an app index; see README for details