本文整理汇总了Golang中mojo/public/go/bindings.Decoder.StartMap方法的典型用法代码示例。如果您正苦于以下问题:Golang Decoder.StartMap方法的具体用法?Golang Decoder.StartMap怎么用?Golang Decoder.StartMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mojo/public/go/bindings.Decoder
的用法示例。
在下文中一共展示了Decoder.StartMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Decode
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)),
}
//.........这里部分代码省略.........