Body:
This commit introduces two key improvements to the `vals` package:
1. **Optimized `CreateCValue` type switch:**
The `type switch` statement in `CreateCValue` has been reordered to prioritize common `CValue` forms (direct value, pointer, slice, function) and then by the frequency of the underlying base types (e.g., `string`, `int`, `bool`). This structure improves readability and potentially runtime performance by hitting more frequent cases earlier.
2. **Added `CValueType.String()` method:**
A `String()` method has been added to the `CValueType` type. This method provides a human-readable string representation of a `CValueType`, correctly handling base types, list types (e.g., `[]string`), map types (e.g., `map[int]string`), and object types (`object` or `object(MyStruct)`). This enhances debugging and logging capabilities.
No new external functions (like `IsListOf` or `IsMapValueOf`) were added, focusing solely on the requested internal refactorings and the `String()` method for `CValueType`.
This commit introduces the foundational CValue type system, enabling
unified handling and representation of various Go data types.
Key features and components:
- **`CValue` struct**: Core data structure for holding any Go value.
- **`CValueType` and `CValueState`**: Enums for type identification and value state.
- **`cValueCreator` interface**: Defines the contract for creating `CValue` instances.
- **`creatorCValueFnc[T]`**: Generic function type implementing `cValueCreator`,
responsible for converting specific Go types (`T`) to `CValue`.
- **`makePointerCreator`, `makeListCreator`, `makeFuncCreator`**: Generic helper
functions for creating specialized `cValueCreator`s for pointers (`*T`),
slices (`[]T`), and provider functions (`func() T`), respectively.
- **`cValueTypeInfo`**: Struct for metadata and associated `cValueCreator`s for each `CValueType`.
- **`createCValueTypeInfo[T]`**: Generic factory function to initialize `cValueTypeInfo` entries,
including support for custom `cValueCreator` overrides.
- **Initial set of `CreateCValue` functions**: Basic implementations for primitive types
(int, string, bool, etc.) and specific types like `[]byte`.
- **Centralized type registration**: `newCValueTypeInfoMap` for organizing all
`cValueTypeInfo` definitions.
This foundational layer is designed for extensibility, allowing easy
addition of new `CValueType`s and custom handling logic.