cuelang.org/go@v0.10.1/encoding/gocode/testdata/pkg1/cue_gen.go (about)

     1  // Code generated by gocode.Generate; DO NOT EDIT.
     2  
     3  package pkg1
     4  
     5  import (
     6  	"fmt"
     7  
     8  	"cuelang.org/go/cue"
     9  	"cuelang.org/go/encoding/gocode/gocodec"
    10  	_ "cuelang.org/go/pkg"
    11  )
    12  
    13  var cuegenvalMyStruct = cuegenMake("MyStruct", &MyStruct{})
    14  
    15  // Validate validates x.
    16  func (x *MyStruct) Validate() error {
    17  	return cuegenCodec.Validate(cuegenvalMyStruct, x)
    18  }
    19  
    20  // Complete completes x.
    21  func (x *MyStruct) Complete() error {
    22  	return cuegenCodec.Complete(cuegenvalMyStruct, x)
    23  }
    24  
    25  var cuegenvalOtherStruct = cuegenMake("OtherStruct", &OtherStruct{})
    26  
    27  // Validate validates x.
    28  func (x *OtherStruct) Validate() error {
    29  	return cuegenCodec.Validate(cuegenvalOtherStruct, x)
    30  }
    31  
    32  var cuegenvalString = cuegenMake("String", nil)
    33  
    34  // ValidateCUE validates x.
    35  func (x String) ValidateCUE() error {
    36  	return cuegenCodec.Validate(cuegenvalString, x)
    37  }
    38  
    39  var cuegenvalSpecialString = cuegenMake("SpecialString", nil)
    40  
    41  // ValidateSpecialString validates x.
    42  func ValidateSpecialString(x string) error {
    43  	return cuegenCodec.Validate(cuegenvalSpecialString, x)
    44  }
    45  
    46  var cuegenvalPtr = cuegenMake("Ptr", Ptr(nil))
    47  
    48  // ValidatePtr validates x.
    49  func ValidatePtr(x Ptr) error {
    50  	return cuegenCodec.Validate(cuegenvalPtr, x)
    51  }
    52  
    53  var cuegenCodec, cuegenInstance_, cuegenValue = func() (*gocodec.Codec, *cue.Instance, cue.Value) {
    54  	var r *cue.Runtime
    55  	r = &cue.Runtime{}
    56  	instances, err := r.Unmarshal(cuegenInstanceData)
    57  	if err != nil {
    58  		panic(err)
    59  	}
    60  	if len(instances) != 1 {
    61  		panic("expected encoding of exactly one instance")
    62  	}
    63  	return gocodec.New(r, nil), instances[0], instances[0].Value()
    64  }()
    65  
    66  // Deprecated: cue.Instance is deprecated. Use cuegenValue instead.
    67  var cuegenInstance = cuegenInstance_
    68  
    69  // cuegenMake is called in the init phase to initialize CUE values for
    70  // validation functions.
    71  func cuegenMake(name string, x interface{}) cue.Value {
    72  	f, err := cuegenValue.FieldByName(name, true)
    73  	if err != nil {
    74  		panic(fmt.Errorf("could not find type %q in instance", name))
    75  	}
    76  	v := f.Value
    77  	if x != nil {
    78  		w, err := cuegenCodec.ExtractType(x)
    79  		if err != nil {
    80  			panic(err)
    81  		}
    82  		v = v.Unify(w)
    83  	}
    84  	return v
    85  }
    86  
    87  // Data size: 603 bytes.
    88  var cuegenInstanceData = []byte("\x01\x1f\x8b\b\x00\x00\x00\x00\x00\x00\xff\x94RMo\xd3J\x14\x9dq\xf2\xa4\x97Q\u07d3\xde\x0fx\xd2eV\t*v\x12\t\x16V\r\xfd\xa0\xa0.\xdaD\xb4 \x04b1\xb5o\x9cQ'3&\x1e\x97F\xd0\x02\xa5\xf4g\xd7h\x1c\xbb\r\xec\x9a\xd5\u044d\xcf=g\xce=\xff\x94?=\xea\x95\u05c4\x96\xdf\by\xf2\xb5E\xe9\x9a\u0539\x15:\xc6\xe7\xc2\n7\xa6-\xda~e\x8c\xa5\x1e\xa1\xed\xb1\xb0S\xbaF\xe8_/\xa4\u009c\x96W\x84\x90\xff\xcb\x1f\x1e\xa5\xff\xbe\xff\x10\x17\xe8O\xa4\xaa\x99W\x84\x96\x97\x84t\xcb\xef-J\xff\xbe\x9b_\x12\xea\xd1\xf6\x81\x98\xa1[\u052e\x86\x8c\x10r\xd3:*\xaf\x89G)\r\xe2\x02\x95\u0429o\xe6i\x90\x9a\x00ul\x12\xa9\x1d\x8eM\x82\x81\xc5\xdc&\u008a ;I\a\x9b\xa7}J\xe9\x7f\x0e\x06\x8du?.\x90\xdex\xef2\x11\x9f\x88\x14\xc1\xfd\u0258\x9cefn\xa1\xcb:\xfc\x1e\x02C\xce:<\xb7s\xa9\xd3\xdc\xc1\x99\xb0S\xcez\x8c\xed/\x0e\xed\xbc\x88m\b\x9fYg+\x04\u0608\x06}\xd6\xd9\x0e\x01\xa2\v\x1e\v\xcb\xe1\v<\xe4\x89I9\ub31e\x850\xb2S\x9c/9\xac\xb3\x17\x82\xb35\xf4\xf7*W\xfb\xc8\xcea35\xdd\xf5\xd8\xcc2\x85\x16\xa3\x9d\x1a\xf4\xd8\n\xb1\x11\xab\r\xf9;F[!u\xbe\xa5\x17]\xfe\x96\xf7Xg\x1c.\xf7\x8ee|\u2db2\xc3\xea\xd3\x10\xea\u07c3\x88\xf3\x06W\x82\xa7B\xc9DX\x8c\xde\xd4`\xe7\xf5n\x8f\x1df\x18K\xa1\x1art\xc1\xf3\xe5\x84/Yv\x91a\xb4t\xd1c{\xa96s<\x9a\u02bc\x92\x89.\xf8\xc4\x18\xceF3iou\x01\xa4\xb6\x15\xf7Q\x8f\xb1 \x80\x03\xa3w\xcfdn\xa5N\xe1\x93T\n\x8e\x11\xccLZ\x8b\t\x88\x1c\u071b\x11d\x0e\xda\x00~,\xe4\xa9P\xa8-\xbc4\xe0\xa4}\xb6B\xafB\xd9nB\xa9\x83\xacUde\r\n\x8dg.gL\xa0\xd0\n\xf3\x1c\xf0,S2\x96V-\x00\xb58V\x98\xf8lbL\xe8l\xb2\xb1\x9d7I\xbb{\xfb\xfb\x85\xb22S8\x9at\a\xfd\x1e;g\x84x\xeb\xf7)Q]\xd1\xe1\xef\x15\x15+\x05\x1d\xde\x16\xf4\xaem\xac)Gcfc\xd0\xef\xaf<\xf5\x8f\xfb\x8b\xe3\x98;s\xcb\u04c7\xf0\xf41#\xe4W\x00\x00\x00\xff\xff{\xa57\xb4\xe3\x03\x00\x00")