Add Defaults For All Types
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -158,6 +158,10 @@ public struct P4Struct: P4Type {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
public func def() -> any P4Value {
|
||||
return P4StructValue(withType: self)
|
||||
}
|
||||
}
|
||||
|
||||
/// An instance of a P4 struct
|
||||
@@ -231,6 +235,9 @@ public struct P4Boolean: P4Type {
|
||||
default: false
|
||||
}
|
||||
}
|
||||
public func def() -> any P4Value {
|
||||
return P4BooleanValue(withValue: false)
|
||||
}
|
||||
}
|
||||
|
||||
/// An instance of a P4 boolean
|
||||
@@ -269,6 +276,9 @@ public struct P4Int: P4Type {
|
||||
default: false
|
||||
}
|
||||
}
|
||||
public func def() -> any P4Value {
|
||||
return P4IntValue(withValue: 0)
|
||||
}
|
||||
}
|
||||
|
||||
/// An instance of a P4 integer
|
||||
@@ -309,6 +319,9 @@ public struct P4String: P4Type {
|
||||
default: false
|
||||
}
|
||||
}
|
||||
public func def() -> any P4Value {
|
||||
return P4StringValue(withValue: "")
|
||||
}
|
||||
}
|
||||
/// An instance of a P4 string
|
||||
public class P4StringValue: P4Value {
|
||||
@@ -358,6 +371,10 @@ public struct P4Array: P4Type {
|
||||
default: false
|
||||
}
|
||||
}
|
||||
|
||||
public func def() -> P4Value {
|
||||
return P4ArrayValue(withType: self, withValue: [])
|
||||
}
|
||||
}
|
||||
|
||||
/// An instance of a P4 array
|
||||
|
||||
Reference in New Issue
Block a user