MCPcopy
hub / github.com/pquerna/ffjson / getGetInnerValue

Function getGetInnerValue

inception/encoder.go:133–324  ·  view source on GitHub ↗
(ic *Inception, name string, typ reflect.Type, ptr bool, forceString bool)

Source from the content-addressed store, hash-verified

131}
132
133func getGetInnerValue(ic *Inception, name string, typ reflect.Type, ptr bool, forceString bool) string {
134 var out = ""
135
136 // Flush if not bool or maps
137 if typ.Kind() != reflect.Bool && typ.Kind() != reflect.Map && typ.Kind() != reflect.Struct {
138 out += ic.q.Flush()
139 }
140
141 if typ.Implements(marshalerFasterType) ||
142 reflect.PtrTo(typ).Implements(marshalerFasterType) ||
143 typeInInception(ic, typ, shared.MustEncoder) ||
144 typ.Implements(marshalerType) ||
145 reflect.PtrTo(typ).Implements(marshalerType) {
146
147 out += ic.q.Flush()
148 out += tplStr(encodeTpl["handleMarshaler"], handleMarshaler{
149 IC: ic,
150 Name: name,
151 Typ: typ,
152 Ptr: reflect.Ptr,
153 MarshalJSONBuf: typ.Implements(marshalerFasterType) || reflect.PtrTo(typ).Implements(marshalerFasterType) || typeInInception(ic, typ, shared.MustEncoder),
154 Marshaler: typ.Implements(marshalerType) || reflect.PtrTo(typ).Implements(marshalerType),
155 })
156 return out
157 }
158
159 ptname := name
160 if ptr {
161 ptname = "*" + name
162 }
163
164 switch typ.Kind() {
165 case reflect.Int,
166 reflect.Int8,
167 reflect.Int16,
168 reflect.Int32,
169 reflect.Int64:
170 ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true
171 out += "fflib.FormatBits2(buf, uint64(" + ptname + "), 10, " + ptname + " < 0)" + "\n"
172 case reflect.Uint,
173 reflect.Uint8,
174 reflect.Uint16,
175 reflect.Uint32,
176 reflect.Uint64,
177 reflect.Uintptr:
178 ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true
179 out += "fflib.FormatBits2(buf, uint64(" + ptname + "), 10, false)" + "\n"
180 case reflect.Float32:
181 ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true
182 out += "fflib.AppendFloat(buf, float64(" + ptname + "), 'g', -1, 32)" + "\n"
183 case reflect.Float64:
184 ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true
185 out += "fflib.AppendFloat(buf, float64(" + ptname + "), 'g', -1, 64)" + "\n"
186 case reflect.Array,
187 reflect.Slice:
188
189 // Arrays cannot be nil
190 if typ.Kind() != reflect.Array {

Callers 2

getMapValueFunction · 0.85
getValueFunction · 0.85

Calls 11

typeInInceptionFunction · 0.85
tplStrFunction · 0.85
getMapValueFunction · 0.85
extractFieldsFunction · 0.85
getFieldFunction · 0.85
lastConditionalFunction · 0.85
FlushMethod · 0.80
GetQueuedMethod · 0.80
DeleteLastMethod · 0.80
WriteFlushMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…