buildClassEncodeFuncs builds the encode() method for each API class type. encode() will call gapil_encode_type() with the class type before encoding the proto message with gapil_encode_object.
()
| 165 | // encode() will call gapil_encode_type() with the class type before encoding |
| 166 | // the proto message with gapil_encode_object. |
| 167 | func (e *encoder) buildClassEncodeFuncs() { |
| 168 | for _, api := range e.APIs { |
| 169 | for _, class := range api.Classes { |
| 170 | e.C.Build(e.Method(true, e.T.Target(class), e.T.VoidPtr, "encode", e.T.CtxPtr, e.T.Bool), func(s *compiler.S) { |
| 171 | this, isGroup := s.Parameter(0), s.Parameter(2) |
| 172 | |
| 173 | e.debug(s, "encoding class: '"+class.Name()+"' this: %p, ctx: %p", this, s.Ctx) |
| 174 | |
| 175 | typeID := s.Call(e.ent(class).encodeType, s.Ctx) |
| 176 | |
| 177 | buf, delBuf := e.newBuf(s) |
| 178 | |
| 179 | s.Call(e.funcs.encodeToBuf[class], this, s.Ctx, buf) |
| 180 | |
| 181 | bufOffset := buf.Index(0, compiler.BufSize).Load() |
| 182 | bufData := buf.Index(0, compiler.BufData).Load() |
| 183 | |
| 184 | out := s.Call(e.callbacks.encodeObject, s.Ctx, isGroup.Cast(e.T.Uint8), typeID, bufOffset, bufData) |
| 185 | |
| 186 | delBuf() |
| 187 | |
| 188 | s.Return(out) |
| 189 | }) |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | // buildStateEncodeFunc builds the encode() method for each API state object. |
| 195 | // encode() will call gapil_encode_type() with the state type before encoding |
no test coverage detected