feat: Implement core CValue type system

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

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="project">
<words>
<w>vtype</w>
</words>
</dictionary>
</component>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/GO·AT.iml" filepath="$PROJECT_DIR$/.idea/GO·AT.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -0,0 +1,33 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package blrs
type Baleable interface {
Bale(baler Baler) error
}

@ -0,0 +1,35 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package blrs
type Baler interface {
Map(mapBaler MapBaler) error
List(listBaler ListBaler) error
Object(objBaler ObjectBaler) error
}

@ -0,0 +1,33 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package blrs
type ListBaler interface {
Add() Baler
}

@ -0,0 +1,33 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package blrs
type MapBaler interface {
Key(key any) Baler
}

@ -0,0 +1,33 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package blrs
type ObjectBaler interface {
Field(name string) Baler
}

@ -0,0 +1,3 @@
module core
go 1.24

@ -0,0 +1,84 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package vals
import (
"core/blrs"
"time"
)
type (
CValue struct {
mType CValueType
mState CValueState
vInt int64
vStr string
vAny any
}
)
func CreateCValueAny(value any) CValue { return CValue{} }
func CreateCValueBool(value bool) CValue { return CValue{} }
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{} }
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{} }
func CreateCValueUintptr(value uintptr) CValue { return CValue{} }
func CreateCValueFloat32(value float32) CValue { return CValue{} }
func CreateCValueFloat64(value float64) CValue { return CValue{} }
func CreateCValueComplex64(value complex64) CValue { return CValue{} }
func CreateCValueComplex128(value complex128) CValue { return CValue{} }
func CreateCValueDuration(value time.Duration) CValue { return CValue{} }
func CreateCValueDate(value time.Time) CValue { return CValue{} }
func CreateCValueString(value string) CValue { return CValue{} }
func CreateCValueBytes(value []byte) CValue { return CValue{} }
func CreateCValueStack(value []string) CValue { return CValue{} }
func CreateCValueBaleable(value blrs.Baleable) CValue { return CValue{} }
func CreateCValueError(value error) CValue { return CValue{} }
func CreateCValueNil(value any) CValue { return CValue{} }
func CreateCValueMap(value any) CValue { return CValue{} }
func CreateCValueList(value any) CValue { return CValue{} }
func createCValueInvalid(value any) CValue { return CValue{} }

@ -0,0 +1,76 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package vals
type (
cValueCreator interface {
createCValue(value any) CValue
}
creatorCValueFnc[T any] func(T) CValue
genericProvider[T any] func() T
)
func (f creatorCValueFnc[T]) createCValue(value any) CValue {
return f(value.(T))
}
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 fnc(caller())
})
}
func makePointerCreator[T any](vtype CValueType, fnc creatorCValueFnc[T]) cValueCreator {
return creatorCValueFnc[*T](func(value *T) CValue { // La entrada es explícitamente *T
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}
}
// Si el puntero no es nil, lo desreferenciamos y llamamos a la función original (fnc).
return fnc(*value)
})
}
func makeListCreator[T any](vtype CValueType) cValueCreator {
return creatorCValueFnc[[]T](func(value []T) CValue {
if value == nil {
return CValue{mType: vtype, mState: CValueStateNil}
}
if len(value) == 0 {
return CValue{mType: vtype, mState: CValueStateZero}
}
return CValue{mType: vtype, vAny: value} // Asegúrate de usar 'anyVal' para el campo de valor
})
}

@ -0,0 +1,63 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package vals
const (
CValueStateInvalid CValueState = 1 << iota
CValueStateNil
CValueStateZero
cValueStateVersion
CValueStateSensitive
CValueStateUnpackable
CValueStateNone CValueState = 0
cValueStateNilOrZero = CValueStateZero | CValueStateNil
cValueStateOptions = CValueStateSensitive | CValueStateUnpackable
)
type CValueState uint8
func (f CValueState) IsInvalid() bool { return f&CValueStateInvalid != 0 }
func (f CValueState) IsNil() bool { return f&CValueStateNil != 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) IsUnpackable() bool { return f&CValueStateUnpackable != 0 }
func (f CValueState) isVersion() bool { return f&cValueStateVersion != 0 }
func (f CValueState) setOption(option CValueState) CValueState {
return f | (cValueStateOptions & option)
}

@ -0,0 +1,78 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package vals
const (
maxCValueTypes int = 32
// Tipos definidos de CValue
CValueTypeInvalid CValueType = 0
CValueTypeAny CValueType = 1 << 0
CValueTypeBool CValueType = 1 << 1
CValueTypeInt CValueType = 1 << 2
CValueTypeInt8 CValueType = 1 << 3
CValueTypeInt16 CValueType = 1 << 4
CValueTypeInt32 CValueType = 1 << 5
CValueTypeInt64 CValueType = 1 << 6
CValueTypeUint CValueType = 1 << 7
CValueTypeUint8 CValueType = 1 << 8
CValueTypeUint16 CValueType = 1 << 9
CValueTypeUint32 CValueType = 1 << 10
CValueTypeUint64 CValueType = 1 << 11
CValueTypeUintptr CValueType = 1 << 12
CValueTypeFloat32 CValueType = 1 << 13
CValueTypeFloat64 CValueType = 1 << 14
CValueTypeComplex64 CValueType = 1 << 15
CValueTypeComplex128 CValueType = 1 << 16
CValueTypeDuration CValueType = 1 << 17
CValueTypeDate CValueType = 1 << 18
CValueTypeString CValueType = 1 << 19
CValueTypeBytes CValueType = 1 << 20
CValueTypeStack CValueType = 1 << 21
CValueTypeBaleable CValueType = 1 << 22
CValueTypeError CValueType = 1 << 23
CValueTypeNil CValueType = 1 << 24
CValueTypeMap CValueType = 1 << 30
CValueTypeList CValueType = 1 << 31
)
type CValueType uint32

@ -0,0 +1,155 @@
// =============================================================================
// 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 28/05/2025
// =============================================================================
package vals
import (
"core/blrs"
"time"
)
const (
idxCValueTypeInvalid = iota
idxCValueTypeAny
idxCValueTypeBool
idxCValueTypeInt
idxCValueTypeInt8
idxCValueTypeInt16
idxCValueTypeInt32
idxCValueTypeInt64
idxCValueTypeUint
idxCValueTypeUint8
idxCValueTypeUint16
idxCValueTypeUint32
idxCValueTypeUint64
idxCValueTypeUintptr
idxCValueTypeFloat32
idxCValueTypeFloat64
idxCValueTypeComplex64
idxCValueTypeComplex128
idxCValueTypeDuration
idxCValueTypeDate
idxCValueTypeString
idxCValueTypeBytes
idxCValueTypeStack
idxCValueTypeBaleable
idxCValueTypeError
idxCValueTypeNil
_
_
_
_
idxCValueTypeMap
idxCValueTypeList
)
type (
cValueTypeInfo struct {
vType CValueType
name string
vCreator,
lCreator,
pCreator,
fCreator cValueCreator
}
)
func createCValueTypeInfo[T any](vtype CValueType, name string, creatorFnc creatorCValueFnc[T]) cValueTypeInfo {
return cValueTypeInfo{
vType: vtype,
name: name,
vCreator: creatorFnc,
lCreator: makeListCreator[T](vtype | CValueTypeList),
fCreator: makeFuncCreator[T](vtype, creatorFnc),
pCreator: makePointerCreator[T](vtype, creatorFnc),
}
}
func createCValueTypeInfos() [maxCValueTypes]cValueTypeInfo {
types := [maxCValueTypes]cValueTypeInfo{
/* 1 CValueTypeAny */ createCValueTypeInfo[any](CValueTypeAny, "any", CreateCValueAny),
/* 2 CValueTypeBool */ createCValueTypeInfo[bool](CValueTypeBool, "bool", CreateCValueBool),
/* 3 CValueTypeInt */ createCValueTypeInfo[int](CValueTypeInt, "int", CreateCValueInt),
/* 4 CValueTypeInt8 */ createCValueTypeInfo[int8](CValueTypeInt8, "int8", CreateCValueInt8),
/* 5 CValueTypeInt16 */ createCValueTypeInfo[int16](CValueTypeInt16, "int16", CreateCValueInt16),
/* 6 CValueTypeInt32 */ createCValueTypeInfo[int32](CValueTypeInt32, "int32", CreateCValueInt32),
/* 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),
/* 11 CValueTypeUint32 */ createCValueTypeInfo[uint32](CValueTypeUint32, "uint32", CreateCValueUint32),
/* 12 CValueTypeUint64 */ createCValueTypeInfo[uint64](CValueTypeUint64, "uint64", CreateCValueUint64),
/* 13 CValueTypeUintptr */ createCValueTypeInfo[uintptr](CValueTypeUintptr, "uintptr", CreateCValueUintptr),
/* 14 CValueTypeFloat32 */ createCValueTypeInfo[float32](CValueTypeFloat32, "float32", CreateCValueFloat32),
/* 15 CValueTypeFloat64 */ createCValueTypeInfo[float64](CValueTypeFloat64, "float64", CreateCValueFloat64),
/* 16 CValueTypeComplex64 */ createCValueTypeInfo[complex64](CValueTypeComplex64, "complex64", CreateCValueComplex64),
/* 17 CValueTypeComplex128*/ createCValueTypeInfo[complex128](CValueTypeComplex128, "complex128", CreateCValueComplex128),
/* 18 CValueTypeDuration*/ createCValueTypeInfo[time.Duration](CValueTypeDuration, "duration", CreateCValueDuration),
/* 19 CValueTypeDate */ createCValueTypeInfo[time.Time](CValueTypeDate, "date", CreateCValueDate),
/* 20 CValueTypeString */ createCValueTypeInfo[string](CValueTypeString, "string", CreateCValueString),
/* 21 CValueTypeBytes */ createCValueTypeInfo[[]uint8](CValueTypeBytes, "bytes", CreateCValueBytes),
/* 22 CValueTypeStack */ createCValueTypeInfo[[]string](CValueTypeStack, "stack", CreateCValueStack),
/* 23 CValueTypePackable*/ createCValueTypeInfo[blrs.Baleable](CValueTypeBaleable, "packable", CreateCValueBaleable),
/* 24 CValueTypeError */ createCValueTypeInfo[error](CValueTypeError, "error", CreateCValueError),
/* 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),
/* 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)
return types
}

@ -0,0 +1,3 @@
go 1.24
use core
Loading…
Cancel
Save

Powered by TurnKey Linux.