(ic *Inception, name string, typ reflect.Type, ptr bool, forceString bool)
| 131 | } |
| 132 | |
| 133 | func 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 { |
no test coverage detected
searching dependent graphs…