(b *BaseElem)
| 342 | } |
| 343 | |
| 344 | func (d *decodeGen) gBase(b *BaseElem) { |
| 345 | if !d.p.ok() { |
| 346 | return |
| 347 | } |
| 348 | |
| 349 | // open block for 'tmp' |
| 350 | var tmp string |
| 351 | lowered := b.Varname() // passed as argument |
| 352 | if b.Convert && b.Value != IDENT { // we don't need block for 'tmp' in case of IDENT |
| 353 | tmp = randIdent() |
| 354 | lowered = b.ToBase() + "(" + lowered + ")" |
| 355 | d.p.printf("\n{ var %s %s", tmp, b.BaseType()) |
| 356 | } |
| 357 | |
| 358 | vname := b.Varname() // e.g. "z.FieldOne" |
| 359 | bname := b.BaseName() // e.g. "Float64" |
| 360 | checkNil := vname // Name of var to check for nil |
| 361 | alwaysRef := vname |
| 362 | |
| 363 | // make sure we always reference the pointer |
| 364 | if strings.Contains(alwaysRef, "*") { |
| 365 | alwaysRef = strings.Trim(alwaysRef, "*()") |
| 366 | } else if !b.parentIsPtr { |
| 367 | alwaysRef = "&" + vname |
| 368 | } |
| 369 | |
| 370 | // handle special cases |
| 371 | // for object type. |
| 372 | switch b.Value { |
| 373 | case Bytes: |
| 374 | if b.Convert { |
| 375 | d.readBytesConvertWithLimit(tmp, b.AllowNil(), lowered) |
| 376 | checkNil = tmp |
| 377 | } else { |
| 378 | checkNil = d.readBytesWithLimit(vname, 0) |
| 379 | } |
| 380 | case BinaryMarshaler, BinaryAppender: |
| 381 | d.p.printf("\nerr = dc.ReadBinaryUnmarshal(%s)", alwaysRef) |
| 382 | case TextMarshalerBin, TextAppenderBin: |
| 383 | d.p.printf("\nerr = dc.ReadTextUnmarshal(%s)", alwaysRef) |
| 384 | case TextMarshalerString, TextAppenderString: |
| 385 | d.p.printf("\nerr = dc.ReadTextUnmarshalString(%s)", alwaysRef) |
| 386 | case IDENT: |
| 387 | dst := b.BaseType() |
| 388 | if b.typeParams.isPtr { |
| 389 | dst = "*" + dst |
| 390 | } |
| 391 | |
| 392 | if b.Convert { |
| 393 | if remap := b.typeParams.ToPointerMap[stripTypeParams(dst)]; remap != "" { |
| 394 | vname = fmt.Sprintf(remap, vname) |
| 395 | } |
| 396 | lowered := b.ToBase() + "(" + vname + ")" |
| 397 | d.p.printf("\nerr = %s.DecodeMsg(dc)", lowered) |
| 398 | } else { |
| 399 | if remap := b.typeParams.ToPointerMap[stripTypeParams(dst)]; remap != "" { |
| 400 | vname = fmt.Sprintf(remap, vname) |
| 401 | } |
nothing calls this directly
no test coverage detected