// 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: base

// Package base is a simple single-file test of vdl functionality.
package base

import (
	"fmt"
	"io"
	"reflect"
	"v.io/v23"
	"v.io/v23/context"
	"v.io/v23/i18n"
	"v.io/v23/rpc"
	"v.io/v23/vdl"
	"v.io/v23/vdl/vdlconv"
	"v.io/v23/verror"
	"v.io/v23/vom"
)

var _ = __VDLInit() // Must be first; see __VDLInit comments for details.

//////////////////////////////////////////////////
// Type definitions

type NamedBool bool

func (NamedBool) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedBool"`
}) {
}

func (m *NamedBool) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromBool(bool((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedBool) MakeVDLTarget() vdl.Target {
	return &NamedBoolTarget{Value: m}
}

type NamedBoolTarget struct {
	Value *NamedBool
	vdl.TargetBase
}

func (t *NamedBoolTarget) FromBool(src bool, tt *vdl.Type) error {

	if ttWant := vdl.TypeOf((*NamedBool)(nil)); !vdl.Compatible(tt, ttWant) {
		return fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = NamedBool(src)

	return nil
}

func (x *NamedBool) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeBool()
	if err != nil {
		return err
	}
	*x = NamedBool(tmp)
	return dec.FinishValue()
}

type NamedByte byte

func (NamedByte) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedByte"`
}) {
}

func (m *NamedByte) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromUint(uint64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedByte) MakeVDLTarget() vdl.Target {
	return &NamedByteTarget{Value: m}
}

type NamedByteTarget struct {
	Value *NamedByte
	vdl.TargetBase
}

func (t *NamedByteTarget) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToUint8(src)
	if err != nil {
		return err
	}
	*t.Value = NamedByte(val)

	return nil
}
func (t *NamedByteTarget) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToUint8(src)
	if err != nil {
		return err
	}
	*t.Value = NamedByte(val)

	return nil
}
func (t *NamedByteTarget) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToUint8(src)
	if err != nil {
		return err
	}
	*t.Value = NamedByte(val)

	return nil
}

func (x *NamedByte) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeUint(8)
	if err != nil {
		return err
	}
	*x = NamedByte(tmp)
	return dec.FinishValue()
}

type NamedUint16 uint16

func (NamedUint16) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedUint16"`
}) {
}

func (m *NamedUint16) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromUint(uint64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedUint16) MakeVDLTarget() vdl.Target {
	return &NamedUint16Target{Value: m}
}

type NamedUint16Target struct {
	Value *NamedUint16
	vdl.TargetBase
}

func (t *NamedUint16Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToUint16(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint16(val)

	return nil
}
func (t *NamedUint16Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToUint16(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint16(val)

	return nil
}
func (t *NamedUint16Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToUint16(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint16(val)

	return nil
}

func (x *NamedUint16) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeUint(16)
	if err != nil {
		return err
	}
	*x = NamedUint16(tmp)
	return dec.FinishValue()
}

type NamedUint32 uint32

func (NamedUint32) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedUint32"`
}) {
}

func (m *NamedUint32) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromUint(uint64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedUint32) MakeVDLTarget() vdl.Target {
	return &NamedUint32Target{Value: m}
}

type NamedUint32Target struct {
	Value *NamedUint32
	vdl.TargetBase
}

func (t *NamedUint32Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToUint32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint32(val)

	return nil
}
func (t *NamedUint32Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToUint32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint32(val)

	return nil
}
func (t *NamedUint32Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToUint32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint32(val)

	return nil
}

func (x *NamedUint32) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeUint(32)
	if err != nil {
		return err
	}
	*x = NamedUint32(tmp)
	return dec.FinishValue()
}

type NamedUint64 uint64

func (NamedUint64) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedUint64"`
}) {
}

func (m *NamedUint64) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromUint(uint64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedUint64) MakeVDLTarget() vdl.Target {
	return &NamedUint64Target{Value: m}
}

type NamedUint64Target struct {
	Value *NamedUint64
	vdl.TargetBase
}

func (t *NamedUint64Target) FromUint(src uint64, tt *vdl.Type) error {

	*t.Value = NamedUint64(src)

	return nil
}
func (t *NamedUint64Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToUint64(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint64(val)

	return nil
}
func (t *NamedUint64Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToUint64(src)
	if err != nil {
		return err
	}
	*t.Value = NamedUint64(val)

	return nil
}

func (x *NamedUint64) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeUint(64)
	if err != nil {
		return err
	}
	*x = NamedUint64(tmp)
	return dec.FinishValue()
}

type NamedInt8 int8

func (NamedInt8) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedInt8"`
}) {
}

func (m *NamedInt8) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromInt(int64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedInt8) MakeVDLTarget() vdl.Target {
	return &NamedInt8Target{Value: m}
}

type NamedInt8Target struct {
	Value *NamedInt8
	vdl.TargetBase
}

func (t *NamedInt8Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToInt8(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt8(val)

	return nil
}
func (t *NamedInt8Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToInt8(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt8(val)

	return nil
}
func (t *NamedInt8Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToInt8(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt8(val)

	return nil
}

func (x *NamedInt8) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeInt(8)
	if err != nil {
		return err
	}
	*x = NamedInt8(tmp)
	return dec.FinishValue()
}

type NamedInt16 int16

func (NamedInt16) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedInt16"`
}) {
}

func (m *NamedInt16) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromInt(int64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedInt16) MakeVDLTarget() vdl.Target {
	return &NamedInt16Target{Value: m}
}

type NamedInt16Target struct {
	Value *NamedInt16
	vdl.TargetBase
}

func (t *NamedInt16Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToInt16(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt16(val)

	return nil
}
func (t *NamedInt16Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToInt16(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt16(val)

	return nil
}
func (t *NamedInt16Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToInt16(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt16(val)

	return nil
}

func (x *NamedInt16) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeInt(16)
	if err != nil {
		return err
	}
	*x = NamedInt16(tmp)
	return dec.FinishValue()
}

type NamedInt32 int32

func (NamedInt32) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedInt32"`
}) {
}

func (m *NamedInt32) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromInt(int64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedInt32) MakeVDLTarget() vdl.Target {
	return &NamedInt32Target{Value: m}
}

type NamedInt32Target struct {
	Value *NamedInt32
	vdl.TargetBase
}

func (t *NamedInt32Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToInt32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt32(val)

	return nil
}
func (t *NamedInt32Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToInt32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt32(val)

	return nil
}
func (t *NamedInt32Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToInt32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt32(val)

	return nil
}

func (x *NamedInt32) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeInt(32)
	if err != nil {
		return err
	}
	*x = NamedInt32(tmp)
	return dec.FinishValue()
}

type NamedInt64 int64

func (NamedInt64) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedInt64"`
}) {
}

func (m *NamedInt64) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromInt(int64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedInt64) MakeVDLTarget() vdl.Target {
	return &NamedInt64Target{Value: m}
}

type NamedInt64Target struct {
	Value *NamedInt64
	vdl.TargetBase
}

func (t *NamedInt64Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToInt64(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt64(val)

	return nil
}
func (t *NamedInt64Target) FromInt(src int64, tt *vdl.Type) error {

	*t.Value = NamedInt64(src)

	return nil
}
func (t *NamedInt64Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToInt64(src)
	if err != nil {
		return err
	}
	*t.Value = NamedInt64(val)

	return nil
}

func (x *NamedInt64) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeInt(64)
	if err != nil {
		return err
	}
	*x = NamedInt64(tmp)
	return dec.FinishValue()
}

type NamedFloat32 float32

func (NamedFloat32) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedFloat32"`
}) {
}

func (m *NamedFloat32) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromFloat(float64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedFloat32) MakeVDLTarget() vdl.Target {
	return &NamedFloat32Target{Value: m}
}

type NamedFloat32Target struct {
	Value *NamedFloat32
	vdl.TargetBase
}

func (t *NamedFloat32Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToFloat32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedFloat32(val)

	return nil
}
func (t *NamedFloat32Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToFloat32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedFloat32(val)

	return nil
}
func (t *NamedFloat32Target) FromFloat(src float64, tt *vdl.Type) error {

	val, err := vdlconv.Float64ToFloat32(src)
	if err != nil {
		return err
	}
	*t.Value = NamedFloat32(val)

	return nil
}

func (x *NamedFloat32) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeFloat(32)
	if err != nil {
		return err
	}
	*x = NamedFloat32(tmp)
	return dec.FinishValue()
}

type NamedFloat64 float64

func (NamedFloat64) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedFloat64"`
}) {
}

func (m *NamedFloat64) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromFloat(float64((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedFloat64) MakeVDLTarget() vdl.Target {
	return &NamedFloat64Target{Value: m}
}

type NamedFloat64Target struct {
	Value *NamedFloat64
	vdl.TargetBase
}

func (t *NamedFloat64Target) FromUint(src uint64, tt *vdl.Type) error {

	val, err := vdlconv.Uint64ToFloat64(src)
	if err != nil {
		return err
	}
	*t.Value = NamedFloat64(val)

	return nil
}
func (t *NamedFloat64Target) FromInt(src int64, tt *vdl.Type) error {

	val, err := vdlconv.Int64ToFloat64(src)
	if err != nil {
		return err
	}
	*t.Value = NamedFloat64(val)

	return nil
}
func (t *NamedFloat64Target) FromFloat(src float64, tt *vdl.Type) error {

	*t.Value = NamedFloat64(src)

	return nil
}

func (x *NamedFloat64) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeFloat(64)
	if err != nil {
		return err
	}
	*x = NamedFloat64(tmp)
	return dec.FinishValue()
}

type NamedString string

func (NamedString) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedString"`
}) {
}

func (m *NamedString) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromString(string((*m)), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedString) MakeVDLTarget() vdl.Target {
	return &NamedStringTarget{Value: m}
}

type NamedStringTarget struct {
	Value *NamedString
	vdl.TargetBase
}

func (t *NamedStringTarget) FromString(src string, tt *vdl.Type) error {

	if ttWant := vdl.TypeOf((*NamedString)(nil)); !vdl.Compatible(tt, ttWant) {
		return fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = NamedString(src)

	return nil
}

func (x *NamedString) VDLRead(dec vdl.Decoder) error {
	var err error
	if err = dec.StartValue(); err != nil {
		return err
	}
	tmp, err := dec.DecodeString()
	if err != nil {
		return err
	}
	*x = NamedString(tmp)
	return dec.FinishValue()
}

type NamedEnum int

const (
	NamedEnumA NamedEnum = iota
	NamedEnumB
	NamedEnumC
)

// NamedEnumAll holds all labels for NamedEnum.
var NamedEnumAll = [...]NamedEnum{NamedEnumA, NamedEnumB, NamedEnumC}

// NamedEnumFromString creates a NamedEnum from a string label.
func NamedEnumFromString(label string) (x NamedEnum, err error) {
	err = x.Set(label)
	return
}

// Set assigns label to x.
func (x *NamedEnum) Set(label string) error {
	switch label {
	case "A", "a":
		*x = NamedEnumA
		return nil
	case "B", "b":
		*x = NamedEnumB
		return nil
	case "C", "c":
		*x = NamedEnumC
		return nil
	}
	*x = -1
	return fmt.Errorf("unknown label %q in base.NamedEnum", label)
}

// String returns the string label of x.
func (x NamedEnum) String() string {
	switch x {
	case NamedEnumA:
		return "A"
	case NamedEnumB:
		return "B"
	case NamedEnumC:
		return "C"
	}
	return ""
}

func (NamedEnum) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedEnum"`
	Enum struct{ A, B, C string }
}) {
}

func (m *NamedEnum) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	if err := t.FromEnumLabel((*m).String(), tt); err != nil {
		return err
	}
	return nil
}

func (m *NamedEnum) MakeVDLTarget() vdl.Target {
	return &NamedEnumTarget{Value: m}
}

type NamedEnumTarget struct {
	Value *NamedEnum
	vdl.TargetBase
}

func (t *NamedEnumTarget) FromEnumLabel(src string, tt *vdl.Type) error {

	if ttWant := vdl.TypeOf((*NamedEnum)(nil)); !vdl.Compatible(tt, ttWant) {
		return fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	switch src {
	case "A":
		*t.Value = 0
	case "B":
		*t.Value = 1
	case "C":
		*t.Value = 2
	default:
		return fmt.Errorf("label %s not in enum NamedEnum", src)
	}

	return nil
}

func (x *NamedEnum) VDLRead(dec vdl.Decoder) error {
	var err 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 NamedArray [2]bool

func (NamedArray) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedArray"`
}) {
}

func (m *NamedArray) 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.FromBool(bool(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 *NamedArray) MakeVDLTarget() vdl.Target {
	return &NamedArrayTarget{Value: m}
}

// NamedArray
type NamedArrayTarget struct {
	Value      *NamedArray
	elemTarget vdl.BoolTarget
	vdl.TargetBase
	vdl.ListTargetBase
}

func (t *NamedArrayTarget) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {

	if ttWant := vdl.TypeOf((*NamedArray)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *NamedArrayTarget) StartElem(index int) (elem vdl.Target, _ error) {
	t.elemTarget.Value = &(*t.Value)[index]
	target, err := &t.elemTarget, error(nil)
	return target, err
}
func (t *NamedArrayTarget) FinishElem(elem vdl.Target) error {
	return nil
}
func (t *NamedArrayTarget) FinishList(elem vdl.ListTarget) error {

	return nil
}

func (x *NamedArray) VDLRead(dec vdl.Decoder) error {
	var err 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
		}
		if x[index], err = dec.DecodeBool(); err != nil {
			return err
		}
		if err = dec.FinishValue(); err != nil {
			return err
		}
		index++
	}
}

type NamedList []uint32

func (NamedList) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedList"`
}) {
}

func (m *NamedList) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	listTarget1, err := t.StartList(tt, len((*m)))
	if err != nil {
		return err
	}
	for i, elem3 := range *m {
		elemTarget2, err := listTarget1.StartElem(i)
		if err != nil {
			return err
		}
		if err := elemTarget2.FromUint(uint64(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 *NamedList) MakeVDLTarget() vdl.Target {
	return &NamedListTarget{Value: m}
}

// NamedList
type NamedListTarget struct {
	Value      *NamedList
	elemTarget vdl.Uint32Target
	vdl.TargetBase
	vdl.ListTargetBase
}

func (t *NamedListTarget) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {

	if ttWant := vdl.TypeOf((*NamedList)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	if cap(*t.Value) < len {
		*t.Value = make(NamedList, len)
	} else {
		*t.Value = (*t.Value)[:len]
	}
	return t, nil
}
func (t *NamedListTarget) StartElem(index int) (elem vdl.Target, _ error) {
	t.elemTarget.Value = &(*t.Value)[index]
	target, err := &t.elemTarget, error(nil)
	return target, err
}
func (t *NamedListTarget) FinishElem(elem vdl.Target) error {
	return nil
}
func (t *NamedListTarget) FinishList(elem vdl.ListTarget) error {

	return nil
}

func (x *NamedList) VDLRead(dec vdl.Decoder) error {
	var err 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(NamedList, 0, len)
	default:
		*x = nil
	}
	for {
		switch done, err := dec.NextEntry(); {
		case err != nil:
			return err
		case done:
			return dec.FinishValue()
		}
		var elem uint32
		if err = dec.StartValue(); err != nil {
			return err
		}
		tmp, err := dec.DecodeUint(32)
		if err != nil {
			return err
		}
		elem = uint32(tmp)
		if err = dec.FinishValue(); err != nil {
			return err
		}
		*x = append(*x, elem)
	}
}

type NamedSet map[string]struct{}

func (NamedSet) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedSet"`
}) {
}

func (m *NamedSet) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	setTarget1, err := t.StartSet(tt, len((*m)))
	if err != nil {
		return err
	}
	for key3 := range *m {
		keyTarget2, err := setTarget1.StartKey()
		if err != nil {
			return err
		}
		if err := keyTarget2.FromString(string(key3), tt.NonOptional().Key()); err != nil {
			return err
		}
		if err := setTarget1.FinishKey(keyTarget2); err != nil {
			return err
		}
	}
	if err := t.FinishSet(setTarget1); err != nil {
		return err
	}
	return nil
}

func (m *NamedSet) MakeVDLTarget() vdl.Target {
	return &NamedSetTarget{Value: m}
}

type NamedSetTarget struct {
	Value     *NamedSet
	currKey   string
	keyTarget vdl.StringTarget
	vdl.TargetBase
	vdl.SetTargetBase
}

func (t *NamedSetTarget) StartSet(tt *vdl.Type, len int) (vdl.SetTarget, error) {

	if ttWant := vdl.TypeOf((*NamedSet)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = make(NamedSet)
	return t, nil
}
func (t *NamedSetTarget) StartKey() (key vdl.Target, _ error) {
	t.currKey = ""
	t.keyTarget.Value = &t.currKey
	target, err := &t.keyTarget, error(nil)
	return target, err
}
func (t *NamedSetTarget) FinishKey(key vdl.Target) error {
	(*t.Value)[t.currKey] = struct{}{}
	return nil
}
func (t *NamedSetTarget) FinishSet(list vdl.SetTarget) error {
	if len(*t.Value) == 0 {
		*t.Value = nil
	}

	return nil
}

func (x *NamedSet) VDLRead(dec vdl.Decoder) error {
	var err 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 NamedSet
	if len := dec.LenHint(); len > 0 {
		tmpMap = make(NamedSet, 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
			}
			if key, err = dec.DecodeString(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		}
		if tmpMap == nil {
			tmpMap = make(NamedSet)
		}
		tmpMap[key] = struct{}{}
	}
}

type NamedMap map[string]float32

func (NamedMap) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedMap"`
}) {
}

func (m *NamedMap) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	mapTarget1, err := t.StartMap(tt, len((*m)))
	if err != nil {
		return err
	}
	for key3, value5 := range *m {
		keyTarget2, err := mapTarget1.StartKey()
		if err != nil {
			return err
		}
		if err := keyTarget2.FromString(string(key3), tt.NonOptional().Key()); err != nil {
			return err
		}
		valueTarget4, err := mapTarget1.FinishKeyStartField(keyTarget2)
		if err != nil {
			return err
		}
		if err := valueTarget4.FromFloat(float64(value5), tt.NonOptional().Elem()); err != nil {
			return err
		}
		if err := mapTarget1.FinishField(keyTarget2, valueTarget4); err != nil {
			return err
		}
	}
	if err := t.FinishMap(mapTarget1); err != nil {
		return err
	}
	return nil
}

func (m *NamedMap) MakeVDLTarget() vdl.Target {
	return &NamedMapTarget{Value: m}
}

type NamedMapTarget struct {
	Value      *NamedMap
	currKey    string
	currElem   float32
	keyTarget  vdl.StringTarget
	elemTarget vdl.Float32Target
	vdl.TargetBase
	vdl.MapTargetBase
}

func (t *NamedMapTarget) StartMap(tt *vdl.Type, len int) (vdl.MapTarget, error) {

	if ttWant := vdl.TypeOf((*NamedMap)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = make(NamedMap)
	return t, nil
}
func (t *NamedMapTarget) StartKey() (key vdl.Target, _ error) {
	t.currKey = ""
	t.keyTarget.Value = &t.currKey
	target, err := &t.keyTarget, error(nil)
	return target, err
}
func (t *NamedMapTarget) FinishKeyStartField(key vdl.Target) (field vdl.Target, _ error) {
	t.currElem = float32(0)
	t.elemTarget.Value = &t.currElem
	target, err := &t.elemTarget, error(nil)
	return target, err
}
func (t *NamedMapTarget) FinishField(key, field vdl.Target) error {
	(*t.Value)[t.currKey] = t.currElem
	return nil
}
func (t *NamedMapTarget) FinishMap(elem vdl.MapTarget) error {
	if len(*t.Value) == 0 {
		*t.Value = nil
	}

	return nil
}

func (x *NamedMap) VDLRead(dec vdl.Decoder) error {
	var err 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 NamedMap
	if len := dec.LenHint(); len > 0 {
		tmpMap = make(NamedMap, 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
			}
			if key, err = dec.DecodeString(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		}
		var elem float32
		{
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeFloat(32)
			if err != nil {
				return err
			}
			elem = float32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		}
		if tmpMap == nil {
			tmpMap = make(NamedMap)
		}
		tmpMap[key] = elem
	}
}

type NamedStruct struct {
	A bool
	B string
	C int32
}

func (NamedStruct) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedStruct"`
}) {
}

func (m *NamedStruct) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	var4 := (m.A == false)
	if var4 {
		if err := fieldsTarget1.ZeroField("A"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget3.FromBool(bool(m.A), tt.NonOptional().Field(0).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
				return err
			}
		}
	}
	var7 := (m.B == "")
	if var7 {
		if err := fieldsTarget1.ZeroField("B"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("B")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget6.FromString(string(m.B), tt.NonOptional().Field(1).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
				return err
			}
		}
	}
	var10 := (m.C == int32(0))
	if var10 {
		if err := fieldsTarget1.ZeroField("C"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("C")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget9.FromInt(int64(m.C), tt.NonOptional().Field(2).Type); 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 *NamedStruct) MakeVDLTarget() vdl.Target {
	return &NamedStructTarget{Value: m}
}

type NamedStructTarget struct {
	Value   *NamedStruct
	aTarget vdl.BoolTarget
	bTarget vdl.StringTarget
	cTarget vdl.Int32Target
	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *NamedStructTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {

	if ttWant := vdl.TypeOf((*NamedStruct)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *NamedStructTarget) StartField(name string) (key, field vdl.Target, _ error) {
	switch name {
	case "A":
		t.aTarget.Value = &t.Value.A
		target, err := &t.aTarget, error(nil)
		return nil, target, err
	case "B":
		t.bTarget.Value = &t.Value.B
		target, err := &t.bTarget, error(nil)
		return nil, target, err
	case "C":
		t.cTarget.Value = &t.Value.C
		target, err := &t.cTarget, error(nil)
		return nil, target, err
	default:
		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.NamedStruct", name)
	}
}
func (t *NamedStructTarget) FinishField(_, _ vdl.Target) error {
	return nil
}
func (t *NamedStructTarget) ZeroField(name string) error {
	switch name {
	case "A":
		t.Value.A = false
		return nil
	case "B":
		t.Value.B = ""
		return nil
	case "C":
		t.Value.C = int32(0)
		return nil
	default:
		return fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.NamedStruct", name)
	}
}
func (t *NamedStructTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

func (x *NamedStruct) VDLRead(dec vdl.Decoder) error {
	*x = NamedStruct{}
	var err 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 struct %T, from %v", *x, dec.Type())
	}
	for {
		f, err := dec.NextField()
		if err != nil {
			return err
		}
		switch f {
		case "":
			return dec.FinishValue()
		case "A":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A, err = dec.DecodeBool(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "B":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.B, err = dec.DecodeString(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "C":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(32)
			if err != nil {
				return err
			}
			x.C = int32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		default:
			if err = dec.SkipValue(); err != nil {
				return err
			}
		}
	}
}

type (
	// NamedUnion represents any single field of the NamedUnion union type.
	NamedUnion 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 NamedUnion union type.
		__VDLReflect(__NamedUnionReflect)
		FillVDLTarget(vdl.Target, *vdl.Type) error
	}
	// NamedUnionA represents field A of the NamedUnion union type.
	NamedUnionA struct{ Value bool }
	// NamedUnionB represents field B of the NamedUnion union type.
	NamedUnionB struct{ Value string }
	// NamedUnionC represents field C of the NamedUnion union type.
	NamedUnionC struct{ Value int32 }
	// __NamedUnionReflect describes the NamedUnion union type.
	__NamedUnionReflect struct {
		Name               string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NamedUnion"`
		Type               NamedUnion
		UnionTargetFactory namedUnionTargetFactory
		Union              struct {
			A NamedUnionA
			B NamedUnionB
			C NamedUnionC
		}
	}
)

func (x NamedUnionA) Index() int                       { return 0 }
func (x NamedUnionA) Interface() interface{}           { return x.Value }
func (x NamedUnionA) Name() string                     { return "A" }
func (x NamedUnionA) __VDLReflect(__NamedUnionReflect) {}

func (m NamedUnionA) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A")
	if err != nil {
		return err
	}
	if err := fieldTarget3.FromBool(bool(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 NamedUnionA) MakeVDLTarget() vdl.Target {
	return nil
}

func (x NamedUnionB) Index() int                       { return 1 }
func (x NamedUnionB) Interface() interface{}           { return x.Value }
func (x NamedUnionB) Name() string                     { return "B" }
func (x NamedUnionB) __VDLReflect(__NamedUnionReflect) {}

func (m NamedUnionB) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("B")
	if err != nil {
		return err
	}
	if err := fieldTarget3.FromString(string(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 NamedUnionB) MakeVDLTarget() vdl.Target {
	return nil
}

func (x NamedUnionC) Index() int                       { return 2 }
func (x NamedUnionC) Interface() interface{}           { return x.Value }
func (x NamedUnionC) Name() string                     { return "C" }
func (x NamedUnionC) __VDLReflect(__NamedUnionReflect) {}

func (m NamedUnionC) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("C")
	if err != nil {
		return err
	}
	if err := fieldTarget3.FromInt(int64(m.Value), 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 NamedUnionC) MakeVDLTarget() vdl.Target {
	return nil
}

type NamedUnionTarget struct {
	Value     *NamedUnion
	fieldName string

	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *NamedUnionTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {
	if ttWant := vdl.TypeOf((*NamedUnion)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}

	return t, nil
}
func (t *NamedUnionTarget) StartField(name string) (key, field vdl.Target, _ error) {
	t.fieldName = name
	switch name {
	case "A":
		val := false
		return nil, &vdl.BoolTarget{Value: &val}, nil
	case "B":
		val := ""
		return nil, &vdl.StringTarget{Value: &val}, nil
	case "C":
		val := int32(0)
		return nil, &vdl.Int32Target{Value: &val}, nil
	default:
		return nil, nil, fmt.Errorf("field %s not in union v.io/x/ref/lib/vdl/testdata/base.NamedUnion", name)
	}
}
func (t *NamedUnionTarget) FinishField(_, fieldTarget vdl.Target) error {
	switch t.fieldName {
	case "A":
		*t.Value = NamedUnionA{*(fieldTarget.(*vdl.BoolTarget)).Value}
	case "B":
		*t.Value = NamedUnionB{*(fieldTarget.(*vdl.StringTarget)).Value}
	case "C":
		*t.Value = NamedUnionC{*(fieldTarget.(*vdl.Int32Target)).Value}
	}
	return nil
}
func (t *NamedUnionTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

type namedUnionTargetFactory struct{}

func (t namedUnionTargetFactory) VDLMakeUnionTarget(union interface{}) (vdl.Target, error) {
	if typedUnion, ok := union.(*NamedUnion); ok {
		return &NamedUnionTarget{Value: typedUnion}, nil
	}
	return nil, fmt.Errorf("got %T, want *NamedUnion", union)
}

func VDLReadNamedUnion(dec vdl.Decoder, x *NamedUnion) error {
	var err 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 "A":
		var field NamedUnionA
		if err = dec.StartValue(); err != nil {
			return err
		}
		if field.Value, err = dec.DecodeBool(); err != nil {
			return err
		}
		if err = dec.FinishValue(); err != nil {
			return err
		}
		*x = field
	case "B":
		var field NamedUnionB
		if err = dec.StartValue(); err != nil {
			return err
		}
		if field.Value, err = dec.DecodeString(); err != nil {
			return err
		}
		if err = dec.FinishValue(); err != nil {
			return err
		}
		*x = field
	case "C":
		var field NamedUnionC
		if err = dec.StartValue(); err != nil {
			return err
		}
		tmp, err := dec.DecodeInt(32)
		if err != nil {
			return err
		}
		field.Value = int32(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 Scalars struct {
	A0  bool
	A1  byte
	A2  uint16
	A3  uint32
	A4  uint64
	A5  int8
	A6  int16
	A7  int32
	A8  int64
	A9  float32
	A10 float64
	A11 string
	A12 error
	A13 *vom.RawBytes
	A14 *vdl.Type
	B0  NamedBool
	B1  NamedByte
	B2  NamedUint16
	B3  NamedUint32
	B4  NamedUint64
	B5  NamedInt8
	B6  NamedInt16
	B7  NamedInt32
	B8  NamedInt64
	B9  NamedFloat32
	B10 NamedFloat64
	B11 NamedString
	B12 NamedEnum
	B13 NamedUnion
}

func (Scalars) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.Scalars"`
}) {
}

func (m *Scalars) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	var4 := (m.A0 == false)
	if var4 {
		if err := fieldsTarget1.ZeroField("A0"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A0")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget3.FromBool(bool(m.A0), tt.NonOptional().Field(0).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
				return err
			}
		}
	}
	var7 := (m.A1 == byte(0))
	if var7 {
		if err := fieldsTarget1.ZeroField("A1"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("A1")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget6.FromUint(uint64(m.A1), tt.NonOptional().Field(1).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
				return err
			}
		}
	}
	var10 := (m.A2 == uint16(0))
	if var10 {
		if err := fieldsTarget1.ZeroField("A2"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("A2")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget9.FromUint(uint64(m.A2), tt.NonOptional().Field(2).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
				return err
			}
		}
	}
	var13 := (m.A3 == uint32(0))
	if var13 {
		if err := fieldsTarget1.ZeroField("A3"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("A3")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget12.FromUint(uint64(m.A3), tt.NonOptional().Field(3).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
				return err
			}
		}
	}
	var16 := (m.A4 == uint64(0))
	if var16 {
		if err := fieldsTarget1.ZeroField("A4"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget14, fieldTarget15, err := fieldsTarget1.StartField("A4")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget15.FromUint(uint64(m.A4), tt.NonOptional().Field(4).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget14, fieldTarget15); err != nil {
				return err
			}
		}
	}
	var19 := (m.A5 == int8(0))
	if var19 {
		if err := fieldsTarget1.ZeroField("A5"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget17, fieldTarget18, err := fieldsTarget1.StartField("A5")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget18.FromInt(int64(m.A5), tt.NonOptional().Field(5).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget17, fieldTarget18); err != nil {
				return err
			}
		}
	}
	var22 := (m.A6 == int16(0))
	if var22 {
		if err := fieldsTarget1.ZeroField("A6"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget20, fieldTarget21, err := fieldsTarget1.StartField("A6")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget21.FromInt(int64(m.A6), tt.NonOptional().Field(6).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget20, fieldTarget21); err != nil {
				return err
			}
		}
	}
	var25 := (m.A7 == int32(0))
	if var25 {
		if err := fieldsTarget1.ZeroField("A7"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget23, fieldTarget24, err := fieldsTarget1.StartField("A7")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget24.FromInt(int64(m.A7), tt.NonOptional().Field(7).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget23, fieldTarget24); err != nil {
				return err
			}
		}
	}
	var28 := (m.A8 == int64(0))
	if var28 {
		if err := fieldsTarget1.ZeroField("A8"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget26, fieldTarget27, err := fieldsTarget1.StartField("A8")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget27.FromInt(int64(m.A8), tt.NonOptional().Field(8).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget26, fieldTarget27); err != nil {
				return err
			}
		}
	}
	var31 := (m.A9 == float32(0))
	if var31 {
		if err := fieldsTarget1.ZeroField("A9"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget29, fieldTarget30, err := fieldsTarget1.StartField("A9")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget30.FromFloat(float64(m.A9), tt.NonOptional().Field(9).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget29, fieldTarget30); err != nil {
				return err
			}
		}
	}
	var34 := (m.A10 == float64(0))
	if var34 {
		if err := fieldsTarget1.ZeroField("A10"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget32, fieldTarget33, err := fieldsTarget1.StartField("A10")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget33.FromFloat(float64(m.A10), tt.NonOptional().Field(10).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget32, fieldTarget33); err != nil {
				return err
			}
		}
	}
	var37 := (m.A11 == "")
	if var37 {
		if err := fieldsTarget1.ZeroField("A11"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget35, fieldTarget36, err := fieldsTarget1.StartField("A11")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget36.FromString(string(m.A11), tt.NonOptional().Field(11).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget35, fieldTarget36); err != nil {
				return err
			}
		}
	}
	var40 := (m.A12 == (error)(nil))
	if var40 {
		if err := fieldsTarget1.ZeroField("A12"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget38, fieldTarget39, err := fieldsTarget1.StartField("A12")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			var wireError41 vdl.WireError
			if err := verror.WireFromNative(&wireError41, m.A12); err != nil {
				return err
			}
			if err := wireError41.FillVDLTarget(fieldTarget39, vdl.ErrorType); err != nil {
				return err
			}

			if err := fieldsTarget1.FinishField(keyTarget38, fieldTarget39); err != nil {
				return err
			}
		}
	}
	var44 := m.A13 == nil || m.A13.IsNilAny()
	if var44 {
		if err := fieldsTarget1.ZeroField("A13"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget42, fieldTarget43, err := fieldsTarget1.StartField("A13")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.A13.FillVDLTarget(fieldTarget43, tt.NonOptional().Field(13).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget42, fieldTarget43); err != nil {
				return err
			}
		}
	}
	var47 := (m.A14 == nil || m.A14 == vdl.AnyType)
	if var47 {
		if err := fieldsTarget1.ZeroField("A14"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget45, fieldTarget46, err := fieldsTarget1.StartField("A14")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			typeObjectVal48 := m.A14
			if typeObjectVal48 == nil {
				typeObjectVal48 = vdl.AnyType
			}
			if err := fieldTarget46.FromTypeObject(typeObjectVal48); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget45, fieldTarget46); err != nil {
				return err
			}
		}
	}
	var51 := (m.B0 == NamedBool(false))
	if var51 {
		if err := fieldsTarget1.ZeroField("B0"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget49, fieldTarget50, err := fieldsTarget1.StartField("B0")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B0.FillVDLTarget(fieldTarget50, tt.NonOptional().Field(15).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget49, fieldTarget50); err != nil {
				return err
			}
		}
	}
	var54 := (m.B1 == NamedByte(0))
	if var54 {
		if err := fieldsTarget1.ZeroField("B1"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget52, fieldTarget53, err := fieldsTarget1.StartField("B1")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B1.FillVDLTarget(fieldTarget53, tt.NonOptional().Field(16).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget52, fieldTarget53); err != nil {
				return err
			}
		}
	}
	var57 := (m.B2 == NamedUint16(0))
	if var57 {
		if err := fieldsTarget1.ZeroField("B2"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget55, fieldTarget56, err := fieldsTarget1.StartField("B2")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B2.FillVDLTarget(fieldTarget56, tt.NonOptional().Field(17).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget55, fieldTarget56); err != nil {
				return err
			}
		}
	}
	var60 := (m.B3 == NamedUint32(0))
	if var60 {
		if err := fieldsTarget1.ZeroField("B3"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget58, fieldTarget59, err := fieldsTarget1.StartField("B3")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B3.FillVDLTarget(fieldTarget59, tt.NonOptional().Field(18).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget58, fieldTarget59); err != nil {
				return err
			}
		}
	}
	var63 := (m.B4 == NamedUint64(0))
	if var63 {
		if err := fieldsTarget1.ZeroField("B4"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget61, fieldTarget62, err := fieldsTarget1.StartField("B4")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B4.FillVDLTarget(fieldTarget62, tt.NonOptional().Field(19).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget61, fieldTarget62); err != nil {
				return err
			}
		}
	}
	var66 := (m.B5 == NamedInt8(0))
	if var66 {
		if err := fieldsTarget1.ZeroField("B5"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget64, fieldTarget65, err := fieldsTarget1.StartField("B5")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B5.FillVDLTarget(fieldTarget65, tt.NonOptional().Field(20).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget64, fieldTarget65); err != nil {
				return err
			}
		}
	}
	var69 := (m.B6 == NamedInt16(0))
	if var69 {
		if err := fieldsTarget1.ZeroField("B6"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget67, fieldTarget68, err := fieldsTarget1.StartField("B6")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B6.FillVDLTarget(fieldTarget68, tt.NonOptional().Field(21).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget67, fieldTarget68); err != nil {
				return err
			}
		}
	}
	var72 := (m.B7 == NamedInt32(0))
	if var72 {
		if err := fieldsTarget1.ZeroField("B7"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget70, fieldTarget71, err := fieldsTarget1.StartField("B7")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B7.FillVDLTarget(fieldTarget71, tt.NonOptional().Field(22).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget70, fieldTarget71); err != nil {
				return err
			}
		}
	}
	var75 := (m.B8 == NamedInt64(0))
	if var75 {
		if err := fieldsTarget1.ZeroField("B8"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget73, fieldTarget74, err := fieldsTarget1.StartField("B8")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B8.FillVDLTarget(fieldTarget74, tt.NonOptional().Field(23).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget73, fieldTarget74); err != nil {
				return err
			}
		}
	}
	var78 := (m.B9 == NamedFloat32(0))
	if var78 {
		if err := fieldsTarget1.ZeroField("B9"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget76, fieldTarget77, err := fieldsTarget1.StartField("B9")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B9.FillVDLTarget(fieldTarget77, tt.NonOptional().Field(24).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget76, fieldTarget77); err != nil {
				return err
			}
		}
	}
	var81 := (m.B10 == NamedFloat64(0))
	if var81 {
		if err := fieldsTarget1.ZeroField("B10"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget79, fieldTarget80, err := fieldsTarget1.StartField("B10")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B10.FillVDLTarget(fieldTarget80, tt.NonOptional().Field(25).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget79, fieldTarget80); err != nil {
				return err
			}
		}
	}
	var84 := (m.B11 == NamedString(""))
	if var84 {
		if err := fieldsTarget1.ZeroField("B11"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget82, fieldTarget83, err := fieldsTarget1.StartField("B11")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B11.FillVDLTarget(fieldTarget83, tt.NonOptional().Field(26).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget82, fieldTarget83); err != nil {
				return err
			}
		}
	}
	var87 := (m.B12 == NamedEnumA)
	if var87 {
		if err := fieldsTarget1.ZeroField("B12"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget85, fieldTarget86, err := fieldsTarget1.StartField("B12")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B12.FillVDLTarget(fieldTarget86, tt.NonOptional().Field(27).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget85, fieldTarget86); err != nil {
				return err
			}
		}
	}
	var var90 bool
	if field, ok := m.B13.(NamedUnionA); ok {

		var91 := (field.Value == false)
		var90 = var91
	}
	if var90 {
		if err := fieldsTarget1.ZeroField("B13"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget88, fieldTarget89, err := fieldsTarget1.StartField("B13")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			unionValue92 := m.B13
			if unionValue92 == nil {
				unionValue92 = NamedUnionA{}
			}
			if err := unionValue92.FillVDLTarget(fieldTarget89, tt.NonOptional().Field(28).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget88, fieldTarget89); err != nil {
				return err
			}
		}
	}
	if err := t.FinishFields(fieldsTarget1); err != nil {
		return err
	}
	return nil
}

func (m *Scalars) MakeVDLTarget() vdl.Target {
	return &ScalarsTarget{Value: m}
}

type ScalarsTarget struct {
	Value     *Scalars
	a0Target  vdl.BoolTarget
	a1Target  vdl.ByteTarget
	a2Target  vdl.Uint16Target
	a3Target  vdl.Uint32Target
	a4Target  vdl.Uint64Target
	a5Target  vdl.Int8Target
	a6Target  vdl.Int16Target
	a7Target  vdl.Int32Target
	a8Target  vdl.Int64Target
	a9Target  vdl.Float32Target
	a10Target vdl.Float64Target
	a11Target vdl.StringTarget
	a12Target verror.ErrorTarget

	a14Target vdl.TypeObjectTarget
	b0Target  NamedBoolTarget
	b1Target  NamedByteTarget
	b2Target  NamedUint16Target
	b3Target  NamedUint32Target
	b4Target  NamedUint64Target
	b5Target  NamedInt8Target
	b6Target  NamedInt16Target
	b7Target  NamedInt32Target
	b8Target  NamedInt64Target
	b9Target  NamedFloat32Target
	b10Target NamedFloat64Target
	b11Target NamedStringTarget
	b12Target NamedEnumTarget
	b13Target NamedUnionTarget
	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *ScalarsTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {

	if ttWant := vdl.TypeOf((*Scalars)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *ScalarsTarget) StartField(name string) (key, field vdl.Target, _ error) {
	switch name {
	case "A0":
		t.a0Target.Value = &t.Value.A0
		target, err := &t.a0Target, error(nil)
		return nil, target, err
	case "A1":
		t.a1Target.Value = &t.Value.A1
		target, err := &t.a1Target, error(nil)
		return nil, target, err
	case "A2":
		t.a2Target.Value = &t.Value.A2
		target, err := &t.a2Target, error(nil)
		return nil, target, err
	case "A3":
		t.a3Target.Value = &t.Value.A3
		target, err := &t.a3Target, error(nil)
		return nil, target, err
	case "A4":
		t.a4Target.Value = &t.Value.A4
		target, err := &t.a4Target, error(nil)
		return nil, target, err
	case "A5":
		t.a5Target.Value = &t.Value.A5
		target, err := &t.a5Target, error(nil)
		return nil, target, err
	case "A6":
		t.a6Target.Value = &t.Value.A6
		target, err := &t.a6Target, error(nil)
		return nil, target, err
	case "A7":
		t.a7Target.Value = &t.Value.A7
		target, err := &t.a7Target, error(nil)
		return nil, target, err
	case "A8":
		t.a8Target.Value = &t.Value.A8
		target, err := &t.a8Target, error(nil)
		return nil, target, err
	case "A9":
		t.a9Target.Value = &t.Value.A9
		target, err := &t.a9Target, error(nil)
		return nil, target, err
	case "A10":
		t.a10Target.Value = &t.Value.A10
		target, err := &t.a10Target, error(nil)
		return nil, target, err
	case "A11":
		t.a11Target.Value = &t.Value.A11
		target, err := &t.a11Target, error(nil)
		return nil, target, err
	case "A12":
		t.a12Target.Value = &t.Value.A12
		target, err := &t.a12Target, error(nil)
		return nil, target, err
	case "A13":
		target, err := vdl.ReflectTarget(reflect.ValueOf(&t.Value.A13))
		return nil, target, err
	case "A14":
		t.a14Target.Value = &t.Value.A14
		target, err := &t.a14Target, error(nil)
		return nil, target, err
	case "B0":
		t.b0Target.Value = &t.Value.B0
		target, err := &t.b0Target, error(nil)
		return nil, target, err
	case "B1":
		t.b1Target.Value = &t.Value.B1
		target, err := &t.b1Target, error(nil)
		return nil, target, err
	case "B2":
		t.b2Target.Value = &t.Value.B2
		target, err := &t.b2Target, error(nil)
		return nil, target, err
	case "B3":
		t.b3Target.Value = &t.Value.B3
		target, err := &t.b3Target, error(nil)
		return nil, target, err
	case "B4":
		t.b4Target.Value = &t.Value.B4
		target, err := &t.b4Target, error(nil)
		return nil, target, err
	case "B5":
		t.b5Target.Value = &t.Value.B5
		target, err := &t.b5Target, error(nil)
		return nil, target, err
	case "B6":
		t.b6Target.Value = &t.Value.B6
		target, err := &t.b6Target, error(nil)
		return nil, target, err
	case "B7":
		t.b7Target.Value = &t.Value.B7
		target, err := &t.b7Target, error(nil)
		return nil, target, err
	case "B8":
		t.b8Target.Value = &t.Value.B8
		target, err := &t.b8Target, error(nil)
		return nil, target, err
	case "B9":
		t.b9Target.Value = &t.Value.B9
		target, err := &t.b9Target, error(nil)
		return nil, target, err
	case "B10":
		t.b10Target.Value = &t.Value.B10
		target, err := &t.b10Target, error(nil)
		return nil, target, err
	case "B11":
		t.b11Target.Value = &t.Value.B11
		target, err := &t.b11Target, error(nil)
		return nil, target, err
	case "B12":
		t.b12Target.Value = &t.Value.B12
		target, err := &t.b12Target, error(nil)
		return nil, target, err
	case "B13":
		t.b13Target.Value = &t.Value.B13
		target, err := &t.b13Target, error(nil)
		return nil, target, err
	default:
		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.Scalars", name)
	}
}
func (t *ScalarsTarget) FinishField(_, _ vdl.Target) error {
	return nil
}
func (t *ScalarsTarget) ZeroField(name string) error {
	switch name {
	case "A0":
		t.Value.A0 = false
		return nil
	case "A1":
		t.Value.A1 = byte(0)
		return nil
	case "A2":
		t.Value.A2 = uint16(0)
		return nil
	case "A3":
		t.Value.A3 = uint32(0)
		return nil
	case "A4":
		t.Value.A4 = uint64(0)
		return nil
	case "A5":
		t.Value.A5 = int8(0)
		return nil
	case "A6":
		t.Value.A6 = int16(0)
		return nil
	case "A7":
		t.Value.A7 = int32(0)
		return nil
	case "A8":
		t.Value.A8 = int64(0)
		return nil
	case "A9":
		t.Value.A9 = float32(0)
		return nil
	case "A10":
		t.Value.A10 = float64(0)
		return nil
	case "A11":
		t.Value.A11 = ""
		return nil
	case "A12":
		t.Value.A12 = (error)(nil)
		return nil
	case "A13":
		t.Value.A13 = vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType))
		return nil
	case "A14":
		t.Value.A14 = vdl.AnyType
		return nil
	case "B0":
		t.Value.B0 = NamedBool(false)
		return nil
	case "B1":
		t.Value.B1 = NamedByte(0)
		return nil
	case "B2":
		t.Value.B2 = NamedUint16(0)
		return nil
	case "B3":
		t.Value.B3 = NamedUint32(0)
		return nil
	case "B4":
		t.Value.B4 = NamedUint64(0)
		return nil
	case "B5":
		t.Value.B5 = NamedInt8(0)
		return nil
	case "B6":
		t.Value.B6 = NamedInt16(0)
		return nil
	case "B7":
		t.Value.B7 = NamedInt32(0)
		return nil
	case "B8":
		t.Value.B8 = NamedInt64(0)
		return nil
	case "B9":
		t.Value.B9 = NamedFloat32(0)
		return nil
	case "B10":
		t.Value.B10 = NamedFloat64(0)
		return nil
	case "B11":
		t.Value.B11 = NamedString("")
		return nil
	case "B12":
		t.Value.B12 = NamedEnumA
		return nil
	case "B13":
		t.Value.B13 = NamedUnion(NamedUnionA{})
		return nil
	default:
		return fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.Scalars", name)
	}
}
func (t *ScalarsTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

func (x *Scalars) VDLRead(dec vdl.Decoder) error {
	*x = Scalars{
		A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
		A14: vdl.AnyType,
		B13: NamedUnionA{},
	}
	var err 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 struct %T, from %v", *x, dec.Type())
	}
	for {
		f, err := dec.NextField()
		if err != nil {
			return err
		}
		switch f {
		case "":
			return dec.FinishValue()
		case "A0":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A0, err = dec.DecodeBool(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A1":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeUint(8)
			if err != nil {
				return err
			}
			x.A1 = byte(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A2":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeUint(16)
			if err != nil {
				return err
			}
			x.A2 = uint16(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A3":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeUint(32)
			if err != nil {
				return err
			}
			x.A3 = uint32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A4":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A4, err = dec.DecodeUint(64); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A5":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(8)
			if err != nil {
				return err
			}
			x.A5 = int8(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A6":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(16)
			if err != nil {
				return err
			}
			x.A6 = int16(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A7":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(32)
			if err != nil {
				return err
			}
			x.A7 = int32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A8":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A8, err = dec.DecodeInt(64); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A9":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeFloat(32)
			if err != nil {
				return err
			}
			x.A9 = float32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A10":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A10, err = dec.DecodeFloat(64); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A11":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A11, err = dec.DecodeString(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A12":
			if err = verror.VDLRead(dec, &x.A12); err != nil {
				return err
			}
		case "A13":
			// TODO(toddw): implement any
		case "A14":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A14, err = dec.DecodeTypeObject(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "B0":
			if err = x.B0.VDLRead(dec); err != nil {
				return err
			}
		case "B1":
			if err = x.B1.VDLRead(dec); err != nil {
				return err
			}
		case "B2":
			if err = x.B2.VDLRead(dec); err != nil {
				return err
			}
		case "B3":
			if err = x.B3.VDLRead(dec); err != nil {
				return err
			}
		case "B4":
			if err = x.B4.VDLRead(dec); err != nil {
				return err
			}
		case "B5":
			if err = x.B5.VDLRead(dec); err != nil {
				return err
			}
		case "B6":
			if err = x.B6.VDLRead(dec); err != nil {
				return err
			}
		case "B7":
			if err = x.B7.VDLRead(dec); err != nil {
				return err
			}
		case "B8":
			if err = x.B8.VDLRead(dec); err != nil {
				return err
			}
		case "B9":
			if err = x.B9.VDLRead(dec); err != nil {
				return err
			}
		case "B10":
			if err = x.B10.VDLRead(dec); err != nil {
				return err
			}
		case "B11":
			if err = x.B11.VDLRead(dec); err != nil {
				return err
			}
		case "B12":
			if err = x.B12.VDLRead(dec); err != nil {
				return err
			}
		case "B13":
			if err = VDLReadNamedUnion(dec, &x.B13); err != nil {
				return err
			}
		default:
			if err = dec.SkipValue(); err != nil {
				return err
			}
		}
	}
}

// These are all scalars that may be used as map or set keys.
type KeyScalars struct {
	A0  bool
	A1  byte
	A2  uint16
	A3  uint32
	A4  uint64
	A5  int8
	A6  int16
	A7  int32
	A8  int64
	A9  float32
	A10 float64
	A11 string
	B0  NamedBool
	B1  NamedByte
	B2  NamedUint16
	B3  NamedUint32
	B4  NamedUint64
	B5  NamedInt8
	B6  NamedInt16
	B7  NamedInt32
	B8  NamedInt64
	B9  NamedFloat32
	B10 NamedFloat64
	B13 NamedString
}

func (KeyScalars) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.KeyScalars"`
}) {
}

func (m *KeyScalars) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	var4 := (m.A0 == false)
	if var4 {
		if err := fieldsTarget1.ZeroField("A0"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A0")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget3.FromBool(bool(m.A0), tt.NonOptional().Field(0).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
				return err
			}
		}
	}
	var7 := (m.A1 == byte(0))
	if var7 {
		if err := fieldsTarget1.ZeroField("A1"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("A1")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget6.FromUint(uint64(m.A1), tt.NonOptional().Field(1).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget5, fieldTarget6); err != nil {
				return err
			}
		}
	}
	var10 := (m.A2 == uint16(0))
	if var10 {
		if err := fieldsTarget1.ZeroField("A2"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget8, fieldTarget9, err := fieldsTarget1.StartField("A2")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget9.FromUint(uint64(m.A2), tt.NonOptional().Field(2).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget8, fieldTarget9); err != nil {
				return err
			}
		}
	}
	var13 := (m.A3 == uint32(0))
	if var13 {
		if err := fieldsTarget1.ZeroField("A3"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget11, fieldTarget12, err := fieldsTarget1.StartField("A3")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget12.FromUint(uint64(m.A3), tt.NonOptional().Field(3).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget11, fieldTarget12); err != nil {
				return err
			}
		}
	}
	var16 := (m.A4 == uint64(0))
	if var16 {
		if err := fieldsTarget1.ZeroField("A4"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget14, fieldTarget15, err := fieldsTarget1.StartField("A4")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget15.FromUint(uint64(m.A4), tt.NonOptional().Field(4).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget14, fieldTarget15); err != nil {
				return err
			}
		}
	}
	var19 := (m.A5 == int8(0))
	if var19 {
		if err := fieldsTarget1.ZeroField("A5"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget17, fieldTarget18, err := fieldsTarget1.StartField("A5")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget18.FromInt(int64(m.A5), tt.NonOptional().Field(5).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget17, fieldTarget18); err != nil {
				return err
			}
		}
	}
	var22 := (m.A6 == int16(0))
	if var22 {
		if err := fieldsTarget1.ZeroField("A6"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget20, fieldTarget21, err := fieldsTarget1.StartField("A6")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget21.FromInt(int64(m.A6), tt.NonOptional().Field(6).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget20, fieldTarget21); err != nil {
				return err
			}
		}
	}
	var25 := (m.A7 == int32(0))
	if var25 {
		if err := fieldsTarget1.ZeroField("A7"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget23, fieldTarget24, err := fieldsTarget1.StartField("A7")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget24.FromInt(int64(m.A7), tt.NonOptional().Field(7).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget23, fieldTarget24); err != nil {
				return err
			}
		}
	}
	var28 := (m.A8 == int64(0))
	if var28 {
		if err := fieldsTarget1.ZeroField("A8"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget26, fieldTarget27, err := fieldsTarget1.StartField("A8")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget27.FromInt(int64(m.A8), tt.NonOptional().Field(8).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget26, fieldTarget27); err != nil {
				return err
			}
		}
	}
	var31 := (m.A9 == float32(0))
	if var31 {
		if err := fieldsTarget1.ZeroField("A9"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget29, fieldTarget30, err := fieldsTarget1.StartField("A9")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget30.FromFloat(float64(m.A9), tt.NonOptional().Field(9).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget29, fieldTarget30); err != nil {
				return err
			}
		}
	}
	var34 := (m.A10 == float64(0))
	if var34 {
		if err := fieldsTarget1.ZeroField("A10"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget32, fieldTarget33, err := fieldsTarget1.StartField("A10")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget33.FromFloat(float64(m.A10), tt.NonOptional().Field(10).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget32, fieldTarget33); err != nil {
				return err
			}
		}
	}
	var37 := (m.A11 == "")
	if var37 {
		if err := fieldsTarget1.ZeroField("A11"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget35, fieldTarget36, err := fieldsTarget1.StartField("A11")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget36.FromString(string(m.A11), tt.NonOptional().Field(11).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget35, fieldTarget36); err != nil {
				return err
			}
		}
	}
	var40 := (m.B0 == NamedBool(false))
	if var40 {
		if err := fieldsTarget1.ZeroField("B0"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget38, fieldTarget39, err := fieldsTarget1.StartField("B0")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B0.FillVDLTarget(fieldTarget39, tt.NonOptional().Field(12).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget38, fieldTarget39); err != nil {
				return err
			}
		}
	}
	var43 := (m.B1 == NamedByte(0))
	if var43 {
		if err := fieldsTarget1.ZeroField("B1"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget41, fieldTarget42, err := fieldsTarget1.StartField("B1")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B1.FillVDLTarget(fieldTarget42, tt.NonOptional().Field(13).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget41, fieldTarget42); err != nil {
				return err
			}
		}
	}
	var46 := (m.B2 == NamedUint16(0))
	if var46 {
		if err := fieldsTarget1.ZeroField("B2"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget44, fieldTarget45, err := fieldsTarget1.StartField("B2")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B2.FillVDLTarget(fieldTarget45, tt.NonOptional().Field(14).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget44, fieldTarget45); err != nil {
				return err
			}
		}
	}
	var49 := (m.B3 == NamedUint32(0))
	if var49 {
		if err := fieldsTarget1.ZeroField("B3"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget47, fieldTarget48, err := fieldsTarget1.StartField("B3")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B3.FillVDLTarget(fieldTarget48, tt.NonOptional().Field(15).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget47, fieldTarget48); err != nil {
				return err
			}
		}
	}
	var52 := (m.B4 == NamedUint64(0))
	if var52 {
		if err := fieldsTarget1.ZeroField("B4"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget50, fieldTarget51, err := fieldsTarget1.StartField("B4")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B4.FillVDLTarget(fieldTarget51, tt.NonOptional().Field(16).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget50, fieldTarget51); err != nil {
				return err
			}
		}
	}
	var55 := (m.B5 == NamedInt8(0))
	if var55 {
		if err := fieldsTarget1.ZeroField("B5"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget53, fieldTarget54, err := fieldsTarget1.StartField("B5")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B5.FillVDLTarget(fieldTarget54, tt.NonOptional().Field(17).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget53, fieldTarget54); err != nil {
				return err
			}
		}
	}
	var58 := (m.B6 == NamedInt16(0))
	if var58 {
		if err := fieldsTarget1.ZeroField("B6"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget56, fieldTarget57, err := fieldsTarget1.StartField("B6")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B6.FillVDLTarget(fieldTarget57, tt.NonOptional().Field(18).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget56, fieldTarget57); err != nil {
				return err
			}
		}
	}
	var61 := (m.B7 == NamedInt32(0))
	if var61 {
		if err := fieldsTarget1.ZeroField("B7"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget59, fieldTarget60, err := fieldsTarget1.StartField("B7")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B7.FillVDLTarget(fieldTarget60, tt.NonOptional().Field(19).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget59, fieldTarget60); err != nil {
				return err
			}
		}
	}
	var64 := (m.B8 == NamedInt64(0))
	if var64 {
		if err := fieldsTarget1.ZeroField("B8"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget62, fieldTarget63, err := fieldsTarget1.StartField("B8")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B8.FillVDLTarget(fieldTarget63, tt.NonOptional().Field(20).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget62, fieldTarget63); err != nil {
				return err
			}
		}
	}
	var67 := (m.B9 == NamedFloat32(0))
	if var67 {
		if err := fieldsTarget1.ZeroField("B9"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget65, fieldTarget66, err := fieldsTarget1.StartField("B9")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B9.FillVDLTarget(fieldTarget66, tt.NonOptional().Field(21).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget65, fieldTarget66); err != nil {
				return err
			}
		}
	}
	var70 := (m.B10 == NamedFloat64(0))
	if var70 {
		if err := fieldsTarget1.ZeroField("B10"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget68, fieldTarget69, err := fieldsTarget1.StartField("B10")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B10.FillVDLTarget(fieldTarget69, tt.NonOptional().Field(22).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget68, fieldTarget69); err != nil {
				return err
			}
		}
	}
	var73 := (m.B13 == NamedString(""))
	if var73 {
		if err := fieldsTarget1.ZeroField("B13"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget71, fieldTarget72, err := fieldsTarget1.StartField("B13")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.B13.FillVDLTarget(fieldTarget72, tt.NonOptional().Field(23).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget71, fieldTarget72); err != nil {
				return err
			}
		}
	}
	if err := t.FinishFields(fieldsTarget1); err != nil {
		return err
	}
	return nil
}

func (m *KeyScalars) MakeVDLTarget() vdl.Target {
	return &KeyScalarsTarget{Value: m}
}

type KeyScalarsTarget struct {
	Value     *KeyScalars
	a0Target  vdl.BoolTarget
	a1Target  vdl.ByteTarget
	a2Target  vdl.Uint16Target
	a3Target  vdl.Uint32Target
	a4Target  vdl.Uint64Target
	a5Target  vdl.Int8Target
	a6Target  vdl.Int16Target
	a7Target  vdl.Int32Target
	a8Target  vdl.Int64Target
	a9Target  vdl.Float32Target
	a10Target vdl.Float64Target
	a11Target vdl.StringTarget
	b0Target  NamedBoolTarget
	b1Target  NamedByteTarget
	b2Target  NamedUint16Target
	b3Target  NamedUint32Target
	b4Target  NamedUint64Target
	b5Target  NamedInt8Target
	b6Target  NamedInt16Target
	b7Target  NamedInt32Target
	b8Target  NamedInt64Target
	b9Target  NamedFloat32Target
	b10Target NamedFloat64Target
	b13Target NamedStringTarget
	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *KeyScalarsTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {

	if ttWant := vdl.TypeOf((*KeyScalars)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *KeyScalarsTarget) StartField(name string) (key, field vdl.Target, _ error) {
	switch name {
	case "A0":
		t.a0Target.Value = &t.Value.A0
		target, err := &t.a0Target, error(nil)
		return nil, target, err
	case "A1":
		t.a1Target.Value = &t.Value.A1
		target, err := &t.a1Target, error(nil)
		return nil, target, err
	case "A2":
		t.a2Target.Value = &t.Value.A2
		target, err := &t.a2Target, error(nil)
		return nil, target, err
	case "A3":
		t.a3Target.Value = &t.Value.A3
		target, err := &t.a3Target, error(nil)
		return nil, target, err
	case "A4":
		t.a4Target.Value = &t.Value.A4
		target, err := &t.a4Target, error(nil)
		return nil, target, err
	case "A5":
		t.a5Target.Value = &t.Value.A5
		target, err := &t.a5Target, error(nil)
		return nil, target, err
	case "A6":
		t.a6Target.Value = &t.Value.A6
		target, err := &t.a6Target, error(nil)
		return nil, target, err
	case "A7":
		t.a7Target.Value = &t.Value.A7
		target, err := &t.a7Target, error(nil)
		return nil, target, err
	case "A8":
		t.a8Target.Value = &t.Value.A8
		target, err := &t.a8Target, error(nil)
		return nil, target, err
	case "A9":
		t.a9Target.Value = &t.Value.A9
		target, err := &t.a9Target, error(nil)
		return nil, target, err
	case "A10":
		t.a10Target.Value = &t.Value.A10
		target, err := &t.a10Target, error(nil)
		return nil, target, err
	case "A11":
		t.a11Target.Value = &t.Value.A11
		target, err := &t.a11Target, error(nil)
		return nil, target, err
	case "B0":
		t.b0Target.Value = &t.Value.B0
		target, err := &t.b0Target, error(nil)
		return nil, target, err
	case "B1":
		t.b1Target.Value = &t.Value.B1
		target, err := &t.b1Target, error(nil)
		return nil, target, err
	case "B2":
		t.b2Target.Value = &t.Value.B2
		target, err := &t.b2Target, error(nil)
		return nil, target, err
	case "B3":
		t.b3Target.Value = &t.Value.B3
		target, err := &t.b3Target, error(nil)
		return nil, target, err
	case "B4":
		t.b4Target.Value = &t.Value.B4
		target, err := &t.b4Target, error(nil)
		return nil, target, err
	case "B5":
		t.b5Target.Value = &t.Value.B5
		target, err := &t.b5Target, error(nil)
		return nil, target, err
	case "B6":
		t.b6Target.Value = &t.Value.B6
		target, err := &t.b6Target, error(nil)
		return nil, target, err
	case "B7":
		t.b7Target.Value = &t.Value.B7
		target, err := &t.b7Target, error(nil)
		return nil, target, err
	case "B8":
		t.b8Target.Value = &t.Value.B8
		target, err := &t.b8Target, error(nil)
		return nil, target, err
	case "B9":
		t.b9Target.Value = &t.Value.B9
		target, err := &t.b9Target, error(nil)
		return nil, target, err
	case "B10":
		t.b10Target.Value = &t.Value.B10
		target, err := &t.b10Target, error(nil)
		return nil, target, err
	case "B13":
		t.b13Target.Value = &t.Value.B13
		target, err := &t.b13Target, error(nil)
		return nil, target, err
	default:
		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.KeyScalars", name)
	}
}
func (t *KeyScalarsTarget) FinishField(_, _ vdl.Target) error {
	return nil
}
func (t *KeyScalarsTarget) ZeroField(name string) error {
	switch name {
	case "A0":
		t.Value.A0 = false
		return nil
	case "A1":
		t.Value.A1 = byte(0)
		return nil
	case "A2":
		t.Value.A2 = uint16(0)
		return nil
	case "A3":
		t.Value.A3 = uint32(0)
		return nil
	case "A4":
		t.Value.A4 = uint64(0)
		return nil
	case "A5":
		t.Value.A5 = int8(0)
		return nil
	case "A6":
		t.Value.A6 = int16(0)
		return nil
	case "A7":
		t.Value.A7 = int32(0)
		return nil
	case "A8":
		t.Value.A8 = int64(0)
		return nil
	case "A9":
		t.Value.A9 = float32(0)
		return nil
	case "A10":
		t.Value.A10 = float64(0)
		return nil
	case "A11":
		t.Value.A11 = ""
		return nil
	case "B0":
		t.Value.B0 = NamedBool(false)
		return nil
	case "B1":
		t.Value.B1 = NamedByte(0)
		return nil
	case "B2":
		t.Value.B2 = NamedUint16(0)
		return nil
	case "B3":
		t.Value.B3 = NamedUint32(0)
		return nil
	case "B4":
		t.Value.B4 = NamedUint64(0)
		return nil
	case "B5":
		t.Value.B5 = NamedInt8(0)
		return nil
	case "B6":
		t.Value.B6 = NamedInt16(0)
		return nil
	case "B7":
		t.Value.B7 = NamedInt32(0)
		return nil
	case "B8":
		t.Value.B8 = NamedInt64(0)
		return nil
	case "B9":
		t.Value.B9 = NamedFloat32(0)
		return nil
	case "B10":
		t.Value.B10 = NamedFloat64(0)
		return nil
	case "B13":
		t.Value.B13 = NamedString("")
		return nil
	default:
		return fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.KeyScalars", name)
	}
}
func (t *KeyScalarsTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

func (x *KeyScalars) VDLRead(dec vdl.Decoder) error {
	*x = KeyScalars{}
	var err 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 struct %T, from %v", *x, dec.Type())
	}
	for {
		f, err := dec.NextField()
		if err != nil {
			return err
		}
		switch f {
		case "":
			return dec.FinishValue()
		case "A0":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A0, err = dec.DecodeBool(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A1":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeUint(8)
			if err != nil {
				return err
			}
			x.A1 = byte(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A2":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeUint(16)
			if err != nil {
				return err
			}
			x.A2 = uint16(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A3":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeUint(32)
			if err != nil {
				return err
			}
			x.A3 = uint32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A4":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A4, err = dec.DecodeUint(64); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A5":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(8)
			if err != nil {
				return err
			}
			x.A5 = int8(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A6":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(16)
			if err != nil {
				return err
			}
			x.A6 = int16(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A7":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(32)
			if err != nil {
				return err
			}
			x.A7 = int32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A8":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A8, err = dec.DecodeInt(64); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A9":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeFloat(32)
			if err != nil {
				return err
			}
			x.A9 = float32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A10":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A10, err = dec.DecodeFloat(64); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "A11":
			if err = dec.StartValue(); err != nil {
				return err
			}
			if x.A11, err = dec.DecodeString(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "B0":
			if err = x.B0.VDLRead(dec); err != nil {
				return err
			}
		case "B1":
			if err = x.B1.VDLRead(dec); err != nil {
				return err
			}
		case "B2":
			if err = x.B2.VDLRead(dec); err != nil {
				return err
			}
		case "B3":
			if err = x.B3.VDLRead(dec); err != nil {
				return err
			}
		case "B4":
			if err = x.B4.VDLRead(dec); err != nil {
				return err
			}
		case "B5":
			if err = x.B5.VDLRead(dec); err != nil {
				return err
			}
		case "B6":
			if err = x.B6.VDLRead(dec); err != nil {
				return err
			}
		case "B7":
			if err = x.B7.VDLRead(dec); err != nil {
				return err
			}
		case "B8":
			if err = x.B8.VDLRead(dec); err != nil {
				return err
			}
		case "B9":
			if err = x.B9.VDLRead(dec); err != nil {
				return err
			}
		case "B10":
			if err = x.B10.VDLRead(dec); err != nil {
				return err
			}
		case "B13":
			if err = x.B13.VDLRead(dec); err != nil {
				return err
			}
		default:
			if err = dec.SkipValue(); err != nil {
				return err
			}
		}
	}
}

type ScalarsArray [2]Scalars

func (ScalarsArray) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.ScalarsArray"`
}) {
}

func (m *ScalarsArray) 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 := elem3.FillVDLTarget(elemTarget2, 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 *ScalarsArray) MakeVDLTarget() vdl.Target {
	return &ScalarsArrayTarget{Value: m}
}

// ScalarsArray
type ScalarsArrayTarget struct {
	Value      *ScalarsArray
	elemTarget ScalarsTarget
	vdl.TargetBase
	vdl.ListTargetBase
}

func (t *ScalarsArrayTarget) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {

	if ttWant := vdl.TypeOf((*ScalarsArray)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *ScalarsArrayTarget) StartElem(index int) (elem vdl.Target, _ error) {
	t.elemTarget.Value = &(*t.Value)[index]
	target, err := &t.elemTarget, error(nil)
	return target, err
}
func (t *ScalarsArrayTarget) FinishElem(elem vdl.Target) error {
	return nil
}
func (t *ScalarsArrayTarget) FinishList(elem vdl.ListTarget) error {

	return nil
}

func (x *ScalarsArray) VDLRead(dec vdl.Decoder) error {
	var err 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 = x[index].VDLRead(dec); err != nil {
			return err
		}
		index++
	}
}

type Composites struct {
	A0 Scalars
	A1 ScalarsArray
	A2 []Scalars
	A3 map[KeyScalars]struct{}
	A4 map[string]Scalars
}

func (Composites) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.Composites"`
}) {
}

func (m *Composites) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	var4 := true
	var5 := (m.A0.A0 == false)
	var4 = var4 && var5
	var6 := (m.A0.A1 == byte(0))
	var4 = var4 && var6
	var7 := (m.A0.A2 == uint16(0))
	var4 = var4 && var7
	var8 := (m.A0.A3 == uint32(0))
	var4 = var4 && var8
	var9 := (m.A0.A4 == uint64(0))
	var4 = var4 && var9
	var10 := (m.A0.A5 == int8(0))
	var4 = var4 && var10
	var11 := (m.A0.A6 == int16(0))
	var4 = var4 && var11
	var12 := (m.A0.A7 == int32(0))
	var4 = var4 && var12
	var13 := (m.A0.A8 == int64(0))
	var4 = var4 && var13
	var14 := (m.A0.A9 == float32(0))
	var4 = var4 && var14
	var15 := (m.A0.A10 == float64(0))
	var4 = var4 && var15
	var16 := (m.A0.A11 == "")
	var4 = var4 && var16
	var17 := (m.A0.A12 == (error)(nil))
	var4 = var4 && var17
	var18 := m.A0.A13 == nil || m.A0.A13.IsNilAny()
	var4 = var4 && var18
	var19 := (m.A0.A14 == nil || m.A0.A14 == vdl.AnyType)
	var4 = var4 && var19
	var20 := (m.A0.B0 == NamedBool(false))
	var4 = var4 && var20
	var21 := (m.A0.B1 == NamedByte(0))
	var4 = var4 && var21
	var22 := (m.A0.B2 == NamedUint16(0))
	var4 = var4 && var22
	var23 := (m.A0.B3 == NamedUint32(0))
	var4 = var4 && var23
	var24 := (m.A0.B4 == NamedUint64(0))
	var4 = var4 && var24
	var25 := (m.A0.B5 == NamedInt8(0))
	var4 = var4 && var25
	var26 := (m.A0.B6 == NamedInt16(0))
	var4 = var4 && var26
	var27 := (m.A0.B7 == NamedInt32(0))
	var4 = var4 && var27
	var28 := (m.A0.B8 == NamedInt64(0))
	var4 = var4 && var28
	var29 := (m.A0.B9 == NamedFloat32(0))
	var4 = var4 && var29
	var30 := (m.A0.B10 == NamedFloat64(0))
	var4 = var4 && var30
	var31 := (m.A0.B11 == NamedString(""))
	var4 = var4 && var31
	var32 := (m.A0.B12 == NamedEnumA)
	var4 = var4 && var32
	var var33 bool
	if field, ok := m.A0.B13.(NamedUnionA); ok {

		var34 := (field.Value == false)
		var33 = var34
	}
	var4 = var4 && var33
	if var4 {
		if err := fieldsTarget1.ZeroField("A0"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A0")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.A0.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
				return err
			}
		}
	}
	var37 := true
	for _, elem38 := range m.A1 {

		var39 := true
		var40 := (elem38.A0 == false)
		var39 = var39 && var40
		var41 := (elem38.A1 == byte(0))
		var39 = var39 && var41
		var42 := (elem38.A2 == uint16(0))
		var39 = var39 && var42
		var43 := (elem38.A3 == uint32(0))
		var39 = var39 && var43
		var44 := (elem38.A4 == uint64(0))
		var39 = var39 && var44
		var45 := (elem38.A5 == int8(0))
		var39 = var39 && var45
		var46 := (elem38.A6 == int16(0))
		var39 = var39 && var46
		var47 := (elem38.A7 == int32(0))
		var39 = var39 && var47
		var48 := (elem38.A8 == int64(0))
		var39 = var39 && var48
		var49 := (elem38.A9 == float32(0))
		var39 = var39 && var49
		var50 := (elem38.A10 == float64(0))
		var39 = var39 && var50
		var51 := (elem38.A11 == "")
		var39 = var39 && var51
		var52 := (elem38.A12 == (error)(nil))
		var39 = var39 && var52
		var53 := elem38.A13 == nil || elem38.A13.IsNilAny()
		var39 = var39 && var53
		var54 := (elem38.A14 == nil || elem38.A14 == vdl.AnyType)
		var39 = var39 && var54
		var55 := (elem38.B0 == NamedBool(false))
		var39 = var39 && var55
		var56 := (elem38.B1 == NamedByte(0))
		var39 = var39 && var56
		var57 := (elem38.B2 == NamedUint16(0))
		var39 = var39 && var57
		var58 := (elem38.B3 == NamedUint32(0))
		var39 = var39 && var58
		var59 := (elem38.B4 == NamedUint64(0))
		var39 = var39 && var59
		var60 := (elem38.B5 == NamedInt8(0))
		var39 = var39 && var60
		var61 := (elem38.B6 == NamedInt16(0))
		var39 = var39 && var61
		var62 := (elem38.B7 == NamedInt32(0))
		var39 = var39 && var62
		var63 := (elem38.B8 == NamedInt64(0))
		var39 = var39 && var63
		var64 := (elem38.B9 == NamedFloat32(0))
		var39 = var39 && var64
		var65 := (elem38.B10 == NamedFloat64(0))
		var39 = var39 && var65
		var66 := (elem38.B11 == NamedString(""))
		var39 = var39 && var66
		var67 := (elem38.B12 == NamedEnumA)
		var39 = var39 && var67
		var var68 bool
		if field, ok := elem38.B13.(NamedUnionA); ok {

			var69 := (field.Value == false)
			var68 = var69
		}
		var39 = var39 && var68
		if !var39 {
			var37 = false
			break
		}
	}
	if var37 {
		if err := fieldsTarget1.ZeroField("A1"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget35, fieldTarget36, err := fieldsTarget1.StartField("A1")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.A1.FillVDLTarget(fieldTarget36, tt.NonOptional().Field(1).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget35, fieldTarget36); err != nil {
				return err
			}
		}
	}
	var var72 bool
	if len(m.A2) == 0 {
		var72 = true
	}
	if var72 {
		if err := fieldsTarget1.ZeroField("A2"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget70, fieldTarget71, err := fieldsTarget1.StartField("A2")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			listTarget73, err := fieldTarget71.StartList(tt.NonOptional().Field(2).Type, len(m.A2))
			if err != nil {
				return err
			}
			for i, elem75 := range m.A2 {
				elemTarget74, err := listTarget73.StartElem(i)
				if err != nil {
					return err
				}

				if err := elem75.FillVDLTarget(elemTarget74, tt.NonOptional().Field(2).Type.Elem()); err != nil {
					return err
				}
				if err := listTarget73.FinishElem(elemTarget74); err != nil {
					return err
				}
			}
			if err := fieldTarget71.FinishList(listTarget73); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget70, fieldTarget71); err != nil {
				return err
			}
		}
	}
	var var78 bool
	if len(m.A3) == 0 {
		var78 = true
	}
	if var78 {
		if err := fieldsTarget1.ZeroField("A3"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget76, fieldTarget77, err := fieldsTarget1.StartField("A3")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			setTarget79, err := fieldTarget77.StartSet(tt.NonOptional().Field(3).Type, len(m.A3))
			if err != nil {
				return err
			}
			for key81 := range m.A3 {
				keyTarget80, err := setTarget79.StartKey()
				if err != nil {
					return err
				}

				if err := key81.FillVDLTarget(keyTarget80, tt.NonOptional().Field(3).Type.Key()); err != nil {
					return err
				}
				if err := setTarget79.FinishKey(keyTarget80); err != nil {
					return err
				}
			}
			if err := fieldTarget77.FinishSet(setTarget79); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget76, fieldTarget77); err != nil {
				return err
			}
		}
	}
	var var84 bool
	if len(m.A4) == 0 {
		var84 = true
	}
	if var84 {
		if err := fieldsTarget1.ZeroField("A4"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget82, fieldTarget83, err := fieldsTarget1.StartField("A4")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			mapTarget85, err := fieldTarget83.StartMap(tt.NonOptional().Field(4).Type, len(m.A4))
			if err != nil {
				return err
			}
			for key87, value89 := range m.A4 {
				keyTarget86, err := mapTarget85.StartKey()
				if err != nil {
					return err
				}
				if err := keyTarget86.FromString(string(key87), tt.NonOptional().Field(4).Type.Key()); err != nil {
					return err
				}
				valueTarget88, err := mapTarget85.FinishKeyStartField(keyTarget86)
				if err != nil {
					return err
				}

				if err := value89.FillVDLTarget(valueTarget88, tt.NonOptional().Field(4).Type.Elem()); err != nil {
					return err
				}
				if err := mapTarget85.FinishField(keyTarget86, valueTarget88); err != nil {
					return err
				}
			}
			if err := fieldTarget83.FinishMap(mapTarget85); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget82, fieldTarget83); err != nil {
				return err
			}
		}
	}
	if err := t.FinishFields(fieldsTarget1); err != nil {
		return err
	}
	return nil
}

func (m *Composites) MakeVDLTarget() vdl.Target {
	return &CompositesTarget{Value: m}
}

type CompositesTarget struct {
	Value    *Composites
	a0Target ScalarsTarget
	a1Target ScalarsArrayTarget
	a2Target __VDLTarget1_list
	a3Target __VDLTarget2_set
	a4Target __VDLTarget3_map
	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *CompositesTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {

	if ttWant := vdl.TypeOf((*Composites)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *CompositesTarget) StartField(name string) (key, field vdl.Target, _ error) {
	switch name {
	case "A0":
		t.a0Target.Value = &t.Value.A0
		target, err := &t.a0Target, error(nil)
		return nil, target, err
	case "A1":
		t.a1Target.Value = &t.Value.A1
		target, err := &t.a1Target, error(nil)
		return nil, target, err
	case "A2":
		t.a2Target.Value = &t.Value.A2
		target, err := &t.a2Target, error(nil)
		return nil, target, err
	case "A3":
		t.a3Target.Value = &t.Value.A3
		target, err := &t.a3Target, error(nil)
		return nil, target, err
	case "A4":
		t.a4Target.Value = &t.Value.A4
		target, err := &t.a4Target, error(nil)
		return nil, target, err
	default:
		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.Composites", name)
	}
}
func (t *CompositesTarget) FinishField(_, _ vdl.Target) error {
	return nil
}
func (t *CompositesTarget) ZeroField(name string) error {
	switch name {
	case "A0":
		t.Value.A0 = Scalars{
			A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
			A14: vdl.AnyType,
			B13: NamedUnionA{},
		}
		return nil
	case "A1":
		t.Value.A1 = ScalarsArray{
			{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
			{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
		}
		return nil
	case "A2":
		t.Value.A2 = []Scalars(nil)
		return nil
	case "A3":
		t.Value.A3 = map[KeyScalars]struct{}(nil)
		return nil
	case "A4":
		t.Value.A4 = map[string]Scalars(nil)
		return nil
	default:
		return fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.Composites", name)
	}
}
func (t *CompositesTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

// []Scalars
type __VDLTarget1_list struct {
	Value      *[]Scalars
	elemTarget ScalarsTarget
	vdl.TargetBase
	vdl.ListTargetBase
}

func (t *__VDLTarget1_list) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {

	if ttWant := vdl.TypeOf((*[]Scalars)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	if cap(*t.Value) < len {
		*t.Value = make([]Scalars, 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[KeyScalars]struct{}
type __VDLTarget2_set struct {
	Value     *map[KeyScalars]struct{}
	currKey   KeyScalars
	keyTarget KeyScalarsTarget
	vdl.TargetBase
	vdl.SetTargetBase
}

func (t *__VDLTarget2_set) StartSet(tt *vdl.Type, len int) (vdl.SetTarget, error) {

	if ttWant := vdl.TypeOf((*map[KeyScalars]struct{})(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = make(map[KeyScalars]struct{})
	return t, nil
}
func (t *__VDLTarget2_set) StartKey() (key vdl.Target, _ error) {
	t.currKey = KeyScalars{}
	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]Scalars
type __VDLTarget3_map struct {
	Value      *map[string]Scalars
	currKey    string
	currElem   Scalars
	keyTarget  vdl.StringTarget
	elemTarget ScalarsTarget
	vdl.TargetBase
	vdl.MapTargetBase
}

func (t *__VDLTarget3_map) StartMap(tt *vdl.Type, len int) (vdl.MapTarget, error) {

	if ttWant := vdl.TypeOf((*map[string]Scalars)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = make(map[string]Scalars)
	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 = Scalars{
		A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
		A14: vdl.AnyType,
		B13: NamedUnionA{},
	}
	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 *Composites) VDLRead(dec vdl.Decoder) error {
	*x = Composites{
		A0: Scalars{
			A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
			A14: vdl.AnyType,
			B13: NamedUnionA{},
		},
		A1: ScalarsArray{
			{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
			{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
		},
	}
	var err 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 struct %T, from %v", *x, dec.Type())
	}
	for {
		f, err := dec.NextField()
		if err != nil {
			return err
		}
		switch f {
		case "":
			return dec.FinishValue()
		case "A0":
			if err = x.A0.VDLRead(dec); err != nil {
				return err
			}
		case "A1":
			if err = x.A1.VDLRead(dec); err != nil {
				return err
			}
		case "A2":
			if err = __VDLRead1_list(dec, &x.A2); err != nil {
				return err
			}
		case "A3":
			if err = __VDLRead2_set(dec, &x.A3); err != nil {
				return err
			}
		case "A4":
			if err = __VDLRead3_map(dec, &x.A4); err != nil {
				return err
			}
		default:
			if err = dec.SkipValue(); err != nil {
				return err
			}
		}
	}
}

func __VDLRead1_list(dec vdl.Decoder, x *[]Scalars) error {
	var err 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([]Scalars, 0, len)
	default:
		*x = nil
	}
	for {
		switch done, err := dec.NextEntry(); {
		case err != nil:
			return err
		case done:
			return dec.FinishValue()
		}
		var elem Scalars
		if err = elem.VDLRead(dec); err != nil {
			return err
		}
		*x = append(*x, elem)
	}
}

func __VDLRead2_set(dec vdl.Decoder, x *map[KeyScalars]struct{}) error {
	var err 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[KeyScalars]struct{}
	if len := dec.LenHint(); len > 0 {
		tmpMap = make(map[KeyScalars]struct{}, len)
	}
	for {
		switch done, err := dec.NextEntry(); {
		case err != nil:
			return err
		case done:
			*x = tmpMap
			return dec.FinishValue()
		}
		var key KeyScalars
		{
			if err = key.VDLRead(dec); err != nil {
				return err
			}
		}
		if tmpMap == nil {
			tmpMap = make(map[KeyScalars]struct{})
		}
		tmpMap[key] = struct{}{}
	}
}

func __VDLRead3_map(dec vdl.Decoder, x *map[string]Scalars) error {
	var err 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]Scalars
	if len := dec.LenHint(); len > 0 {
		tmpMap = make(map[string]Scalars, 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
			}
			if key, err = dec.DecodeString(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		}
		var elem Scalars
		{
			if err = elem.VDLRead(dec); err != nil {
				return err
			}
		}
		if tmpMap == nil {
			tmpMap = make(map[string]Scalars)
		}
		tmpMap[key] = elem
	}
}

type CompositesArray [2]Composites

func (CompositesArray) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.CompositesArray"`
}) {
}

func (m *CompositesArray) 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 := elem3.FillVDLTarget(elemTarget2, 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 *CompositesArray) MakeVDLTarget() vdl.Target {
	return &CompositesArrayTarget{Value: m}
}

// CompositesArray
type CompositesArrayTarget struct {
	Value      *CompositesArray
	elemTarget CompositesTarget
	vdl.TargetBase
	vdl.ListTargetBase
}

func (t *CompositesArrayTarget) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {

	if ttWant := vdl.TypeOf((*CompositesArray)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *CompositesArrayTarget) StartElem(index int) (elem vdl.Target, _ error) {
	t.elemTarget.Value = &(*t.Value)[index]
	target, err := &t.elemTarget, error(nil)
	return target, err
}
func (t *CompositesArrayTarget) FinishElem(elem vdl.Target) error {
	return nil
}
func (t *CompositesArrayTarget) FinishList(elem vdl.ListTarget) error {

	return nil
}

func (x *CompositesArray) VDLRead(dec vdl.Decoder) error {
	var err 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 = x[index].VDLRead(dec); err != nil {
			return err
		}
		index++
	}
}

type CompComp struct {
	A0 Composites
	A1 CompositesArray
	A2 []Composites
	A3 map[string]Composites
	A4 map[KeyScalars][]map[string]Composites
}

func (CompComp) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.CompComp"`
}) {
}

func (m *CompComp) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	var4 := true
	var5 := true
	var6 := (m.A0.A0.A0 == false)
	var5 = var5 && var6
	var7 := (m.A0.A0.A1 == byte(0))
	var5 = var5 && var7
	var8 := (m.A0.A0.A2 == uint16(0))
	var5 = var5 && var8
	var9 := (m.A0.A0.A3 == uint32(0))
	var5 = var5 && var9
	var10 := (m.A0.A0.A4 == uint64(0))
	var5 = var5 && var10
	var11 := (m.A0.A0.A5 == int8(0))
	var5 = var5 && var11
	var12 := (m.A0.A0.A6 == int16(0))
	var5 = var5 && var12
	var13 := (m.A0.A0.A7 == int32(0))
	var5 = var5 && var13
	var14 := (m.A0.A0.A8 == int64(0))
	var5 = var5 && var14
	var15 := (m.A0.A0.A9 == float32(0))
	var5 = var5 && var15
	var16 := (m.A0.A0.A10 == float64(0))
	var5 = var5 && var16
	var17 := (m.A0.A0.A11 == "")
	var5 = var5 && var17
	var18 := (m.A0.A0.A12 == (error)(nil))
	var5 = var5 && var18
	var19 := m.A0.A0.A13 == nil || m.A0.A0.A13.IsNilAny()
	var5 = var5 && var19
	var20 := (m.A0.A0.A14 == nil || m.A0.A0.A14 == vdl.AnyType)
	var5 = var5 && var20
	var21 := (m.A0.A0.B0 == NamedBool(false))
	var5 = var5 && var21
	var22 := (m.A0.A0.B1 == NamedByte(0))
	var5 = var5 && var22
	var23 := (m.A0.A0.B2 == NamedUint16(0))
	var5 = var5 && var23
	var24 := (m.A0.A0.B3 == NamedUint32(0))
	var5 = var5 && var24
	var25 := (m.A0.A0.B4 == NamedUint64(0))
	var5 = var5 && var25
	var26 := (m.A0.A0.B5 == NamedInt8(0))
	var5 = var5 && var26
	var27 := (m.A0.A0.B6 == NamedInt16(0))
	var5 = var5 && var27
	var28 := (m.A0.A0.B7 == NamedInt32(0))
	var5 = var5 && var28
	var29 := (m.A0.A0.B8 == NamedInt64(0))
	var5 = var5 && var29
	var30 := (m.A0.A0.B9 == NamedFloat32(0))
	var5 = var5 && var30
	var31 := (m.A0.A0.B10 == NamedFloat64(0))
	var5 = var5 && var31
	var32 := (m.A0.A0.B11 == NamedString(""))
	var5 = var5 && var32
	var33 := (m.A0.A0.B12 == NamedEnumA)
	var5 = var5 && var33
	var var34 bool
	if field, ok := m.A0.A0.B13.(NamedUnionA); ok {

		var35 := (field.Value == false)
		var34 = var35
	}
	var5 = var5 && var34
	var4 = var4 && var5
	var36 := true
	for _, elem37 := range m.A0.A1 {

		var38 := true
		var39 := (elem37.A0 == false)
		var38 = var38 && var39
		var40 := (elem37.A1 == byte(0))
		var38 = var38 && var40
		var41 := (elem37.A2 == uint16(0))
		var38 = var38 && var41
		var42 := (elem37.A3 == uint32(0))
		var38 = var38 && var42
		var43 := (elem37.A4 == uint64(0))
		var38 = var38 && var43
		var44 := (elem37.A5 == int8(0))
		var38 = var38 && var44
		var45 := (elem37.A6 == int16(0))
		var38 = var38 && var45
		var46 := (elem37.A7 == int32(0))
		var38 = var38 && var46
		var47 := (elem37.A8 == int64(0))
		var38 = var38 && var47
		var48 := (elem37.A9 == float32(0))
		var38 = var38 && var48
		var49 := (elem37.A10 == float64(0))
		var38 = var38 && var49
		var50 := (elem37.A11 == "")
		var38 = var38 && var50
		var51 := (elem37.A12 == (error)(nil))
		var38 = var38 && var51
		var52 := elem37.A13 == nil || elem37.A13.IsNilAny()
		var38 = var38 && var52
		var53 := (elem37.A14 == nil || elem37.A14 == vdl.AnyType)
		var38 = var38 && var53
		var54 := (elem37.B0 == NamedBool(false))
		var38 = var38 && var54
		var55 := (elem37.B1 == NamedByte(0))
		var38 = var38 && var55
		var56 := (elem37.B2 == NamedUint16(0))
		var38 = var38 && var56
		var57 := (elem37.B3 == NamedUint32(0))
		var38 = var38 && var57
		var58 := (elem37.B4 == NamedUint64(0))
		var38 = var38 && var58
		var59 := (elem37.B5 == NamedInt8(0))
		var38 = var38 && var59
		var60 := (elem37.B6 == NamedInt16(0))
		var38 = var38 && var60
		var61 := (elem37.B7 == NamedInt32(0))
		var38 = var38 && var61
		var62 := (elem37.B8 == NamedInt64(0))
		var38 = var38 && var62
		var63 := (elem37.B9 == NamedFloat32(0))
		var38 = var38 && var63
		var64 := (elem37.B10 == NamedFloat64(0))
		var38 = var38 && var64
		var65 := (elem37.B11 == NamedString(""))
		var38 = var38 && var65
		var66 := (elem37.B12 == NamedEnumA)
		var38 = var38 && var66
		var var67 bool
		if field, ok := elem37.B13.(NamedUnionA); ok {

			var68 := (field.Value == false)
			var67 = var68
		}
		var38 = var38 && var67
		if !var38 {
			var36 = false
			break
		}
	}
	var4 = var4 && var36
	var var69 bool
	if len(m.A0.A2) == 0 {
		var69 = true
	}
	var4 = var4 && var69
	var var70 bool
	if len(m.A0.A3) == 0 {
		var70 = true
	}
	var4 = var4 && var70
	var var71 bool
	if len(m.A0.A4) == 0 {
		var71 = true
	}
	var4 = var4 && var71
	if var4 {
		if err := fieldsTarget1.ZeroField("A0"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A0")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.A0.FillVDLTarget(fieldTarget3, tt.NonOptional().Field(0).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
				return err
			}
		}
	}
	var74 := true
	for _, elem75 := range m.A1 {

		var76 := true
		var77 := true
		var78 := (elem75.A0.A0 == false)
		var77 = var77 && var78
		var79 := (elem75.A0.A1 == byte(0))
		var77 = var77 && var79
		var80 := (elem75.A0.A2 == uint16(0))
		var77 = var77 && var80
		var81 := (elem75.A0.A3 == uint32(0))
		var77 = var77 && var81
		var82 := (elem75.A0.A4 == uint64(0))
		var77 = var77 && var82
		var83 := (elem75.A0.A5 == int8(0))
		var77 = var77 && var83
		var84 := (elem75.A0.A6 == int16(0))
		var77 = var77 && var84
		var85 := (elem75.A0.A7 == int32(0))
		var77 = var77 && var85
		var86 := (elem75.A0.A8 == int64(0))
		var77 = var77 && var86
		var87 := (elem75.A0.A9 == float32(0))
		var77 = var77 && var87
		var88 := (elem75.A0.A10 == float64(0))
		var77 = var77 && var88
		var89 := (elem75.A0.A11 == "")
		var77 = var77 && var89
		var90 := (elem75.A0.A12 == (error)(nil))
		var77 = var77 && var90
		var91 := elem75.A0.A13 == nil || elem75.A0.A13.IsNilAny()
		var77 = var77 && var91
		var92 := (elem75.A0.A14 == nil || elem75.A0.A14 == vdl.AnyType)
		var77 = var77 && var92
		var93 := (elem75.A0.B0 == NamedBool(false))
		var77 = var77 && var93
		var94 := (elem75.A0.B1 == NamedByte(0))
		var77 = var77 && var94
		var95 := (elem75.A0.B2 == NamedUint16(0))
		var77 = var77 && var95
		var96 := (elem75.A0.B3 == NamedUint32(0))
		var77 = var77 && var96
		var97 := (elem75.A0.B4 == NamedUint64(0))
		var77 = var77 && var97
		var98 := (elem75.A0.B5 == NamedInt8(0))
		var77 = var77 && var98
		var99 := (elem75.A0.B6 == NamedInt16(0))
		var77 = var77 && var99
		var100 := (elem75.A0.B7 == NamedInt32(0))
		var77 = var77 && var100
		var101 := (elem75.A0.B8 == NamedInt64(0))
		var77 = var77 && var101
		var102 := (elem75.A0.B9 == NamedFloat32(0))
		var77 = var77 && var102
		var103 := (elem75.A0.B10 == NamedFloat64(0))
		var77 = var77 && var103
		var104 := (elem75.A0.B11 == NamedString(""))
		var77 = var77 && var104
		var105 := (elem75.A0.B12 == NamedEnumA)
		var77 = var77 && var105
		var var106 bool
		if field, ok := elem75.A0.B13.(NamedUnionA); ok {

			var107 := (field.Value == false)
			var106 = var107
		}
		var77 = var77 && var106
		var76 = var76 && var77
		var108 := true
		for _, elem109 := range elem75.A1 {

			var110 := true
			var111 := (elem109.A0 == false)
			var110 = var110 && var111
			var112 := (elem109.A1 == byte(0))
			var110 = var110 && var112
			var113 := (elem109.A2 == uint16(0))
			var110 = var110 && var113
			var114 := (elem109.A3 == uint32(0))
			var110 = var110 && var114
			var115 := (elem109.A4 == uint64(0))
			var110 = var110 && var115
			var116 := (elem109.A5 == int8(0))
			var110 = var110 && var116
			var117 := (elem109.A6 == int16(0))
			var110 = var110 && var117
			var118 := (elem109.A7 == int32(0))
			var110 = var110 && var118
			var119 := (elem109.A8 == int64(0))
			var110 = var110 && var119
			var120 := (elem109.A9 == float32(0))
			var110 = var110 && var120
			var121 := (elem109.A10 == float64(0))
			var110 = var110 && var121
			var122 := (elem109.A11 == "")
			var110 = var110 && var122
			var123 := (elem109.A12 == (error)(nil))
			var110 = var110 && var123
			var124 := elem109.A13 == nil || elem109.A13.IsNilAny()
			var110 = var110 && var124
			var125 := (elem109.A14 == nil || elem109.A14 == vdl.AnyType)
			var110 = var110 && var125
			var126 := (elem109.B0 == NamedBool(false))
			var110 = var110 && var126
			var127 := (elem109.B1 == NamedByte(0))
			var110 = var110 && var127
			var128 := (elem109.B2 == NamedUint16(0))
			var110 = var110 && var128
			var129 := (elem109.B3 == NamedUint32(0))
			var110 = var110 && var129
			var130 := (elem109.B4 == NamedUint64(0))
			var110 = var110 && var130
			var131 := (elem109.B5 == NamedInt8(0))
			var110 = var110 && var131
			var132 := (elem109.B6 == NamedInt16(0))
			var110 = var110 && var132
			var133 := (elem109.B7 == NamedInt32(0))
			var110 = var110 && var133
			var134 := (elem109.B8 == NamedInt64(0))
			var110 = var110 && var134
			var135 := (elem109.B9 == NamedFloat32(0))
			var110 = var110 && var135
			var136 := (elem109.B10 == NamedFloat64(0))
			var110 = var110 && var136
			var137 := (elem109.B11 == NamedString(""))
			var110 = var110 && var137
			var138 := (elem109.B12 == NamedEnumA)
			var110 = var110 && var138
			var var139 bool
			if field, ok := elem109.B13.(NamedUnionA); ok {

				var140 := (field.Value == false)
				var139 = var140
			}
			var110 = var110 && var139
			if !var110 {
				var108 = false
				break
			}
		}
		var76 = var76 && var108
		var var141 bool
		if len(elem75.A2) == 0 {
			var141 = true
		}
		var76 = var76 && var141
		var var142 bool
		if len(elem75.A3) == 0 {
			var142 = true
		}
		var76 = var76 && var142
		var var143 bool
		if len(elem75.A4) == 0 {
			var143 = true
		}
		var76 = var76 && var143
		if !var76 {
			var74 = false
			break
		}
	}
	if var74 {
		if err := fieldsTarget1.ZeroField("A1"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget72, fieldTarget73, err := fieldsTarget1.StartField("A1")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.A1.FillVDLTarget(fieldTarget73, tt.NonOptional().Field(1).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget72, fieldTarget73); err != nil {
				return err
			}
		}
	}
	var var146 bool
	if len(m.A2) == 0 {
		var146 = true
	}
	if var146 {
		if err := fieldsTarget1.ZeroField("A2"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget144, fieldTarget145, err := fieldsTarget1.StartField("A2")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			listTarget147, err := fieldTarget145.StartList(tt.NonOptional().Field(2).Type, len(m.A2))
			if err != nil {
				return err
			}
			for i, elem149 := range m.A2 {
				elemTarget148, err := listTarget147.StartElem(i)
				if err != nil {
					return err
				}

				if err := elem149.FillVDLTarget(elemTarget148, tt.NonOptional().Field(2).Type.Elem()); err != nil {
					return err
				}
				if err := listTarget147.FinishElem(elemTarget148); err != nil {
					return err
				}
			}
			if err := fieldTarget145.FinishList(listTarget147); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget144, fieldTarget145); err != nil {
				return err
			}
		}
	}
	var var152 bool
	if len(m.A3) == 0 {
		var152 = true
	}
	if var152 {
		if err := fieldsTarget1.ZeroField("A3"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget150, fieldTarget151, err := fieldsTarget1.StartField("A3")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			mapTarget153, err := fieldTarget151.StartMap(tt.NonOptional().Field(3).Type, len(m.A3))
			if err != nil {
				return err
			}
			for key155, value157 := range m.A3 {
				keyTarget154, err := mapTarget153.StartKey()
				if err != nil {
					return err
				}
				if err := keyTarget154.FromString(string(key155), tt.NonOptional().Field(3).Type.Key()); err != nil {
					return err
				}
				valueTarget156, err := mapTarget153.FinishKeyStartField(keyTarget154)
				if err != nil {
					return err
				}

				if err := value157.FillVDLTarget(valueTarget156, tt.NonOptional().Field(3).Type.Elem()); err != nil {
					return err
				}
				if err := mapTarget153.FinishField(keyTarget154, valueTarget156); err != nil {
					return err
				}
			}
			if err := fieldTarget151.FinishMap(mapTarget153); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget150, fieldTarget151); err != nil {
				return err
			}
		}
	}
	var var160 bool
	if len(m.A4) == 0 {
		var160 = true
	}
	if var160 {
		if err := fieldsTarget1.ZeroField("A4"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget158, fieldTarget159, err := fieldsTarget1.StartField("A4")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			mapTarget161, err := fieldTarget159.StartMap(tt.NonOptional().Field(4).Type, len(m.A4))
			if err != nil {
				return err
			}
			for key163, value165 := range m.A4 {
				keyTarget162, err := mapTarget161.StartKey()
				if err != nil {
					return err
				}

				if err := key163.FillVDLTarget(keyTarget162, tt.NonOptional().Field(4).Type.Key()); err != nil {
					return err
				}
				valueTarget164, err := mapTarget161.FinishKeyStartField(keyTarget162)
				if err != nil {
					return err
				}

				listTarget166, err := valueTarget164.StartList(tt.NonOptional().Field(4).Type.Elem(), len(value165))
				if err != nil {
					return err
				}
				for i, elem168 := range value165 {
					elemTarget167, err := listTarget166.StartElem(i)
					if err != nil {
						return err
					}

					mapTarget169, err := elemTarget167.StartMap(tt.NonOptional().Field(4).Type.Elem().Elem(), len(elem168))
					if err != nil {
						return err
					}
					for key171, value173 := range elem168 {
						keyTarget170, err := mapTarget169.StartKey()
						if err != nil {
							return err
						}
						if err := keyTarget170.FromString(string(key171), tt.NonOptional().Field(4).Type.Elem().Elem().Key()); err != nil {
							return err
						}
						valueTarget172, err := mapTarget169.FinishKeyStartField(keyTarget170)
						if err != nil {
							return err
						}

						if err := value173.FillVDLTarget(valueTarget172, tt.NonOptional().Field(4).Type.Elem().Elem().Elem()); err != nil {
							return err
						}
						if err := mapTarget169.FinishField(keyTarget170, valueTarget172); err != nil {
							return err
						}
					}
					if err := elemTarget167.FinishMap(mapTarget169); err != nil {
						return err
					}
					if err := listTarget166.FinishElem(elemTarget167); err != nil {
						return err
					}
				}
				if err := valueTarget164.FinishList(listTarget166); err != nil {
					return err
				}
				if err := mapTarget161.FinishField(keyTarget162, valueTarget164); err != nil {
					return err
				}
			}
			if err := fieldTarget159.FinishMap(mapTarget161); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget158, fieldTarget159); err != nil {
				return err
			}
		}
	}
	if err := t.FinishFields(fieldsTarget1); err != nil {
		return err
	}
	return nil
}

func (m *CompComp) MakeVDLTarget() vdl.Target {
	return &CompCompTarget{Value: m}
}

type CompCompTarget struct {
	Value    *CompComp
	a0Target CompositesTarget
	a1Target CompositesArrayTarget
	a2Target __VDLTarget4_list
	a3Target __VDLTarget5_map
	a4Target __VDLTarget6_map
	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *CompCompTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {

	if ttWant := vdl.TypeOf((*CompComp)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *CompCompTarget) StartField(name string) (key, field vdl.Target, _ error) {
	switch name {
	case "A0":
		t.a0Target.Value = &t.Value.A0
		target, err := &t.a0Target, error(nil)
		return nil, target, err
	case "A1":
		t.a1Target.Value = &t.Value.A1
		target, err := &t.a1Target, error(nil)
		return nil, target, err
	case "A2":
		t.a2Target.Value = &t.Value.A2
		target, err := &t.a2Target, error(nil)
		return nil, target, err
	case "A3":
		t.a3Target.Value = &t.Value.A3
		target, err := &t.a3Target, error(nil)
		return nil, target, err
	case "A4":
		t.a4Target.Value = &t.Value.A4
		target, err := &t.a4Target, error(nil)
		return nil, target, err
	default:
		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.CompComp", name)
	}
}
func (t *CompCompTarget) FinishField(_, _ vdl.Target) error {
	return nil
}
func (t *CompCompTarget) ZeroField(name string) error {
	switch name {
	case "A0":
		t.Value.A0 = Composites{
			A0: Scalars{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
			A1: ScalarsArray{
				{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
				{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
			},
		}
		return nil
	case "A1":
		t.Value.A1 = CompositesArray{
			{
				A0: Scalars{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
				A1: ScalarsArray{
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
				},
			},
			{
				A0: Scalars{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
				A1: ScalarsArray{
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
				},
			},
		}
		return nil
	case "A2":
		t.Value.A2 = []Composites(nil)
		return nil
	case "A3":
		t.Value.A3 = map[string]Composites(nil)
		return nil
	case "A4":
		t.Value.A4 = map[KeyScalars][]map[string]Composites(nil)
		return nil
	default:
		return fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.CompComp", name)
	}
}
func (t *CompCompTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

// []Composites
type __VDLTarget4_list struct {
	Value      *[]Composites
	elemTarget CompositesTarget
	vdl.TargetBase
	vdl.ListTargetBase
}

func (t *__VDLTarget4_list) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {

	if ttWant := vdl.TypeOf((*[]Composites)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	if cap(*t.Value) < len {
		*t.Value = make([]Composites, len)
	} else {
		*t.Value = (*t.Value)[:len]
	}
	return t, nil
}
func (t *__VDLTarget4_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 *__VDLTarget4_list) FinishElem(elem vdl.Target) error {
	return nil
}
func (t *__VDLTarget4_list) FinishList(elem vdl.ListTarget) error {

	return nil
}

// map[string]Composites
type __VDLTarget5_map struct {
	Value      *map[string]Composites
	currKey    string
	currElem   Composites
	keyTarget  vdl.StringTarget
	elemTarget CompositesTarget
	vdl.TargetBase
	vdl.MapTargetBase
}

func (t *__VDLTarget5_map) StartMap(tt *vdl.Type, len int) (vdl.MapTarget, error) {

	if ttWant := vdl.TypeOf((*map[string]Composites)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = make(map[string]Composites)
	return t, nil
}
func (t *__VDLTarget5_map) StartKey() (key vdl.Target, _ error) {
	t.currKey = ""
	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 = Composites{
		A0: Scalars{
			A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
			A14: vdl.AnyType,
			B13: NamedUnionA{},
		},
		A1: ScalarsArray{
			{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
			{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
		},
	}
	t.elemTarget.Value = &t.currElem
	target, err := &t.elemTarget, 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
}

// map[KeyScalars][]map[string]Composites
type __VDLTarget6_map struct {
	Value      *map[KeyScalars][]map[string]Composites
	currKey    KeyScalars
	currElem   []map[string]Composites
	keyTarget  KeyScalarsTarget
	elemTarget __VDLTarget7_list
	vdl.TargetBase
	vdl.MapTargetBase
}

func (t *__VDLTarget6_map) StartMap(tt *vdl.Type, len int) (vdl.MapTarget, error) {

	if ttWant := vdl.TypeOf((*map[KeyScalars][]map[string]Composites)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	*t.Value = make(map[KeyScalars][]map[string]Composites)
	return t, nil
}
func (t *__VDLTarget6_map) StartKey() (key vdl.Target, _ error) {
	t.currKey = KeyScalars{}
	t.keyTarget.Value = &t.currKey
	target, err := &t.keyTarget, error(nil)
	return target, err
}
func (t *__VDLTarget6_map) FinishKeyStartField(key vdl.Target) (field vdl.Target, _ error) {
	t.currElem = []map[string]Composites(nil)
	t.elemTarget.Value = &t.currElem
	target, err := &t.elemTarget, error(nil)
	return target, err
}
func (t *__VDLTarget6_map) FinishField(key, field vdl.Target) error {
	(*t.Value)[t.currKey] = t.currElem
	return nil
}
func (t *__VDLTarget6_map) FinishMap(elem vdl.MapTarget) error {
	if len(*t.Value) == 0 {
		*t.Value = nil
	}

	return nil
}

// []map[string]Composites
type __VDLTarget7_list struct {
	Value      *[]map[string]Composites
	elemTarget __VDLTarget5_map
	vdl.TargetBase
	vdl.ListTargetBase
}

func (t *__VDLTarget7_list) StartList(tt *vdl.Type, len int) (vdl.ListTarget, error) {

	if ttWant := vdl.TypeOf((*[]map[string]Composites)(nil)); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	if cap(*t.Value) < len {
		*t.Value = make([]map[string]Composites, len)
	} else {
		*t.Value = (*t.Value)[:len]
	}
	return t, nil
}
func (t *__VDLTarget7_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 *__VDLTarget7_list) FinishElem(elem vdl.Target) error {
	return nil
}
func (t *__VDLTarget7_list) FinishList(elem vdl.ListTarget) error {

	return nil
}

func (x *CompComp) VDLRead(dec vdl.Decoder) error {
	*x = CompComp{
		A0: Composites{
			A0: Scalars{
				A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
				A14: vdl.AnyType,
				B13: NamedUnionA{},
			},
			A1: ScalarsArray{
				{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
				{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
			},
		},
		A1: CompositesArray{
			{
				A0: Scalars{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
				A1: ScalarsArray{
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
				},
			},
			{
				A0: Scalars{
					A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
					A14: vdl.AnyType,
					B13: NamedUnionA{},
				},
				A1: ScalarsArray{
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
					{
						A13: vom.RawBytesOf(vdl.ZeroValue(vdl.AnyType)),
						A14: vdl.AnyType,
						B13: NamedUnionA{},
					},
				},
			},
		},
	}
	var err 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 struct %T, from %v", *x, dec.Type())
	}
	for {
		f, err := dec.NextField()
		if err != nil {
			return err
		}
		switch f {
		case "":
			return dec.FinishValue()
		case "A0":
			if err = x.A0.VDLRead(dec); err != nil {
				return err
			}
		case "A1":
			if err = x.A1.VDLRead(dec); err != nil {
				return err
			}
		case "A2":
			if err = __VDLRead4_list(dec, &x.A2); err != nil {
				return err
			}
		case "A3":
			if err = __VDLRead5_map(dec, &x.A3); err != nil {
				return err
			}
		case "A4":
			if err = __VDLRead6_map(dec, &x.A4); err != nil {
				return err
			}
		default:
			if err = dec.SkipValue(); err != nil {
				return err
			}
		}
	}
}

func __VDLRead4_list(dec vdl.Decoder, x *[]Composites) error {
	var err 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([]Composites, 0, len)
	default:
		*x = nil
	}
	for {
		switch done, err := dec.NextEntry(); {
		case err != nil:
			return err
		case done:
			return dec.FinishValue()
		}
		var elem Composites
		if err = elem.VDLRead(dec); err != nil {
			return err
		}
		*x = append(*x, elem)
	}
}

func __VDLRead5_map(dec vdl.Decoder, x *map[string]Composites) error {
	var err 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]Composites
	if len := dec.LenHint(); len > 0 {
		tmpMap = make(map[string]Composites, 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
			}
			if key, err = dec.DecodeString(); err != nil {
				return err
			}
			if err = dec.FinishValue(); err != nil {
				return err
			}
		}
		var elem Composites
		{
			if err = elem.VDLRead(dec); err != nil {
				return err
			}
		}
		if tmpMap == nil {
			tmpMap = make(map[string]Composites)
		}
		tmpMap[key] = elem
	}
}

func __VDLRead6_map(dec vdl.Decoder, x *map[KeyScalars][]map[string]Composites) error {
	var err 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[KeyScalars][]map[string]Composites
	if len := dec.LenHint(); len > 0 {
		tmpMap = make(map[KeyScalars][]map[string]Composites, len)
	}
	for {
		switch done, err := dec.NextEntry(); {
		case err != nil:
			return err
		case done:
			*x = tmpMap
			return dec.FinishValue()
		}
		var key KeyScalars
		{
			if err = key.VDLRead(dec); err != nil {
				return err
			}
		}
		var elem []map[string]Composites
		{
			if err = __VDLRead7_list(dec, &elem); err != nil {
				return err
			}
		}
		if tmpMap == nil {
			tmpMap = make(map[KeyScalars][]map[string]Composites)
		}
		tmpMap[key] = elem
	}
}

func __VDLRead7_list(dec vdl.Decoder, x *[]map[string]Composites) error {
	var err 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([]map[string]Composites, 0, len)
	default:
		*x = nil
	}
	for {
		switch done, err := dec.NextEntry(); {
		case err != nil:
			return err
		case done:
			return dec.FinishValue()
		}
		var elem map[string]Composites
		if err = __VDLRead5_map(dec, &elem); err != nil {
			return err
		}
		*x = append(*x, elem)
	}
}

// Args will be reordered to show up before NestedArgs in the generated output.
type Args struct {
	A int32
	B int32
}

func (Args) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.Args"`
}) {
}

func (m *Args) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	var4 := (m.A == int32(0))
	if var4 {
		if err := fieldsTarget1.ZeroField("A"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("A")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget3.FromInt(int64(m.A), tt.NonOptional().Field(0).Type); err != nil {
				return err
			}
			if err := fieldsTarget1.FinishField(keyTarget2, fieldTarget3); err != nil {
				return err
			}
		}
	}
	var7 := (m.B == int32(0))
	if var7 {
		if err := fieldsTarget1.ZeroField("B"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget5, fieldTarget6, err := fieldsTarget1.StartField("B")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}
			if err := fieldTarget6.FromInt(int64(m.B), 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 *Args) MakeVDLTarget() vdl.Target {
	return &ArgsTarget{Value: m}
}

type ArgsTarget struct {
	Value   *Args
	aTarget vdl.Int32Target
	bTarget vdl.Int32Target
	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *ArgsTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {

	if ttWant := vdl.TypeOf((*Args)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *ArgsTarget) StartField(name string) (key, field vdl.Target, _ error) {
	switch name {
	case "A":
		t.aTarget.Value = &t.Value.A
		target, err := &t.aTarget, error(nil)
		return nil, target, err
	case "B":
		t.bTarget.Value = &t.Value.B
		target, err := &t.bTarget, error(nil)
		return nil, target, err
	default:
		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.Args", name)
	}
}
func (t *ArgsTarget) FinishField(_, _ vdl.Target) error {
	return nil
}
func (t *ArgsTarget) ZeroField(name string) error {
	switch name {
	case "A":
		t.Value.A = int32(0)
		return nil
	case "B":
		t.Value.B = int32(0)
		return nil
	default:
		return fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.Args", name)
	}
}
func (t *ArgsTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

func (x *Args) VDLRead(dec vdl.Decoder) error {
	*x = Args{}
	var err 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 struct %T, from %v", *x, dec.Type())
	}
	for {
		f, err := dec.NextField()
		if err != nil {
			return err
		}
		switch f {
		case "":
			return dec.FinishValue()
		case "A":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(32)
			if err != nil {
				return err
			}
			x.A = int32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		case "B":
			if err = dec.StartValue(); err != nil {
				return err
			}
			tmp, err := dec.DecodeInt(32)
			if err != nil {
				return err
			}
			x.B = int32(tmp)
			if err = dec.FinishValue(); err != nil {
				return err
			}
		default:
			if err = dec.SkipValue(); err != nil {
				return err
			}
		}
	}
}

// NestedArgs is defined before Args; that's allowed in regular Go, and also
// allowed in our vdl files.  The compiler will re-order dependent types to ease
// code generation in other languages.
type NestedArgs struct {
	Args Args
}

func (NestedArgs) __VDLReflect(struct {
	Name string `vdl:"v.io/x/ref/lib/vdl/testdata/base.NestedArgs"`
}) {
}

func (m *NestedArgs) FillVDLTarget(t vdl.Target, tt *vdl.Type) error {
	fieldsTarget1, err := t.StartFields(tt)
	if err != nil {
		return err
	}
	var4 := (m.Args == Args{})
	if var4 {
		if err := fieldsTarget1.ZeroField("Args"); err != nil && err != vdl.ErrFieldNoExist {
			return err
		}
	} else {
		keyTarget2, fieldTarget3, err := fieldsTarget1.StartField("Args")
		if err != vdl.ErrFieldNoExist {
			if err != nil {
				return err
			}

			if err := m.Args.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 *NestedArgs) MakeVDLTarget() vdl.Target {
	return &NestedArgsTarget{Value: m}
}

type NestedArgsTarget struct {
	Value      *NestedArgs
	argsTarget ArgsTarget
	vdl.TargetBase
	vdl.FieldsTargetBase
}

func (t *NestedArgsTarget) StartFields(tt *vdl.Type) (vdl.FieldsTarget, error) {

	if ttWant := vdl.TypeOf((*NestedArgs)(nil)).Elem(); !vdl.Compatible(tt, ttWant) {
		return nil, fmt.Errorf("type %v incompatible with %v", tt, ttWant)
	}
	return t, nil
}
func (t *NestedArgsTarget) StartField(name string) (key, field vdl.Target, _ error) {
	switch name {
	case "Args":
		t.argsTarget.Value = &t.Value.Args
		target, err := &t.argsTarget, error(nil)
		return nil, target, err
	default:
		return nil, nil, fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.NestedArgs", name)
	}
}
func (t *NestedArgsTarget) FinishField(_, _ vdl.Target) error {
	return nil
}
func (t *NestedArgsTarget) ZeroField(name string) error {
	switch name {
	case "Args":
		t.Value.Args = Args{}
		return nil
	default:
		return fmt.Errorf("field %s not in struct v.io/x/ref/lib/vdl/testdata/base.NestedArgs", name)
	}
}
func (t *NestedArgsTarget) FinishFields(_ vdl.FieldsTarget) error {

	return nil
}

func (x *NestedArgs) VDLRead(dec vdl.Decoder) error {
	*x = NestedArgs{}
	var err 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 struct %T, from %v", *x, dec.Type())
	}
	for {
		f, err := dec.NextField()
		if err != nil {
			return err
		}
		switch f {
		case "":
			return dec.FinishValue()
		case "Args":
			if err = x.Args.VDLRead(dec); err != nil {
				return err
			}
		default:
			if err = dec.SkipValue(); err != nil {
				return err
			}
		}
	}
}

//////////////////////////////////////////////////
// Const definitions

const Cbool = true
const Cbyte = byte(1)
const Cint32 = int32(2)
const Cint64 = int64(3)
const Cuint32 = uint32(4)
const Cuint64 = uint64(5)
const Cfloat32 = float32(6)
const Cfloat64 = float64(7)
const CNamedBool = NamedBool(true)

var CNamedStruct = NamedStruct{
	A: true,
	B: "test",
}

const Cstring = "foo"
const Cenum = NamedEnumA

var Cunion = NamedUnion(NamedUnionA{true})
var Carray = NamedArray{
	true,
	false,
}
var Clist = []int32{
	1,
	2,
	3,
}
var Cset = map[int32]struct{}{
	1: struct{}{},
	2: struct{}{},
	3: struct{}{},
}
var cmap = map[int32]string{
	1: "A",
	2: "B",
	3: "C",
}
var Cargs = Args{
	A: 1,
	B: 2,
}
var CScalars = Scalars{
	A0:  true,
	A1:  1,
	A2:  2,
	A3:  3,
	A4:  4,
	A5:  5,
	A6:  6,
	A7:  7,
	A8:  8,
	A9:  9,
	A10: 10,
	A11: "abc",
	A13: vom.RawBytesOf(false),
	A14: vdl.TypeOf((*bool)(nil)),
	B0:  true,
	B1:  1,
	B2:  2,
	B3:  3,
	B4:  4,
	B5:  5,
	B6:  6,
	B7:  7,
	B8:  8,
	B9:  9,
	B10: 10,
	B11: "abc",
	B12: NamedEnumB,
	B13: NamedUnionC{123},
}

const True = true
const Foo = "foo"
const Five = int32(5)
const Six = uint64(6)
const SixSquared = uint64(36)
const FiveSquared = int32(25)

var CTypeObject_bool = vdl.TypeOf((*bool)(nil))
var CTypeObject_string = vdl.TypeOf((*string)(nil))
var CTypeObject_bytes = vdl.TypeOf((*[]byte)(nil))
var CTypeObject_byte = vdl.TypeOf((*byte)(nil))
var CTypeObject_uint16 = vdl.TypeOf((*uint16)(nil))
var CTypeObject_int8 = vdl.TypeOf((*int8)(nil))
var CTypeObject_int16 = vdl.TypeOf((*int16)(nil))
var CTypeObject_float32 = vdl.TypeOf((*float32)(nil))
var CTypeObject_enum = vdl.TypeOf((*NamedEnum)(nil))
var CTypeObject_Array = vdl.TypeOf((*NamedArray)(nil))
var CTypeObject_List = vdl.TypeOf((*[]string)(nil))
var CTypeObject_Set = vdl.TypeOf((*map[string]struct{})(nil))
var CTypeObject_Map = vdl.TypeOf((*map[string]int64)(nil))
var CTypeObject_Struct = vdl.TypeOf((*Scalars)(nil)).Elem()
var CTypeObject_Union = vdl.TypeOf((*NamedUnion)(nil))
var CTypeObject_TypeObject = vdl.TypeObjectType
var CTypeObject_Any = vdl.AnyType

//////////////////////////////////////////////////
// Error definitions
var (
	ErrNoParams1   = verror.Register("v.io/x/ref/lib/vdl/testdata/base.NoParams1", verror.NoRetry, "{1:}{2:} en msg")
	ErrNoParams2   = verror.Register("v.io/x/ref/lib/vdl/testdata/base.NoParams2", verror.RetryRefetch, "{1:}{2:} en msg")
	ErrWithParams1 = verror.Register("v.io/x/ref/lib/vdl/testdata/base.WithParams1", verror.NoRetry, "{1:}{2:} en x={3} y={4}")
	ErrWithParams2 = verror.Register("v.io/x/ref/lib/vdl/testdata/base.WithParams2", verror.RetryRefetch, "{1:}{2:} en x={3} y={4}")
	errNotExported = verror.Register("v.io/x/ref/lib/vdl/testdata/base.notExported", verror.NoRetry, "{1:}{2:} en x={3} y={4}")
)

// NewErrNoParams1 returns an error with the ErrNoParams1 ID.
func NewErrNoParams1(ctx *context.T) error {
	return verror.New(ErrNoParams1, ctx)
}

// NewErrNoParams2 returns an error with the ErrNoParams2 ID.
func NewErrNoParams2(ctx *context.T) error {
	return verror.New(ErrNoParams2, ctx)
}

// NewErrWithParams1 returns an error with the ErrWithParams1 ID.
func NewErrWithParams1(ctx *context.T, x string, y int32) error {
	return verror.New(ErrWithParams1, ctx, x, y)
}

// NewErrWithParams2 returns an error with the ErrWithParams2 ID.
func NewErrWithParams2(ctx *context.T, x string, y int32) error {
	return verror.New(ErrWithParams2, ctx, x, y)
}

// newErrNotExported returns an error with the errNotExported ID.
func newErrNotExported(ctx *context.T, x string, y int32) error {
	return verror.New(errNotExported, ctx, x, y)
}

//////////////////////////////////////////////////
// Interface definitions

// ServiceAClientMethods is the client interface
// containing ServiceA methods.
type ServiceAClientMethods interface {
	MethodA1(*context.T, ...rpc.CallOpt) error
	MethodA2(_ *context.T, a int32, b string, _ ...rpc.CallOpt) (s string, _ error)
	MethodA3(_ *context.T, a int32, _ ...rpc.CallOpt) (ServiceAMethodA3ClientCall, error)
	MethodA4(_ *context.T, a int32, _ ...rpc.CallOpt) (ServiceAMethodA4ClientCall, error)
}

// ServiceAClientStub adds universal methods to ServiceAClientMethods.
type ServiceAClientStub interface {
	ServiceAClientMethods
	rpc.UniversalServiceMethods
}

// ServiceAClient returns a client stub for ServiceA.
func ServiceAClient(name string) ServiceAClientStub {
	return implServiceAClientStub{name}
}

type implServiceAClientStub struct {
	name string
}

func (c implServiceAClientStub) MethodA1(ctx *context.T, opts ...rpc.CallOpt) (err error) {
	err = v23.GetClient(ctx).Call(ctx, c.name, "MethodA1", nil, nil, opts...)
	return
}

func (c implServiceAClientStub) MethodA2(ctx *context.T, i0 int32, i1 string, opts ...rpc.CallOpt) (o0 string, err error) {
	err = v23.GetClient(ctx).Call(ctx, c.name, "MethodA2", []interface{}{i0, i1}, []interface{}{&o0}, opts...)
	return
}

func (c implServiceAClientStub) MethodA3(ctx *context.T, i0 int32, opts ...rpc.CallOpt) (ocall ServiceAMethodA3ClientCall, err error) {
	var call rpc.ClientCall
	if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "MethodA3", []interface{}{i0}, opts...); err != nil {
		return
	}
	ocall = &implServiceAMethodA3ClientCall{ClientCall: call}
	return
}

func (c implServiceAClientStub) MethodA4(ctx *context.T, i0 int32, opts ...rpc.CallOpt) (ocall ServiceAMethodA4ClientCall, err error) {
	var call rpc.ClientCall
	if call, err = v23.GetClient(ctx).StartCall(ctx, c.name, "MethodA4", []interface{}{i0}, opts...); err != nil {
		return
	}
	ocall = &implServiceAMethodA4ClientCall{ClientCall: call}
	return
}

// ServiceAMethodA3ClientStream is the client stream for ServiceA.MethodA3.
type ServiceAMethodA3ClientStream interface {
	// RecvStream returns the receiver side of the ServiceA.MethodA3 client stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() Scalars
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
}

// ServiceAMethodA3ClientCall represents the call returned from ServiceA.MethodA3.
type ServiceAMethodA3ClientCall interface {
	ServiceAMethodA3ClientStream
	// Finish blocks until the server is done, and returns the positional return
	// values for call.
	//
	// Finish returns immediately if the call has been canceled; depending on the
	// timing the output could either be an error signaling cancelation, or the
	// valid positional return values from the server.
	//
	// Calling Finish is mandatory for releasing stream resources, unless the call
	// has been canceled or any of the other methods return an error.  Finish should
	// be called at most once.
	Finish() (s string, _ error)
}

type implServiceAMethodA3ClientCall struct {
	rpc.ClientCall
	valRecv Scalars
	errRecv error
}

func (c *implServiceAMethodA3ClientCall) RecvStream() interface {
	Advance() bool
	Value() Scalars
	Err() error
} {
	return implServiceAMethodA3ClientCallRecv{c}
}

type implServiceAMethodA3ClientCallRecv struct {
	c *implServiceAMethodA3ClientCall
}

func (c implServiceAMethodA3ClientCallRecv) Advance() bool {
	c.c.valRecv = Scalars{}
	c.c.errRecv = c.c.Recv(&c.c.valRecv)
	return c.c.errRecv == nil
}
func (c implServiceAMethodA3ClientCallRecv) Value() Scalars {
	return c.c.valRecv
}
func (c implServiceAMethodA3ClientCallRecv) Err() error {
	if c.c.errRecv == io.EOF {
		return nil
	}
	return c.c.errRecv
}
func (c *implServiceAMethodA3ClientCall) Finish() (o0 string, err error) {
	err = c.ClientCall.Finish(&o0)
	return
}

// ServiceAMethodA4ClientStream is the client stream for ServiceA.MethodA4.
type ServiceAMethodA4ClientStream interface {
	// RecvStream returns the receiver side of the ServiceA.MethodA4 client stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() string
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
	// SendStream returns the send side of the ServiceA.MethodA4 client stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors
		// encountered while sending, or if Send is called after Close or
		// the stream has been canceled.  Blocks if there is no buffer
		// space; will unblock when buffer space is available or after
		// the stream has been canceled.
		Send(item int32) error
		// Close indicates to the server that no more items will be sent;
		// server Recv calls will receive io.EOF after all sent items.
		// This is an optional call - e.g. a client might call Close if it
		// needs to continue receiving items from the server after it's
		// done sending.  Returns errors encountered while closing, or if
		// Close is called after the stream has been canceled.  Like Send,
		// blocks if there is no buffer space available.
		Close() error
	}
}

// ServiceAMethodA4ClientCall represents the call returned from ServiceA.MethodA4.
type ServiceAMethodA4ClientCall interface {
	ServiceAMethodA4ClientStream
	// Finish performs the equivalent of SendStream().Close, then blocks until
	// the server is done, and returns the positional return values for the call.
	//
	// Finish returns immediately if the call has been canceled; depending on the
	// timing the output could either be an error signaling cancelation, or the
	// valid positional return values from the server.
	//
	// Calling Finish is mandatory for releasing stream resources, unless the call
	// has been canceled or any of the other methods return an error.  Finish should
	// be called at most once.
	Finish() error
}

type implServiceAMethodA4ClientCall struct {
	rpc.ClientCall
	valRecv string
	errRecv error
}

func (c *implServiceAMethodA4ClientCall) RecvStream() interface {
	Advance() bool
	Value() string
	Err() error
} {
	return implServiceAMethodA4ClientCallRecv{c}
}

type implServiceAMethodA4ClientCallRecv struct {
	c *implServiceAMethodA4ClientCall
}

func (c implServiceAMethodA4ClientCallRecv) Advance() bool {
	c.c.errRecv = c.c.Recv(&c.c.valRecv)
	return c.c.errRecv == nil
}
func (c implServiceAMethodA4ClientCallRecv) Value() string {
	return c.c.valRecv
}
func (c implServiceAMethodA4ClientCallRecv) Err() error {
	if c.c.errRecv == io.EOF {
		return nil
	}
	return c.c.errRecv
}
func (c *implServiceAMethodA4ClientCall) SendStream() interface {
	Send(item int32) error
	Close() error
} {
	return implServiceAMethodA4ClientCallSend{c}
}

type implServiceAMethodA4ClientCallSend struct {
	c *implServiceAMethodA4ClientCall
}

func (c implServiceAMethodA4ClientCallSend) Send(item int32) error {
	return c.c.Send(item)
}
func (c implServiceAMethodA4ClientCallSend) Close() error {
	return c.c.CloseSend()
}
func (c *implServiceAMethodA4ClientCall) Finish() (err error) {
	err = c.ClientCall.Finish()
	return
}

// ServiceAServerMethods is the interface a server writer
// implements for ServiceA.
type ServiceAServerMethods interface {
	MethodA1(*context.T, rpc.ServerCall) error
	MethodA2(_ *context.T, _ rpc.ServerCall, a int32, b string) (s string, _ error)
	MethodA3(_ *context.T, _ ServiceAMethodA3ServerCall, a int32) (s string, _ error)
	MethodA4(_ *context.T, _ ServiceAMethodA4ServerCall, a int32) error
}

// ServiceAServerStubMethods is the server interface containing
// ServiceA methods, as expected by rpc.Server.
// The only difference between this interface and ServiceAServerMethods
// is the streaming methods.
type ServiceAServerStubMethods interface {
	MethodA1(*context.T, rpc.ServerCall) error
	MethodA2(_ *context.T, _ rpc.ServerCall, a int32, b string) (s string, _ error)
	MethodA3(_ *context.T, _ *ServiceAMethodA3ServerCallStub, a int32) (s string, _ error)
	MethodA4(_ *context.T, _ *ServiceAMethodA4ServerCallStub, a int32) error
}

// ServiceAServerStub adds universal methods to ServiceAServerStubMethods.
type ServiceAServerStub interface {
	ServiceAServerStubMethods
	// Describe the ServiceA interfaces.
	Describe__() []rpc.InterfaceDesc
}

// ServiceAServer returns a server stub for ServiceA.
// It converts an implementation of ServiceAServerMethods into
// an object that may be used by rpc.Server.
func ServiceAServer(impl ServiceAServerMethods) ServiceAServerStub {
	stub := implServiceAServerStub{
		impl: impl,
	}
	// Initialize GlobState; always check the stub itself first, to handle the
	// case where the user has the Glob method defined in their VDL source.
	if gs := rpc.NewGlobState(stub); gs != nil {
		stub.gs = gs
	} else if gs := rpc.NewGlobState(impl); gs != nil {
		stub.gs = gs
	}
	return stub
}

type implServiceAServerStub struct {
	impl ServiceAServerMethods
	gs   *rpc.GlobState
}

func (s implServiceAServerStub) MethodA1(ctx *context.T, call rpc.ServerCall) error {
	return s.impl.MethodA1(ctx, call)
}

func (s implServiceAServerStub) MethodA2(ctx *context.T, call rpc.ServerCall, i0 int32, i1 string) (string, error) {
	return s.impl.MethodA2(ctx, call, i0, i1)
}

func (s implServiceAServerStub) MethodA3(ctx *context.T, call *ServiceAMethodA3ServerCallStub, i0 int32) (string, error) {
	return s.impl.MethodA3(ctx, call, i0)
}

func (s implServiceAServerStub) MethodA4(ctx *context.T, call *ServiceAMethodA4ServerCallStub, i0 int32) error {
	return s.impl.MethodA4(ctx, call, i0)
}

func (s implServiceAServerStub) Globber() *rpc.GlobState {
	return s.gs
}

func (s implServiceAServerStub) Describe__() []rpc.InterfaceDesc {
	return []rpc.InterfaceDesc{ServiceADesc}
}

// ServiceADesc describes the ServiceA interface.
var ServiceADesc rpc.InterfaceDesc = descServiceA

// descServiceA hides the desc to keep godoc clean.
var descServiceA = rpc.InterfaceDesc{
	Name:    "ServiceA",
	PkgPath: "v.io/x/ref/lib/vdl/testdata/base",
	Methods: []rpc.MethodDesc{
		{
			Name: "MethodA1",
		},
		{
			Name: "MethodA2",
			InArgs: []rpc.ArgDesc{
				{"a", ``}, // int32
				{"b", ``}, // string
			},
			OutArgs: []rpc.ArgDesc{
				{"s", ``}, // string
			},
		},
		{
			Name: "MethodA3",
			InArgs: []rpc.ArgDesc{
				{"a", ``}, // int32
			},
			OutArgs: []rpc.ArgDesc{
				{"s", ``}, // string
			},
			Tags: []*vdl.Value{vdl.ValueOf("tag"), vdl.ValueOf(uint64(6))},
		},
		{
			Name: "MethodA4",
			InArgs: []rpc.ArgDesc{
				{"a", ``}, // int32
			},
		},
	},
}

// ServiceAMethodA3ServerStream is the server stream for ServiceA.MethodA3.
type ServiceAMethodA3ServerStream interface {
	// SendStream returns the send side of the ServiceA.MethodA3 server stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors encountered
		// while sending.  Blocks if there is no buffer space; will unblock when
		// buffer space is available.
		Send(item Scalars) error
	}
}

// ServiceAMethodA3ServerCall represents the context passed to ServiceA.MethodA3.
type ServiceAMethodA3ServerCall interface {
	rpc.ServerCall
	ServiceAMethodA3ServerStream
}

// ServiceAMethodA3ServerCallStub is a wrapper that converts rpc.StreamServerCall into
// a typesafe stub that implements ServiceAMethodA3ServerCall.
type ServiceAMethodA3ServerCallStub struct {
	rpc.StreamServerCall
}

// Init initializes ServiceAMethodA3ServerCallStub from rpc.StreamServerCall.
func (s *ServiceAMethodA3ServerCallStub) Init(call rpc.StreamServerCall) {
	s.StreamServerCall = call
}

// SendStream returns the send side of the ServiceA.MethodA3 server stream.
func (s *ServiceAMethodA3ServerCallStub) SendStream() interface {
	Send(item Scalars) error
} {
	return implServiceAMethodA3ServerCallSend{s}
}

type implServiceAMethodA3ServerCallSend struct {
	s *ServiceAMethodA3ServerCallStub
}

func (s implServiceAMethodA3ServerCallSend) Send(item Scalars) error {
	return s.s.Send(item)
}

// ServiceAMethodA4ServerStream is the server stream for ServiceA.MethodA4.
type ServiceAMethodA4ServerStream interface {
	// RecvStream returns the receiver side of the ServiceA.MethodA4 server stream.
	RecvStream() interface {
		// Advance stages an item so that it may be retrieved via Value.  Returns
		// true iff there is an item to retrieve.  Advance must be called before
		// Value is called.  May block if an item is not available.
		Advance() bool
		// Value returns the item that was staged by Advance.  May panic if Advance
		// returned false or was not called.  Never blocks.
		Value() int32
		// Err returns any error encountered by Advance.  Never blocks.
		Err() error
	}
	// SendStream returns the send side of the ServiceA.MethodA4 server stream.
	SendStream() interface {
		// Send places the item onto the output stream.  Returns errors encountered
		// while sending.  Blocks if there is no buffer space; will unblock when
		// buffer space is available.
		Send(item string) error
	}
}

// ServiceAMethodA4ServerCall represents the context passed to ServiceA.MethodA4.
type ServiceAMethodA4ServerCall interface {
	rpc.ServerCall
	ServiceAMethodA4ServerStream
}

// ServiceAMethodA4ServerCallStub is a wrapper that converts rpc.StreamServerCall into
// a typesafe stub that implements ServiceAMethodA4ServerCall.
type ServiceAMethodA4ServerCallStub struct {
	rpc.StreamServerCall
	valRecv int32
	errRecv error
}

// Init initializes ServiceAMethodA4ServerCallStub from rpc.StreamServerCall.
func (s *ServiceAMethodA4ServerCallStub) Init(call rpc.StreamServerCall) {
	s.StreamServerCall = call
}

// RecvStream returns the receiver side of the ServiceA.MethodA4 server stream.
func (s *ServiceAMethodA4ServerCallStub) RecvStream() interface {
	Advance() bool
	Value() int32
	Err() error
} {
	return implServiceAMethodA4ServerCallRecv{s}
}

type implServiceAMethodA4ServerCallRecv struct {
	s *ServiceAMethodA4ServerCallStub
}

func (s implServiceAMethodA4ServerCallRecv) Advance() bool {
	s.s.errRecv = s.s.Recv(&s.s.valRecv)
	return s.s.errRecv == nil
}
func (s implServiceAMethodA4ServerCallRecv) Value() int32 {
	return s.s.valRecv
}
func (s implServiceAMethodA4ServerCallRecv) Err() error {
	if s.s.errRecv == io.EOF {
		return nil
	}
	return s.s.errRecv
}

// SendStream returns the send side of the ServiceA.MethodA4 server stream.
func (s *ServiceAMethodA4ServerCallStub) SendStream() interface {
	Send(item string) error
} {
	return implServiceAMethodA4ServerCallSend{s}
}

type implServiceAMethodA4ServerCallSend struct {
	s *ServiceAMethodA4ServerCallStub
}

func (s implServiceAMethodA4ServerCallSend) Send(item string) error {
	return s.s.Send(item)
}

// ServiceBClientMethods is the client interface
// containing ServiceB methods.
type ServiceBClientMethods interface {
	ServiceAClientMethods
	MethodB1(_ *context.T, a Scalars, b Composites, _ ...rpc.CallOpt) (c CompComp, _ error)
}

// ServiceBClientStub adds universal methods to ServiceBClientMethods.
type ServiceBClientStub interface {
	ServiceBClientMethods
	rpc.UniversalServiceMethods
}

// ServiceBClient returns a client stub for ServiceB.
func ServiceBClient(name string) ServiceBClientStub {
	return implServiceBClientStub{name, ServiceAClient(name)}
}

type implServiceBClientStub struct {
	name string

	ServiceAClientStub
}

func (c implServiceBClientStub) MethodB1(ctx *context.T, i0 Scalars, i1 Composites, opts ...rpc.CallOpt) (o0 CompComp, err error) {
	err = v23.GetClient(ctx).Call(ctx, c.name, "MethodB1", []interface{}{i0, i1}, []interface{}{&o0}, opts...)
	return
}

// ServiceBServerMethods is the interface a server writer
// implements for ServiceB.
type ServiceBServerMethods interface {
	ServiceAServerMethods
	MethodB1(_ *context.T, _ rpc.ServerCall, a Scalars, b Composites) (c CompComp, _ error)
}

// ServiceBServerStubMethods is the server interface containing
// ServiceB methods, as expected by rpc.Server.
// The only difference between this interface and ServiceBServerMethods
// is the streaming methods.
type ServiceBServerStubMethods interface {
	ServiceAServerStubMethods
	MethodB1(_ *context.T, _ rpc.ServerCall, a Scalars, b Composites) (c CompComp, _ error)
}

// ServiceBServerStub adds universal methods to ServiceBServerStubMethods.
type ServiceBServerStub interface {
	ServiceBServerStubMethods
	// Describe the ServiceB interfaces.
	Describe__() []rpc.InterfaceDesc
}

// ServiceBServer returns a server stub for ServiceB.
// It converts an implementation of ServiceBServerMethods into
// an object that may be used by rpc.Server.
func ServiceBServer(impl ServiceBServerMethods) ServiceBServerStub {
	stub := implServiceBServerStub{
		impl:               impl,
		ServiceAServerStub: ServiceAServer(impl),
	}
	// Initialize GlobState; always check the stub itself first, to handle the
	// case where the user has the Glob method defined in their VDL source.
	if gs := rpc.NewGlobState(stub); gs != nil {
		stub.gs = gs
	} else if gs := rpc.NewGlobState(impl); gs != nil {
		stub.gs = gs
	}
	return stub
}

type implServiceBServerStub struct {
	impl ServiceBServerMethods
	ServiceAServerStub
	gs *rpc.GlobState
}

func (s implServiceBServerStub) MethodB1(ctx *context.T, call rpc.ServerCall, i0 Scalars, i1 Composites) (CompComp, error) {
	return s.impl.MethodB1(ctx, call, i0, i1)
}

func (s implServiceBServerStub) Globber() *rpc.GlobState {
	return s.gs
}

func (s implServiceBServerStub) Describe__() []rpc.InterfaceDesc {
	return []rpc.InterfaceDesc{ServiceBDesc, ServiceADesc}
}

// ServiceBDesc describes the ServiceB interface.
var ServiceBDesc rpc.InterfaceDesc = descServiceB

// descServiceB hides the desc to keep godoc clean.
var descServiceB = rpc.InterfaceDesc{
	Name:    "ServiceB",
	PkgPath: "v.io/x/ref/lib/vdl/testdata/base",
	Embeds: []rpc.EmbedDesc{
		{"ServiceA", "v.io/x/ref/lib/vdl/testdata/base", ``},
	},
	Methods: []rpc.MethodDesc{
		{
			Name: "MethodB1",
			InArgs: []rpc.ArgDesc{
				{"a", ``}, // Scalars
				{"b", ``}, // Composites
			},
			OutArgs: []rpc.ArgDesc{
				{"c", ``}, // CompComp
			},
		},
	},
}

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((*NamedBool)(nil))
	vdl.Register((*NamedByte)(nil))
	vdl.Register((*NamedUint16)(nil))
	vdl.Register((*NamedUint32)(nil))
	vdl.Register((*NamedUint64)(nil))
	vdl.Register((*NamedInt8)(nil))
	vdl.Register((*NamedInt16)(nil))
	vdl.Register((*NamedInt32)(nil))
	vdl.Register((*NamedInt64)(nil))
	vdl.Register((*NamedFloat32)(nil))
	vdl.Register((*NamedFloat64)(nil))
	vdl.Register((*NamedString)(nil))
	vdl.Register((*NamedEnum)(nil))
	vdl.Register((*NamedArray)(nil))
	vdl.Register((*NamedList)(nil))
	vdl.Register((*NamedSet)(nil))
	vdl.Register((*NamedMap)(nil))
	vdl.Register((*NamedStruct)(nil))
	vdl.Register((*NamedUnion)(nil))
	vdl.Register((*Scalars)(nil))
	vdl.Register((*KeyScalars)(nil))
	vdl.Register((*ScalarsArray)(nil))
	vdl.Register((*Composites)(nil))
	vdl.Register((*CompositesArray)(nil))
	vdl.Register((*CompComp)(nil))
	vdl.Register((*Args)(nil))
	vdl.Register((*NestedArgs)(nil))

	// Set error format strings.
	i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrNoParams1.ID), "{1:}{2:} en msg")
	i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrNoParams2.ID), "{1:}{2:} en msg")
	i18n.Cat().SetWithBase(i18n.LangID("fr"), i18n.MsgID(ErrNoParams2.ID), "{1:}{2:} fr msg")
	i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrWithParams1.ID), "{1:}{2:} en x={3} y={4}")
	i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrWithParams2.ID), "{1:}{2:} en x={3} y={4}")
	i18n.Cat().SetWithBase(i18n.LangID("fr"), i18n.MsgID(ErrWithParams2.ID), "{1:}{2:} fr y={4} x={3}")
	i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(errNotExported.ID), "{1:}{2:} en x={3} y={4}")

	return struct{}{}
}
