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

Method buildClassEncodeToBufFuncs

gapil/compiler/plugins/encoder/encoder.go:146–162  ·  view source on GitHub ↗

buildClassEncodeToBufFuncs builds the encode_to_buf() method for each API class type. encode_to_buf() encode the class message to a buffer.

()

Source from the content-addressed store, hash-verified

144// class type.
145// encode_to_buf() encode the class message to a buffer.
146func (e *encoder) buildClassEncodeToBufFuncs() {
147 for _, api := range e.APIs {
148 for _, ty := range api.Classes {
149 e.funcs.encodeToBuf[ty] = e.Method(false, e.T.Target(ty), e.T.Void, "encode_to_buf", e.T.CtxPtr, e.T.BufPtr).
150 LinkPrivate()
151 }
152 for _, class := range api.Classes {
153 e.C.Build(e.funcs.encodeToBuf[class], func(s *compiler.S) {
154 this, buf := s.Parameter(0), s.Parameter(2)
155 for i, f := range class.Fields {
156 ptr := this.Index(0, f.Name())
157 e.encodeField(s, ptr, buf, serialization.ClassFieldStart+serialization.ProtoFieldID(i), f.Type)
158 }
159 })
160 }
161 }
162}
163
164// buildClassEncodeFuncs builds the encode() method for each API class type.
165// encode() will call gapil_encode_type() with the class type before encoding

Callers 1

buildEncoderFuncsMethod · 0.95

Calls 8

encodeFieldMethod · 0.95
MethodMethod · 0.80
BuildMethod · 0.65
IndexMethod · 0.65
NameMethod · 0.65
LinkPrivateMethod · 0.45
TargetMethod · 0.45
ParameterMethod · 0.45

Tested by

no test coverage detected