| 1 | // Copyright 2015 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package binresscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/ |
| 6 | |
| 7 | import ( |
| 8 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 9 | "unicode/utf16scip-go gomod github.com/golang/go/src go1.24.0 `unicode/utf16`/" |
| 10 | ) |
| 11 | |
| 12 | const ( |
| 13 | SortedFlagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/SortedFlag. uint32 = 1 << 0 |
| 14 | UTF8Flagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/UTF8Flag. = 1 << 8 |
| 15 | ) |
| 16 | |
| 17 | // PoolRef is the i'th string in a pool. |
| 18 | type PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef# uint32 |
| 19 | |
| 20 | // Resolve returns the string entry of PoolRef in pl. |
| 21 | func (ref PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef#) Resolvescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef#Resolve().(pl *Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#) string { |
| 22 | return pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings.[ref] |
| 23 | } |
| 24 | |
| 25 | // Pool is a container for string and style span collections. |
| 26 | // |
| 27 | // Pool has the following structure marshalled: |
| 28 | // |
| 29 | // chunkHeader |
| 30 | // uint32 number of strings in this pool |
| 31 | // uint32 number of style spans in pool |
| 32 | // uint32 SortedFlag, UTF8Flag |
| 33 | // uint32 index of string data from header |
| 34 | // uint32 index of style data from header |
| 35 | // []uint32 string indices starting at zero |
| 36 | // []uint16 or []uint8 concatenation of string entries |
| 37 | // |
| 38 | // UTF-16 entries are as follows: |
| 39 | // |
| 40 | // uint16 string length, exclusive |
| 41 | // uint16 [optional] low word if high bit of length set |
| 42 | // [n]byte data |
| 43 | // uint16 0x0000 terminator |
| 44 | // |
| 45 | // UTF-8 entries are as follows: |
| 46 | // |
| 47 | // uint8 character length, exclusive |
| 48 | // uint8 [optional] low word if high bit of character length set |
| 49 | // uint8 byte length, exclusive |
| 50 | // uint8 [optional] low word if high bit of byte length set |
| 51 | // [n]byte data |
| 52 | // uint8 0x00 terminator |
| 53 | type Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool# struct { |
| 54 | chunkHeaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#chunkHeader. |
| 55 | stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. []string |
| 56 | stylesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#styles. []*Spanscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span# |
| 57 | flagsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#flags. uint32 // SortedFlag, UTF8Flag |
| 58 | } |
| 59 | |
| 60 | // ref returns the PoolRef of s, inserting s if it doesn't exist. |
| 61 | func (pl *Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#) refscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#ref().(s string) PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef# { |
| 62 | for i, x := range pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. { |
| 63 | if s == x { |
| 64 | return PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef#(i) |
| 65 | } |
| 66 | } |
| 67 | pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. = append(pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings., s) |
| 68 | return PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef#(len(pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings.) - 1) |
| 69 | } |
| 70 | |
| 71 | // RefByName returns the PoolRef of s, or error if not exists. |
| 72 | func (pl *Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#) RefByNamescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#RefByName().(s string) (PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef#, error) { |
| 73 | for i, x := range pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. { |
| 74 | if s == x { |
| 75 | return PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef#(i), nil |
| 76 | } |
| 77 | } |
| 78 | return 0, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("PoolRef by name %q does not exist", s) |
| 79 | } |
| 80 | |
| 81 | func (pl *Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#) IsSortedscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#IsSorted().() bool { return pl.flagsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#flags.&SortedFlagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/SortedFlag. == SortedFlagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/SortedFlag. } |
| 82 | func (pl *Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#) IsUTF8scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#IsUTF8().() bool { return pl.flagsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#flags.&UTF8Flagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/UTF8Flag. == UTF8Flagscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/UTF8Flag. } |
| 83 | |
| 84 | func (pl *Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#) UnmarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#UnmarshalBinary().(bin []byte) error { |
| 85 | if err := (&pl.chunkHeaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#chunkHeader.).UnmarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#UnmarshalBinary().(bin); err != nil { |
| 86 | return err |
| 87 | } |
| 88 | if pl.typscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#typ. != ResStringPoolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/ResStringPool. { |
| 89 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("have type %s, want %s", pl.typscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#typ., ResStringPoolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/ResStringPool.) |
| 90 | } |
| 91 | |
| 92 | pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. = make([]string, btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[8:])) |
| 93 | pl.stylesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#styles. = make([]*Spanscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#, btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[12:])) |
| 94 | pl.flagsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#flags. = btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[16:]) |
| 95 | |
| 96 | offstrings := btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[20:]) |
| 97 | offstyle := btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[24:]) |
| 98 | hdrlen := 28 |
| 99 | |
| 100 | if pl.IsUTF8scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#IsUTF8().() { |
| 101 | for i := range pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. { |
| 102 | offset := int(offstrings + btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[hdrlen+i*4:])) |
| 103 | |
| 104 | // if leading bit set for nchars and nbytes, |
| 105 | // treat first byte as 7-bit high word and next as low word. |
| 106 | nchars := int(bin[offset]) |
| 107 | offset++ |
| 108 | if nchars&(1<<7) != 0 { |
| 109 | n0 := nchars ^ (1 << 7) // high word |
| 110 | n1 := int(bin[offset]) // low word |
| 111 | nchars = n0*(1<<8) + n1 |
| 112 | offset++ |
| 113 | } |
| 114 | |
| 115 | // TODO(d) At least one case in android.jar (api-10) resource table has only |
| 116 | // highbit set, making 7-bit highword zero. The reason for this is currently |
| 117 | // unknown but would make tests that unmarshal-marshal to match bytes impossible. |
| 118 | // The values noted were high-word: 0 (after highbit unset), low-word: 141 |
| 119 | // The size may be treated as an int8 triggering the use of two bytes to store size |
| 120 | // even though the implementation uses uint8. |
| 121 | nbytes := int(bin[offset]) |
| 122 | offset++ |
| 123 | if nbytes&(1<<7) != 0 { |
| 124 | n0 := nbytes ^ (1 << 7) // high word |
| 125 | n1 := int(bin[offset]) // low word |
| 126 | nbytes = n0*(1<<8) + n1 |
| 127 | offset++ |
| 128 | } |
| 129 | |
| 130 | data := bin[offset : offset+nbytes] |
| 131 | if x := uint8(bin[offset+nbytes]); x != 0 { |
| 132 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("expected zero terminator, got 0x%02X for nchars=%v nbytes=%v data=%q", x, nchars, nbytes, data) |
| 133 | } |
| 134 | pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings.[i] = string(data) |
| 135 | } |
| 136 | } else { |
| 137 | for i := range pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. { |
| 138 | offset := int(offstrings + btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[hdrlen+i*4:])) // read index of string |
| 139 | |
| 140 | // if leading bit set for nchars, treat first byte as 7-bit high word and next as low word. |
| 141 | nchars := int(btou16scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou16.(bin[offset:])) |
| 142 | offset += 2 |
| 143 | if nchars&(1<<15) != 0 { // TODO(d) this is untested |
| 144 | n0 := nchars ^ (1 << 15) // high word |
| 145 | n1 := int(btou16scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou16.(bin[offset:])) // low word |
| 146 | nchars = n0*(1<<16) + n1 |
| 147 | offset += 2 |
| 148 | } |
| 149 | |
| 150 | data := make([]uint16, nchars) |
| 151 | for i := range data { |
| 152 | data[i] = btou16scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou16.(bin[offset+2*i:]) |
| 153 | } |
| 154 | |
| 155 | if x := btou16scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou16.(bin[offset+nchars*2:]); x != 0 { |
| 156 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("expected zero terminator, got 0x%04X for nchars=%v data=%q", x, nchars, data) |
| 157 | } |
| 158 | pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings.[i] = string(utf16scip-go gomod github.com/golang/go/src go1.24.0 `unicode/utf16`/.Decodescip-go gomod github.com/golang/go/src go1.24.0 `unicode/utf16`/Decode().(data)) |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | // TODO decode styles |
| 163 | _ = offstyle |
| 164 | |
| 165 | return nil |
| 166 | } |
| 167 | |
| 168 | func (pl *Poolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#) MarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#MarshalBinary().() ([]byte, error) { |
| 169 | if pl.IsUTF8scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#IsUTF8().() { |
| 170 | return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("encode utf8 not supported") |
| 171 | } |
| 172 | |
| 173 | var ( |
| 174 | hdrlen = 28 |
| 175 | // indices of string indices |
| 176 | iis = make([]uint32, len(pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings.)) |
| 177 | iislen = len(iis) * 4 |
| 178 | // utf16 encoded strings concatenated together |
| 179 | strs []uint16 |
| 180 | ) |
| 181 | for i, x := range pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings. { |
| 182 | if len(x)>>16 > 0 { |
| 183 | panic(fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("string lengths over 1<<15 not yet supported, got len %d", len(x))) |
| 184 | } |
| 185 | p := utf16scip-go gomod github.com/golang/go/src go1.24.0 `unicode/utf16`/.Encodescip-go gomod github.com/golang/go/src go1.24.0 `unicode/utf16`/Encode().([]rune(x)) |
| 186 | if len(p) == 0 { |
| 187 | strs = append(strs, 0x0000, 0x0000) |
| 188 | } else { |
| 189 | strs = append(strs, uint16(len(p))) // string length (implicitly includes zero terminator to follow) |
| 190 | strs = append(strs, p...) |
| 191 | strs = append(strs, 0) // zero terminated |
| 192 | } |
| 193 | // indices start at zero |
| 194 | if i+1 != len(iis) { |
| 195 | iis[i+1] = uint32(len(strs) * 2) // utf16 byte index |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // check strings is 4-byte aligned, pad with zeros if not. |
| 200 | for x := (len(strs) * 2) % 4; x != 0; x -= 2 { |
| 201 | strs = append(strs, 0x0000) |
| 202 | } |
| 203 | |
| 204 | strslen := len(strs) * 2 |
| 205 | |
| 206 | hdr := chunkHeaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#{ |
| 207 | typscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#typ.: ResStringPoolscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/ResStringPool., |
| 208 | headerByteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#headerByteSize.: 28, |
| 209 | byteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#byteSize.: uint32(28 + iislen + strslen), |
| 210 | } |
| 211 | |
| 212 | bin := make([]byte, hdr.byteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#byteSize.) |
| 213 | |
| 214 | hdrbin, err := hdr.MarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#MarshalBinary().() |
| 215 | if err != nil { |
| 216 | return nil, err |
| 217 | } |
| 218 | copy(bin, hdrbin) |
| 219 | |
| 220 | putu32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu32.(bin[8:], uint32(len(pl.stringsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#strings.))) |
| 221 | putu32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu32.(bin[12:], uint32(len(pl.stylesscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#styles.))) |
| 222 | putu32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu32.(bin[16:], pl.flagsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Pool#flags.) |
| 223 | putu32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu32.(bin[20:], uint32(hdrlen+iislen)) |
| 224 | putu32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu32.(bin[24:], 0) // index of styles start, is 0 when styles length is 0 |
| 225 | |
| 226 | buf := bin[28:] |
| 227 | for _, x := range iis { |
| 228 | putu32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu32.(buf, x) |
| 229 | buf = buf[4:] |
| 230 | } |
| 231 | |
| 232 | for _, x := range strs { |
| 233 | putu16scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu16.(buf, x) |
| 234 | buf = buf[2:] |
| 235 | } |
| 236 | |
| 237 | if len(buf) != 0 { |
| 238 | panic(fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("failed to fill allocated buffer, %v bytes left over", len(buf))) |
| 239 | } |
| 240 | |
| 241 | return bin, nil |
| 242 | } |
| 243 | |
| 244 | type Spanscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span# struct { |
| 245 | namescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#name. PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef# |
| 246 | |
| 247 | firstCharscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#firstChar., lastCharscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#lastChar. uint32 |
| 248 | } |
| 249 | |
| 250 | func (spn *Spanscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#) UnmarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#UnmarshalBinary().(bin []byte) error { |
| 251 | const end = 0xFFFFFFFF |
| 252 | spn.namescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#name. = PoolRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/PoolRef#(btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin)) |
| 253 | if spn.namescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#name. == end { |
| 254 | return nil |
| 255 | } |
| 256 | spn.firstCharscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#firstChar. = btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[4:]) |
| 257 | spn.lastCharscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Span#lastChar. = btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(bin[8:]) |
| 258 | return nil |
| 259 | } |
| 260 | |
| 261 | // Map contains a uint32 slice mapping strings in the string |
| 262 | // pool back to resource identifiers. The i'th element of the slice |
| 263 | // is also the same i'th element of the string pool. |
| 264 | type Mapscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map# struct { |
| 265 | chunkHeaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#chunkHeader. |
| 266 | rsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#rs. []TableRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/TableRef# |
| 267 | } |
| 268 | |
| 269 | func (m *Mapscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#) UnmarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#UnmarshalBinary().(bin []byte) error { |
| 270 | (&m.chunkHeaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#chunkHeader.).UnmarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#UnmarshalBinary().(bin) |
| 271 | buf := bin[m.headerByteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#headerByteSize.:m.byteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#byteSize.] |
| 272 | m.rsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#rs. = make([]TableRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/TableRef#, len(buf)/4) |
| 273 | for i := range m.rsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#rs. { |
| 274 | m.rsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#rs.[i] = TableRefscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/TableRef#(btou32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/btou32.(buf[i*4:])) |
| 275 | } |
| 276 | return nil |
| 277 | } |
| 278 | |
| 279 | func (m *Mapscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#) MarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#MarshalBinary().() ([]byte, error) { |
| 280 | m.typscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#typ. = ResXMLResourceMapscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/ResXMLResourceMap. |
| 281 | m.headerByteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#headerByteSize. = 8 |
| 282 | m.byteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#byteSize. = uint32(m.headerByteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#headerByteSize.) + uint32(len(m.rsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#rs.)*4) |
| 283 | bin := make([]byte, m.byteSizescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#byteSize.) |
| 284 | b, err := m.chunkHeaderscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#chunkHeader..MarshalBinaryscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/chunkHeader#MarshalBinary().() |
| 285 | if err != nil { |
| 286 | return nil, err |
| 287 | } |
| 288 | copy(bin, b) |
| 289 | for i, r := range m.rsscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/Map#rs. { |
| 290 | putu32scip-go gomod golang.org/x/mobile . `golang.org/x/mobile/internal/binres`/putu32.(bin[8+i*4:], uint32(r)) |
| 291 | } |
| 292 | return bin, nil |
| 293 | } |