mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-04-18 13:33:31 +00:00
update to class getters/setters and meta module
rename factory functions. class getters now send is_string parameter. each property type for each class now has separate meta function.
This commit is contained in:
64
lib/meta.ps1
64
lib/meta.ps1
@@ -1,16 +1,25 @@
|
||||
Function AddPublicMembers($obj) {
|
||||
Function AddBoolMembers() {
|
||||
param(
|
||||
[String[]]$PARAMS
|
||||
)
|
||||
[HashTable]$Signatures = @{}
|
||||
ForEach($param in $obj.bool_params) {
|
||||
ForEach($param in $PARAMS) {
|
||||
# Define getter
|
||||
$Signatures["Getter"] = "`$this.Getter(`$this.cmd('{0}'))" -f $param
|
||||
$Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('{0}'))" -f $param
|
||||
# Define setter
|
||||
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
||||
-f $param
|
||||
|
||||
Addmember
|
||||
}
|
||||
}
|
||||
|
||||
ForEach($param in $obj.float_params) {
|
||||
Function AddFloatMembers() {
|
||||
param(
|
||||
[String[]]$PARAMS
|
||||
)
|
||||
[HashTable]$Signatures = @{}
|
||||
ForEach($param in $PARAMS) {
|
||||
# Define getter
|
||||
$Signatures["Getter"] = "[math]::Round(`$this.Getter(`$this.cmd('{0}')), 1)" -f $param
|
||||
# Define setter
|
||||
@@ -19,8 +28,14 @@ Function AddPublicMembers($obj) {
|
||||
|
||||
Addmember
|
||||
}
|
||||
|
||||
ForEach($param in $obj.int_params) {
|
||||
}
|
||||
|
||||
Function AddIntMembers() {
|
||||
param(
|
||||
[String[]]$PARAMS
|
||||
)
|
||||
[HashTable]$Signatures = @{}
|
||||
ForEach($param in $PARAMS) {
|
||||
# Define getter
|
||||
$Signatures["Getter"] = "[Int]`$this.Getter(`$this.cmd('{0}'))" -f $param
|
||||
# Define setter
|
||||
@@ -29,18 +44,51 @@ Function AddPublicMembers($obj) {
|
||||
|
||||
Addmember
|
||||
}
|
||||
}
|
||||
|
||||
ForEach($param in $obj.string_params) {
|
||||
Function AddStringMembers() {
|
||||
param(
|
||||
[String[]]$PARAMS
|
||||
)
|
||||
[HashTable]$Signatures = @{}
|
||||
ForEach($param in $PARAMS) {
|
||||
# Define getter
|
||||
$Signatures["Getter"] = "[String]`$this.Getter_String(`$this.cmd('{0}'))" -f $param
|
||||
# Define setter
|
||||
$Signatures["Setter"] = "param ( [String]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
||||
-f $param
|
||||
|
||||
Addmember
|
||||
}
|
||||
}
|
||||
|
||||
Function AddCommandMembers() {
|
||||
param(
|
||||
[String[]]$PARAMS
|
||||
)
|
||||
[HashTable]$Signatures = @{}
|
||||
ForEach($param in $PARAMS) {
|
||||
# Define getter
|
||||
$Signatures["Getter"] = "`$this.Getter(`$this.cmd('{0}'))" -f $_
|
||||
# Define setter
|
||||
$Signatures["Setter"] = "`$this.Setter(`$this.cmd('{0}'))" -f $_
|
||||
|
||||
Addmember
|
||||
}
|
||||
}
|
||||
|
||||
Function AddChannelMembers() {
|
||||
$num_A = $layout.p_out
|
||||
$num_B = $layout.v_out
|
||||
|
||||
[System.Collections.ArrayList]$channels = @()
|
||||
1..$($num_A + $num_B) | ForEach-Object {
|
||||
if($_ -le $num_A) {$channels.Add("A{0}" -f $_)} else {$channels.Add("B{0}" -f $($_ - $num_A))}
|
||||
}
|
||||
|
||||
AddBoolMembers -PARAMS $channels
|
||||
}
|
||||
|
||||
Function Addmember{
|
||||
$AddMemberParams = @{
|
||||
Name = $param
|
||||
@@ -48,5 +96,5 @@ Function Addmember{
|
||||
Value = [ScriptBlock]::Create($Signatures["Getter"])
|
||||
SecondValue = [ScriptBlock]::Create($Signatures["Setter"])
|
||||
}
|
||||
$obj | Add-Member @AddMemberParams
|
||||
$this | Add-Member @AddMemberParams
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user