(t reflect.Type)
| 249 | } |
| 250 | |
| 251 | func makeTypes(t reflect.Type) []messageType { |
| 252 | minVersion := int16(-1) |
| 253 | maxVersion := int16(-1) |
| 254 | |
| 255 | // All future versions will be flexible (according to spec), so don't need to |
| 256 | // worry about maxes here. |
| 257 | minFlexibleVersion := int16(-1) |
| 258 | |
| 259 | forEachStructField(t, func(_ reflect.Type, _ index, tag string) { |
| 260 | forEachStructTag(tag, func(tag structTag) bool { |
| 261 | if minVersion < 0 || tag.MinVersion < minVersion { |
| 262 | minVersion = tag.MinVersion |
| 263 | } |
| 264 | if maxVersion < 0 || tag.MaxVersion > maxVersion { |
| 265 | maxVersion = tag.MaxVersion |
| 266 | } |
| 267 | if tag.TagID > -2 && (minFlexibleVersion < 0 || tag.MinVersion < minFlexibleVersion) { |
| 268 | minFlexibleVersion = tag.MinVersion |
| 269 | } |
| 270 | return true |
| 271 | }) |
| 272 | }) |
| 273 | |
| 274 | types := make([]messageType, 0, (maxVersion-minVersion)+1) |
| 275 | |
| 276 | for v := minVersion; v <= maxVersion; v++ { |
| 277 | flexible := minFlexibleVersion >= 0 && v >= minFlexibleVersion |
| 278 | |
| 279 | types = append(types, messageType{ |
| 280 | version: v, |
| 281 | gotype: t, |
| 282 | flexible: flexible, |
| 283 | decode: decodeFuncOf(t, v, flexible, structTag{}), |
| 284 | encode: encodeFuncOf(t, v, flexible, structTag{}), |
| 285 | }) |
| 286 | } |
| 287 | |
| 288 | return types |
| 289 | } |
| 290 | |
| 291 | type structTag struct { |
| 292 | MinVersion int16 |
searching dependent graphs…