func (uj *Pos2D) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_Pos2Dbase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_Pos2Dno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'x': if bytes.Equal(ffj_key_Pos2D_X, kn) { currentKey = ffj_t_Pos2D_X state = fflib.FFParse_want_colon goto mainparse } case 'y': if bytes.Equal(ffj_key_Pos2D_Y, kn) { currentKey = ffj_t_Pos2D_Y state = fflib.FFParse_want_colon goto mainparse } } if fflib.SimpleLetterEqualFold(ffj_key_Pos2D_Y, kn) { currentKey = ffj_t_Pos2D_Y state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Pos2D_X, kn) { currentKey = ffj_t_Pos2D_X state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_Pos2Dno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_Pos2D_X: goto handle_X case ffj_t_Pos2D_Y: goto handle_Y case ffj_t_Pos2Dno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_X: /* handler: uj.X type=float64 kind=float64 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 64) if err != nil { return fs.WrapErr(err) } uj.X = float64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Y: /* handler: uj.Y type=float64 kind=float64 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 64) if err != nil { return fs.WrapErr(err) } uj.Y = float64(tval) } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }
func (uj *AnyType) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_AnyTypebase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_AnyTypeno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'C': if bytes.Equal(ffj_key_AnyType_Channels, kn) { currentKey = ffj_t_AnyType_Channels state = fflib.FFParse_want_colon goto mainparse } case 'E': if bytes.Equal(ffj_key_AnyType_ExName, kn) { currentKey = ffj_t_AnyType_ExName state = fflib.FFParse_want_colon goto mainparse } case 'F': if bytes.Equal(ffj_key_AnyType_FileBytes, kn) { currentKey = ffj_t_AnyType_FileBytes state = fflib.FFParse_want_colon goto mainparse } case 'H': if bytes.Equal(ffj_key_AnyType_Height, kn) { currentKey = ffj_t_AnyType_Height state = fflib.FFParse_want_colon goto mainparse } case 'I': if bytes.Equal(ffj_key_AnyType_ID, kn) { currentKey = ffj_t_AnyType_ID state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_AnyType_IsSharpen, kn) { currentKey = ffj_t_AnyType_IsSharpen state = fflib.FFParse_want_colon goto mainparse } case 'L': if bytes.Equal(ffj_key_AnyType_List, kn) { currentKey = ffj_t_AnyType_List state = fflib.FFParse_want_colon goto mainparse } case 'M': if bytes.Equal(ffj_key_AnyType_MinWidth, kn) { currentKey = ffj_t_AnyType_MinWidth state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_AnyType_MinHeight, kn) { currentKey = ffj_t_AnyType_MinHeight state = fflib.FFParse_want_colon goto mainparse } case 'P': if bytes.Equal(ffj_key_AnyType_Proportion, kn) { currentKey = ffj_t_AnyType_Proportion state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_AnyType_Position, kn) { currentKey = ffj_t_AnyType_Position state = fflib.FFParse_want_colon goto mainparse } case 'R': if bytes.Equal(ffj_key_AnyType_Radius, kn) { currentKey = ffj_t_AnyType_Radius state = fflib.FFParse_want_colon goto mainparse } case 'S': if bytes.Equal(ffj_key_AnyType_Sigma, kn) { currentKey = ffj_t_AnyType_Sigma state = fflib.FFParse_want_colon goto mainparse } case 'T': if bytes.Equal(ffj_key_AnyType_Type, kn) { currentKey = ffj_t_AnyType_Type state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_AnyType_TargetFormat, kn) { currentKey = ffj_t_AnyType_TargetFormat state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_AnyType_TargetQuality, kn) { currentKey = ffj_t_AnyType_TargetQuality state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_AnyType_Transparency, kn) { currentKey = ffj_t_AnyType_Transparency state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_AnyType_Taipe, kn) { currentKey = ffj_t_AnyType_Taipe state = fflib.FFParse_want_colon goto mainparse } case 'W': if bytes.Equal(ffj_key_AnyType_Width, kn) { currentKey = ffj_t_AnyType_Width state = fflib.FFParse_want_colon goto mainparse } case 'X': if bytes.Equal(ffj_key_AnyType_X, kn) { currentKey = ffj_t_AnyType_X state = fflib.FFParse_want_colon goto mainparse } case 'Y': if bytes.Equal(ffj_key_AnyType_Y, kn) { currentKey = ffj_t_AnyType_Y state = fflib.FFParse_want_colon goto mainparse } } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_Taipe, kn) { currentKey = ffj_t_AnyType_Taipe state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_Height, kn) { currentKey = ffj_t_AnyType_Height state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_Width, kn) { currentKey = ffj_t_AnyType_Width state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_FileBytes, kn) { currentKey = ffj_t_AnyType_FileBytes state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_MinHeight, kn) { currentKey = ffj_t_AnyType_MinHeight state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_MinWidth, kn) { currentKey = ffj_t_AnyType_MinWidth state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_Y, kn) { currentKey = ffj_t_AnyType_Y state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_X, kn) { currentKey = ffj_t_AnyType_X state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_Position, kn) { currentKey = ffj_t_AnyType_Position state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_Transparency, kn) { currentKey = ffj_t_AnyType_Transparency state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_Proportion, kn) { currentKey = ffj_t_AnyType_Proportion state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_List, kn) { currentKey = ffj_t_AnyType_List state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_Channels, kn) { currentKey = ffj_t_AnyType_Channels state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_Sigma, kn) { currentKey = ffj_t_AnyType_Sigma state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_Radius, kn) { currentKey = ffj_t_AnyType_Radius state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AnyType_IsSharpen, kn) { currentKey = ffj_t_AnyType_IsSharpen state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_TargetQuality, kn) { currentKey = ffj_t_AnyType_TargetQuality state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_TargetFormat, kn) { currentKey = ffj_t_AnyType_TargetFormat state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_ExName, kn) { currentKey = ffj_t_AnyType_ExName state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_ID, kn) { currentKey = ffj_t_AnyType_ID state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AnyType_Type, kn) { currentKey = ffj_t_AnyType_Type state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_AnyTypeno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_AnyType_Type: goto handle_Type case ffj_t_AnyType_ID: goto handle_ID case ffj_t_AnyType_ExName: goto handle_ExName case ffj_t_AnyType_TargetFormat: goto handle_TargetFormat case ffj_t_AnyType_TargetQuality: goto handle_TargetQuality case ffj_t_AnyType_IsSharpen: goto handle_IsSharpen case ffj_t_AnyType_Radius: goto handle_Radius case ffj_t_AnyType_Sigma: goto handle_Sigma case ffj_t_AnyType_Channels: goto handle_Channels case ffj_t_AnyType_List: goto handle_List case ffj_t_AnyType_Proportion: goto handle_Proportion case ffj_t_AnyType_Transparency: goto handle_Transparency case ffj_t_AnyType_Position: goto handle_Position case ffj_t_AnyType_X: goto handle_X case ffj_t_AnyType_Y: goto handle_Y case ffj_t_AnyType_MinWidth: goto handle_MinWidth case ffj_t_AnyType_MinHeight: goto handle_MinHeight case ffj_t_AnyType_FileBytes: goto handle_FileBytes case ffj_t_AnyType_Width: goto handle_Width case ffj_t_AnyType_Height: goto handle_Height case ffj_t_AnyType_Taipe: goto handle_Taipe case ffj_t_AnyTypeno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_Type: /* handler: uj.Type type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Type = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_ID: /* handler: uj.ID type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.ID = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_ExName: /* handler: uj.ExName type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.ExName = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_TargetFormat: /* handler: uj.TargetFormat type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.TargetFormat = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_TargetQuality: /* handler: uj.TargetQuality type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.TargetQuality = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_IsSharpen: /* handler: uj.IsSharpen type=bool kind=bool quoted=false*/ { if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) } } { if tok == fflib.FFTok_null { } else { tmpb := fs.Output.Bytes() if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { uj.IsSharpen = true } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { uj.IsSharpen = false } else { err = errors.New("unexpected bytes for true/false value") return fs.WrapErr(err) } } } state = fflib.FFParse_after_value goto mainparse handle_Radius: /* handler: uj.Radius type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Radius = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Sigma: /* handler: uj.Sigma type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Sigma = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Channels: /* handler: uj.Channels type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Channels = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_List: /* handler: uj.List type=processplan.ProcessList kind=struct quoted=false*/ { if tok == fflib.FFTok_null { state = fflib.FFParse_after_value goto mainparse } err = uj.List.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) if err != nil { return err } state = fflib.FFParse_after_value } state = fflib.FFParse_after_value goto mainparse handle_Proportion: /* handler: uj.Proportion type=float64 kind=float64 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 64) if err != nil { return fs.WrapErr(err) } uj.Proportion = float64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Transparency: /* handler: uj.Transparency type=float64 kind=float64 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 64) if err != nil { return fs.WrapErr(err) } uj.Transparency = float64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Position: /* handler: uj.Position type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Position = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_X: /* handler: uj.X type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.X = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Y: /* handler: uj.Y type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Y = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_MinWidth: /* handler: uj.MinWidth type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.MinWidth = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_MinHeight: /* handler: uj.MinHeight type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.MinHeight = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_FileBytes: /* handler: uj.FileBytes type=[]uint8 kind=slice quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) } } if tok == fflib.FFTok_null { uj.FileBytes = nil } else { b := make([]byte, base64.StdEncoding.DecodedLen(fs.Output.Len())) n, err := base64.StdEncoding.Decode(b, fs.Output.Bytes()) if err != nil { return fs.WrapErr(err) } v := reflect.ValueOf(&uj.FileBytes).Elem() v.SetBytes(b[0:n]) } } state = fflib.FFParse_after_value goto mainparse handle_Width: /* handler: uj.Width type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Width = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Height: /* handler: uj.Height type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Height = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Taipe: /* handler: uj.Taipe type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Taipe = int(tval) } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }
func (uj *AgentRender) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_AgentRenderbase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_AgentRenderno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'a': if bytes.Equal(ffj_key_AgentRender_Type, kn) { currentKey = ffj_t_AgentRender_Type state = fflib.FFParse_want_colon goto mainparse } case 'c': if bytes.Equal(ffj_key_AgentRender_Colour, kn) { currentKey = ffj_t_AgentRender_Colour state = fflib.FFParse_want_colon goto mainparse } case 'h': if bytes.Equal(ffj_key_AgentRender_Heading, kn) { currentKey = ffj_t_AgentRender_Heading state = fflib.FFParse_want_colon goto mainparse } case 'p': if bytes.Equal(ffj_key_AgentRender_Pos2D, kn) { currentKey = ffj_t_AgentRender_Pos2D state = fflib.FFParse_want_colon goto mainparse } } if fflib.SimpleLetterEqualFold(ffj_key_AgentRender_Colour, kn) { currentKey = ffj_t_AgentRender_Colour state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_AgentRender_Heading, kn) { currentKey = ffj_t_AgentRender_Heading state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_AgentRender_Pos2D, kn) { currentKey = ffj_t_AgentRender_Pos2D state = fflib.FFParse_want_colon goto mainparse } if fflib.AsciiEqualFold(ffj_key_AgentRender_Type, kn) { currentKey = ffj_t_AgentRender_Type state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_AgentRenderno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_AgentRender_Type: goto handle_Type case ffj_t_AgentRender_Pos2D: goto handle_Pos2D case ffj_t_AgentRender_Heading: goto handle_Heading case ffj_t_AgentRender_Colour: goto handle_Colour case ffj_t_AgentRenderno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_Type: /* handler: uj.Type type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Type = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Pos2D: /* handler: uj.Pos2D type=render.Pos2D kind=struct quoted=false*/ { if tok == fflib.FFTok_null { state = fflib.FFParse_after_value goto mainparse } err = uj.Pos2D.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) if err != nil { return err } state = fflib.FFParse_after_value } state = fflib.FFParse_after_value goto mainparse handle_Heading: /* handler: uj.Heading type=float64 kind=float64 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 64) if err != nil { return fs.WrapErr(err) } uj.Heading = float64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Colour: /* handler: uj.Colour type=colour.RGB256 kind=struct quoted=false*/ { /* Falling back. type=colour.RGB256 kind=struct */ tbuf, err := fs.CaptureField(tok) if err != nil { return fs.WrapErr(err) } err = json.Unmarshal(tbuf, &uj.Colour) if err != nil { return fs.WrapErr(err) } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }
func (uj *Event) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_Eventbase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_Eventno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'h': if bytes.Equal(ffj_key_Event_Host, kn) { currentKey = ffj_t_Event_Host state = fflib.FFParse_want_colon goto mainparse } case 'm': if bytes.Equal(ffj_key_Event_Metric, kn) { currentKey = ffj_t_Event_Metric state = fflib.FFParse_want_colon goto mainparse } case 's': if bytes.Equal(ffj_key_Event_Service, kn) { currentKey = ffj_t_Event_Service state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_Event_SubService, kn) { currentKey = ffj_t_Event_SubService state = fflib.FFParse_want_colon goto mainparse } case 't': if bytes.Equal(ffj_key_Event_Tags, kn) { currentKey = ffj_t_Event_Tags state = fflib.FFParse_want_colon goto mainparse } } if fflib.EqualFoldRight(ffj_key_Event_Tags, kn) { currentKey = ffj_t_Event_Tags state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Event_Metric, kn) { currentKey = ffj_t_Event_Metric state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Event_SubService, kn) { currentKey = ffj_t_Event_SubService state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Event_Service, kn) { currentKey = ffj_t_Event_Service state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Event_Host, kn) { currentKey = ffj_t_Event_Host state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_Eventno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_Event_Host: goto handle_Host case ffj_t_Event_Service: goto handle_Service case ffj_t_Event_SubService: goto handle_SubService case ffj_t_Event_Metric: goto handle_Metric case ffj_t_Event_Tags: goto handle_Tags case ffj_t_Eventno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_Host: /* handler: uj.Host type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.Host = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_Service: /* handler: uj.Service type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.Service = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_SubService: /* handler: uj.SubService type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.SubService = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_Metric: /* handler: uj.Metric type=float64 kind=float64 */ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 64) if err != nil { return fs.WrapErr(err) } uj.Metric = float64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Tags: /* handler: uj.Tags type=map[string]string kind=map */ { /* Falling back. type=map[string]string kind=map */ tbuf, err := fs.CaptureField(tok) if err != nil { return fs.WrapErr(err) } err = json.Unmarshal(tbuf, &uj.Tags) if err != nil { return fs.WrapErr(err) } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }
func (uj *Event) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_Eventbase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_Eventno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'c': if bytes.Equal(ffj_key_Event_Clock, kn) { currentKey = ffj_t_Event_Clock state = fflib.FFParse_want_colon goto mainparse } case 'h': if bytes.Equal(ffj_key_Event_Hostname, kn) { currentKey = ffj_t_Event_Hostname state = fflib.FFParse_want_colon goto mainparse } case 'p': if bytes.Equal(ffj_key_Event_PID, kn) { currentKey = ffj_t_Event_PID state = fflib.FFParse_want_colon goto mainparse } case 't': if bytes.Equal(ffj_key_Event_Type, kn) { currentKey = ffj_t_Event_Type state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_Event_Timestamp, kn) { currentKey = ffj_t_Event_Timestamp state = fflib.FFParse_want_colon goto mainparse } case 'u': if bytes.Equal(ffj_key_Event_UTCOffset, kn) { currentKey = ffj_t_Event_UTCOffset state = fflib.FFParse_want_colon goto mainparse } } if fflib.EqualFoldRight(ffj_key_Event_UTCOffset, kn) { currentKey = ffj_t_Event_UTCOffset state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Event_Clock, kn) { currentKey = ffj_t_Event_Clock state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Event_PID, kn) { currentKey = ffj_t_Event_PID state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Event_Timestamp, kn) { currentKey = ffj_t_Event_Timestamp state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Event_Hostname, kn) { currentKey = ffj_t_Event_Hostname state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Event_Type, kn) { currentKey = ffj_t_Event_Type state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_Eventno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_Event_Type: goto handle_Type case ffj_t_Event_Hostname: goto handle_Hostname case ffj_t_Event_Timestamp: goto handle_Timestamp case ffj_t_Event_PID: goto handle_PID case ffj_t_Event_Clock: goto handle_Clock case ffj_t_Event_UTCOffset: goto handle_UTCOffset case ffj_t_Eventno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_Type: /* handler: uj.Type type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Type = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Hostname: /* handler: uj.Hostname type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Hostname = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Timestamp: /* handler: uj.Timestamp type=float32 kind=float32 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float32", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 32) if err != nil { return fs.WrapErr(err) } uj.Timestamp = float32(tval) } } state = fflib.FFParse_after_value goto mainparse handle_PID: /* handler: uj.PID type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.PID = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Clock: /* handler: uj.Clock type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Clock = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_UTCOffset: /* handler: uj.UTCOffset type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.UTCOffset = int(tval) } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }
func (uj *TaskEvent) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_TaskEventbase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_TaskEventno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'a': if bytes.Equal(ffj_key_TaskEvent_Args, kn) { currentKey = ffj_t_TaskEvent_Args state = fflib.FFParse_want_colon goto mainparse } case 'c': if bytes.Equal(ffj_key_TaskEvent_Clock, kn) { currentKey = ffj_t_TaskEvent_Clock state = fflib.FFParse_want_colon goto mainparse } case 'e': if bytes.Equal(ffj_key_TaskEvent_ETA, kn) { currentKey = ffj_t_TaskEvent_ETA state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_Exception, kn) { currentKey = ffj_t_TaskEvent_Exception state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_Expired, kn) { currentKey = ffj_t_TaskEvent_Expired state = fflib.FFParse_want_colon goto mainparse } case 'h': if bytes.Equal(ffj_key_TaskEvent_Hostname, kn) { currentKey = ffj_t_TaskEvent_Hostname state = fflib.FFParse_want_colon goto mainparse } case 'k': if bytes.Equal(ffj_key_TaskEvent_Kwargs, kn) { currentKey = ffj_t_TaskEvent_Kwargs state = fflib.FFParse_want_colon goto mainparse } case 'n': if bytes.Equal(ffj_key_TaskEvent_Name, kn) { currentKey = ffj_t_TaskEvent_Name state = fflib.FFParse_want_colon goto mainparse } case 'p': if bytes.Equal(ffj_key_TaskEvent_PID, kn) { currentKey = ffj_t_TaskEvent_PID state = fflib.FFParse_want_colon goto mainparse } case 'r': if bytes.Equal(ffj_key_TaskEvent_Result, kn) { currentKey = ffj_t_TaskEvent_Result state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_Runtime, kn) { currentKey = ffj_t_TaskEvent_Runtime state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_Retries, kn) { currentKey = ffj_t_TaskEvent_Retries state = fflib.FFParse_want_colon goto mainparse } case 's': if bytes.Equal(ffj_key_TaskEvent_Signum, kn) { currentKey = ffj_t_TaskEvent_Signum state = fflib.FFParse_want_colon goto mainparse } case 't': if bytes.Equal(ffj_key_TaskEvent_Type, kn) { currentKey = ffj_t_TaskEvent_Type state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_Timestamp, kn) { currentKey = ffj_t_TaskEvent_Timestamp state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_Traceback, kn) { currentKey = ffj_t_TaskEvent_Traceback state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_Terminated, kn) { currentKey = ffj_t_TaskEvent_Terminated state = fflib.FFParse_want_colon goto mainparse } case 'u': if bytes.Equal(ffj_key_TaskEvent_UTCOffset, kn) { currentKey = ffj_t_TaskEvent_UTCOffset state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_TaskEvent_UUID, kn) { currentKey = ffj_t_TaskEvent_UUID state = fflib.FFParse_want_colon goto mainparse } } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_Expired, kn) { currentKey = ffj_t_TaskEvent_Expired state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Signum, kn) { currentKey = ffj_t_TaskEvent_Signum state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_Terminated, kn) { currentKey = ffj_t_TaskEvent_Terminated state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Traceback, kn) { currentKey = ffj_t_TaskEvent_Traceback state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_Exception, kn) { currentKey = ffj_t_TaskEvent_Exception state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_ETA, kn) { currentKey = ffj_t_TaskEvent_ETA state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Retries, kn) { currentKey = ffj_t_TaskEvent_Retries state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_Runtime, kn) { currentKey = ffj_t_TaskEvent_Runtime state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Result, kn) { currentKey = ffj_t_TaskEvent_Result state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Kwargs, kn) { currentKey = ffj_t_TaskEvent_Kwargs state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Args, kn) { currentKey = ffj_t_TaskEvent_Args state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_Name, kn) { currentKey = ffj_t_TaskEvent_Name state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_UUID, kn) { currentKey = ffj_t_TaskEvent_UUID state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_UTCOffset, kn) { currentKey = ffj_t_TaskEvent_UTCOffset state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Clock, kn) { currentKey = ffj_t_TaskEvent_Clock state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_PID, kn) { currentKey = ffj_t_TaskEvent_PID state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Timestamp, kn) { currentKey = ffj_t_TaskEvent_Timestamp state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_TaskEvent_Hostname, kn) { currentKey = ffj_t_TaskEvent_Hostname state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_TaskEvent_Type, kn) { currentKey = ffj_t_TaskEvent_Type state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_TaskEventno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_TaskEvent_Type: goto handle_Type case ffj_t_TaskEvent_Hostname: goto handle_Hostname case ffj_t_TaskEvent_Timestamp: goto handle_Timestamp case ffj_t_TaskEvent_PID: goto handle_PID case ffj_t_TaskEvent_Clock: goto handle_Clock case ffj_t_TaskEvent_UTCOffset: goto handle_UTCOffset case ffj_t_TaskEvent_UUID: goto handle_UUID case ffj_t_TaskEvent_Name: goto handle_Name case ffj_t_TaskEvent_Args: goto handle_Args case ffj_t_TaskEvent_Kwargs: goto handle_Kwargs case ffj_t_TaskEvent_Result: goto handle_Result case ffj_t_TaskEvent_Runtime: goto handle_Runtime case ffj_t_TaskEvent_Retries: goto handle_Retries case ffj_t_TaskEvent_ETA: goto handle_ETA case ffj_t_TaskEvent_Exception: goto handle_Exception case ffj_t_TaskEvent_Traceback: goto handle_Traceback case ffj_t_TaskEvent_Terminated: goto handle_Terminated case ffj_t_TaskEvent_Signum: goto handle_Signum case ffj_t_TaskEvent_Expired: goto handle_Expired case ffj_t_TaskEventno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_Type: /* handler: uj.Type type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Type = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Hostname: /* handler: uj.Hostname type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Hostname = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Timestamp: /* handler: uj.Timestamp type=float32 kind=float32 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float32", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 32) if err != nil { return fs.WrapErr(err) } uj.Timestamp = float32(tval) } } state = fflib.FFParse_after_value goto mainparse handle_PID: /* handler: uj.PID type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.PID = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Clock: /* handler: uj.Clock type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Clock = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_UTCOffset: /* handler: uj.UTCOffset type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.UTCOffset = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_UUID: /* handler: uj.UUID type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.UUID = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Name: /* handler: uj.Name type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Name = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Args: /* handler: uj.Args type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Args = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Kwargs: /* handler: uj.Kwargs type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Kwargs = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Result: /* handler: uj.Result type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Result = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Runtime: /* handler: uj.Runtime type=float32 kind=float32 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float32", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 32) if err != nil { return fs.WrapErr(err) } uj.Runtime = float32(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Retries: /* handler: uj.Retries type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Retries = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_ETA: /* handler: uj.ETA type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.ETA = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Exception: /* handler: uj.Exception type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Exception = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Traceback: /* handler: uj.Traceback type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Traceback = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Terminated: /* handler: uj.Terminated type=bool kind=bool quoted=false*/ { if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) } } { if tok == fflib.FFTok_null { } else { tmpb := fs.Output.Bytes() if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { uj.Terminated = true } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { uj.Terminated = false } else { err = errors.New("unexpected bytes for true/false value") return fs.WrapErr(err) } } } state = fflib.FFParse_after_value goto mainparse handle_Signum: /* handler: uj.Signum type=interface {} kind=interface quoted=false*/ { /* Falling back. type=interface {} kind=interface */ tbuf, err := fs.CaptureField(tok) if err != nil { return fs.WrapErr(err) } err = json.Unmarshal(tbuf, &uj.Signum) if err != nil { return fs.WrapErr(err) } } state = fflib.FFParse_after_value goto mainparse handle_Expired: /* handler: uj.Expired type=bool kind=bool quoted=false*/ { if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) } } { if tok == fflib.FFTok_null { } else { tmpb := fs.Output.Bytes() if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { uj.Expired = true } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { uj.Expired = false } else { err = errors.New("unexpected bytes for true/false value") return fs.WrapErr(err) } } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }
func (uj *WorkerEvent) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_WorkerEventbase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_WorkerEventno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'a': if bytes.Equal(ffj_key_WorkerEvent_Active, kn) { currentKey = ffj_t_WorkerEvent_Active state = fflib.FFParse_want_colon goto mainparse } case 'c': if bytes.Equal(ffj_key_WorkerEvent_Clock, kn) { currentKey = ffj_t_WorkerEvent_Clock state = fflib.FFParse_want_colon goto mainparse } case 'f': if bytes.Equal(ffj_key_WorkerEvent_Freq, kn) { currentKey = ffj_t_WorkerEvent_Freq state = fflib.FFParse_want_colon goto mainparse } case 'h': if bytes.Equal(ffj_key_WorkerEvent_Hostname, kn) { currentKey = ffj_t_WorkerEvent_Hostname state = fflib.FFParse_want_colon goto mainparse } case 'l': if bytes.Equal(ffj_key_WorkerEvent_LoadAverage, kn) { currentKey = ffj_t_WorkerEvent_LoadAverage state = fflib.FFParse_want_colon goto mainparse } case 'p': if bytes.Equal(ffj_key_WorkerEvent_PID, kn) { currentKey = ffj_t_WorkerEvent_PID state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_WorkerEvent_Processed, kn) { currentKey = ffj_t_WorkerEvent_Processed state = fflib.FFParse_want_colon goto mainparse } case 's': if bytes.Equal(ffj_key_WorkerEvent_SWSystem, kn) { currentKey = ffj_t_WorkerEvent_SWSystem state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_WorkerEvent_SWVersion, kn) { currentKey = ffj_t_WorkerEvent_SWVersion state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_WorkerEvent_SWIdentity, kn) { currentKey = ffj_t_WorkerEvent_SWIdentity state = fflib.FFParse_want_colon goto mainparse } case 't': if bytes.Equal(ffj_key_WorkerEvent_Type, kn) { currentKey = ffj_t_WorkerEvent_Type state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_WorkerEvent_Timestamp, kn) { currentKey = ffj_t_WorkerEvent_Timestamp state = fflib.FFParse_want_colon goto mainparse } case 'u': if bytes.Equal(ffj_key_WorkerEvent_UTCOffset, kn) { currentKey = ffj_t_WorkerEvent_UTCOffset state = fflib.FFParse_want_colon goto mainparse } } if fflib.SimpleLetterEqualFold(ffj_key_WorkerEvent_Active, kn) { currentKey = ffj_t_WorkerEvent_Active state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_Processed, kn) { currentKey = ffj_t_WorkerEvent_Processed state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_SWIdentity, kn) { currentKey = ffj_t_WorkerEvent_SWIdentity state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_WorkerEvent_Freq, kn) { currentKey = ffj_t_WorkerEvent_Freq state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_WorkerEvent_LoadAverage, kn) { currentKey = ffj_t_WorkerEvent_LoadAverage state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_SWVersion, kn) { currentKey = ffj_t_WorkerEvent_SWVersion state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_SWSystem, kn) { currentKey = ffj_t_WorkerEvent_SWSystem state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_UTCOffset, kn) { currentKey = ffj_t_WorkerEvent_UTCOffset state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_Clock, kn) { currentKey = ffj_t_WorkerEvent_Clock state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_WorkerEvent_PID, kn) { currentKey = ffj_t_WorkerEvent_PID state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_Timestamp, kn) { currentKey = ffj_t_WorkerEvent_Timestamp state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_WorkerEvent_Hostname, kn) { currentKey = ffj_t_WorkerEvent_Hostname state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_WorkerEvent_Type, kn) { currentKey = ffj_t_WorkerEvent_Type state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_WorkerEventno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_WorkerEvent_Type: goto handle_Type case ffj_t_WorkerEvent_Hostname: goto handle_Hostname case ffj_t_WorkerEvent_Timestamp: goto handle_Timestamp case ffj_t_WorkerEvent_PID: goto handle_PID case ffj_t_WorkerEvent_Clock: goto handle_Clock case ffj_t_WorkerEvent_UTCOffset: goto handle_UTCOffset case ffj_t_WorkerEvent_SWSystem: goto handle_SWSystem case ffj_t_WorkerEvent_SWVersion: goto handle_SWVersion case ffj_t_WorkerEvent_LoadAverage: goto handle_LoadAverage case ffj_t_WorkerEvent_Freq: goto handle_Freq case ffj_t_WorkerEvent_SWIdentity: goto handle_SWIdentity case ffj_t_WorkerEvent_Processed: goto handle_Processed case ffj_t_WorkerEvent_Active: goto handle_Active case ffj_t_WorkerEventno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_Type: /* handler: uj.Type type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Type = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Hostname: /* handler: uj.Hostname type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.Hostname = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Timestamp: /* handler: uj.Timestamp type=float32 kind=float32 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float32", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 32) if err != nil { return fs.WrapErr(err) } uj.Timestamp = float32(tval) } } state = fflib.FFParse_after_value goto mainparse handle_PID: /* handler: uj.PID type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.PID = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Clock: /* handler: uj.Clock type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Clock = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_UTCOffset: /* handler: uj.UTCOffset type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.UTCOffset = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_SWSystem: /* handler: uj.SWSystem type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.SWSystem = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_SWVersion: /* handler: uj.SWVersion type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.SWVersion = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_LoadAverage: /* handler: uj.LoadAverage type=[]float32 kind=slice quoted=false*/ { { if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) } } if tok == fflib.FFTok_null { uj.LoadAverage = nil } else { uj.LoadAverage = make([]float32, 0) wantVal := true for { var v float32 tok = fs.Scan() if tok == fflib.FFTok_error { goto tokerror } if tok == fflib.FFTok_right_brace { break } if tok == fflib.FFTok_comma { if wantVal == true { // TODO(pquerna): this isn't an ideal error message, this handles // things like [,,,] as an array value. return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) } continue } else { wantVal = true } /* handler: v type=float32 kind=float32 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float32", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 32) if err != nil { return fs.WrapErr(err) } v = float32(tval) } } uj.LoadAverage = append(uj.LoadAverage, v) wantVal = false } } } state = fflib.FFParse_after_value goto mainparse handle_Freq: /* handler: uj.Freq type=float32 kind=float32 quoted=false*/ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float32", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 32) if err != nil { return fs.WrapErr(err) } uj.Freq = float32(tval) } } state = fflib.FFParse_after_value goto mainparse handle_SWIdentity: /* handler: uj.SWIdentity type=string kind=string quoted=false*/ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { outBuf := fs.Output.Bytes() uj.SWIdentity = string(string(outBuf)) } } state = fflib.FFParse_after_value goto mainparse handle_Processed: /* handler: uj.Processed type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Processed = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Active: /* handler: uj.Active type=int kind=int quoted=false*/ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Active = int(tval) } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }
func (uj *Incident) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { var err error = nil currentKey := ffj_t_Incidentbase _ = currentKey tok := fflib.FFTok_init wantedTok := fflib.FFTok_init mainparse: for { tok = fs.Scan() // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) if tok == fflib.FFTok_error { goto tokerror } switch state { case fflib.FFParse_map_start: if tok != fflib.FFTok_left_bracket { wantedTok = fflib.FFTok_left_bracket goto wrongtokenerror } state = fflib.FFParse_want_key continue case fflib.FFParse_after_value: if tok == fflib.FFTok_comma { state = fflib.FFParse_want_key } else if tok == fflib.FFTok_right_bracket { goto done } else { wantedTok = fflib.FFTok_comma goto wrongtokenerror } case fflib.FFParse_want_key: // json {} ended. goto exit. woo. if tok == fflib.FFTok_right_bracket { goto done } if tok != fflib.FFTok_string { wantedTok = fflib.FFTok_string goto wrongtokenerror } kn := fs.Output.Bytes() if len(kn) <= 0 { // "" case. hrm. currentKey = ffj_t_Incidentno_such_key state = fflib.FFParse_want_colon goto mainparse } else { switch kn[0] { case 'a': if bytes.Equal(ffj_key_Incident_Active, kn) { currentKey = ffj_t_Incident_Active state = fflib.FFParse_want_colon goto mainparse } case 'd': if bytes.Equal(ffj_key_Incident_Description, kn) { currentKey = ffj_t_Incident_Description state = fflib.FFParse_want_colon goto mainparse } case 'e': if bytes.Equal(ffj_key_Incident_EventName, kn) { currentKey = ffj_t_Incident_EventName state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_Incident_Escalation, kn) { currentKey = ffj_t_Incident_Escalation state = fflib.FFParse_want_colon goto mainparse } case 'h': if bytes.Equal(ffj_key_Incident_Host, kn) { currentKey = ffj_t_Incident_Host state = fflib.FFParse_want_colon goto mainparse } case 'i': if bytes.Equal(ffj_key_Incident_Id, kn) { currentKey = ffj_t_Incident_Id state = fflib.FFParse_want_colon goto mainparse } case 'm': if bytes.Equal(ffj_key_Incident_Metric, kn) { currentKey = ffj_t_Incident_Metric state = fflib.FFParse_want_colon goto mainparse } case 'p': if bytes.Equal(ffj_key_Incident_Policy, kn) { currentKey = ffj_t_Incident_Policy state = fflib.FFParse_want_colon goto mainparse } case 's': if bytes.Equal(ffj_key_Incident_Status, kn) { currentKey = ffj_t_Incident_Status state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_Incident_Service, kn) { currentKey = ffj_t_Incident_Service state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_Incident_SubService, kn) { currentKey = ffj_t_Incident_SubService state = fflib.FFParse_want_colon goto mainparse } case 't': if bytes.Equal(ffj_key_Incident_Time, kn) { currentKey = ffj_t_Incident_Time state = fflib.FFParse_want_colon goto mainparse } else if bytes.Equal(ffj_key_Incident_Tags, kn) { currentKey = ffj_t_Incident_Tags state = fflib.FFParse_want_colon goto mainparse } } if fflib.EqualFoldRight(ffj_key_Incident_Tags, kn) { currentKey = ffj_t_Incident_Tags state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Incident_Metric, kn) { currentKey = ffj_t_Incident_Metric state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Incident_SubService, kn) { currentKey = ffj_t_Incident_SubService state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Incident_Service, kn) { currentKey = ffj_t_Incident_Service state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Incident_Host, kn) { currentKey = ffj_t_Incident_Host state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Incident_Status, kn) { currentKey = ffj_t_Incident_Status state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Incident_Policy, kn) { currentKey = ffj_t_Incident_Policy state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Incident_Description, kn) { currentKey = ffj_t_Incident_Description state = fflib.FFParse_want_colon goto mainparse } if fflib.EqualFoldRight(ffj_key_Incident_Escalation, kn) { currentKey = ffj_t_Incident_Escalation state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Incident_Active, kn) { currentKey = ffj_t_Incident_Active state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Incident_Id, kn) { currentKey = ffj_t_Incident_Id state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Incident_Time, kn) { currentKey = ffj_t_Incident_Time state = fflib.FFParse_want_colon goto mainparse } if fflib.SimpleLetterEqualFold(ffj_key_Incident_EventName, kn) { currentKey = ffj_t_Incident_EventName state = fflib.FFParse_want_colon goto mainparse } currentKey = ffj_t_Incidentno_such_key state = fflib.FFParse_want_colon goto mainparse } case fflib.FFParse_want_colon: if tok != fflib.FFTok_colon { wantedTok = fflib.FFTok_colon goto wrongtokenerror } state = fflib.FFParse_want_value continue case fflib.FFParse_want_value: if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { switch currentKey { case ffj_t_Incident_EventName: goto handle_EventName case ffj_t_Incident_Time: goto handle_Time case ffj_t_Incident_Id: goto handle_Id case ffj_t_Incident_Active: goto handle_Active case ffj_t_Incident_Escalation: goto handle_Escalation case ffj_t_Incident_Description: goto handle_Description case ffj_t_Incident_Policy: goto handle_Policy case ffj_t_Incident_Status: goto handle_Status case ffj_t_Incident_Host: goto handle_Host case ffj_t_Incident_Service: goto handle_Service case ffj_t_Incident_SubService: goto handle_SubService case ffj_t_Incident_Metric: goto handle_Metric case ffj_t_Incident_Tags: goto handle_Tags case ffj_t_Incidentno_such_key: err = fs.SkipField(tok) if err != nil { return fs.WrapErr(err) } state = fflib.FFParse_after_value goto mainparse } } else { goto wantedvalue } } } handle_EventName: /* handler: uj.EventName type=[]uint8 kind=slice */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) } } if tok == fflib.FFTok_null { uj.EventName = nil } else { b := make([]byte, base64.StdEncoding.DecodedLen(fs.Output.Len())) n, err := base64.StdEncoding.Decode(b, fs.Output.Bytes()) if err != nil { return fs.WrapErr(err) } v := reflect.ValueOf(&uj.EventName).Elem() v.SetBytes(b[0:n]) } } state = fflib.FFParse_after_value goto mainparse handle_Time: /* handler: uj.Time type=int64 kind=int64 */ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Time = int64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Id: /* handler: uj.Id type=int64 kind=int64 */ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Id = int64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Active: /* handler: uj.Active type=bool kind=bool */ { { if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) } } if tok == fflib.FFTok_null { } else { tmpb := fs.Output.Bytes() if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { uj.Active = true } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { uj.Active = false } else { err = errors.New("unexpected bytes for true/false value") return fs.WrapErr(err) } } } state = fflib.FFParse_after_value goto mainparse handle_Escalation: /* handler: uj.Escalation type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.Escalation = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_Description: /* handler: uj.Description type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.Description = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_Policy: /* handler: uj.Policy type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.Policy = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_Status: /* handler: uj.Status type=int kind=int */ { if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) if err != nil { return fs.WrapErr(err) } uj.Status = int(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Host: /* handler: uj.Host type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.Host = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_Service: /* handler: uj.Service type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.Service = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_SubService: /* handler: uj.SubService type=string kind=string */ { { if tok != fflib.FFTok_string && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) } } if tok == fflib.FFTok_null { } else { uj.SubService = string(fs.Output.String()) } } state = fflib.FFParse_after_value goto mainparse handle_Metric: /* handler: uj.Metric type=float64 kind=float64 */ { if tok != fflib.FFTok_double && tok != fflib.FFTok_integer && tok != fflib.FFTok_null { return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for float64", tok)) } } { if tok == fflib.FFTok_null { } else { tval, err := fflib.ParseFloat(fs.Output.Bytes(), 64) if err != nil { return fs.WrapErr(err) } uj.Metric = float64(tval) } } state = fflib.FFParse_after_value goto mainparse handle_Tags: /* handler: uj.Tags type=map[string]string kind=map */ { /* Falling back. type=map[string]string kind=map */ tbuf, err := fs.CaptureField(tok) if err != nil { return fs.WrapErr(err) } err = json.Unmarshal(tbuf, &uj.Tags) if err != nil { return fs.WrapErr(err) } } state = fflib.FFParse_after_value goto mainparse wantedvalue: return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) wrongtokenerror: return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) tokerror: if fs.BigError != nil { return fs.WrapErr(fs.BigError) } err = fs.Error.ToError() if err != nil { return fs.WrapErr(err) } panic("ffjson-generated: unreachable, please report bug.") done: return nil }