Subject: Refactor(vals): Optimize CreateCValue type switch and add CValueType.String()

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`.
master
dev 1 year ago
parent f3d4502763
commit 66db3529f2

@ -0,0 +1,95 @@
// =============================================================================
// Active-GO Framework
// Copyright (c) 2025 ActiveThing (https://activething.com)
// Author: Juan V. Navarro juanvnl@activething.com
// =============================================================================
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// =============================================================================
// Date Create 13/05/2025
// =============================================================================
// Package excs provides utilities for capturing and working with execution contexts,
// primarily focused on stack traces. This package is used by the errs package
// to include stack trace information in structured errors.
package excs
import (
"runtime"
)
// Constants used for stack trace configuration and handling.
const (
// stackSkipFrames defines how many initial frames are skipped when capturing the stack.
// 2 frames are skipped to exclude internal system calls (runtime.Callers and this function).
stackSkipFrames = 2
// stackMaxFrames defines the maximum number of frames that will be captured.
// Limits the depth of the stack trace to 32 frames by default.
stackMaxFrames = 32
)
// Stack is a slice of program counters, representing a captured stack trace.
type Stack []uintptr
// CreateStack captures the current execution stack trace.
// It takes an offset (number of frames to skip in addition to the default)
// and maxFrames (maximum number of frames to capture).
// Returns a Stack slice containing the captured program counters.
func CreateStack(options ...int) Stack {
offset := 0
maxFrames := stackMaxFrames
if len(options) > 0 {
offset = options[0]
if offset < 0 {
offset = 0
}
if len(options) > 1 {
maxFrames = options[1]
if maxFrames < 0 || maxFrames > stackMaxFrames {
maxFrames = stackMaxFrames
}
}
}
ls := make([]uintptr, maxFrames)
// Capture the stack trace using runtime.Callers.
// runtime.Callers fills the slice 'ls' with program counters,
// skipping 'offset + stackSkipFrames' frames.
// 'cn' will contain the actual number of frames captured.
cn := runtime.Callers(offset+stackSkipFrames, ls)
// Return only the slice containing valid program counters (up to 'cn').
return ls[:cn]
}
// Frames converts the Stack (slice of program counters) into a slice of StackFrame objects.
// Each StackFrame provides detailed information about a single frame in the stack.
func (s Stack) Frames() []StackFrame {
// Create a slice to store StackFrame objects with the same length as the stack.
f := make([]StackFrame, len(s))
// Convert each program counter to a StackFrame object.
for i, p := range s {
f[i] = CreateStackFrame(p)
}
return f
}

@ -0,0 +1,149 @@
// =============================================================================
// Active-GO Framework
// Copyright (c) 2025 ActiveThing (https://activething.com)
// Author: Juan V. Navarro juanvnl@activething.com
// =============================================================================
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// =============================================================================
// Date Create 13/05/2025
// =============================================================================
package excs
import (
"bufio"
"bytes"
"os"
"runtime"
"strings"
)
const (
// stackUnknownInfo is the default value when information about a stack frame cannot be obtained.
stackUnknownInfo = "???"
)
type (
// StackFrame represents a single frame in a stack trace.
// It contains detailed information about the function call at that point.
StackFrame struct {
// LineNumber is the line number in the source file where this frame was created.
LineNumber int
// File is the full path to the source file containing this frame.
File string
// FuncName is the name of the function where this frame was created,
// with any receiver types removed.
FuncName string
// Package is the full package path where this frame was created.
Package string
// Counter is the program counter address for this frame.
Counter uintptr
// files is an internal cache of file contents.
// Note: This field is present but not used in the current implementation of SourceLine.
files map[string][]byte
}
)
// CreateStackFrame creates a new StackFrame from a program counter address.
// It uses runtime information to populate the frame details.
// Returns an empty StackFrame if the counter is 0.
func CreateStackFrame(counter uintptr) StackFrame {
sf := StackFrame{}
if counter == 0 {
return sf
}
sf.Counter = counter
// Get runtime.Func for the program counter.
fn := runtime.FuncForPC(counter)
// Extract package and function name.
sf.Package, sf.FuncName = packageAndName(fn)
// Get file and line number. Note: counter - 1 is used to get the call site.
sf.File, sf.LineNumber = fn.FileLine(counter - 1)
return sf
}
// SourceLine attempts to retrieve the source code line for this stack frame.
// It reads the source file and returns the content of the line specified by LineNumber.
// Returns stackUnknownInfo if the line number is invalid or an error occurs while reading the file.
func (f StackFrame) SourceLine() (string, error) {
// Return unknown info if line number is not valid.
if f.LineNumber <= 0 {
return stackUnknownInfo, nil
}
// Open the source file.
file, err := os.Open(f.File)
if err != nil {
return "", err // Return error if file cannot be opened.
}
defer func(file *os.File) {
err := file.Close()
if err != nil {
//todo
}
}(file) // Ensure the file is closed.
scanner := bufio.NewScanner(file)
currentLine := 1
// Scan the file line by line.
for scanner.Scan() {
// If the current line matches the frame's line number.
if currentLine == f.LineNumber {
// Return the trimmed line content as a string.
return string(bytes.Trim(scanner.Bytes(), " \t")), nil
}
currentLine++
}
// Check for scanner errors.
if err := scanner.Err(); err != nil {
return "", err // Return scanner error.
}
// If the line number was not found (e.g., file shorter than expected).
return stackUnknownInfo, nil
}
// packageAndName extracts the package path and function name from a runtime.Func.
// It handles different naming conventions, including methods.
func packageAndName(fn *runtime.Func) (string, string) {
nm := fn.Name() // Get the full name, e.g., "main.(*MyType).MyMethod" or "main.myFunction"
pg := "" // Initialize package path
// Find the last slash, which separates package path components.
if ls := strings.LastIndex(nm, "/"); ls >= 0 {
pg = nm[:ls] + "/" // Extract the path part
nm = nm[ls+1:] // Keep the rest of the name
}
// Find the first dot after the last slash, which separates package name from function name.
if pd := strings.Index(nm, "."); pd >= 0 {
pg += nm[:pd] // Add the package name to the path
nm = nm[pd+1:] // Keep the function name
}
// Replace the Go internal method separator '·' with '.' for readability.
return pg, strings.Replace(nm, "·", ".", -1)
}

@ -0,0 +1,49 @@
// =============================================================================
// GO·AT Framework
// Copyright (c) 2025 ActiveThing (https://activething.com)
// Author: Juan V. Navarro juanvnl@activething.com
// =============================================================================
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// =============================================================================
// Date Create 29/05/2025
// =============================================================================
package vals
import (
"math"
"time"
)
var (
g = struct {
minTime,
maxTime time.Time
cValueTypeInfos [maxCValueTypes]cValueTypeInfo
}{
minTime: time.Unix(0, math.MinInt64),
maxTime: time.Unix(0, math.MaxInt64),
cValueTypeInfos: createCValueTypeInfos(),
}
)

@ -30,6 +30,9 @@ package vals
import (
"core/blrs"
"core/excs"
"math"
"reflect"
"time"
)
@ -37,48 +40,657 @@ type (
CValue struct {
mType CValueType
mState CValueState
vInt int64
vStr string
vAny any
intVal int64
strVal string
anyVal any
}
)
func CreateCValueAny(value any) CValue { return CValue{} }
func CreateCValue (value any) CValue {
// idxC
// 0 value
// 1 pointer
// 2 list
// 3 func
var idxT,idxC int
switch value.(type) {
func CreateCValueBool(value bool) CValue { return CValue{} }
/*
case string : idxT,idxC = idxCValueTypeString,0
case *string : idxT,idxC = idxCValueTypeString,1
case []string : idxT,idxC = idxCValueTypeString,2
case func()string : idxT,idxC = idxCValueTypeString,3
func CreateCValueInt(value int) CValue { return CValue{} }
func CreateCValueInt8(value int8) CValue { return CValue{} }
func CreateCValueInt16(value int16) CValue { return CValue{} }
func CreateCValueInt32(value int32) CValue { return CValue{} }
func CreateCValueInt64(value int64) CValue { return CValue{} }
case bool : idxT,idxC = idxCValueTypeBool,0
case *bool : idxT,idxC = idxCValueTypeBool,1
case []bool : idxT,idxC = idxCValueTypeBool,2
case func()bool : idxT,idxC = idxCValueTypeBool,3
func CreateCValueUint(value uint) CValue { return CValue{} }
func CreateCValueUint8(value uint8) CValue { return CValue{} }
func CreateCValueUint16(value uint16) CValue { return CValue{} }
func CreateCValueUint32(value uint32) CValue { return CValue{} }
func CreateCValueUint64(value uint64) CValue { return CValue{} }
case int : idxT,idxC = idxCValueTypeInt,0
case *int : idxT,idxC = idxCValueTypeInt,1
case []int : idxT,idxC = idxCValueTypeInt,2
case func()int : idxT,idxC = idxCValueTypeInt,3
func CreateCValueUintptr(value uintptr) CValue { return CValue{} }
case int8 : idxT,idxC = idxCValueTypeInt8,0
case *int8 : idxT,idxC = idxCValueTypeInt8,1
case []int8 : idxT,idxC = idxCValueTypeInt8,2
case func()int8 : idxT,idxC = idxCValueTypeInt8,3
func CreateCValueFloat32(value float32) CValue { return CValue{} }
func CreateCValueFloat64(value float64) CValue { return CValue{} }
case int16 : idxT,idxC = idxCValueTypeInt16,0
case *int16 : idxT,idxC = idxCValueTypeInt16,1
case []int16 : idxT,idxC = idxCValueTypeInt16,2
case func()int16 : idxT,idxC = idxCValueTypeInt16,3
func CreateCValueComplex64(value complex64) CValue { return CValue{} }
func CreateCValueComplex128(value complex128) CValue { return CValue{} }
case int32 : idxT,idxC = idxCValueTypeInt32,0
case *int32 : idxT,idxC = idxCValueTypeInt32,1
case []int32 : idxT,idxC = idxCValueTypeInt32,2
case func()int32 : idxT,idxC = idxCValueTypeInt32,3
func CreateCValueDuration(value time.Duration) CValue { return CValue{} }
func CreateCValueDate(value time.Time) CValue { return CValue{} }
case int64 : idxT,idxC = idxCValueTypeInt64,0
case *int64 : idxT,idxC = idxCValueTypeInt64,1
case []int64 : idxT,idxC = idxCValueTypeInt64,2
case func()int64 : idxT,idxC = idxCValueTypeInt64,3
func CreateCValueString(value string) CValue { return CValue{} }
func CreateCValueBytes(value []byte) CValue { return CValue{} }
func CreateCValueStack(value []string) CValue { return CValue{} }
case uint : idxT,idxC = idxCValueTypeUint,0
case *uint : idxT,idxC = idxCValueTypeUint,1
case []uint : idxT,idxC = idxCValueTypeUint,2
case func()uint : idxT,idxC = idxCValueTypeUint,3
func CreateCValueBaleable(value blrs.Baleable) CValue { return CValue{} }
func CreateCValueError(value error) CValue { return CValue{} }
case uint8 : idxT,idxC = idxCValueTypeUint8,0
case *uint8 : idxT,idxC = idxCValueTypeUint8,1
// ya esta contemplado en el array de constructores
// que este tipo se convierta en CValueTypes
case []uint8 : idxT,idxC = idxCValueTypeUint8,2
case func()uint8 : idxT,idxC = idxCValueTypeUint8,3
func CreateCValueNil(value any) CValue { return CValue{} }
func CreateCValueMap(value any) CValue { return CValue{} }
func CreateCValueList(value any) CValue { return CValue{} }
case uint16 : idxT,idxC = idxCValueTypeUint16,0
case *uint16 : idxT,idxC = idxCValueTypeUint16,1
case []uint16 : idxT,idxC = idxCValueTypeUint16,2
case func()uint16 : idxT,idxC = idxCValueTypeUint16,3
func createCValueInvalid(value any) CValue { return CValue{} }
case uint32 : idxT,idxC = idxCValueTypeUint32,0
case *uint32 : idxT,idxC = idxCValueTypeUint32,1
case []uint32 : idxT,idxC = idxCValueTypeUint32,2
case func()uint32 : idxT,idxC = idxCValueTypeUint32,3
case uint64 : idxT,idxC = idxCValueTypeUint64,0
case *uint64 : idxT,idxC = idxCValueTypeUint64,1
case []uint64 : idxT,idxC = idxCValueTypeUint64,2
case func()uint64 : idxT,idxC = idxCValueTypeUint64,3
case float32 : idxT,idxC = idxCValueTypeFloat32,0
case *float32 : idxT,idxC = idxCValueTypeFloat32,1
case []float32 : idxT,idxC = idxCValueTypeFloat32,2
case func()float32 : idxT,idxC = idxCValueTypeFloat32,3
case float64 : idxT,idxC = idxCValueTypeFloat64,0
case *float64 : idxT,idxC = idxCValueTypeFloat64,1
case []float64 : idxT,idxC = idxCValueTypeFloat64,2
case func()float64 : idxT,idxC = idxCValueTypeFloat64,3
case complex64 : idxT,idxC = idxCValueTypeComplex64,0
case *complex64 : idxT,idxC = idxCValueTypeComplex64,1
case []complex64 : idxT,idxC = idxCValueTypeComplex64,2
case func()complex64: idxT,idxC = idxCValueTypeComplex64,3
case complex128 : idxT,idxC = idxCValueTypeComplex128,0
case *complex128 : idxT,idxC = idxCValueTypeComplex128,1
case []complex128 : idxT,idxC = idxCValueTypeComplex128,2
case func()complex128:idxT,idxC = idxCValueTypeComplex128,3
case time.Duration : idxT,idxC = idxCValueTypeDuration,0
case *time.Duration : idxT,idxC = idxCValueTypeDuration,1
case []time.Duration : idxT,idxC = idxCValueTypeDuration,2
case func()time.Duration: idxT,idxC = idxCValueTypeDuration,3
case time.Time : idxT,idxC = idxCValueTypeDate,0
case *time.Time : idxT,idxC = idxCValueTypeDate,1
case []time.Time : idxT,idxC = idxCValueTypeDate,2
case func()time.Time : idxT,idxC = idxCValueTypeDate,3
//
//case []uint8 : idxT,idxC = idxCValueTypeBytes,0
case *[]uint8 : idxT,idxC = idxCValueTypeBytes,1
case [][]uint8 : idxT,idxC = idxCValueTypeBytes,2
case func()[]uint8 : idxT,idxC = idxCValueTypeBytes,3
case excs.Stack : idxT,idxC = idxCValueTypeStack,0
case *excs.Stack : idxT,idxC = idxCValueTypeStack,1
case []excs.Stack : idxT,idxC = idxCValueTypeStack,2
case func()excs.Stack: idxT,idxC = idxCValueTypeStack,3
case blrs.Baleable : idxT,idxC = idxCValueTypeBaleable,0
case *blrs.Baleable : idxT,idxC = idxCValueTypeBaleable,1
case []blrs.Baleable: idxT,idxC = idxCValueTypeBaleable,2
case func()blrs.Baleable : idxT,idxC = idxCValueTypeBaleable,3
case error : idxT,idxC = idxCValueTypeError,0
case *error : idxT,idxC = idxCValueTypeError,1
case []error : idxT,idxC = idxCValueTypeError,2
case func()error : idxT,idxC = idxCValueTypeError,3
*/
// --- CATEGORÍA 0: VALORES DIRECTOS (idxC = 0) ---
// Ordenados por frecuencia: string, int, bool, int64, float64, otros numéricos, tiempo, complejos, custom
case string : idxT, idxC = idxCValueTypeString, 0
case int : idxT, idxC = idxCValueTypeInt, 0
case bool : idxT, idxC = idxCValueTypeBool, 0
// []uint8 is handled explicitly as CValueTypeBytes and often passed by value.
// It's placed here as its common "value" form.
case []uint8 : idxT, idxC = idxCValueTypeBytes, 0
case int64 : idxT, idxC = idxCValueTypeInt64, 0
case float64 : idxT, idxC = idxCValueTypeFloat64, 0
case int8 : idxT, idxC = idxCValueTypeInt8, 0
case int16 : idxT, idxC = idxCValueTypeInt16, 0
case int32 : idxT, idxC = idxCValueTypeInt32, 0
case uint : idxT, idxC = idxCValueTypeUint, 0
case uint8 : idxT, idxC = idxCValueTypeUint8, 0
case uint16 : idxT, idxC = idxCValueTypeUint16, 0
case uint32 : idxT, idxC = idxCValueTypeUint32, 0
case uint64 : idxT, idxC = idxCValueTypeUint64, 0
case float32 : idxT, idxC = idxCValueTypeFloat32, 0
case time.Time : idxT, idxC = idxCValueTypeDate, 0
case time.Duration: idxT, idxC = idxCValueTypeDuration, 0
case complex64 : idxT, idxC = idxCValueTypeComplex64, 0
case complex128 : idxT, idxC = idxCValueTypeComplex128, 0
case excs.Stack : idxT, idxC = idxCValueTypeStack, 0
case blrs.Baleable: idxT, idxC = idxCValueTypeBaleable, 0
case error : idxT, idxC = idxCValueTypeError, 0
// --- CATEGORÍA 1: PUNTEROS (idxC = 1) ---
// Ordenados por frecuencia de su tipo base: *string, *int, *bool, *int64, *float64, etc.
case *string : idxT, idxC = idxCValueTypeString, 1
case *int : idxT, idxC = idxCValueTypeInt, 1
case *bool : idxT, idxC = idxCValueTypeBool, 1
case *[]uint8 : idxT, idxC = idxCValueTypeBytes, 1
case *int64 : idxT, idxC = idxCValueTypeInt64, 1
case *float64 : idxT, idxC = idxCValueTypeFloat64, 1
case *int8 : idxT, idxC = idxCValueTypeInt8, 1
case *int16 : idxT, idxC = idxCValueTypeInt16, 1
case *int32 : idxT, idxC = idxCValueTypeInt32, 1
case *uint : idxT, idxC = idxCValueTypeUint, 1
case *uint8 : idxT, idxC = idxCValueTypeUint8, 1
case *uint16 : idxT, idxC = idxCValueTypeUint16, 1
case *uint32 : idxT, idxC = idxCValueTypeUint32, 1
case *uint64 : idxT, idxC = idxCValueTypeUint64, 1
case *float32 : idxT, idxC = idxCValueTypeFloat32, 1
case *time.Time : idxT, idxC = idxCValueTypeDate, 1
case *time.Duration: idxT, idxC = idxCValueTypeDuration, 1
case *complex64 : idxT, idxC = idxCValueTypeComplex64, 1
case *complex128: idxT, idxC = idxCValueTypeComplex128, 1
case *excs.Stack: idxT, idxC = idxCValueTypeStack, 1
case *blrs.Baleable: idxT, idxC = idxCValueTypeBaleable, 1
case *error: idxT, idxC = idxCValueTypeError, 1
// --- CATEGORÍA 2: SLICES (idxC = 2) ---
// Ordenados por frecuencia de su tipo base: []string, []int, []bool, []int64, []float64, etc.
case []string : idxT, idxC = idxCValueTypeString, 2
case []int : idxT, idxC = idxCValueTypeInt, 2
case []bool : idxT, idxC = idxCValueTypeBool, 2
// Note: []uint8 handled in idxC=0 for CValueTypeBytes, if needed.
// This case [][]uint8 is for slice of slices of bytes.
case [][]uint8 : idxT, idxC = idxCValueTypeBytes, 2
case []int64 : idxT, idxC = idxCValueTypeInt64, 2
case []float64 : idxT, idxC = idxCValueTypeFloat64, 2
case []int8 : idxT, idxC = idxCValueTypeInt8, 2
case []int16 : idxT, idxC = idxCValueTypeInt16, 2
case []int32 : idxT, idxC = idxCValueTypeInt32, 2
case []uint : idxT, idxC = idxCValueTypeUint, 2
case []uint16 :
idxT, idxC = idxCValueTypeUint16, 2
case []uint32 :
idxT, idxC = idxCValueTypeUint32, 2
case []uint64 :
idxT, idxC = idxCValueTypeUint64, 2
case []float32 :
idxT, idxC = idxCValueTypeFloat32, 2
case []time.Time :
idxT, idxC = idxCValueTypeDate, 2
case []time.Duration:
idxT, idxC = idxCValueTypeDuration, 2
case []complex64 :
idxT, idxC = idxCValueTypeComplex64, 2
case []complex128 :
idxT, idxC = idxCValueTypeComplex128, 2
case []excs.Stack :
idxT, idxC = idxCValueTypeStack, 2
case []blrs.Baleable:
idxT, idxC = idxCValueTypeBaleable, 2
case []error :
idxT, idxC = idxCValueTypeError, 2
// --- CATEGORÍA 3: FUNCIONES (idxC = 3) ---
// Ordenados por frecuencia de su tipo de retorno: func()string, func()int, func()bool, etc.
case func() string :
idxT, idxC = idxCValueTypeString, 3
case func() int :
idxT, idxC = idxCValueTypeInt, 3
case func() bool :
idxT, idxC = idxCValueTypeBool, 3
case func() []uint8 : // func() []byte
idxT, idxC = idxCValueTypeBytes, 3
case func() int64 :
idxT, idxC = idxCValueTypeInt64, 3
case func() float64 :
idxT, idxC = idxCValueTypeFloat64, 3
case func() int8 :
idxT, idxC = idxCValueTypeInt8, 3
case func() int16 :
idxT, idxC = idxCValueTypeInt16, 3
case func() int32 :
idxT, idxC = idxCValueTypeInt32, 3
case func() uint :
idxT, idxC = idxCValueTypeUint, 3
case func() uint8 :
idxT, idxC = idxCValueTypeUint8, 3
case func() uint16 :
idxT, idxC = idxCValueTypeUint16, 3
case func() uint32 :
idxT, idxC = idxCValueTypeUint32, 3
case func() uint64 :
idxT, idxC = idxCValueTypeUint64, 3
case func() float32 :
idxT, idxC = idxCValueTypeFloat32, 3
case func() time.Duration:
idxT, idxC = idxCValueTypeDuration, 3
case func() time.Time :
idxT, idxC = idxCValueTypeDate, 3
case func() complex64 :
idxT, idxC = idxCValueTypeComplex64, 3
case func() complex128 :
idxT, idxC = idxCValueTypeComplex128, 3
case func() excs.Stack :
idxT, idxC = idxCValueTypeStack, 3
case func() blrs.Baleable:
idxT, idxC = idxCValueTypeBaleable, 3
case func() error :
idxT, idxC = idxCValueTypeError, 3
default:
return createCValueByReflect(value,cValueTypeCompositeMask|cValueTypeBaseMask)
}
switch idxC {
case 0: return g.cValueTypeInfos[idxT].vCreator.createCValue(value)
case 1: return g.cValueTypeInfos[idxT].pCreator.createCValue(value)
case 2: return g.cValueTypeInfos[idxT].lCreator.createCValue(value)
case 3: return g.cValueTypeInfos[idxT].fCreator.createCValue(value)
}
return createCValueInvalid(value)
}
func CreateCValueAny (value any) CValue {
if value == nil {
return CValue{mType: CValueTypeAny, mState: cValueStateNil, anyVal: value }
}
return CValue{mType: CValueTypeAny, anyVal: value }
}
func CreateCValueBool(value bool) CValue {
if !value {
return CValue{mType: CValueTypeBool, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeBool, intVal: 1}
}
func CreateCValueInt (value int) CValue {
if value == 0 {
return CValue{mType: CValueTypeInt, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeInt, intVal: int64(value)}
}
func CreateCValueInt8 (value int8) CValue {
if value == 0 {
return CValue{mType: CValueTypeInt8, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeInt8, intVal: int64(value)}
}
func CreateCValueInt16(value int16) CValue {
if value == 0 {
return CValue{mType: CValueTypeInt16, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeInt16, intVal: int64(value)}
}
func CreateCValueInt32(value int32) CValue {
if value == 0 {
return CValue{mType: CValueTypeInt32, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeInt32, intVal: int64(value)}
}
func CreateCValueInt64(value int64) CValue {
if value == 0 {
return CValue{mType: CValueTypeInt64, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeInt64, intVal: value}
}
func CreateCValueUint(value uint) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeUint, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeUint, intVal: int64(value)}
}
func CreateCValueUint8(value uint8) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeUint8, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeUint8, intVal: int64(value)}
}
func CreateCValueUint16(value uint16) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeUint16, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeUint16, intVal: int64(value)}
}
func CreateCValueUint32(value uint32) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeUint32, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeUint32, intVal: int64(value)}
}
func CreateCValueUint64(value uint64) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeUint64, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeUint64, intVal: int64(value)}
}
func CreateCValueUintptr(value uintptr) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeUintptr, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeUintptr, intVal: int64(value)}
}
func CreateCValueFloat32(value float32) CValue {
if value == 0.0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeFloat32, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeFloat32, intVal: int64(math.Float32bits(value))}
}
func CreateCValueFloat64(value float64) CValue {
if value == 0.0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeFloat64, mState: cValueStateZero, intVal: 0}
}
return CValue{mType: CValueTypeFloat64, intVal: int64(math.Float64bits(value))}
}
func CreateCValueComplex64(value complex64) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeComplex64, mState: cValueStateZero, anyVal: value}
}
return CValue{mType: CValueTypeComplex64, anyVal: value}
}
func CreateCValueComplex128(value complex128) CValue {
if value == 0 { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeComplex128, mState: cValueStateZero, anyVal: value}
}
return CValue{mType: CValueTypeComplex128, anyVal: value}
}
func CreateCValueDuration(value time.Duration) CValue {
if value == 0 {
return CValue{mType: CValueTypeDuration, mState: cValueStateZero, intVal: int64(value)}
}
return CValue{mType: CValueTypeDuration, intVal: int64(value)}
}
func CreateCValueDate(value time.Time) CValue {
var valType = CValueTypeDate // Ya sabemos que es time.Time, por defecto CValueTypeDate
if value.IsZero() { // Comprobación directa para el valor cero
return CValue{mType: valType, mState: cValueStateZero}
}
if value.After(g.minTime) && value.Before(g.maxTime) {
return CValue{mType: valType, mState: cValueStateVersion,intVal: int64(value.UnixNano()), anyVal: value.Location()}
}
return CValue{mType: valType, anyVal: value}
}
func CreateCValueString(value string) CValue {
if value == "" { // Comprobación directa para el valor cero
return CValue{mType: CValueTypeString, mState: cValueStateZero, strVal: ""}
}
return CValue{mType: CValueTypeString, strVal: value}
}
func CreateCValueBytes (value []byte) CValue {
if len(value) > 0 {
return CValue{mType: CValueTypeBytes, anyVal: value}
}
var vs CValueState
if value == nil {
vs = cValueStateNil
} else {
vs = cValueStateZero
}
return CValue{mType: CValueTypeBytes, mState: vs}
}
func CreateCValueStack(value excs.Stack) CValue {
if len(value) > 0 {
return CValue{mType: CValueTypeStack, anyVal: value}
}
var vs CValueState
if value == nil {
vs = cValueStateNil
} else {
vs = cValueStateZero
}
return CValue{mType: CValueTypeStack, mState: vs}
}
func CreateCValueBaleable(value blrs.Baleable) CValue {
if value == nil {
return CValue{mType: CValueTypeBaleable, mState: cValueStateNil}
}
return CValue{mType: CValueTypeBaleable, anyVal: value}
}
func CreateCValueError(value error) CValue {
if value == nil {
return CValue{mType: CValueTypeError, mState: cValueStateNil}
}
return CValue{mType: CValueTypeError , anyVal: value}
}
func CreateCValueNil (value any) CValue {
return CValue{mType: CValueTypeNil, mState: cValueStateNil }
}
func CreateCValueObject(value any) CValue { return createCValueByReflect(value,CValueTypeObject)}
func CreateCValueMap (value any) CValue {
return createCValueByReflect(value,CValueTypeMap)
}
func CreateCValueList(value any) CValue {
return createCValueByReflect(value,CValueTypeList)
}
func createCValueInvalid(value any) CValue {
return CValue{ mType: CValueTypeInvalid, anyVal: value }
}
func createCValueByReflect(value any, expected CValueType) CValue {
rv := reflect.ValueOf(value)
if !rv.IsValid() {
return CValue{mType: CValueTypeInvalid, mState: cValueStateError | cValueStateNil } // O createCValueInvalid(nil) si nil no es aceptable
}
tv := rv.Type()
switch rv.Kind() {
case reflect.Slice,
reflect.Array:
if !expected.IsList() {
return createCValueInvalid(value) // No es el tipo de lista esperado
}
eleType := tv.Elem()
zeroEle := reflect.Zero(eleType)
baseEleType := reflectToCValueType(zeroEle, eleType)
finalListCType := CValueTypeList | baseEleType
var vState CValueState
if rv.IsNil() { // Aunque Kind sea Slice, el slice subyacente puede ser nil
vState = cValueStateNil
return CValue{mType: finalListCType, mState: vState}
}
if rv.Len() == 0 {
vState = cValueStateZero
return CValue{mType: finalListCType, mState: vState, anyVal: value} // Guardamos el slice vacío
}
vState = cValueStateReflected
return CValue{mType: finalListCType, mState: vState, anyVal: value}
case reflect.Map:
if !expected.IsMap() {
return createCValueInvalid(value) // No es el tipo de mapa esperado
}
keyType := tv.Key()
valueType := tv.Elem()
zeroKey := reflect.Zero(keyType)
zeroValue := reflect.Zero(valueType)
mapType := buildMapType(reflectToCValueType(zeroKey, keyType), reflectToCValueType(zeroValue, valueType))
var vState CValueState
if rv.IsNil() {
vState = cValueStateNil
return CValue{mType: mapType, mState: vState}
}
if rv.Len() == 0 {
vState = cValueStateZero
return CValue{mType: mapType, mState: vState, anyVal: value}
}
vState = cValueStateReflected
return CValue{mType: mapType, mState: vState, anyVal: rv}
case reflect.Struct:
if CValueTypeObject & expected == 0 {
return createCValueInvalid(value) // No es el tipo de mapa esperado
}
return CValue{mType: CValueTypeObject, mState: cValueStateReflected, anyVal: rv}
default:
// Si el Kind no es Slice, Array, Object, o Map, y no se espera que esta función
// maneje otros tipos que no sean Slice, Array, Object y Map debera devolver CValueObjectAny
// con el estado reflejado
return CValue{ mType: CValueTypeAny, mState: cValueStateReflected,anyVal: rv}
}
}
// reflectToCValueType determina el CValueType base para un reflect.Value y reflect.Type dados.
func reflectToCValueType(rv reflect.Value, tp reflect.Type) CValueType {
// Primero, intentar identificar por el valor concreto usando un type switch.
// Esto es más eficiente para tipos conocidos que no son interfaces puras.
// rv.Interface() puede causar pánico si rv es un valor cero de un tipo no exportado
// o si rv no es válido. Asegurarse de que rv sea válido antes de llamar a Interface().
if rv.IsValid() { // Añadir chequeo de validez
switch rv.Interface().(type) {
case time.Time: return CValueTypeDate
case time.Duration: return CValueTypeDuration
case excs.Stack: return CValueTypeStack
case []byte: return CValueTypeBytes
case blrs.Baleable: return CValueTypeBaleable
case error: return CValueTypeError
}
}
if tp != nil {
typeError := reflect.TypeOf((*error)(nil)).Elem()
typeBaleable := reflect.TypeOf((*blrs.Baleable)(nil)).Elem()
if tp.Implements(typeError) {
return CValueTypeError
}
if tp.Implements(typeBaleable) {
return CValueTypeBaleable
}
// Comprobación para tipos concretos especiales por reflect.Type
if tp == reflect.TypeOf(time.Time{}) {
return CValueTypeDate
}
if tp == reflect.TypeOf(time.Duration(0)) {
return CValueTypeDuration
}
if tp == reflect.TypeOf([]byte{}) {
return CValueTypeBytes
}
if tp == reflect.TypeOf(excs.Stack{}) { // Si Stack es un tipo específico
return CValueTypeStack
}
return kindToCValueType(tp.Kind(),false)
}
return CValueTypeInvalid // Si tp es nil
}
func kindToCValueType(kind reflect.Kind, base bool) CValueType {
switch kind {
case reflect.Bool: return CValueTypeBool
case reflect.Int: return CValueTypeInt
case reflect.Int8: return CValueTypeInt8
case reflect.Int16: return CValueTypeInt16
case reflect.Int32: return CValueTypeInt32
case reflect.Int64: return CValueTypeInt64
case reflect.Uint: return CValueTypeUint
case reflect.Uint8: return CValueTypeUint8
case reflect.Uint16: return CValueTypeUint16
case reflect.Uint32: return CValueTypeUint32
case reflect.Uint64: return CValueTypeUint64
case reflect.Uintptr: return CValueTypeUintptr
case reflect.Float32: return CValueTypeFloat32
case reflect.Float64: return CValueTypeFloat64
case reflect.Complex64: return CValueTypeComplex64
case reflect.Complex128:return CValueTypeComplex128
case reflect.String: return CValueTypeString
case reflect.Array,
reflect.Slice:
if base {
return CValueTypeList
}
return CValueTypeAny
case reflect.Map:
if base {
return CValueTypeMap
}
return CValueTypeAny
case reflect.Struct:
if base {
return CValueTypeObject
}
return CValueTypeAny
default:
return CValueTypeAny
}
}

@ -44,7 +44,7 @@ func (f creatorCValueFnc[T]) createCValue(value any) CValue {
func makeFuncCreator[T any](vtype CValueType, fnc creatorCValueFnc[T]) cValueCreator {
return creatorCValueFnc[genericProvider[T]](func(caller genericProvider[T]) CValue {
if caller == nil {
return CValue{mType: vtype, mState: CValueStateNil}
return CValue{mType: vtype, mState: cValueStateNil}
}
return fnc(caller())
})
@ -55,7 +55,7 @@ func makePointerCreator[T any](vtype CValueType, fnc creatorCValueFnc[T]) cValue
if value == nil {
// Si el puntero es nil, creamos un CValue que representa un valor nil del tipo T.
// Para obtener el CValueType de T, usamos una función auxiliar.
return CValue{mType: vtype, mState: CValueStateNil}
return CValue{mType: vtype, mState: cValueStateNil}
}
// Si el puntero no es nil, lo desreferenciamos y llamamos a la función original (fnc).
@ -66,11 +66,11 @@ func makePointerCreator[T any](vtype CValueType, fnc creatorCValueFnc[T]) cValue
func makeListCreator[T any](vtype CValueType) cValueCreator {
return creatorCValueFnc[[]T](func(value []T) CValue {
if value == nil {
return CValue{mType: vtype, mState: CValueStateNil}
return CValue{mType: vtype, mState: cValueStateNil}
}
if len(value) == 0 {
return CValue{mType: vtype, mState: CValueStateZero}
return CValue{mType: vtype, mState: cValueStateZero}
}
return CValue{mType: vtype, vAny: value} // Asegúrate de usar 'anyVal' para el campo de valor
return CValue{mType: vtype, anyVal: value} // Asegúrate de usar 'anyVal' para el campo de valor
})
}

@ -29,32 +29,38 @@
package vals
const (
CValueStateInvalid CValueState = 1 << iota
CValueStateNil
CValueStateZero
cValueStateInvalid CValueState = 1 << iota
cValueStateNil
cValueStateZero
cValueStateVersion
CValueStateSensitive
CValueStateUnpackable
cValueStateSensitive
cValueStateUnpackable
cValueStateReflected
cValueStateError
CValueStateNone CValueState = 0
cValueStateNone CValueState = 0
cValueStateNilOrZero = CValueStateZero | CValueStateNil
cValueStateOptions = CValueStateSensitive | CValueStateUnpackable
cValueStateNilOrZero = cValueStateZero | cValueStateNil
cValueStateOptions = cValueStateSensitive | cValueStateUnpackable
)
type CValueState uint8
func (f CValueState) IsInvalid() bool { return f&CValueStateInvalid != 0 }
func (f CValueState) IsInvalid() bool { return f&cValueStateInvalid != 0 }
func (f CValueState) IsNil() bool { return f&CValueStateNil != 0 }
func (f CValueState) IsNil () bool { return f&cValueStateNil != 0 }
func (f CValueState) IsZero() bool { return f&CValueStateZero != 0 }
func (f CValueState) IsZero() bool { return f&cValueStateZero != 0 }
func (f CValueState) IsNilOrZero() bool { return f&cValueStateNilOrZero != 0 }
func (f CValueState) IsSensitive() bool { return f&CValueStateSensitive != 0 }
func (f CValueState) IsSensitive() bool { return f&cValueStateSensitive != 0 }
func (f CValueState) IsUnpackable() bool { return f&CValueStateUnpackable != 0 }
func (f CValueState) IsUnpackable() bool { return f&cValueStateUnpackable != 0 }
func (f CValueState) IsReflected() bool { return f&cValueStateReflected != 0 }
func (f CValueState) IsError() bool { return f&cValueStateError != 0 }
func (f CValueState) isVersion() bool { return f&cValueStateVersion != 0 }

@ -28,6 +28,8 @@
package vals
import "math/bits"
const (
maxCValueTypes int = 32
@ -71,8 +73,136 @@ const (
CValueTypeError CValueType = 1 << 23
CValueTypeNil CValueType = 1 << 24
CValueTypeMap CValueType = 1 << 30
CValueTypeObject CValueType = 1 << 28
// cValueTypeMKey
// determina si los valores del mapa representados en basetype
// son los siguientes, en caso de que el base type solo tenga
// un bit activado, y cValueTypeMKey no este activado
// indica que el tipo de la key y el tipo de los elementos
// son los mismos
// si el bit de MKey no esta activado, indica que el tipo
// de menos valor corresponde a la clave y el de mayor valor
// al tipo de los elementos
// en caso de que este activo, representaria la inversa la
// key seria el tipo de mayor valor y el tipo de los elementos
// el de menos valor
// se recomienda usar buildMapType para evitar posibles errores
//
cValueTypeMKey CValueType = 1 << 29
CValueTypeMap CValueType = 1 << 30
CValueTypeList CValueType = 1 << 31
cValueTypeCompositeMask = cValueTypeMKey | CValueTypeMap | CValueTypeList
cValueTypeBaseMask = ^cValueTypeCompositeMask
)
type CValueType uint32
func (v CValueType) IsComposite () bool { return v&cValueTypeCompositeMask != 0 }
func (v CValueType) CompositeType () CValueType { return v &cValueTypeBaseMask }
func (v CValueType) BaseType () CValueType {
bs := v & cValueTypeBaseMask
if v&CValueTypeMap == 0 {
return bs
}
nb := bits.OnesCount32(uint32(bs))
if nb == 0 || nb > 2 {
return CValueTypeInvalid
}
if nb == 1 {
return bs
}
lsb := bs & -bs
if v&cValueTypeMKey != 0 {
// clave está en MSB → valor está en LSB
return lsb
}
// clave está en LSB → valor está en MSB
return bs &^ lsb
}
func (v CValueType) KeyType () CValueType {
if v&cValueTypeCompositeMask != CValueTypeMap {
return CValueTypeInvalid
}
bs := v &cValueTypeBaseMask
nb := bits.OnesCount32(uint32(bs))
if nb == 0 || nb > 2 {
return CValueTypeInvalid
}
if nb == 1 {
return bs
}
// obtenemos el bit menos significativo para la key
// y el más significativo para el valor de los
// elementos del map
lsb := bs & -bs
if v&cValueTypeCompositeMask != cValueTypeMKey {
//si no esta activado el bit de key indica que la key
//esta representada por el bit menos significativa
return lsb
}
return bs &^ lsb
}
func (v CValueType) MapType () (CValueType, CValueType) {
if !v.IsMap() {
return CValueTypeInvalid,CValueTypeInvalid
}
bs := v &cValueTypeBaseMask
nb := bits.OnesCount32(uint32(bs))
if nb == 0 || nb > 2 {
return CValueTypeInvalid,CValueTypeInvalid
}
if nb == 1 {
return bs,bs
}
// obtenemos el bit menos significativo para la key
// y el más significativo para el valor de los
// elementos del map
lsb := bs & -bs
if v&cValueTypeCompositeMask != cValueTypeMKey {
//si no esta activado el bit de key indica que la key
//esta representada por el bit menos significativa
return lsb,bs &^ lsb
}
return bs &^ lsb, lsb
}
func (v CValueType) IsMap () bool { return v&cValueTypeCompositeMask == CValueTypeMap }
func (v CValueType) IsList () bool { return v&cValueTypeCompositeMask == CValueTypeList }
func (v CValueType) IsListOf (baseType CValueType) bool {
return v&cValueTypeCompositeMask == CValueTypeList && v&cValueTypeBaseMask == baseType
}
func (v CValueType) IsMapValueOf (baseType CValueType) bool {
_,tv := v.MapType()
return tv == baseType
}
func buildMapType (keyType, valueType CValueType) CValueType {
if keyType == CValueTypeInvalid || valueType == CValueTypeInvalid {
return CValueTypeInvalid
}
if keyType == valueType {
return keyType|CValueTypeMap
}
if keyType < valueType {
return keyType|valueType|CValueTypeMap
}
return keyType|valueType|CValueTypeMap| cValueTypeMKey
}

@ -30,6 +30,7 @@ package vals
import (
"core/blrs"
"core/excs"
"time"
)
@ -72,7 +73,8 @@ const (
idxCValueTypeNil
_
_
_
idxCValueTypeObject
_
idxCValueTypeMap
idxCValueTypeList
@ -115,8 +117,10 @@ func createCValueTypeInfos() [maxCValueTypes]cValueTypeInfo {
/* 7 CValueTypeInt64 */ createCValueTypeInfo[int64](CValueTypeInt64, "int64", CreateCValueInt64),
/* 8 CValueTypeUint */ createCValueTypeInfo[uint](CValueTypeUint, "uint", CreateCValueUint),
/* 9 CValueTypeUint8 */ createCValueTypeInfo[uint8](CValueTypeUint8, "uint8", CreateCValueUint8),
/* 10 CValueTypeUint16 */ createCValueTypeInfo[uint16](CValueTypeUint8, "uint16", CreateCValueUint16),
/* -- Exception
/* 9 CValueTypeUint8 createCValueTypeInfo[uint8](CValueTypeUint8, "uint8", CreateCValueUint8), */
/* --
/* 10 CValueTypeUint16 */ createCValueTypeInfo[uint16](CValueTypeUint16, "uint16", CreateCValueUint16),
/* 11 CValueTypeUint32 */ createCValueTypeInfo[uint32](CValueTypeUint32, "uint32", CreateCValueUint32),
/* 12 CValueTypeUint64 */ createCValueTypeInfo[uint64](CValueTypeUint64, "uint64", CreateCValueUint64),
@ -133,7 +137,7 @@ func createCValueTypeInfos() [maxCValueTypes]cValueTypeInfo {
/* 20 CValueTypeString */ createCValueTypeInfo[string](CValueTypeString, "string", CreateCValueString),
/* 21 CValueTypeBytes */ createCValueTypeInfo[[]uint8](CValueTypeBytes, "bytes", CreateCValueBytes),
/* 22 CValueTypeStack */ createCValueTypeInfo[[]string](CValueTypeStack, "stack", CreateCValueStack),
/* 22 CValueTypeStack */ createCValueTypeInfo[excs.Stack](CValueTypeStack, "stack", CreateCValueStack),
/* 23 CValueTypePackable*/ createCValueTypeInfo[blrs.Baleable](CValueTypeBaleable, "packable", CreateCValueBaleable),
/* 24 CValueTypeError */ createCValueTypeInfo[error](CValueTypeError, "error", CreateCValueError),
@ -141,15 +145,25 @@ func createCValueTypeInfos() [maxCValueTypes]cValueTypeInfo {
/* 25 CValueTypeInvalid */ createCValueTypeInfo[any](CValueTypeInvalid, "invalid", createCValueInvalid),
/* 26 CValueTypeInvalid */ createCValueTypeInfo[any](CValueTypeInvalid, "invalid", createCValueInvalid),
/* 27 CValueTypeInvalid */ createCValueTypeInfo[any](CValueTypeInvalid, "invalid", createCValueInvalid),
/* 28 CValueTypeInvalid */ createCValueTypeInfo[any](CValueTypeInvalid, "invalid", createCValueInvalid),
/* 29 CValueTypeInvalid */ createCValueTypeInfo[any](CValueTypeInvalid, "invalid", createCValueInvalid),
/* 28 CValueTypeObject */ createCValueTypeInfo[any](CValueTypeObject, "object", CreateCValueObject),
// Reservad for map key
/* 29 CValueTypeMKey */ createCValueTypeInfo[any](CValueTypeInvalid, "invalid", createCValueInvalid),
/* 30 CValueTypeMap */ createCValueTypeInfo[any](CValueTypeMap, "map", CreateCValueMap),
/* 31 CValueTypeList */ createCValueTypeInfo[any](CValueTypeList, "list", CreateCValueList),
}
// excepcion de []uint8 debe de ser tratado como bytes
types[idxCValueTypeUint8].lCreator = creatorCValueFnc[[]uint8](CreateCValueBytes)
// exception de []uint8 debe de ser tratado como bytes
types[idxCValueTypeUint8] = cValueTypeInfo{
vType: CValueTypeUint8,
name: "uint8",
vCreator: creatorCValueFnc[uint8](CreateCValueUint8),
lCreator: creatorCValueFnc[[]uint8](CreateCValueBytes),
fCreator: makeFuncCreator[uint8](CValueTypeUint8, CreateCValueUint8),
pCreator: makePointerCreator[uint8](CValueTypeUint8, CreateCValueUint8),
}
return types
}

Loading…
Cancel
Save

Powered by TurnKey Linux.