MCPcopy Create free account
hub / github.com/apache/fory / isPrimitiveType

Function isPrimitiveType

go/fory/codegen/utils.go:147–173  ·  view source on GitHub ↗

isPrimitiveType checks if a type is considered primitive in Fory

(t types.Type)

Source from the content-addressed store, hash-verified

145
146// isPrimitiveType checks if a type is considered primitive in Fory
147func isPrimitiveType(t types.Type) bool {
148 // Unwrap alias types
149 t = types.Unalias(t)
150 if elem, ok := getOptionalElementType(t); ok {
151 t = elem
152 }
153
154 // Handle pointer types
155 if ptr, ok := t.(*types.Pointer); ok {
156 t = ptr.Elem()
157 }
158
159 // Check basic types
160 if basic, ok := t.Underlying().(*types.Basic); ok {
161 switch basic.Kind() {
162 case types.Bool, types.Int8, types.Int16, types.Int32, types.Int, types.Int64,
163 types.Uint8, types.Uint16, types.Uint32, types.Uint, types.Uint64,
164 types.Float32, types.Float64:
165 return true
166 }
167 }
168
169 // String is NOT considered primitive for sorting purposes (it goes to final group)
170 // This matches reflection's behavior where STRING goes to final group, not boxed group
171
172 return false
173}
174
175// getTypeID returns the Fory TypeID for a given type
176func getTypeID(t types.Type) string {

Callers 1

analyzeFieldFunction · 0.70

Calls 2

getOptionalElementTypeFunction · 0.85
KindMethod · 0.80

Tested by

no test coverage detected