()
| 246 | } |
| 247 | |
| 248 | func (e *StructEncoder) optInstrEscape() { |
| 249 | if e.f.Type.Kind() == reflect.Slice { |
| 250 | e.flunk() |
| 251 | |
| 252 | /// create an escape string encoder internally instead of mirroring the struct, so people only need to pass the ,escape opt instead |
| 253 | enc := NewSliceEncoder([]EscapeString{}) |
| 254 | f := e.f |
| 255 | e.appendInstructionFun(func(v unsafe.Pointer, w *Buffer) { |
| 256 | var em interface{} = unsafe.Pointer(uintptr(v) + f.Offset) |
| 257 | enc.Marshal(em, w) |
| 258 | }) |
| 259 | return |
| 260 | } |
| 261 | |
| 262 | if e.f.Type.Kind() == reflect.Ptr { |
| 263 | e.ptrstringval(ptrEscapeStringToBuf) |
| 264 | } else { |
| 265 | e.chunk(`"`) |
| 266 | e.val(ptrEscapeStringToBuf) |
| 267 | e.chunk(`"`) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | // chunk writes a chunk of body data to the chunk buffer. only for writing static |
| 272 | // |
no test coverage detected