isPrimitiveType checks if a type is considered primitive in Fory
(t types.Type)
| 145 | |
| 146 | // isPrimitiveType checks if a type is considered primitive in Fory |
| 147 | func 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 |
| 176 | func getTypeID(t types.Type) string { |
no test coverage detected