MCPcopy Create free account
hub / github.com/google/gapid / buildClassEncodeFuncs

Method buildClassEncodeFuncs

gapil/compiler/plugins/encoder/encoder.go:167–192  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

165// encode() will call gapil_encode_type() with the class type before encoding
166// the proto message with gapil_encode_object.
167func (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

Callers 1

buildEncoderFuncsMethod · 0.95

Calls 13

debugMethod · 0.95
entMethod · 0.95
newBufMethod · 0.95
MethodMethod · 0.80
BuildMethod · 0.65
NameMethod · 0.65
CallMethod · 0.65
LoadMethod · 0.65
IndexMethod · 0.65
TargetMethod · 0.45
ParameterMethod · 0.45
CastMethod · 0.45

Tested by

no test coverage detected