blob: b7e79498bb69e88b27159965a75b26578ac9188e [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Package: demodb
package demodb
import (
"fmt"
"reflect"
"time"
"v.io/v23/vdl"
time_2 "v.io/v23/vdlroot/time"
"v.io/v23/vom"
)
var _ = __VDLInit() // Must be first; see __VDLInit comments for details.
//////////////////////////////////////////////////
// Type definitions
type AddressInfo struct {
Street string
City string
State string
Zip string
}
func (AddressInfo) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.AddressInfo"`
}) {
}
func (m *AddressInfo) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Street == "")
if var4 {
if err := fieldsTarget1.ZeroField("Street"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Street")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromString(string(m.Street), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var7 := (m.City == "")
if var7 {
if err := fieldsTarget1.ZeroField("City"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("City")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget6.FromString(string(m.City), tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
var10 := (m.State == "")
if var10 {
if err := fieldsTarget1.ZeroField("State"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("State")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget9.FromString(string(m.State), tt.NonOptional().Field(2).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
return err
}
}
}
var13 := (m.Zip == "")
if var13 {
if err := fieldsTarget1.ZeroField("Zip"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("Zip")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget12.FromString(string(m.Zip), tt.NonOptional().Field(3).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *AddressInfo) MakeVDLTarget() vdl.Target {
return &AddressInfoTarget{Value: m}
}
type AddressInfoTarget struct {
Value *AddressInfo
streetTarget vdl.StringTarget
cityTarget vdl.StringTarget
stateTarget vdl.StringTarget
zipTarget vdl.StringTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *AddressInfoTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*AddressInfo)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *AddressInfoTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Street":
t.streetTarget.Value = &t.Value.Street
target, err := &t.streetTarget, error(nil)
return nil, target, err
case "City":
t.cityTarget.Value = &t.Value.City
target, err := &t.cityTarget, error(nil)
return nil, target, err
case "State":
t.stateTarget.Value = &t.Value.State
target, err := &t.stateTarget, error(nil)
return nil, target, err
case "Zip":
t.zipTarget.Value = &t.Value.Zip
target, err := &t.zipTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.AddressInfo", name)
}
}
func (t *AddressInfoTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *AddressInfoTarget) ZeroField(name string) error {
switch name {
case "Street":
t.Value.Street = ""
return nil
case "City":
t.Value.City = ""
return nil
case "State":
t.Value.State = ""
return nil
case "Zip":
t.Value.Zip = ""
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.AddressInfo", name)
}
}
func (t *AddressInfoTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x AddressInfo) VDLIsZero() (bool, error) {
return x == AddressInfo{}, nil
}
func (x AddressInfo) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*AddressInfo)(nil)).Elem()); err != nil {
return err
}
if x.Street != "" {
if err := enc.NextField("Street"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.Street); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.City != "" {
if err := enc.NextField("City"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.City); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.State != "" {
if err := enc.NextField("State"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.State); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Zip != "" {
if err := enc.NextField("Zip"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.Zip); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *AddressInfo) VDLRead(dec vdl.Decoder) error {
*x = AddressInfo{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Street":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Street, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "City":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.City, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "State":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.State, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "Zip":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Zip, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type CreditAgency int
const (
CreditAgencyEquifax CreditAgency = iota
CreditAgencyExperian
CreditAgencyTransUnion
)
// CreditAgencyAll holds all labels for CreditAgency.
var CreditAgencyAll = [...]CreditAgency{CreditAgencyEquifax, CreditAgencyExperian, CreditAgencyTransUnion}
// CreditAgencyFromString creates a CreditAgency from a string label.
func CreditAgencyFromString(label string) (x CreditAgency, err error) {
err = x.Set(label)
return
}
// Set assigns label to x.
func (x *CreditAgency) Set(label string) error {
switch label {
case "Equifax", "equifax":
*x = CreditAgencyEquifax
return nil
case "Experian", "experian":
*x = CreditAgencyExperian
return nil
case "TransUnion", "transunion":
*x = CreditAgencyTransUnion
return nil
}
*x = -1
return fmt.Errorf("unknown label %q in demodb.CreditAgency", label)
}
// String returns the string label of x.
func (x CreditAgency) String() string {
switch x {
case CreditAgencyEquifax:
return "Equifax"
case CreditAgencyExperian:
return "Experian"
case CreditAgencyTransUnion:
return "TransUnion"
}
return ""
}
func (CreditAgency) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.CreditAgency"`
Enum struct{ Equifax, Experian, TransUnion string }
}) {
}
func (m *CreditAgency) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
if err := t.FromEnumLabel((*m).String(), tt); err != nil {
return err
}
return nil
}
func (m *CreditAgency) MakeVDLTarget() vdl.Target {
return &CreditAgencyTarget{Value: m}
}
type CreditAgencyTarget struct {
Value *CreditAgency
vdl.TargetBase
}
func (t *CreditAgencyTarget) FromEnumLabel(src string, tt *vdl.Type) error {
if ttWant := vdl.TypeOf((*CreditAgency)(nil)); !vdl.Compatible(tt, ttWant) {
return fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
switch src {
case "Equifax":
*t.Value = 0
case "Experian":
*t.Value = 1
case "TransUnion":
*t.Value = 2
default:
return fmt.Errorf("label %s not in enum CreditAgency", src)
}
return nil
}
func (x CreditAgency) VDLIsZero() (bool, error) {
return x == CreditAgencyEquifax, nil
}
func (x CreditAgency) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*CreditAgency)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.String()); err != nil {
return err
}
return enc.FinishValue()
}
func (x *CreditAgency) VDLRead(dec vdl.Decoder) error {
if err := dec.StartValue(); err != nil {
return err
}
enum, err := dec.DecodeString()
if err != nil {
return err
}
if err := x.Set(enum); err != nil {
return err
}
return dec.FinishValue()
}
type ExperianRating int
const (
ExperianRatingGood ExperianRating = iota
ExperianRatingBad
)
// ExperianRatingAll holds all labels for ExperianRating.
var ExperianRatingAll = [...]ExperianRating{ExperianRatingGood, ExperianRatingBad}
// ExperianRatingFromString creates a ExperianRating from a string label.
func ExperianRatingFromString(label string) (x ExperianRating, err error) {
err = x.Set(label)
return
}
// Set assigns label to x.
func (x *ExperianRating) Set(label string) error {
switch label {
case "Good", "good":
*x = ExperianRatingGood
return nil
case "Bad", "bad":
*x = ExperianRatingBad
return nil
}
*x = -1
return fmt.Errorf("unknown label %q in demodb.ExperianRating", label)
}
// String returns the string label of x.
func (x ExperianRating) String() string {
switch x {
case ExperianRatingGood:
return "Good"
case ExperianRatingBad:
return "Bad"
}
return ""
}
func (ExperianRating) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.ExperianRating"`
Enum struct{ Good, Bad string }
}) {
}
func (m *ExperianRating) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
if err := t.FromEnumLabel((*m).String(), tt); err != nil {
return err
}
return nil
}
func (m *ExperianRating) MakeVDLTarget() vdl.Target {
return &ExperianRatingTarget{Value: m}
}
type ExperianRatingTarget struct {
Value *ExperianRating
vdl.TargetBase
}
func (t *ExperianRatingTarget) FromEnumLabel(src string, tt *vdl.Type) error {
if ttWant := vdl.TypeOf((*ExperianRating)(nil)); !vdl.Compatible(tt, ttWant) {
return fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
switch src {
case "Good":
*t.Value = 0
case "Bad":
*t.Value = 1
default:
return fmt.Errorf("label %s not in enum ExperianRating", src)
}
return nil
}
func (x ExperianRating) VDLIsZero() (bool, error) {
return x == ExperianRatingGood, nil
}
func (x ExperianRating) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*ExperianRating)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.String()); err != nil {
return err
}
return enc.FinishValue()
}
func (x *ExperianRating) VDLRead(dec vdl.Decoder) error {
if err := dec.StartValue(); err != nil {
return err
}
enum, err := dec.DecodeString()
if err != nil {
return err
}
if err := x.Set(enum); err != nil {
return err
}
return dec.FinishValue()
}
type EquifaxCreditReport struct {
Rating byte
}
func (EquifaxCreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.EquifaxCreditReport"`
}) {
}
func (m *EquifaxCreditReport) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Rating == byte(0))
if var4 {
if err := fieldsTarget1.ZeroField("Rating"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Rating")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromUint(uint64(m.Rating), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *EquifaxCreditReport) MakeVDLTarget() vdl.Target {
return &EquifaxCreditReportTarget{Value: m}
}
type EquifaxCreditReportTarget struct {
Value *EquifaxCreditReport
ratingTarget vdl.ByteTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *EquifaxCreditReportTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*EquifaxCreditReport)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *EquifaxCreditReportTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Rating":
t.ratingTarget.Value = &t.Value.Rating
target, err := &t.ratingTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.EquifaxCreditReport", name)
}
}
func (t *EquifaxCreditReportTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *EquifaxCreditReportTarget) ZeroField(name string) error {
switch name {
case "Rating":
t.Value.Rating = byte(0)
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.EquifaxCreditReport", name)
}
}
func (t *EquifaxCreditReportTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x EquifaxCreditReport) VDLIsZero() (bool, error) {
return x == EquifaxCreditReport{}, nil
}
func (x EquifaxCreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*EquifaxCreditReport)(nil)).Elem()); err != nil {
return err
}
if x.Rating != 0 {
if err := enc.NextField("Rating"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*byte)(nil))); err != nil {
return err
}
if err := enc.EncodeUint(uint64(x.Rating)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *EquifaxCreditReport) VDLRead(dec vdl.Decoder) error {
*x = EquifaxCreditReport{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Rating":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeUint(8)
if err != nil {
return err
}
x.Rating = byte(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type ExperianCreditReport struct {
Rating ExperianRating
}
func (ExperianCreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.ExperianCreditReport"`
}) {
}
func (m *ExperianCreditReport) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Rating == ExperianRatingGood)
if var4 {
if err := fieldsTarget1.ZeroField("Rating"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Rating")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Rating.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *ExperianCreditReport) MakeVDLTarget() vdl.Target {
return &ExperianCreditReportTarget{Value: m}
}
type ExperianCreditReportTarget struct {
Value *ExperianCreditReport
ratingTarget ExperianRatingTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *ExperianCreditReportTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*ExperianCreditReport)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *ExperianCreditReportTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Rating":
t.ratingTarget.Value = &t.Value.Rating
target, err := &t.ratingTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.ExperianCreditReport", name)
}
}
func (t *ExperianCreditReportTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *ExperianCreditReportTarget) ZeroField(name string) error {
switch name {
case "Rating":
t.Value.Rating = ExperianRatingGood
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.ExperianCreditReport", name)
}
}
func (t *ExperianCreditReportTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x ExperianCreditReport) VDLIsZero() (bool, error) {
return x == ExperianCreditReport{}, nil
}
func (x ExperianCreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*ExperianCreditReport)(nil)).Elem()); err != nil {
return err
}
if x.Rating != ExperianRatingGood {
if err := enc.NextField("Rating"); err != nil {
return err
}
if err := x.Rating.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *ExperianCreditReport) VDLRead(dec vdl.Decoder) error {
*x = ExperianCreditReport{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Rating":
if err := x.Rating.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type TransUnionCreditReport struct {
Rating int16
}
func (TransUnionCreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.TransUnionCreditReport"`
}) {
}
func (m *TransUnionCreditReport) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Rating == int16(0))
if var4 {
if err := fieldsTarget1.ZeroField("Rating"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Rating")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromInt(int64(m.Rating), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *TransUnionCreditReport) MakeVDLTarget() vdl.Target {
return &TransUnionCreditReportTarget{Value: m}
}
type TransUnionCreditReportTarget struct {
Value *TransUnionCreditReport
ratingTarget vdl.Int16Target
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *TransUnionCreditReportTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*TransUnionCreditReport)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *TransUnionCreditReportTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Rating":
t.ratingTarget.Value = &t.Value.Rating
target, err := &t.ratingTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.TransUnionCreditReport", name)
}
}
func (t *TransUnionCreditReportTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *TransUnionCreditReportTarget) ZeroField(name string) error {
switch name {
case "Rating":
t.Value.Rating = int16(0)
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.TransUnionCreditReport", name)
}
}
func (t *TransUnionCreditReportTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x TransUnionCreditReport) VDLIsZero() (bool, error) {
return x == TransUnionCreditReport{}, nil
}
func (x TransUnionCreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*TransUnionCreditReport)(nil)).Elem()); err != nil {
return err
}
if x.Rating != 0 {
if err := enc.NextField("Rating"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int16)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(int64(x.Rating)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *TransUnionCreditReport) VDLRead(dec vdl.Decoder) error {
*x = TransUnionCreditReport{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Rating":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeInt(16)
if err != nil {
return err
}
x.Rating = int16(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type (
// AgencyReport represents any single field of the AgencyReport union type.
AgencyReport interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// __VDLReflect describes the AgencyReport union type.
__VDLReflect(__AgencyReportReflect)
FillVDLTarget(vdl.Target, *vdl.Type) error
VDLIsZero() (bool, error)
VDLWrite(vdl.Encoder) error
}
// AgencyReportEquifaxReport represents field EquifaxReport of the AgencyReport union type.
AgencyReportEquifaxReport struct{ Value EquifaxCreditReport }
// AgencyReportExperianReport represents field ExperianReport of the AgencyReport union type.
AgencyReportExperianReport struct{ Value ExperianCreditReport }
// AgencyReportTransUnionReport represents field TransUnionReport of the AgencyReport union type.
AgencyReportTransUnionReport struct{ Value TransUnionCreditReport }
// __AgencyReportReflect describes the AgencyReport union type.
__AgencyReportReflect struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.AgencyReport"`
Type AgencyReport
UnionTargetFactory agencyReportTargetFactory
Union struct {
EquifaxReport AgencyReportEquifaxReport
ExperianReport AgencyReportExperianReport
TransUnionReport AgencyReportTransUnionReport
}
}
)
func (x AgencyReportEquifaxReport) Index() int { return 0 }
func (x AgencyReportEquifaxReport) Interface() interface{} { return x.Value }
func (x AgencyReportEquifaxReport) Name() string { return "EquifaxReport" }
func (x AgencyReportEquifaxReport) __VDLReflect(__AgencyReportReflect) {}
func (m AgencyReportEquifaxReport) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("EquifaxReport")
if err != nil {
return err
}
if err := m.Value.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m AgencyReportEquifaxReport) MakeVDLTarget() vdl.Target {
return nil
}
func (x AgencyReportExperianReport) Index() int { return 1 }
func (x AgencyReportExperianReport) Interface() interface{} { return x.Value }
func (x AgencyReportExperianReport) Name() string { return "ExperianReport" }
func (x AgencyReportExperianReport) __VDLReflect(__AgencyReportReflect) {}
func (m AgencyReportExperianReport) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("ExperianReport")
if err != nil {
return err
}
if err := m.Value.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m AgencyReportExperianReport) MakeVDLTarget() vdl.Target {
return nil
}
func (x AgencyReportTransUnionReport) Index() int { return 2 }
func (x AgencyReportTransUnionReport) Interface() interface{} { return x.Value }
func (x AgencyReportTransUnionReport) Name() string { return "TransUnionReport" }
func (x AgencyReportTransUnionReport) __VDLReflect(__AgencyReportReflect) {}
func (m AgencyReportTransUnionReport) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("TransUnionReport")
if err != nil {
return err
}
if err := m.Value.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(2).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m AgencyReportTransUnionReport) MakeVDLTarget() vdl.Target {
return nil
}
type AgencyReportTarget struct {
Value *AgencyReport
fieldName string
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *AgencyReportTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*AgencyReport)(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *AgencyReportTarget) StartField(name string) (key, field vdl.Target, _ error) {
t.fieldName = name
switch name {
case "EquifaxReport":
val := EquifaxCreditReport{}
return nil, &EquifaxCreditReportTarget{Value: &val}, nil
case "ExperianReport":
val := ExperianCreditReport{}
return nil, &ExperianCreditReportTarget{Value: &val}, nil
case "TransUnionReport":
val := TransUnionCreditReport{}
return nil, &TransUnionCreditReportTarget{Value: &val}, nil
default:
return nil, nil, fmt.Errorf("field %s not in union v.io/x/ref/cmd/sb/internal/demodb.AgencyReport", name)
}
}
func (t *AgencyReportTarget) FinishField(_, fieldTarget vdl.Target) error {
switch t.fieldName {
case "EquifaxReport":
*t.Value = AgencyReportEquifaxReport{*(fieldTarget.(*EquifaxCreditReportTarget)).Value}
case "ExperianReport":
*t.Value = AgencyReportExperianReport{*(fieldTarget.(*ExperianCreditReportTarget)).Value}
case "TransUnionReport":
*t.Value = AgencyReportTransUnionReport{*(fieldTarget.(*TransUnionCreditReportTarget)).Value}
}
return nil
}
func (t *AgencyReportTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
type agencyReportTargetFactory struct{}
func (t agencyReportTargetFactory) VDLMakeUnionTarget(union interface{}) (vdl.Target, error) {
if typedUnion, ok := union.(*AgencyReport); ok {
return &AgencyReportTarget{Value: typedUnion}, nil
}
return nil, fmt.Errorf("got %T, want *AgencyReport", union)
}
func (x AgencyReportEquifaxReport) VDLIsZero() (bool, error) {
return x.Value == EquifaxCreditReport{}, nil
}
func (x AgencyReportExperianReport) VDLIsZero() (bool, error) {
return false, nil
}
func (x AgencyReportTransUnionReport) VDLIsZero() (bool, error) {
return false, nil
}
func (x AgencyReportEquifaxReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*AgencyReport)(nil))); err != nil {
return err
}
if err := enc.NextField("EquifaxReport"); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x AgencyReportExperianReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*AgencyReport)(nil))); err != nil {
return err
}
if err := enc.NextField("ExperianReport"); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x AgencyReportTransUnionReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*AgencyReport)(nil))); err != nil {
return err
}
if err := enc.NextField("TransUnionReport"); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadAgencyReport(dec vdl.Decoder, x *AgencyReport) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(x), dec.Type()) {
return fmt.Errorf("incompatible union %T, from %v", x, dec.Type())
}
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "EquifaxReport":
var field AgencyReportEquifaxReport
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
case "ExperianReport":
var field AgencyReportExperianReport
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
case "TransUnionReport":
var field AgencyReportTransUnionReport
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
case "":
return fmt.Errorf("missing field in union %T, from %v", x, dec.Type())
default:
return fmt.Errorf("field %q not in union %T, from %v", f, x, dec.Type())
}
switch f, err := dec.NextField(); {
case err != nil:
return err
case f != "":
return fmt.Errorf("extra field %q in union %T, from %v", f, x, dec.Type())
}
return dec.FinishValue()
}
type CreditReport struct {
Agency CreditAgency
Report AgencyReport
}
func (CreditReport) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.CreditReport"`
}) {
}
func (m *CreditReport) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Agency == CreditAgencyEquifax)
if var4 {
if err := fieldsTarget1.ZeroField("Agency"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Agency")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Agency.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var var7 bool
if field, ok := m.Report.(AgencyReportEquifaxReport); ok {
var8 := (field.Value == EquifaxCreditReport{})
var7 = var8
}
if var7 {
if err := fieldsTarget1.ZeroField("Report"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("Report")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
unionValue9 := m.Report
if unionValue9 == nil {
unionValue9 = AgencyReportEquifaxReport{}
}
if err := unionValue9.FillVDLTarget(fieldTarget6, tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *CreditReport) MakeVDLTarget() vdl.Target {
return &CreditReportTarget{Value: m}
}
type CreditReportTarget struct {
Value *CreditReport
agencyTarget CreditAgencyTarget
reportTarget AgencyReportTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *CreditReportTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*CreditReport)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *CreditReportTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Agency":
t.agencyTarget.Value = &t.Value.Agency
target, err := &t.agencyTarget, error(nil)
return nil, target, err
case "Report":
t.reportTarget.Value = &t.Value.Report
target, err := &t.reportTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.CreditReport", name)
}
}
func (t *CreditReportTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *CreditReportTarget) ZeroField(name string) error {
switch name {
case "Agency":
t.Value.Agency = CreditAgencyEquifax
return nil
case "Report":
t.Value.Report = AgencyReport(AgencyReportEquifaxReport{})
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.CreditReport", name)
}
}
func (t *CreditReportTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x CreditReport) VDLIsZero() (bool, error) {
if x.Agency != CreditAgencyEquifax {
return false, nil
}
var isZeroReport bool
if x.Report != nil {
var err error
if isZeroReport, err = x.Report.VDLIsZero(); err != nil {
return false, err
}
}
if x.Report != nil && !isZeroReport {
return false, nil
}
return true, nil
}
func (x CreditReport) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*CreditReport)(nil)).Elem()); err != nil {
return err
}
if x.Agency != CreditAgencyEquifax {
if err := enc.NextField("Agency"); err != nil {
return err
}
if err := x.Agency.VDLWrite(enc); err != nil {
return err
}
}
var isZeroReport bool
if x.Report != nil {
var err error
if isZeroReport, err = x.Report.VDLIsZero(); err != nil {
return err
}
}
if x.Report != nil && !isZeroReport {
if err := enc.NextField("Report"); err != nil {
return err
}
if err := x.Report.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *CreditReport) VDLRead(dec vdl.Decoder) error {
*x = CreditReport{
Report: AgencyReportEquifaxReport{},
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Agency":
if err := x.Agency.VDLRead(dec); err != nil {
return err
}
case "Report":
if err := VDLReadAgencyReport(dec, &x.Report); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Customer struct {
Name string
Id int64
Active bool
Address AddressInfo
Credit CreditReport
}
func (Customer) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Customer"`
}) {
}
func (m *Customer) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Name == "")
if var4 {
if err := fieldsTarget1.ZeroField("Name"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Name")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromString(string(m.Name), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var7 := (m.Id == int64(0))
if var7 {
if err := fieldsTarget1.ZeroField("Id"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("Id")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget6.FromInt(int64(m.Id), tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
var10 := (m.Active == false)
if var10 {
if err := fieldsTarget1.ZeroField("Active"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("Active")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget9.FromBool(bool(m.Active), tt.NonOptional().Field(2).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
return err
}
}
}
var13 := (m.Address == AddressInfo{})
if var13 {
if err := fieldsTarget1.ZeroField("Address"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("Address")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Address.FillVDLTarget(fieldTarget12, tt.NonOptional().Field(3).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
return err
}
}
}
var16 := (m.Credit == CreditReport{
Report: AgencyReportEquifaxReport{},
})
if var16 {
if err := fieldsTarget1.ZeroField("Credit"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget14, fieldTarget15, err := fieldsTarget1.StartField("Credit")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Credit.FillVDLTarget(fieldTarget15, tt.NonOptional().Field(4).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget14, fieldTarget15); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *Customer) MakeVDLTarget() vdl.Target {
return &CustomerTarget{Value: m}
}
type CustomerTarget struct {
Value *Customer
nameTarget vdl.StringTarget
idTarget vdl.Int64Target
activeTarget vdl.BoolTarget
addressTarget AddressInfoTarget
creditTarget CreditReportTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *CustomerTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*Customer)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *CustomerTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Name":
t.nameTarget.Value = &t.Value.Name
target, err := &t.nameTarget, error(nil)
return nil, target, err
case "Id":
t.idTarget.Value = &t.Value.Id
target, err := &t.idTarget, error(nil)
return nil, target, err
case "Active":
t.activeTarget.Value = &t.Value.Active
target, err := &t.activeTarget, error(nil)
return nil, target, err
case "Address":
t.addressTarget.Value = &t.Value.Address
target, err := &t.addressTarget, error(nil)
return nil, target, err
case "Credit":
t.creditTarget.Value = &t.Value.Credit
target, err := &t.creditTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Customer", name)
}
}
func (t *CustomerTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *CustomerTarget) ZeroField(name string) error {
switch name {
case "Name":
t.Value.Name = ""
return nil
case "Id":
t.Value.Id = int64(0)
return nil
case "Active":
t.Value.Active = false
return nil
case "Address":
t.Value.Address = AddressInfo{}
return nil
case "Credit":
t.Value.Credit = CreditReport{
Report: AgencyReportEquifaxReport{},
}
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Customer", name)
}
}
func (t *CustomerTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x Customer) VDLIsZero() (bool, error) {
if x.Name != "" {
return false, nil
}
if x.Id != 0 {
return false, nil
}
if x.Active {
return false, nil
}
if x.Address != (AddressInfo{}) {
return false, nil
}
isZeroCredit, err := x.Credit.VDLIsZero()
if err != nil {
return false, err
}
if !isZeroCredit {
return false, nil
}
return true, nil
}
func (x Customer) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Customer)(nil)).Elem()); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextField("Name"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.Name); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Id != 0 {
if err := enc.NextField("Id"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int64)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(x.Id); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Active {
if err := enc.NextField("Active"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*bool)(nil))); err != nil {
return err
}
if err := enc.EncodeBool(x.Active); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Address != (AddressInfo{}) {
if err := enc.NextField("Address"); err != nil {
return err
}
if err := x.Address.VDLWrite(enc); err != nil {
return err
}
}
isZeroCredit, err := x.Credit.VDLIsZero()
if err != nil {
return err
}
if !isZeroCredit {
if err := enc.NextField("Credit"); err != nil {
return err
}
if err := x.Credit.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Customer) VDLRead(dec vdl.Decoder) error {
*x = Customer{
Credit: CreditReport{
Report: AgencyReportEquifaxReport{},
},
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Name":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Name, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "Id":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Id, err = dec.DecodeInt(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "Active":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Active, err = dec.DecodeBool(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "Address":
if err := x.Address.VDLRead(dec); err != nil {
return err
}
case "Credit":
if err := x.Credit.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Invoice struct {
CustId int64
InvoiceNum int64
Amount int64
ShipTo AddressInfo
}
func (Invoice) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Invoice"`
}) {
}
func (m *Invoice) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.CustId == int64(0))
if var4 {
if err := fieldsTarget1.ZeroField("CustId"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("CustId")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromInt(int64(m.CustId), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var7 := (m.InvoiceNum == int64(0))
if var7 {
if err := fieldsTarget1.ZeroField("InvoiceNum"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("InvoiceNum")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget6.FromInt(int64(m.InvoiceNum), tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
var10 := (m.Amount == int64(0))
if var10 {
if err := fieldsTarget1.ZeroField("Amount"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("Amount")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget9.FromInt(int64(m.Amount), tt.NonOptional().Field(2).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
return err
}
}
}
var13 := (m.ShipTo == AddressInfo{})
if var13 {
if err := fieldsTarget1.ZeroField("ShipTo"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("ShipTo")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.ShipTo.FillVDLTarget(fieldTarget12, tt.NonOptional().Field(3).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *Invoice) MakeVDLTarget() vdl.Target {
return &InvoiceTarget{Value: m}
}
type InvoiceTarget struct {
Value *Invoice
custIdTarget vdl.Int64Target
invoiceNumTarget vdl.Int64Target
amountTarget vdl.Int64Target
shipToTarget AddressInfoTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *InvoiceTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*Invoice)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *InvoiceTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "CustId":
t.custIdTarget.Value = &t.Value.CustId
target, err := &t.custIdTarget, error(nil)
return nil, target, err
case "InvoiceNum":
t.invoiceNumTarget.Value = &t.Value.InvoiceNum
target, err := &t.invoiceNumTarget, error(nil)
return nil, target, err
case "Amount":
t.amountTarget.Value = &t.Value.Amount
target, err := &t.amountTarget, error(nil)
return nil, target, err
case "ShipTo":
t.shipToTarget.Value = &t.Value.ShipTo
target, err := &t.shipToTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Invoice", name)
}
}
func (t *InvoiceTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *InvoiceTarget) ZeroField(name string) error {
switch name {
case "CustId":
t.Value.CustId = int64(0)
return nil
case "InvoiceNum":
t.Value.InvoiceNum = int64(0)
return nil
case "Amount":
t.Value.Amount = int64(0)
return nil
case "ShipTo":
t.Value.ShipTo = AddressInfo{}
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Invoice", name)
}
}
func (t *InvoiceTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x Invoice) VDLIsZero() (bool, error) {
return x == Invoice{}, nil
}
func (x Invoice) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Invoice)(nil)).Elem()); err != nil {
return err
}
if x.CustId != 0 {
if err := enc.NextField("CustId"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int64)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(x.CustId); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.InvoiceNum != 0 {
if err := enc.NextField("InvoiceNum"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int64)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(x.InvoiceNum); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Amount != 0 {
if err := enc.NextField("Amount"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int64)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(x.Amount); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.ShipTo != (AddressInfo{}) {
if err := enc.NextField("ShipTo"); err != nil {
return err
}
if err := x.ShipTo.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Invoice) VDLRead(dec vdl.Decoder) error {
*x = Invoice{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "CustId":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.CustId, err = dec.DecodeInt(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "InvoiceNum":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.InvoiceNum, err = dec.DecodeInt(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "Amount":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Amount, err = dec.DecodeInt(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "ShipTo":
if err := x.ShipTo.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Numbers struct {
B byte
Ui16 uint16
Ui32 uint32
Ui64 uint64
I16 int16
I32 int32
I64 int64
F32 float32
F64 float64
}
func (Numbers) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Numbers"`
}) {
}
func (m *Numbers) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.B == byte(0))
if var4 {
if err := fieldsTarget1.ZeroField("B"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("B")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromUint(uint64(m.B), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var7 := (m.Ui16 == uint16(0))
if var7 {
if err := fieldsTarget1.ZeroField("Ui16"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("Ui16")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget6.FromUint(uint64(m.Ui16), tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
var10 := (m.Ui32 == uint32(0))
if var10 {
if err := fieldsTarget1.ZeroField("Ui32"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("Ui32")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget9.FromUint(uint64(m.Ui32), tt.NonOptional().Field(2).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
return err
}
}
}
var13 := (m.Ui64 == uint64(0))
if var13 {
if err := fieldsTarget1.ZeroField("Ui64"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("Ui64")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget12.FromUint(uint64(m.Ui64), tt.NonOptional().Field(3).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
return err
}
}
}
var16 := (m.I16 == int16(0))
if var16 {
if err := fieldsTarget1.ZeroField("I16"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget14, fieldTarget15, err := fieldsTarget1.StartField("I16")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget15.FromInt(int64(m.I16), tt.NonOptional().Field(4).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget14, fieldTarget15); err != nil {
return err
}
}
}
var19 := (m.I32 == int32(0))
if var19 {
if err := fieldsTarget1.ZeroField("I32"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget17, fieldTarget18, err := fieldsTarget1.StartField("I32")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget18.FromInt(int64(m.I32), tt.NonOptional().Field(5).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget17, fieldTarget18); err != nil {
return err
}
}
}
var22 := (m.I64 == int64(0))
if var22 {
if err := fieldsTarget1.ZeroField("I64"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget20, fieldTarget21, err := fieldsTarget1.StartField("I64")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget21.FromInt(int64(m.I64), tt.NonOptional().Field(6).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget20, fieldTarget21); err != nil {
return err
}
}
}
var25 := (m.F32 == float32(0))
if var25 {
if err := fieldsTarget1.ZeroField("F32"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget23, fieldTarget24, err := fieldsTarget1.StartField("F32")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget24.FromFloat(float64(m.F32), tt.NonOptional().Field(7).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget23, fieldTarget24); err != nil {
return err
}
}
}
var28 := (m.F64 == float64(0))
if var28 {
if err := fieldsTarget1.ZeroField("F64"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget26, fieldTarget27, err := fieldsTarget1.StartField("F64")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget27.FromFloat(float64(m.F64), tt.NonOptional().Field(8).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget26, fieldTarget27); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *Numbers) MakeVDLTarget() vdl.Target {
return &NumbersTarget{Value: m}
}
type NumbersTarget struct {
Value *Numbers
bTarget vdl.ByteTarget
ui16Target vdl.Uint16Target
ui32Target vdl.Uint32Target
ui64Target vdl.Uint64Target
i16Target vdl.Int16Target
i32Target vdl.Int32Target
i64Target vdl.Int64Target
f32Target vdl.Float32Target
f64Target vdl.Float64Target
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *NumbersTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*Numbers)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *NumbersTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "B":
t.bTarget.Value = &t.Value.B
target, err := &t.bTarget, error(nil)
return nil, target, err
case "Ui16":
t.ui16Target.Value = &t.Value.Ui16
target, err := &t.ui16Target, error(nil)
return nil, target, err
case "Ui32":
t.ui32Target.Value = &t.Value.Ui32
target, err := &t.ui32Target, error(nil)
return nil, target, err
case "Ui64":
t.ui64Target.Value = &t.Value.Ui64
target, err := &t.ui64Target, error(nil)
return nil, target, err
case "I16":
t.i16Target.Value = &t.Value.I16
target, err := &t.i16Target, error(nil)
return nil, target, err
case "I32":
t.i32Target.Value = &t.Value.I32
target, err := &t.i32Target, error(nil)
return nil, target, err
case "I64":
t.i64Target.Value = &t.Value.I64
target, err := &t.i64Target, error(nil)
return nil, target, err
case "F32":
t.f32Target.Value = &t.Value.F32
target, err := &t.f32Target, error(nil)
return nil, target, err
case "F64":
t.f64Target.Value = &t.Value.F64
target, err := &t.f64Target, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Numbers", name)
}
}
func (t *NumbersTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *NumbersTarget) ZeroField(name string) error {
switch name {
case "B":
t.Value.B = byte(0)
return nil
case "Ui16":
t.Value.Ui16 = uint16(0)
return nil
case "Ui32":
t.Value.Ui32 = uint32(0)
return nil
case "Ui64":
t.Value.Ui64 = uint64(0)
return nil
case "I16":
t.Value.I16 = int16(0)
return nil
case "I32":
t.Value.I32 = int32(0)
return nil
case "I64":
t.Value.I64 = int64(0)
return nil
case "F32":
t.Value.F32 = float32(0)
return nil
case "F64":
t.Value.F64 = float64(0)
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Numbers", name)
}
}
func (t *NumbersTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x Numbers) VDLIsZero() (bool, error) {
return x == Numbers{}, nil
}
func (x Numbers) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Numbers)(nil)).Elem()); err != nil {
return err
}
if x.B != 0 {
if err := enc.NextField("B"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*byte)(nil))); err != nil {
return err
}
if err := enc.EncodeUint(uint64(x.B)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Ui16 != 0 {
if err := enc.NextField("Ui16"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*uint16)(nil))); err != nil {
return err
}
if err := enc.EncodeUint(uint64(x.Ui16)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Ui32 != 0 {
if err := enc.NextField("Ui32"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*uint32)(nil))); err != nil {
return err
}
if err := enc.EncodeUint(uint64(x.Ui32)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Ui64 != 0 {
if err := enc.NextField("Ui64"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*uint64)(nil))); err != nil {
return err
}
if err := enc.EncodeUint(x.Ui64); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.I16 != 0 {
if err := enc.NextField("I16"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int16)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(int64(x.I16)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.I32 != 0 {
if err := enc.NextField("I32"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int32)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(int64(x.I32)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.I64 != 0 {
if err := enc.NextField("I64"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int64)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(x.I64); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.F32 != 0 {
if err := enc.NextField("F32"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*float32)(nil))); err != nil {
return err
}
if err := enc.EncodeFloat(float64(x.F32)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.F64 != 0 {
if err := enc.NextField("F64"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*float64)(nil))); err != nil {
return err
}
if err := enc.EncodeFloat(x.F64); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Numbers) VDLRead(dec vdl.Decoder) error {
*x = Numbers{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "B":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeUint(8)
if err != nil {
return err
}
x.B = byte(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
case "Ui16":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeUint(16)
if err != nil {
return err
}
x.Ui16 = uint16(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
case "Ui32":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeUint(32)
if err != nil {
return err
}
x.Ui32 = uint32(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
case "Ui64":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Ui64, err = dec.DecodeUint(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "I16":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeInt(16)
if err != nil {
return err
}
x.I16 = int16(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
case "I32":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeInt(32)
if err != nil {
return err
}
x.I32 = int32(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
case "I64":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.I64, err = dec.DecodeInt(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "F32":
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeFloat(32)
if err != nil {
return err
}
x.F32 = float32(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
case "F64":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.F64, err = dec.DecodeFloat(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type (
// TitleOrValueType represents any single field of the TitleOrValueType union type.
TitleOrValueType interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// __VDLReflect describes the TitleOrValueType union type.
__VDLReflect(__TitleOrValueTypeReflect)
FillVDLTarget(vdl.Target, *vdl.Type) error
VDLIsZero() (bool, error)
VDLWrite(vdl.Encoder) error
}
// TitleOrValueTypeTitle represents field Title of the TitleOrValueType union type.
TitleOrValueTypeTitle struct{ Value string }
// TitleOrValueTypeValue represents field Value of the TitleOrValueType union type.
TitleOrValueTypeValue struct{ Value int64 }
// __TitleOrValueTypeReflect describes the TitleOrValueType union type.
__TitleOrValueTypeReflect struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.TitleOrValueType"`
Type TitleOrValueType
UnionTargetFactory titleOrValueTypeTargetFactory
Union struct {
Title TitleOrValueTypeTitle
Value TitleOrValueTypeValue
}
}
)
func (x TitleOrValueTypeTitle) Index() int { return 0 }
func (x TitleOrValueTypeTitle) Interface() interface{} { return x.Value }
func (x TitleOrValueTypeTitle) Name() string { return "Title" }
func (x TitleOrValueTypeTitle) __VDLReflect(__TitleOrValueTypeReflect) {}
func (m TitleOrValueTypeTitle) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Title")
if err != nil {
return err
}
if err := fieldTarget3.FromString(string(m.Value), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m TitleOrValueTypeTitle) MakeVDLTarget() vdl.Target {
return nil
}
func (x TitleOrValueTypeValue) Index() int { return 1 }
func (x TitleOrValueTypeValue) Interface() interface{} { return x.Value }
func (x TitleOrValueTypeValue) Name() string { return "Value" }
func (x TitleOrValueTypeValue) __VDLReflect(__TitleOrValueTypeReflect) {}
func (m TitleOrValueTypeValue) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Value")
if err != nil {
return err
}
if err := fieldTarget3.FromInt(int64(m.Value), tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m TitleOrValueTypeValue) MakeVDLTarget() vdl.Target {
return nil
}
type TitleOrValueTypeTarget struct {
Value *TitleOrValueType
fieldName string
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *TitleOrValueTypeTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*TitleOrValueType)(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *TitleOrValueTypeTarget) StartField(name string) (key, field vdl.Target, _ error) {
t.fieldName = name
switch name {
case "Title":
val := ""
return nil, &vdl.StringTarget{Value: &val}, nil
case "Value":
val := int64(0)
return nil, &vdl.Int64Target{Value: &val}, nil
default:
return nil, nil, fmt.Errorf("field %s not in union v.io/x/ref/cmd/sb/internal/demodb.TitleOrValueType", name)
}
}
func (t *TitleOrValueTypeTarget) FinishField(_, fieldTarget vdl.Target) error {
switch t.fieldName {
case "Title":
*t.Value = TitleOrValueTypeTitle{*(fieldTarget.(*vdl.StringTarget)).Value}
case "Value":
*t.Value = TitleOrValueTypeValue{*(fieldTarget.(*vdl.Int64Target)).Value}
}
return nil
}
func (t *TitleOrValueTypeTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
type titleOrValueTypeTargetFactory struct{}
func (t titleOrValueTypeTargetFactory) VDLMakeUnionTarget(union interface{}) (vdl.Target, error) {
if typedUnion, ok := union.(*TitleOrValueType); ok {
return &TitleOrValueTypeTarget{Value: typedUnion}, nil
}
return nil, fmt.Errorf("got %T, want *TitleOrValueType", union)
}
func (x TitleOrValueTypeTitle) VDLIsZero() (bool, error) {
return x.Value == "", nil
}
func (x TitleOrValueTypeValue) VDLIsZero() (bool, error) {
return false, nil
}
func (x TitleOrValueTypeTitle) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*TitleOrValueType)(nil))); err != nil {
return err
}
if err := enc.NextField("Title"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.Value); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x TitleOrValueTypeValue) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*TitleOrValueType)(nil))); err != nil {
return err
}
if err := enc.NextField("Value"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int64)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(x.Value); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadTitleOrValueType(dec vdl.Decoder, x *TitleOrValueType) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(x), dec.Type()) {
return fmt.Errorf("incompatible union %T, from %v", x, dec.Type())
}
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "Title":
var field TitleOrValueTypeTitle
if err := dec.StartValue(); err != nil {
return err
}
var err error
if field.Value, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
*x = field
case "Value":
var field TitleOrValueTypeValue
if err := dec.StartValue(); err != nil {
return err
}
var err error
if field.Value, err = dec.DecodeInt(64); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
*x = field
case "":
return fmt.Errorf("missing field in union %T, from %v", x, dec.Type())
default:
return fmt.Errorf("field %q not in union %T, from %v", f, x, dec.Type())
}
switch f, err := dec.NextField(); {
case err != nil:
return err
case f != "":
return fmt.Errorf("extra field %q in union %T, from %v", f, x, dec.Type())
}
return dec.FinishValue()
}
type BazType struct {
Name string
TitleOrValue TitleOrValueType
}
func (BazType) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.BazType"`
}) {
}
func (m *BazType) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Name == "")
if var4 {
if err := fieldsTarget1.ZeroField("Name"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Name")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromString(string(m.Name), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var var7 bool
if field, ok := m.TitleOrValue.(TitleOrValueTypeTitle); ok {
var8 := (field.Value == "")
var7 = var8
}
if var7 {
if err := fieldsTarget1.ZeroField("TitleOrValue"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("TitleOrValue")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
unionValue9 := m.TitleOrValue
if unionValue9 == nil {
unionValue9 = TitleOrValueTypeTitle{}
}
if err := unionValue9.FillVDLTarget(fieldTarget6, tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *BazType) MakeVDLTarget() vdl.Target {
return &BazTypeTarget{Value: m}
}
type BazTypeTarget struct {
Value *BazType
nameTarget vdl.StringTarget
titleOrValueTarget TitleOrValueTypeTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *BazTypeTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*BazType)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *BazTypeTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Name":
t.nameTarget.Value = &t.Value.Name
target, err := &t.nameTarget, error(nil)
return nil, target, err
case "TitleOrValue":
t.titleOrValueTarget.Value = &t.Value.TitleOrValue
target, err := &t.titleOrValueTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.BazType", name)
}
}
func (t *BazTypeTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *BazTypeTarget) ZeroField(name string) error {
switch name {
case "Name":
t.Value.Name = ""
return nil
case "TitleOrValue":
t.Value.TitleOrValue = TitleOrValueType(TitleOrValueTypeTitle{})
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.BazType", name)
}
}
func (t *BazTypeTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x BazType) VDLIsZero() (bool, error) {
if x.Name != "" {
return false, nil
}
var isZeroTitleOrValue bool
if x.TitleOrValue != nil {
var err error
if isZeroTitleOrValue, err = x.TitleOrValue.VDLIsZero(); err != nil {
return false, err
}
}
if x.TitleOrValue != nil && !isZeroTitleOrValue {
return false, nil
}
return true, nil
}
func (x BazType) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*BazType)(nil)).Elem()); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextField("Name"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.Name); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
var isZeroTitleOrValue bool
if x.TitleOrValue != nil {
var err error
if isZeroTitleOrValue, err = x.TitleOrValue.VDLIsZero(); err != nil {
return err
}
}
if x.TitleOrValue != nil && !isZeroTitleOrValue {
if err := enc.NextField("TitleOrValue"); err != nil {
return err
}
if err := x.TitleOrValue.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *BazType) VDLRead(dec vdl.Decoder) error {
*x = BazType{
TitleOrValue: TitleOrValueTypeTitle{},
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Name":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Name, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "TitleOrValue":
if err := VDLReadTitleOrValueType(dec, &x.TitleOrValue); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type BarType struct {
Baz BazType
}
func (BarType) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.BarType"`
}) {
}
func (m *BarType) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Baz == BazType{
TitleOrValue: TitleOrValueTypeTitle{},
})
if var4 {
if err := fieldsTarget1.ZeroField("Baz"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Baz")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Baz.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *BarType) MakeVDLTarget() vdl.Target {
return &BarTypeTarget{Value: m}
}
type BarTypeTarget struct {
Value *BarType
bazTarget BazTypeTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *BarTypeTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*BarType)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *BarTypeTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Baz":
t.bazTarget.Value = &t.Value.Baz
target, err := &t.bazTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.BarType", name)
}
}
func (t *BarTypeTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *BarTypeTarget) ZeroField(name string) error {
switch name {
case "Baz":
t.Value.Baz = BazType{
TitleOrValue: TitleOrValueTypeTitle{},
}
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.BarType", name)
}
}
func (t *BarTypeTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x BarType) VDLIsZero() (bool, error) {
isZeroBaz, err := x.Baz.VDLIsZero()
if err != nil {
return false, err
}
if !isZeroBaz {
return false, nil
}
return true, nil
}
func (x BarType) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*BarType)(nil)).Elem()); err != nil {
return err
}
isZeroBaz, err := x.Baz.VDLIsZero()
if err != nil {
return err
}
if !isZeroBaz {
if err := enc.NextField("Baz"); err != nil {
return err
}
if err := x.Baz.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *BarType) VDLRead(dec vdl.Decoder) error {
*x = BarType{
Baz: BazType{
TitleOrValue: TitleOrValueTypeTitle{},
},
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Baz":
if err := x.Baz.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type FooType struct {
Bar BarType
}
func (FooType) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.FooType"`
}) {
}
func (m *FooType) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Bar == BarType{
Baz: BazType{
TitleOrValue: TitleOrValueTypeTitle{},
},
})
if var4 {
if err := fieldsTarget1.ZeroField("Bar"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Bar")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Bar.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *FooType) MakeVDLTarget() vdl.Target {
return &FooTypeTarget{Value: m}
}
type FooTypeTarget struct {
Value *FooType
barTarget BarTypeTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *FooTypeTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*FooType)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *FooTypeTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Bar":
t.barTarget.Value = &t.Value.Bar
target, err := &t.barTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.FooType", name)
}
}
func (t *FooTypeTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *FooTypeTarget) ZeroField(name string) error {
switch name {
case "Bar":
t.Value.Bar = BarType{
Baz: BazType{
TitleOrValue: TitleOrValueTypeTitle{},
},
}
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.FooType", name)
}
}
func (t *FooTypeTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x FooType) VDLIsZero() (bool, error) {
isZeroBar, err := x.Bar.VDLIsZero()
if err != nil {
return false, err
}
if !isZeroBar {
return false, nil
}
return true, nil
}
func (x FooType) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*FooType)(nil)).Elem()); err != nil {
return err
}
isZeroBar, err := x.Bar.VDLIsZero()
if err != nil {
return err
}
if !isZeroBar {
if err := enc.NextField("Bar"); err != nil {
return err
}
if err := x.Bar.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *FooType) VDLRead(dec vdl.Decoder) error {
*x = FooType{
Bar: BarType{
Baz: BazType{
TitleOrValue: TitleOrValueTypeTitle{},
},
},
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Bar":
if err := x.Bar.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Array2String [2]string
func (Array2String) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Array2String"`
}) {
}
func (m *Array2String) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
listTarget1, err := t.StartList(tt, 2)
if err != nil {
return err
}
for i, elem3 := range *m {
elemTarget2, err := listTarget1.StartElem(i)
if err != nil {
return err
}
if err := elemTarget2.FromString(string(elem3), tt.NonOptional().Elem()); err != nil {
return err
}
if err := listTarget1.FinishElem(elemTarget2); err != nil {
return err
}
}
if err := t.FinishList(listTarget1); err != nil {
return err
}
return nil
}
func (m *Array2String) MakeVDLTarget() vdl.Target {
return &Array2StringTarget{Value: m}
}
// Array2String
type Array2StringTarget struct {
Value *Array2String
elemTarget vdl.StringTarget
vdl.TargetBase
vdl.ListTargetBase
}
func (t *Array2StringTarget) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {
if ttWant := vdl.TypeOf((*Array2String)(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *Array2StringTarget) StartElem(index int) (elem vdl.Target, _ error) {
t.elemTarget.Value = &(*t.Value)[index]
target, err := &t.elemTarget, error(nil)
return target, err
}
func (t *Array2StringTarget) FinishElem(elem vdl.Target) error {
return nil
}
func (t *Array2StringTarget) FinishList(elem vdl.ListTarget) error {
return nil
}
func (x Array2String) VDLIsZero() (bool, error) {
return x == Array2String{}, nil
}
func (x Array2String) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Array2String)(nil))); err != nil {
return err
}
for i := 0; i < 2; i++ {
if err := enc.NextEntry(false); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x[i]); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Array2String) VDLRead(dec vdl.Decoder) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible array %T, from %v", *x, dec.Type())
}
index := 0
for {
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case done != (index >= len(*x)):
return fmt.Errorf("array len mismatch, got %d, want %T", index, *x)
case done:
return dec.FinishValue()
}
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x[index], err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
index++
}
}
type Composite struct {
Arr Array2String
ListInt []int32
MySet map[int32]struct{}
Map map[string]int32
}
func (Composite) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Composite"`
}) {
}
func (m *Composite) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Arr == Array2String{})
if var4 {
if err := fieldsTarget1.ZeroField("Arr"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Arr")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Arr.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var var7 bool
if len(m.ListInt) == 0 {
var7 = true
}
if var7 {
if err := fieldsTarget1.ZeroField("ListInt"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("ListInt")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
listTarget8, err := fieldTarget6.StartList(tt.NonOptional().Field(1).Type, len(m.ListInt))
if err != nil {
return err
}
for i, elem10 := range m.ListInt {
elemTarget9, err := listTarget8.StartElem(i)
if err != nil {
return err
}
if err := elemTarget9.FromInt(int64(elem10), tt.NonOptional().Field(1).Type.Elem()); err != nil {
return err
}
if err := listTarget8.FinishElem(elemTarget9); err != nil {
return err
}
}
if err := fieldTarget6.FinishList(listTarget8); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
var var13 bool
if len(m.MySet) == 0 {
var13 = true
}
if var13 {
if err := fieldsTarget1.ZeroField("MySet"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("MySet")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
setTarget14, err := fieldTarget12.StartSet(tt.NonOptional().Field(2).Type, len(m.MySet))
if err != nil {
return err
}
for key16 := range m.MySet {
keyTarget15, err := setTarget14.StartKey()
if err != nil {
return err
}
if err := keyTarget15.FromInt(int64(key16), tt.NonOptional().Field(2).Type.Key()); err != nil {
return err
}
if err := setTarget14.FinishKey(keyTarget15); err != nil {
return err
}
}
if err := fieldTarget12.FinishSet(setTarget14); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
return err
}
}
}
var var19 bool
if len(m.Map) == 0 {
var19 = true
}
if var19 {
if err := fieldsTarget1.ZeroField("Map"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget17, fieldTarget18, err := fieldsTarget1.StartField("Map")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
mapTarget20, err := fieldTarget18.StartMap(tt.NonOptional().Field(3).Type, len(m.Map))
if err != nil {
return err
}
for key22, value24 := range m.Map {
keyTarget21, err := mapTarget20.StartKey()
if err != nil {
return err
}
if err := keyTarget21.FromString(string(key22), tt.NonOptional().Field(3).Type.Key()); err != nil {
return err
}
valueTarget23, err := mapTarget20.FinishKeyStartField(keyTarget21)
if err != nil {
return err
}
if err := valueTarget23.FromInt(int64(value24), tt.NonOptional().Field(3).Type.Elem()); err != nil {
return err
}
if err := mapTarget20.FinishField(keyTarget21, valueTarget23); err != nil {
return err
}
}
if err := fieldTarget18.FinishMap(mapTarget20); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget17, fieldTarget18); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *Composite) MakeVDLTarget() vdl.Target {
return &CompositeTarget{Value: m}
}
type CompositeTarget struct {
Value *Composite
arrTarget Array2StringTarget
listIntTarget __VDLTarget1_list
mySetTarget __VDLTarget2_set
mapTarget __VDLTarget3_map
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *CompositeTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*Composite)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *CompositeTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Arr":
t.arrTarget.Value = &t.Value.Arr
target, err := &t.arrTarget, error(nil)
return nil, target, err
case "ListInt":
t.listIntTarget.Value = &t.Value.ListInt
target, err := &t.listIntTarget, error(nil)
return nil, target, err
case "MySet":
t.mySetTarget.Value = &t.Value.MySet
target, err := &t.mySetTarget, error(nil)
return nil, target, err
case "Map":
t.mapTarget.Value = &t.Value.Map
target, err := &t.mapTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Composite", name)
}
}
func (t *CompositeTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *CompositeTarget) ZeroField(name string) error {
switch name {
case "Arr":
t.Value.Arr = Array2String{}
return nil
case "ListInt":
t.Value.ListInt = []int32(nil)
return nil
case "MySet":
t.Value.MySet = map[int32]struct{}(nil)
return nil
case "Map":
t.Value.Map = map[string]int32(nil)
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Composite", name)
}
}
func (t *CompositeTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
// []int32
type __VDLTarget1_list struct {
Value *[]int32
elemTarget vdl.Int32Target
vdl.TargetBase
vdl.ListTargetBase
}
func (t *__VDLTarget1_list) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {
if ttWant := vdl.TypeOf((*[]int32)(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
if cap(*t.Value) < len {
*t.Value = make([]int32, len)
} else {
*t.Value = (*t.Value)[:len]
}
return t, nil
}
func (t *__VDLTarget1_list) StartElem(index int) (elem vdl.Target, _ error) {
t.elemTarget.Value = &(*t.Value)[index]
target, err := &t.elemTarget, error(nil)
return target, err
}
func (t *__VDLTarget1_list) FinishElem(elem vdl.Target) error {
return nil
}
func (t *__VDLTarget1_list) FinishList(elem vdl.ListTarget) error {
return nil
}
// map[int32]struct{}
type __VDLTarget2_set struct {
Value *map[int32]struct{}
currKey int32
keyTarget vdl.Int32Target
vdl.TargetBase
vdl.SetTargetBase
}
func (t *__VDLTarget2_set) StartSet(tt *vdl.Type, len int) (vdl.SetTarget, error) {
if ttWant := vdl.TypeOf((*map[int32]struct{})(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
*t.Value = make(map[int32]struct{})
return t, nil
}
func (t *__VDLTarget2_set) StartKey() (key vdl.Target, _ error) {
t.currKey = int32(0)
t.keyTarget.Value = &t.currKey
target, err := &t.keyTarget, error(nil)
return target, err
}
func (t *__VDLTarget2_set) FinishKey(key vdl.Target) error {
(*t.Value)[t.currKey] = struct{}{}
return nil
}
func (t *__VDLTarget2_set) FinishSet(list vdl.SetTarget) error {
if len(*t.Value) == 0 {
*t.Value = nil
}
return nil
}
// map[string]int32
type __VDLTarget3_map struct {
Value *map[string]int32
currKey string
currElem int32
keyTarget vdl.StringTarget
elemTarget vdl.Int32Target
vdl.TargetBase
vdl.MapTargetBase
}
func (t *__VDLTarget3_map) StartMap(tt *vdl.Type, len int) (vdl.MapTarget, error) {
if ttWant := vdl.TypeOf((*map[string]int32)(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
*t.Value = make(map[string]int32)
return t, nil
}
func (t *__VDLTarget3_map) StartKey() (key vdl.Target, _ error) {
t.currKey = ""
t.keyTarget.Value = &t.currKey
target, err := &t.keyTarget, error(nil)
return target, err
}
func (t *__VDLTarget3_map) FinishKeyStartField(key vdl.Target) (field vdl.Target, _ error) {
t.currElem = int32(0)
t.elemTarget.Value = &t.currElem
target, err := &t.elemTarget, error(nil)
return target, err
}
func (t *__VDLTarget3_map) FinishField(key, field vdl.Target) error {
(*t.Value)[t.currKey] = t.currElem
return nil
}
func (t *__VDLTarget3_map) FinishMap(elem vdl.MapTarget) error {
if len(*t.Value) == 0 {
*t.Value = nil
}
return nil
}
func (x Composite) VDLIsZero() (bool, error) {
if x.Arr != (Array2String{}) {
return false, nil
}
if len(x.ListInt) != 0 {
return false, nil
}
if len(x.MySet) != 0 {
return false, nil
}
if len(x.Map) != 0 {
return false, nil
}
return true, nil
}
func (x Composite) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Composite)(nil)).Elem()); err != nil {
return err
}
if x.Arr != (Array2String{}) {
if err := enc.NextField("Arr"); err != nil {
return err
}
if err := x.Arr.VDLWrite(enc); err != nil {
return err
}
}
if len(x.ListInt) != 0 {
if err := enc.NextField("ListInt"); err != nil {
return err
}
if err := __VDLWriteAnon_list_1(enc, x.ListInt); err != nil {
return err
}
}
if len(x.MySet) != 0 {
if err := enc.NextField("MySet"); err != nil {
return err
}
if err := __VDLWriteAnon_set_2(enc, x.MySet); err != nil {
return err
}
}
if len(x.Map) != 0 {
if err := enc.NextField("Map"); err != nil {
return err
}
if err := __VDLWriteAnon_map_3(enc, x.Map); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_list_1(enc vdl.Encoder, x []int32) error {
if err := enc.StartValue(vdl.TypeOf((*[]int32)(nil))); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for i := 0; i < len(x); i++ {
if err := enc.NextEntry(false); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int32)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(int64(x[i])); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_set_2(enc vdl.Encoder, x map[int32]struct{}) error {
if err := enc.StartValue(vdl.TypeOf((*map[int32]struct{})(nil))); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for key := range x {
if err := enc.NextEntry(false); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int32)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(int64(key)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_map_3(enc vdl.Encoder, x map[string]int32) error {
if err := enc.StartValue(vdl.TypeOf((*map[string]int32)(nil))); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for key, elem := range x {
if err := enc.NextEntry(false); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(key); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*int32)(nil))); err != nil {
return err
}
if err := enc.EncodeInt(int64(elem)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Composite) VDLRead(dec vdl.Decoder) error {
*x = Composite{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Arr":
if err := x.Arr.VDLRead(dec); err != nil {
return err
}
case "ListInt":
if err := __VDLReadAnon_list_1(dec, &x.ListInt); err != nil {
return err
}
case "MySet":
if err := __VDLReadAnon_set_2(dec, &x.MySet); err != nil {
return err
}
case "Map":
if err := __VDLReadAnon_map_3(dec, &x.Map); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
func __VDLReadAnon_list_1(dec vdl.Decoder, x *[]int32) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible list %T, from %v", *x, dec.Type())
}
switch len := dec.LenHint(); {
case len > 0:
*x = make([]int32, 0, len)
default:
*x = nil
}
for {
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case done:
return dec.FinishValue()
}
var elem int32
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeInt(32)
if err != nil {
return err
}
elem = int32(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
*x = append(*x, elem)
}
}
func __VDLReadAnon_set_2(dec vdl.Decoder, x *map[int32]struct{}) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible set %T, from %v", *x, dec.Type())
}
var tmpMap map[int32]struct{}
if len := dec.LenHint(); len > 0 {
tmpMap = make(map[int32]struct{}, len)
}
for {
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case done:
*x = tmpMap
return dec.FinishValue()
}
var key int32
{
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeInt(32)
if err != nil {
return err
}
key = int32(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
}
if tmpMap == nil {
tmpMap = make(map[int32]struct{})
}
tmpMap[key] = struct{}{}
}
}
func __VDLReadAnon_map_3(dec vdl.Decoder, x *map[string]int32) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible map %T, from %v", *x, dec.Type())
}
var tmpMap map[string]int32
if len := dec.LenHint(); len > 0 {
tmpMap = make(map[string]int32, len)
}
for {
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case done:
*x = tmpMap
return dec.FinishValue()
}
var key string
{
if err := dec.StartValue(); err != nil {
return err
}
var err error
if key, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
}
var elem int32
{
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeInt(32)
if err != nil {
return err
}
elem = int32(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
}
if tmpMap == nil {
tmpMap = make(map[string]int32)
}
tmpMap[key] = elem
}
}
type Times struct {
Stamp time.Time
Interval time.Duration
}
func (Times) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Times"`
}) {
}
func (m *Times) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var wireValue2 time_2.Time
if err := time_2.TimeFromNative(&wireValue2, m.Stamp); err != nil {
return err
}
var5 := (wireValue2 == time_2.Time{})
if var5 {
if err := fieldsTarget1.ZeroField("Stamp"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget3, fieldTarget4, err := fieldsTarget1.StartField("Stamp")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := wireValue2.FillVDLTarget(fieldTarget4, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget3, fieldTarget4); err != nil {
return err
}
}
}
var wireValue6 time_2.Duration
if err := time_2.DurationFromNative(&wireValue6, m.Interval); err != nil {
return err
}
var9 := (wireValue6 == time_2.Duration{})
if var9 {
if err := fieldsTarget1.ZeroField("Interval"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget7, fieldTarget8, err := fieldsTarget1.StartField("Interval")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := wireValue6.FillVDLTarget(fieldTarget8, tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget7, fieldTarget8); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *Times) MakeVDLTarget() vdl.Target {
return &TimesTarget{Value: m}
}
type TimesTarget struct {
Value *Times
stampTarget time_2.TimeTarget
intervalTarget time_2.DurationTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *TimesTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*Times)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *TimesTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Stamp":
t.stampTarget.Value = &t.Value.Stamp
target, err := &t.stampTarget, error(nil)
return nil, target, err
case "Interval":
t.intervalTarget.Value = &t.Value.Interval
target, err := &t.intervalTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Times", name)
}
}
func (t *TimesTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *TimesTarget) ZeroField(name string) error {
switch name {
case "Stamp":
t.Value.Stamp = func() time.Time {
var native time.Time
if err := vdl.Convert(&native, time_2.Time{}); err != nil {
panic(err)
}
return native
}()
return nil
case "Interval":
t.Value.Interval = func() time.Duration {
var native time.Duration
if err := vdl.Convert(&native, time_2.Duration{}); err != nil {
panic(err)
}
return native
}()
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Times", name)
}
}
func (t *TimesTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x Times) VDLIsZero() (bool, error) {
var wireStamp time_2.Time
if err := time_2.TimeFromNative(&wireStamp, x.Stamp); err != nil {
return false, err
}
if wireStamp != (time_2.Time{}) {
return false, nil
}
var wireInterval time_2.Duration
if err := time_2.DurationFromNative(&wireInterval, x.Interval); err != nil {
return false, err
}
if wireInterval != (time_2.Duration{}) {
return false, nil
}
return true, nil
}
func (x Times) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Times)(nil)).Elem()); err != nil {
return err
}
var wireStamp time_2.Time
if err := time_2.TimeFromNative(&wireStamp, x.Stamp); err != nil {
return err
}
if wireStamp != (time_2.Time{}) {
if err := enc.NextField("Stamp"); err != nil {
return err
}
if err := wireStamp.VDLWrite(enc); err != nil {
return err
}
}
var wireInterval time_2.Duration
if err := time_2.DurationFromNative(&wireInterval, x.Interval); err != nil {
return err
}
if wireInterval != (time_2.Duration{}) {
if err := enc.NextField("Interval"); err != nil {
return err
}
if err := wireInterval.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Times) VDLRead(dec vdl.Decoder) error {
*x = Times{}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Stamp":
var wire time_2.Time
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := time_2.TimeToNative(wire, &x.Stamp); err != nil {
return err
}
case "Interval":
var wire time_2.Duration
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := time_2.DurationToNative(wire, &x.Interval); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type Recursive struct {
Any *vom.RawBytes
Maybe *Times
Rec map[Array2String]Recursive
}
func (Recursive) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Recursive"`
}) {
}
func (m *Recursive) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := m.Any == nil || (m.Any.Type.Kind() == vdl.Any && m.Any.IsNil())
if var4 {
if err := fieldsTarget1.ZeroField("Any"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Any")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Any.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var7 := (m.Maybe == (*Times)(nil))
if var7 {
if err := fieldsTarget1.ZeroField("Maybe"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("Maybe")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Maybe.FillVDLTarget(fieldTarget6, tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
var var10 bool
if len(m.Rec) == 0 {
var10 = true
}
if var10 {
if err := fieldsTarget1.ZeroField("Rec"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("Rec")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
mapTarget11, err := fieldTarget9.StartMap(tt.NonOptional().Field(2).Type, len(m.Rec))
if err != nil {
return err
}
for key13, value15 := range m.Rec {
keyTarget12, err := mapTarget11.StartKey()
if err != nil {
return err
}
if err := key13.FillVDLTarget(keyTarget12, tt.NonOptional().Field(2).Type.Key()); err != nil {
return err
}
valueTarget14, err := mapTarget11.FinishKeyStartField(keyTarget12)
if err != nil {
return err
}
if err := value15.FillVDLTarget(valueTarget14, tt.NonOptional().Field(2).Type.Elem()); err != nil {
return err
}
if err := mapTarget11.FinishField(keyTarget12, valueTarget14); err != nil {
return err
}
}
if err := fieldTarget9.FinishMap(mapTarget11); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *Recursive) MakeVDLTarget() vdl.Target {
return &RecursiveTarget{Value: m}
}
type RecursiveTarget struct {
Value *Recursive
maybeTarget __VDLTarget4_optional
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *RecursiveTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*Recursive)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *RecursiveTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Any":
target, err := vdl.ReflectTarget(reflect.ValueOf(&t.Value.Any))
return nil, target, err
case "Maybe":
t.maybeTarget.Value = &t.Value.Maybe
target, err := &t.maybeTarget, error(nil)
return nil, target, err
case "Rec":
target, err := &__VDLTarget5_map{Value: &t.Value.Rec}, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Recursive", name)
}
}
func (t *RecursiveTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *RecursiveTarget) ZeroField(name string) error {
switch name {
case "Any":
t.Value.Any = vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType))
return nil
case "Maybe":
t.Value.Maybe = (*Times)(nil)
return nil
case "Rec":
t.Value.Rec = map[Array2String]Recursive(nil)
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Recursive", name)
}
}
func (t *RecursiveTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
// Optional Times
type __VDLTarget4_optional struct {
Value **Times
elemTarget TimesTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *__VDLTarget4_optional) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if *t.Value == nil {
*t.Value = &Times{}
}
t.elemTarget.Value = *t.Value
target, err := &t.elemTarget, error(nil)
if err != nil {
return nil, err
}
return target.StartFields(tt)
}
func (t *__VDLTarget4_optional) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (t *__VDLTarget4_optional) FromNil(tt *vdl.Type) error {
*t.Value = (*Times)(nil)
return nil
}
// map[Array2String]Recursive
type __VDLTarget5_map struct {
Value *map[Array2String]Recursive
currKey Array2String
currElem Recursive
keyTarget Array2StringTarget
vdl.TargetBase
vdl.MapTargetBase
}
func (t *__VDLTarget5_map) StartMap(tt *vdl.Type, len int) (vdl.MapTarget, error) {
if ttWant := vdl.TypeOf((*map[Array2String]Recursive)(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
*t.Value = make(map[Array2String]Recursive)
return t, nil
}
func (t *__VDLTarget5_map) StartKey() (key vdl.Target, _ error) {
t.currKey = Array2String{}
t.keyTarget.Value = &t.currKey
target, err := &t.keyTarget, error(nil)
return target, err
}
func (t *__VDLTarget5_map) FinishKeyStartField(key vdl.Target) (field vdl.Target, _ error) {
t.currElem = reflect.Zero(reflect.TypeOf(t.currElem)).Interface().(Recursive)
target, err := &RecursiveTarget{Value: &t.currElem}, error(nil)
return target, err
}
func (t *__VDLTarget5_map) FinishField(key, field vdl.Target) error {
(*t.Value)[t.currKey] = t.currElem
return nil
}
func (t *__VDLTarget5_map) FinishMap(elem vdl.MapTarget) error {
if len(*t.Value) == 0 {
*t.Value = nil
}
return nil
}
func (x Recursive) VDLIsZero() (bool, error) {
var isZeroAny bool
if x.Any != nil {
var err error
if isZeroAny, err = x.Any.VDLIsZero(); err != nil {
return false, err
}
}
if x.Any != nil && !isZeroAny {
return false, nil
}
if x.Maybe != nil {
return false, nil
}
if len(x.Rec) != 0 {
return false, nil
}
return true, nil
}
func (x Recursive) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Recursive)(nil)).Elem()); err != nil {
return err
}
var isZeroAny bool
if x.Any != nil {
var err error
if isZeroAny, err = x.Any.VDLIsZero(); err != nil {
return err
}
}
if x.Any != nil && !isZeroAny {
if err := enc.NextField("Any"); err != nil {
return err
}
if err := enc.StartValue(vdl.AnyType); err != nil {
return err
}
switch {
case x.Any.IsNil():
if err := enc.NilValue(x.Any.Type); err != nil {
return err
}
default:
if err := x.Any.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if x.Maybe != nil {
if err := enc.NextField("Maybe"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((**Times)(nil))); err != nil {
return err
}
enc.SetNextStartValueIsOptional()
if err := x.Maybe.VDLWrite(enc); err != nil {
return err
}
}
if len(x.Rec) != 0 {
if err := enc.NextField("Rec"); err != nil {
return err
}
if err := __VDLWriteAnon_map_4(enc, x.Rec); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_map_4(enc vdl.Encoder, x map[Array2String]Recursive) error {
if err := enc.StartValue(vdl.TypeOf((*map[Array2String]Recursive)(nil))); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for key, elem := range x {
if err := enc.NextEntry(false); err != nil {
return err
}
if err := key.VDLWrite(enc); err != nil {
return err
}
if err := elem.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Recursive) VDLRead(dec vdl.Decoder) error {
*x = Recursive{
Any: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Any":
if err := x.Any.VDLRead(dec); err != nil {
return err
}
case "Maybe":
if err := dec.StartValue(); err != nil {
return err
}
if dec.IsNil() {
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(x.Maybe), dec.Type()) {
return fmt.Errorf("incompatible optional %T, from %v", x.Maybe, dec.Type())
}
x.Maybe = nil
if err := dec.FinishValue(); err != nil {
return err
}
} else {
x.Maybe = new(Times)
dec.IgnoreNextStartValue()
if err := x.Maybe.VDLRead(dec); err != nil {
return err
}
}
case "Rec":
if err := __VDLReadAnon_map_4(dec, &x.Rec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
func __VDLReadAnon_map_4(dec vdl.Decoder, x *map[Array2String]Recursive) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible map %T, from %v", *x, dec.Type())
}
var tmpMap map[Array2String]Recursive
if len := dec.LenHint(); len > 0 {
tmpMap = make(map[Array2String]Recursive, len)
}
for {
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case done:
*x = tmpMap
return dec.FinishValue()
}
var key Array2String
{
if err := key.VDLRead(dec); err != nil {
return err
}
}
var elem Recursive
{
if err := elem.VDLRead(dec); err != nil {
return err
}
}
if tmpMap == nil {
tmpMap = make(map[Array2String]Recursive)
}
tmpMap[key] = elem
}
}
type (
// ActOrSatScore represents any single field of the ActOrSatScore union type.
ActOrSatScore interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// __VDLReflect describes the ActOrSatScore union type.
__VDLReflect(__ActOrSatScoreReflect)
FillVDLTarget(vdl.Target, *vdl.Type) error
VDLIsZero() (bool, error)
VDLWrite(vdl.Encoder) error
}
// ActOrSatScoreActScore represents field ActScore of the ActOrSatScore union type.
ActOrSatScoreActScore struct{ Value uint16 }
// ActOrSatScoreSatScore represents field SatScore of the ActOrSatScore union type.
ActOrSatScoreSatScore struct{ Value uint16 }
// __ActOrSatScoreReflect describes the ActOrSatScore union type.
__ActOrSatScoreReflect struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.ActOrSatScore"`
Type ActOrSatScore
UnionTargetFactory actOrSatScoreTargetFactory
Union struct {
ActScore ActOrSatScoreActScore
SatScore ActOrSatScoreSatScore
}
}
)
func (x ActOrSatScoreActScore) Index() int { return 0 }
func (x ActOrSatScoreActScore) Interface() interface{} { return x.Value }
func (x ActOrSatScoreActScore) Name() string { return "ActScore" }
func (x ActOrSatScoreActScore) __VDLReflect(__ActOrSatScoreReflect) {}
func (m ActOrSatScoreActScore) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("ActScore")
if err != nil {
return err
}
if err := fieldTarget3.FromUint(uint64(m.Value), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m ActOrSatScoreActScore) MakeVDLTarget() vdl.Target {
return nil
}
func (x ActOrSatScoreSatScore) Index() int { return 1 }
func (x ActOrSatScoreSatScore) Interface() interface{} { return x.Value }
func (x ActOrSatScoreSatScore) Name() string { return "SatScore" }
func (x ActOrSatScoreSatScore) __VDLReflect(__ActOrSatScoreReflect) {}
func (m ActOrSatScoreSatScore) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("SatScore")
if err != nil {
return err
}
if err := fieldTarget3.FromUint(uint64(m.Value), tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m ActOrSatScoreSatScore) MakeVDLTarget() vdl.Target {
return nil
}
type ActOrSatScoreTarget struct {
Value *ActOrSatScore
fieldName string
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *ActOrSatScoreTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*ActOrSatScore)(nil)); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *ActOrSatScoreTarget) StartField(name string) (key, field vdl.Target, _ error) {
t.fieldName = name
switch name {
case "ActScore":
val := uint16(0)
return nil, &vdl.Uint16Target{Value: &val}, nil
case "SatScore":
val := uint16(0)
return nil, &vdl.Uint16Target{Value: &val}, nil
default:
return nil, nil, fmt.Errorf("field %s not in union v.io/x/ref/cmd/sb/internal/demodb.ActOrSatScore", name)
}
}
func (t *ActOrSatScoreTarget) FinishField(_, fieldTarget vdl.Target) error {
switch t.fieldName {
case "ActScore":
*t.Value = ActOrSatScoreActScore{*(fieldTarget.(*vdl.Uint16Target)).Value}
case "SatScore":
*t.Value = ActOrSatScoreSatScore{*(fieldTarget.(*vdl.Uint16Target)).Value}
}
return nil
}
func (t *ActOrSatScoreTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
type actOrSatScoreTargetFactory struct{}
func (t actOrSatScoreTargetFactory) VDLMakeUnionTarget(union interface{}) (vdl.Target, error) {
if typedUnion, ok := union.(*ActOrSatScore); ok {
return &ActOrSatScoreTarget{Value: typedUnion}, nil
}
return nil, fmt.Errorf("got %T, want *ActOrSatScore", union)
}
func (x ActOrSatScoreActScore) VDLIsZero() (bool, error) {
return x.Value == 0, nil
}
func (x ActOrSatScoreSatScore) VDLIsZero() (bool, error) {
return false, nil
}
func (x ActOrSatScoreActScore) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*ActOrSatScore)(nil))); err != nil {
return err
}
if err := enc.NextField("ActScore"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*uint16)(nil))); err != nil {
return err
}
if err := enc.EncodeUint(uint64(x.Value)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x ActOrSatScoreSatScore) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*ActOrSatScore)(nil))); err != nil {
return err
}
if err := enc.NextField("SatScore"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*uint16)(nil))); err != nil {
return err
}
if err := enc.EncodeUint(uint64(x.Value)); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadActOrSatScore(dec vdl.Decoder, x *ActOrSatScore) error {
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(x), dec.Type()) {
return fmt.Errorf("incompatible union %T, from %v", x, dec.Type())
}
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "ActScore":
var field ActOrSatScoreActScore
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeUint(16)
if err != nil {
return err
}
field.Value = uint16(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
*x = field
case "SatScore":
var field ActOrSatScoreSatScore
if err := dec.StartValue(); err != nil {
return err
}
tmp, err := dec.DecodeUint(16)
if err != nil {
return err
}
field.Value = uint16(tmp)
if err := dec.FinishValue(); err != nil {
return err
}
*x = field
case "":
return fmt.Errorf("missing field in union %T, from %v", x, dec.Type())
default:
return fmt.Errorf("field %q not in union %T, from %v", f, x, dec.Type())
}
switch f, err := dec.NextField(); {
case err != nil:
return err
case f != "":
return fmt.Errorf("extra field %q in union %T, from %v", f, x, dec.Type())
}
return dec.FinishValue()
}
type Student struct {
Name string
TestTime time.Time
Score ActOrSatScore
}
func (Student) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.Student"`
}) {
}
func (m *Student) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.Name == "")
if var4 {
if err := fieldsTarget1.ZeroField("Name"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Name")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromString(string(m.Name), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var wireValue5 time_2.Time
if err := time_2.TimeFromNative(&wireValue5, m.TestTime); err != nil {
return err
}
var8 := (wireValue5 == time_2.Time{})
if var8 {
if err := fieldsTarget1.ZeroField("TestTime"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget6, fieldTarget7, err := fieldsTarget1.StartField("TestTime")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := wireValue5.FillVDLTarget(fieldTarget7, tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget6, fieldTarget7); err != nil {
return err
}
}
}
var var11 bool
if field, ok := m.Score.(ActOrSatScoreActScore); ok {
var12 := (field.Value == uint16(0))
var11 = var12
}
if var11 {
if err := fieldsTarget1.ZeroField("Score"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget9, fieldTarget10, err := fieldsTarget1.StartField("Score")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
unionValue13 := m.Score
if unionValue13 == nil {
unionValue13 = ActOrSatScoreActScore{}
}
if err := unionValue13.FillVDLTarget(fieldTarget10, tt.NonOptional().Field(2).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget9, fieldTarget10); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *Student) MakeVDLTarget() vdl.Target {
return &StudentTarget{Value: m}
}
type StudentTarget struct {
Value *Student
nameTarget vdl.StringTarget
testTimeTarget time_2.TimeTarget
scoreTarget ActOrSatScoreTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *StudentTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*Student)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *StudentTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "Name":
t.nameTarget.Value = &t.Value.Name
target, err := &t.nameTarget, error(nil)
return nil, target, err
case "TestTime":
t.testTimeTarget.Value = &t.Value.TestTime
target, err := &t.testTimeTarget, error(nil)
return nil, target, err
case "Score":
t.scoreTarget.Value = &t.Value.Score
target, err := &t.scoreTarget, error(nil)
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Student", name)
}
}
func (t *StudentTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *StudentTarget) ZeroField(name string) error {
switch name {
case "Name":
t.Value.Name = ""
return nil
case "TestTime":
t.Value.TestTime = func() time.Time {
var native time.Time
if err := vdl.Convert(&native, time_2.Time{}); err != nil {
panic(err)
}
return native
}()
return nil
case "Score":
t.Value.Score = ActOrSatScore(ActOrSatScoreActScore{})
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.Student", name)
}
}
func (t *StudentTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x Student) VDLIsZero() (bool, error) {
if x.Name != "" {
return false, nil
}
var wireTestTime time_2.Time
if err := time_2.TimeFromNative(&wireTestTime, x.TestTime); err != nil {
return false, err
}
if wireTestTime != (time_2.Time{}) {
return false, nil
}
var isZeroScore bool
if x.Score != nil {
var err error
if isZeroScore, err = x.Score.VDLIsZero(); err != nil {
return false, err
}
}
if x.Score != nil && !isZeroScore {
return false, nil
}
return true, nil
}
func (x Student) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*Student)(nil)).Elem()); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextField("Name"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.Name); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
var wireTestTime time_2.Time
if err := time_2.TimeFromNative(&wireTestTime, x.TestTime); err != nil {
return err
}
if wireTestTime != (time_2.Time{}) {
if err := enc.NextField("TestTime"); err != nil {
return err
}
if err := wireTestTime.VDLWrite(enc); err != nil {
return err
}
}
var isZeroScore bool
if x.Score != nil {
var err error
if isZeroScore, err = x.Score.VDLIsZero(); err != nil {
return err
}
}
if x.Score != nil && !isZeroScore {
if err := enc.NextField("Score"); err != nil {
return err
}
if err := x.Score.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Student) VDLRead(dec vdl.Decoder) error {
*x = Student{
Score: ActOrSatScoreActScore{},
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "Name":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.Name, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "TestTime":
var wire time_2.Time
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := time_2.TimeToNative(wire, &x.TestTime); err != nil {
return err
}
case "Score":
if err := VDLReadActOrSatScore(dec, &x.Score); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
type AnythingGoes struct {
NameOfType string
Anything *vom.RawBytes
}
func (AnythingGoes) __VDLReflect(struct {
Name string `vdl:"v.io/x/ref/cmd/sb/internal/demodb.AnythingGoes"`
}) {
}
func (m *AnythingGoes) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
fieldsTarget1, err := t.StartFields(tt)
if err != nil {
return err
}
var4 := (m.NameOfType == "")
if var4 {
if err := fieldsTarget1.ZeroField("NameOfType"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("NameOfType")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := fieldTarget3.FromString(string(m.NameOfType), tt.NonOptional().Field(0).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
return err
}
}
}
var7 := m.Anything == nil || (m.Anything.Type.Kind() == vdl.Any && m.Anything.IsNil())
if var7 {
if err := fieldsTarget1.ZeroField("Anything"); err != nil && err != vdl.ErrFieldNoExist {
return err
}
} else {
keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("Anything")
if err != vdl.ErrFieldNoExist {
if err != nil {
return err
}
if err := m.Anything.FillVDLTarget(fieldTarget6, tt.NonOptional().Field(1).Type); err != nil {
return err
}
if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
return err
}
}
}
if err := t.FinishFields(fieldsTarget1); err != nil {
return err
}
return nil
}
func (m *AnythingGoes) MakeVDLTarget() vdl.Target {
return &AnythingGoesTarget{Value: m}
}
type AnythingGoesTarget struct {
Value *AnythingGoes
nameOfTypeTarget vdl.StringTarget
vdl.TargetBase
vdl.FieldsTargetBase
}
func (t *AnythingGoesTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
if ttWant := vdl.TypeOf((*AnythingGoes)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
}
return t, nil
}
func (t *AnythingGoesTarget) StartField(name string) (key, field vdl.Target, _ error) {
switch name {
case "NameOfType":
t.nameOfTypeTarget.Value = &t.Value.NameOfType
target, err := &t.nameOfTypeTarget, error(nil)
return nil, target, err
case "Anything":
target, err := vdl.ReflectTarget(reflect.ValueOf(&t.Value.Anything))
return nil, target, err
default:
return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.AnythingGoes", name)
}
}
func (t *AnythingGoesTarget) FinishField(_, _ vdl.Target) error {
return nil
}
func (t *AnythingGoesTarget) ZeroField(name string) error {
switch name {
case "NameOfType":
t.Value.NameOfType = ""
return nil
case "Anything":
t.Value.Anything = vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType))
return nil
default:
return fmt.Errorf("field %s not in struct v.io/x/ref/cmd/sb/internal/demodb.AnythingGoes", name)
}
}
func (t *AnythingGoesTarget) FinishFields(_ vdl.FieldsTarget) error {
return nil
}
func (x AnythingGoes) VDLIsZero() (bool, error) {
if x.NameOfType != "" {
return false, nil
}
var isZeroAnything bool
if x.Anything != nil {
var err error
if isZeroAnything, err = x.Anything.VDLIsZero(); err != nil {
return false, err
}
}
if x.Anything != nil && !isZeroAnything {
return false, nil
}
return true, nil
}
func (x AnythingGoes) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(vdl.TypeOf((*AnythingGoes)(nil)).Elem()); err != nil {
return err
}
if x.NameOfType != "" {
if err := enc.NextField("NameOfType"); err != nil {
return err
}
if err := enc.StartValue(vdl.TypeOf((*string)(nil))); err != nil {
return err
}
if err := enc.EncodeString(x.NameOfType); err != nil {
return err
}
if err := enc.FinishValue(); err != nil {
return err
}
}
var isZeroAnything bool
if x.Anything != nil {
var err error
if isZeroAnything, err = x.Anything.VDLIsZero(); err != nil {
return err
}
}
if x.Anything != nil && !isZeroAnything {
if err := enc.NextField("Anything"); err != nil {
return err
}
if err := enc.StartValue(vdl.AnyType); err != nil {
return err
}
switch {
case x.Anything.IsNil():
if err := enc.NilValue(x.Anything.Type); err != nil {
return err
}
default:
if err := x.Anything.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.FinishValue(); err != nil {
return err
}
}
if err := enc.NextField(""); err != nil {
return err
}
return enc.FinishValue()
}
func (x *AnythingGoes) VDLRead(dec vdl.Decoder) error {
*x = AnythingGoes{
Anything: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
}
if err := dec.StartValue(); err != nil {
return err
}
if (dec.StackDepth() == 1 || dec.IsAny()) && !vdl.Compatible(vdl.TypeOf(*x), dec.Type()) {
return fmt.Errorf("incompatible struct %T, from %v", *x, dec.Type())
}
for {
f, err := dec.NextField()
if err != nil {
return err
}
switch f {
case "":
return dec.FinishValue()
case "NameOfType":
if err := dec.StartValue(); err != nil {
return err
}
var err error
if x.NameOfType, err = dec.DecodeString(); err != nil {
return err
}
if err := dec.FinishValue(); err != nil {
return err
}
case "Anything":
if err := x.Anything.VDLRead(dec); err != nil {
return err
}
default:
if err := dec.SkipValue(); err != nil {
return err
}
}
}
}
var __VDLInitCalled bool
// __VDLInit performs vdl initialization. It is safe to call multiple times.
// If you have an init ordering issue, just insert the following line verbatim
// into your source files in this package, right after the "package foo" clause:
//
// var _ = __VDLInit()
//
// The purpose of this function is to ensure that vdl initialization occurs in
// the right order, and very early in the init sequence. In particular, vdl
// registration and package variable initialization needs to occur before
// functions like vdl.TypeOf will work properly.
//
// This function returns a dummy value, so that it can be used to initialize the
// first var in the file, to take advantage of Go's defined init order.
func __VDLInit() struct{} {
if __VDLInitCalled {
return struct{}{}
}
__VDLInitCalled = true
// Register types.
vdl.Register((*AddressInfo)(nil))
vdl.Register((*CreditAgency)(nil))
vdl.Register((*ExperianRating)(nil))
vdl.Register((*EquifaxCreditReport)(nil))
vdl.Register((*ExperianCreditReport)(nil))
vdl.Register((*TransUnionCreditReport)(nil))
vdl.Register((*AgencyReport)(nil))
vdl.Register((*CreditReport)(nil))
vdl.Register((*Customer)(nil))
vdl.Register((*Invoice)(nil))
vdl.Register((*Numbers)(nil))
vdl.Register((*TitleOrValueType)(nil))
vdl.Register((*BazType)(nil))
vdl.Register((*BarType)(nil))
vdl.Register((*FooType)(nil))
vdl.Register((*Array2String)(nil))
vdl.Register((*Composite)(nil))
vdl.Register((*Times)(nil))
vdl.Register((*Recursive)(nil))
vdl.Register((*ActOrSatScore)(nil))
vdl.Register((*Student)(nil))
vdl.Register((*AnythingGoes)(nil))
return struct{}{}
}