// automatically generated by stateify.

package refs

import (
	"inet.af/netstack/state"
)

func (w *WeakRef) StateTypeName() string {
	return "pkg/refs.WeakRef"
}

func (w *WeakRef) StateFields() []string {
	return []string{
		"obj",
		"user",
	}
}

func (w *WeakRef) beforeSave() {}

// +checklocksignore
func (w *WeakRef) StateSave(stateSinkObject state.Sink) {
	w.beforeSave()
	var objValue savedReference
	objValue = w.saveObj()
	stateSinkObject.SaveValue(0, objValue)
	stateSinkObject.Save(1, &w.user)
}

func (w *WeakRef) afterLoad() {}

// +checklocksignore
func (w *WeakRef) StateLoad(stateSourceObject state.Source) {
	stateSourceObject.Load(1, &w.user)
	stateSourceObject.LoadValue(0, new(savedReference), func(y interface{}) { w.loadObj(y.(savedReference)) })
}

func (r *AtomicRefCount) StateTypeName() string {
	return "pkg/refs.AtomicRefCount"
}

func (r *AtomicRefCount) StateFields() []string {
	return []string{
		"refCount",
		"name",
		"stack",
	}
}

func (r *AtomicRefCount) beforeSave() {}

// +checklocksignore
func (r *AtomicRefCount) StateSave(stateSinkObject state.Sink) {
	r.beforeSave()
	stateSinkObject.Save(0, &r.refCount)
	stateSinkObject.Save(1, &r.name)
	stateSinkObject.Save(2, &r.stack)
}

func (r *AtomicRefCount) afterLoad() {}

// +checklocksignore
func (r *AtomicRefCount) StateLoad(stateSourceObject state.Source) {
	stateSourceObject.Load(0, &r.refCount)
	stateSourceObject.Load(1, &r.name)
	stateSourceObject.Load(2, &r.stack)
}

func (s *savedReference) StateTypeName() string {
	return "pkg/refs.savedReference"
}

func (s *savedReference) StateFields() []string {
	return []string{
		"obj",
	}
}

func (s *savedReference) beforeSave() {}

// +checklocksignore
func (s *savedReference) StateSave(stateSinkObject state.Sink) {
	s.beforeSave()
	stateSinkObject.Save(0, &s.obj)
}

func (s *savedReference) afterLoad() {}

// +checklocksignore
func (s *savedReference) StateLoad(stateSourceObject state.Source) {
	stateSourceObject.Load(0, &s.obj)
}

func (l *weakRefList) StateTypeName() string {
	return "pkg/refs.weakRefList"
}

func (l *weakRefList) StateFields() []string {
	return []string{
		"head",
		"tail",
	}
}

func (l *weakRefList) beforeSave() {}

// +checklocksignore
func (l *weakRefList) StateSave(stateSinkObject state.Sink) {
	l.beforeSave()
	stateSinkObject.Save(0, &l.head)
	stateSinkObject.Save(1, &l.tail)
}

func (l *weakRefList) afterLoad() {}

// +checklocksignore
func (l *weakRefList) StateLoad(stateSourceObject state.Source) {
	stateSourceObject.Load(0, &l.head)
	stateSourceObject.Load(1, &l.tail)
}

func (e *weakRefEntry) StateTypeName() string {
	return "pkg/refs.weakRefEntry"
}

func (e *weakRefEntry) StateFields() []string {
	return []string{
		"next",
		"prev",
	}
}

func (e *weakRefEntry) beforeSave() {}

// +checklocksignore
func (e *weakRefEntry) StateSave(stateSinkObject state.Sink) {
	e.beforeSave()
	stateSinkObject.Save(0, &e.next)
	stateSinkObject.Save(1, &e.prev)
}

func (e *weakRefEntry) afterLoad() {}

// +checklocksignore
func (e *weakRefEntry) StateLoad(stateSourceObject state.Source) {
	stateSourceObject.Load(0, &e.next)
	stateSourceObject.Load(1, &e.prev)
}

func init() {
	state.Register((*WeakRef)(nil))
	state.Register((*AtomicRefCount)(nil))
	state.Register((*savedReference)(nil))
	state.Register((*weakRefList)(nil))
	state.Register((*weakRefEntry)(nil))
}
