sensorlog: Update generated vdl with new union targets
MultiPart: 3/3
Change-Id: I7673dd36b14b9c85cb6a3fc7b082f700bb5417e4
diff --git a/go/src/v.io/x/sensorlog/internal/sbmodel/sbmodel.vdl.go b/go/src/v.io/x/sensorlog/internal/sbmodel/sbmodel.vdl.go
index 1f1bd6f..bff9f2a 100644
--- a/go/src/v.io/x/sensorlog/internal/sbmodel/sbmodel.vdl.go
+++ b/go/src/v.io/x/sensorlog/internal/sbmodel/sbmodel.vdl.go
@@ -636,9 +636,10 @@
VDataPointError struct{ Value string }
// __VDataPointReflect describes the VDataPoint union type.
__VDataPointReflect struct {
- Name string `vdl:"v.io/x/sensorlog/internal/sbmodel.VDataPoint"`
- Type VDataPoint
- Union struct {
+ Name string `vdl:"v.io/x/sensorlog/internal/sbmodel.VDataPoint"`
+ Type VDataPoint
+ UnionTargetFactory vDataPointTargetFactory
+ Union struct {
Value VDataPointValue
Error VDataPointError
}
@@ -707,6 +708,57 @@
return nil
}
+type VDataPointTarget struct {
+ Value *VDataPoint
+ fieldName string
+
+ vdl.TargetBase
+ vdl.FieldsTargetBase
+}
+
+func (t *VDataPointTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
+ if ttWant := vdl.TypeOf((*VDataPoint)(nil)); !vdl.Compatible(tt, ttWant) {
+ return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
+ }
+
+ return t, nil
+}
+func (t *VDataPointTarget) StartField(name string) (key, field vdl.Target, _ error) {
+ t.fieldName = name
+ switch name {
+ case "Value":
+ val := float64(0)
+ return nil, &vdl.Float64Target{Value: &val}, nil
+ case "Error":
+ val := ""
+ return nil, &vdl.StringTarget{Value: &val}, nil
+ default:
+ return nil, nil, fmt.Errorf("field %s not in union v.io/x/sensorlog/internal/sbmodel.VDataPoint", name)
+ }
+}
+func (t *VDataPointTarget) FinishField(_, fieldTarget vdl.Target) error {
+ switch t.fieldName {
+ case "Value":
+ *t.Value = VDataPointValue{*(fieldTarget.(*vdl.Float64Target)).Value}
+ case "Error":
+ *t.Value = VDataPointError{*(fieldTarget.(*vdl.StringTarget)).Value}
+ }
+ return nil
+}
+func (t *VDataPointTarget) FinishFields(_ vdl.FieldsTarget) error {
+
+ return nil
+}
+
+type vDataPointTargetFactory struct{}
+
+func (t vDataPointTargetFactory) VDLMakeUnionTarget(union interface{}) (vdl.Target, error) {
+ if typedUnion, ok := union.(*VDataPoint); ok {
+ return &VDataPointTarget{Value: typedUnion}, nil
+ }
+ return nil, fmt.Errorf("got %T, want *VDataPoint", union)
+}
+
// Create zero values for each type.
var (
__VDLZeroVDeviceCfg = VDeviceCfg{}