package decoder

import (
	
	
	

	
)

type boolDecoder struct {
	structName string
	fieldName  string
	// typ is the type of the value, which the type errors report.
	typ reflect.Type
}

func newBoolDecoder(,  string) *boolDecoder {
	return &boolDecoder{structName: , fieldName: , typ: reflect.TypeOf(false)}
}

func ( *boolDecoder) ( *RuntimeContext, ,  int64,  unsafe.Pointer) (int64, error) {
	 := .Buf
	 = skipWhiteSpace(, )
	switch [] {
	case 't':
		if  := validateTrue(, );  != nil {
			return 0, 
		}
		 += 4
		**(**bool)(unsafe.Pointer(&)) = true
		return , nil
	case 'f':
		if  := validateFalse(, );  != nil {
			return 0, 
		}
		 += 5
		**(**bool)(unsafe.Pointer(&)) = false
		return , nil
	case 'n':
		if  := validateNull(, );  != nil {
			return 0, 
		}
		if .Option.V2&(V2Semantics|V2MergeWithLegacySemantics) == V2Semantics {
			// the semantics of encoding/json/v2 decode null as the zero value, but with MergeWithLegacySemantics
			**(**bool)(unsafe.Pointer(&)) = false
		}
		 += 4
		return , nil
	}
	return .decodeOther(, , )
}

// decodeOther skips the value at cursor, which is not a bool: a value of another kind is a type error, and
// anything else a syntax error. It is a function of its own, so that Decode keeps the size it had.
//
//go:noinline
func ( *boolDecoder) ( *RuntimeContext, ,  int64) (int64, error) {
	if isOtherValue(.Buf[], boolValue) {
		return .skipTypeError(, , .typ)
	}
	return 0, errors.ErrUnexpectedEndOfJSON("bool", )
}

func ( *boolDecoder) ( *RuntimeContext, ,  int64) ([][]byte, int64, error) {
	return nil, 0, fmt.Errorf("json: bool decoder does not support decode path")
}