MCPcopy Create free account
hub / github.com/bet365/jingo / ptrval

Method ptrval

structencoder.go:440–457  ·  view source on GitHub ↗

ptrval creates an instruction to read from a pointer field we're marshaling

(conv func(unsafe.Pointer, *Buffer))

Source from the content-addressed store, hash-verified

438
439// ptrval creates an instruction to read from a pointer field we're marshaling
440func (e *StructEncoder) ptrval(conv func(unsafe.Pointer, *Buffer)) {
441
442 e.flunk() // flush any chunk data we've buffered
443
444 // avoids allocs at runtime
445 null := []byte("null")
446
447 f := e.f
448 e.appendInstructionFun(func(v unsafe.Pointer, w *Buffer) {
449
450 p := unsafe.Pointer(*(*unsafe.Pointer)(unsafe.Pointer(uintptr(v) + f.Offset)))
451 if p == unsafe.Pointer(nil) {
452 w.Write(null)
453 return
454 }
455 conv(p, w)
456 })
457}
458
459// ptrstringval is essentially the same as ptrval but quotes strings if not nil
460func (e *StructEncoder) ptrstringval(conv func(unsafe.Pointer, *Buffer)) {

Callers 4

optInstrStringerMethod · 0.95
optInstrEncoderMethod · 0.95
optInstrEncoderWriterMethod · 0.95
optInstrRawMethod · 0.95

Calls 3

flunkMethod · 0.95
appendInstructionFunMethod · 0.95
WriteMethod · 0.80

Tested by

no test coverage detected