func (s *KeysByType) Decode(decoder *bindings.Decoder) error { header, err := decoder.StartStruct() if err != nil { return err } index := sort.Search(len(keysByType_Versions), func(i int) bool { return keysByType_Versions[i].ElementsOrVersion >= header.ElementsOrVersion }) if index < len(keysByType_Versions) { if keysByType_Versions[index].ElementsOrVersion > header.ElementsOrVersion { index-- } expectedSize := keysByType_Versions[index].Size if expectedSize != header.Size { return &bindings.ValidationError{bindings.UnexpectedStructHeader, fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.Interfaces = nil } else { s.Interfaces = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.Interfaces) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.Interfaces)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.Structs = nil } else { s.Structs = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.Structs) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.Structs)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.Unions = nil } else { s.Unions = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.Unions) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.Unions)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.TopLevelEnums = nil } else { s.TopLevelEnums = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.TopLevelEnums) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.TopLevelEnums)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.EmbeddedEnums = nil } else { s.EmbeddedEnums = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.EmbeddedEnums) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.EmbeddedEnums)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.TopLevelConstants = nil } else { s.TopLevelConstants = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.TopLevelConstants) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.TopLevelConstants)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.EmbeddedConstants = nil } else { s.EmbeddedConstants = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.EmbeddedConstants) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.EmbeddedConstants)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if err := decoder.Finish(); err != nil { return err } return nil }
func (s *MojomFile) Decode(decoder *bindings.Decoder) error { header, err := decoder.StartStruct() if err != nil { return err } index := sort.Search(len(mojomFile_Versions), func(i int) bool { return mojomFile_Versions[i].ElementsOrVersion >= header.ElementsOrVersion }) if index < len(mojomFile_Versions) { if mojomFile_Versions[index].ElementsOrVersion > header.ElementsOrVersion { index-- } expectedSize := mojomFile_Versions[index].Size if expectedSize != header.Size { return &bindings.ValidationError{bindings.UnexpectedStructHeader, fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value0, err := decoder.ReadString() if err != nil { return err } s.FileName = value0 } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.ModuleNamespace = nil } else { s.ModuleNamespace = new(string) value0, err := decoder.ReadString() if err != nil { return err } (*s.ModuleNamespace) = value0 } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.Attributes = nil } else { s.Attributes = new([]mojom_types.Attribute) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.Attributes) = make([]mojom_types.Attribute, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { if err := (*s.Attributes)[i0].Decode(decoder); err != nil { return err } } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { s.Imports = nil } else { s.Imports = new([]string) len0, err := decoder.StartArray(64) if err != nil { return err } (*s.Imports) = make([]string, len0) for i0 := uint32(0); i0 < len0; i0++ { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value1, err := decoder.ReadString() if err != nil { return err } (*s.Imports)[i0] = value1 } } if err := decoder.Finish(); err != nil { return err } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { if err := s.DeclaredMojomObjects.Decode(decoder); err != nil { return err } } } if err := decoder.Finish(); err != nil { return err } return nil }
func (s *MojomFileGraph) Decode(decoder *bindings.Decoder) error { header, err := decoder.StartStruct() if err != nil { return err } index := sort.Search(len(mojomFileGraph_Versions), func(i int) bool { return mojomFileGraph_Versions[i].ElementsOrVersion >= header.ElementsOrVersion }) if index < len(mojomFileGraph_Versions) { if mojomFileGraph_Versions[index].ElementsOrVersion > header.ElementsOrVersion { index-- } expectedSize := mojomFileGraph_Versions[index].Size if expectedSize != header.Size { return &bindings.ValidationError{bindings.UnexpectedStructHeader, fmt.Sprintf("invalid struct header size: should be %d, but was %d", expectedSize, header.Size), } } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { if err := decoder.StartMap(); err != nil { return err } var keys0 []string { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { len1, err := decoder.StartArray(64) if err != nil { return err } keys0 = make([]string, len1) for i1 := uint32(0); i1 < len1; i1++ { pointer2, err := decoder.ReadPointer() if err != nil { return err } if pointer2 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value2, err := decoder.ReadString() if err != nil { return err } keys0[i1] = value2 } } if err := decoder.Finish(); err != nil { return err } } } var values0 []MojomFile { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { len1, err := decoder.StartArray(64) if err != nil { return err } values0 = make([]MojomFile, len1) for i1 := uint32(0); i1 < len1; i1++ { pointer2, err := decoder.ReadPointer() if err != nil { return err } if pointer2 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { if err := values0[i1].Decode(decoder); err != nil { return err } } } if err := decoder.Finish(); err != nil { return err } } } if len(keys0) != len(values0) { return &bindings.ValidationError{bindings.DifferentSizedArraysInMap, fmt.Sprintf("Number of keys %d is different from number of values %d", len(keys0), len(values0)), } } if err := decoder.Finish(); err != nil { return err } len0 := len(keys0) map0 := make(map[string]MojomFile) for i0 := 0; i0 < len0; i0++ { map0[keys0[i0]] = values0[i0] } s.Files = map0 } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { if err := decoder.StartMap(); err != nil { return err } var keys0 []string { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { len1, err := decoder.StartArray(64) if err != nil { return err } keys0 = make([]string, len1) for i1 := uint32(0); i1 < len1; i1++ { pointer2, err := decoder.ReadPointer() if err != nil { return err } if pointer2 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value2, err := decoder.ReadString() if err != nil { return err } keys0[i1] = value2 } } if err := decoder.Finish(); err != nil { return err } } } var values0 []mojom_types.UserDefinedType { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { len1, err := decoder.StartArray(128) if err != nil { return err } values0 = make([]mojom_types.UserDefinedType, len1) for i1 := uint32(0); i1 < len1; i1++ { var err error values0[i1], err = mojom_types.DecodeUserDefinedType(decoder) if err != nil { return err } if values0[i1] == nil { return &bindings.ValidationError{bindings.UnexpectedNullUnion, "unexpected null union"} } } if err := decoder.Finish(); err != nil { return err } } } if len(keys0) != len(values0) { return &bindings.ValidationError{bindings.DifferentSizedArraysInMap, fmt.Sprintf("Number of keys %d is different from number of values %d", len(keys0), len(values0)), } } if err := decoder.Finish(); err != nil { return err } len0 := len(keys0) map0 := make(map[string]mojom_types.UserDefinedType) for i0 := 0; i0 < len0; i0++ { map0[keys0[i0]] = values0[i0] } s.ResolvedTypes = map0 } } if header.ElementsOrVersion >= 0 { pointer0, err := decoder.ReadPointer() if err != nil { return err } if pointer0 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { if err := decoder.StartMap(); err != nil { return err } var keys0 []string { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { len1, err := decoder.StartArray(64) if err != nil { return err } keys0 = make([]string, len1) for i1 := uint32(0); i1 < len1; i1++ { pointer2, err := decoder.ReadPointer() if err != nil { return err } if pointer2 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { value2, err := decoder.ReadString() if err != nil { return err } keys0[i1] = value2 } } if err := decoder.Finish(); err != nil { return err } } } var values0 []mojom_types.DeclaredConstant { pointer1, err := decoder.ReadPointer() if err != nil { return err } if pointer1 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { len1, err := decoder.StartArray(64) if err != nil { return err } values0 = make([]mojom_types.DeclaredConstant, len1) for i1 := uint32(0); i1 < len1; i1++ { pointer2, err := decoder.ReadPointer() if err != nil { return err } if pointer2 == 0 { return &bindings.ValidationError{bindings.UnexpectedNullPointer, "unexpected null pointer"} } else { if err := values0[i1].Decode(decoder); err != nil { return err } } } if err := decoder.Finish(); err != nil { return err } } } if len(keys0) != len(values0) { return &bindings.ValidationError{bindings.DifferentSizedArraysInMap, fmt.Sprintf("Number of keys %d is different from number of values %d", len(keys0), len(values0)), } } if err := decoder.Finish(); err != nil { return err } len0 := len(keys0) map0 := make(map[string]mojom_types.DeclaredConstant) for i0 := 0; i0 < len0; i0++ { map0[keys0[i0]] = values0[i0] } s.ResolvedConstants = map0 } } if err := decoder.Finish(); err != nil { return err } return nil }