parent
53d28a0f13
commit
408753bc9f
@ -0,0 +1,34 @@
|
||||
// =============================================================================
|
||||
// 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 04/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cfls
|
||||
|
||||
|
||||
|
||||
|
||||
type CFields = map[string]CVal
|
||||
@ -0,0 +1,200 @@
|
||||
// =============================================================================
|
||||
// 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.
|
||||
// /
|
||||
// ============================================================================
|
||||
// ate Create 03/06/2025
|
||||
// ============================================================================
|
||||
|
||||
package cfls
|
||||
|
||||
import (
|
||||
"core/blrs"
|
||||
"core/excs"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type cValTypeCacheEntry struct {
|
||||
t CValType
|
||||
i int
|
||||
c int
|
||||
}
|
||||
|
||||
func makeCacheCValTypes () map[reflect.Type]cValTypeCacheEntry {
|
||||
return map[reflect.Type]cValTypeCacheEntry {
|
||||
// Any
|
||||
reflect.TypeOf(any(nil)): {i: 1, t: CValTypeAny, c: 0},
|
||||
reflect.TypeOf((*any)(nil)): {i: 1, t: CValTypeAny, c: 1},
|
||||
reflect.TypeOf([]any(nil)): {i: 1, t: CValTypeAny|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func()any)(nil)).Elem(): {i: 1, t: CValTypeAny|CValTypeDefer, c: 3},
|
||||
|
||||
// Bool
|
||||
reflect.TypeOf(true): {i: 2, t: CValTypeBool, c: 0},
|
||||
reflect.TypeOf(new(bool)): {i: 2, t: CValTypeBool, c: 1},
|
||||
reflect.TypeOf([]bool(nil)): {i: 2, t: CValTypeBool|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() bool)(nil)).Elem(): {i: 2, t: CValTypeBool|CValTypeDefer, c: 3},
|
||||
|
||||
// Int
|
||||
reflect.TypeOf(int(0)): {i: 3, t: CValTypeInt, c: 0},
|
||||
reflect.TypeOf(new(int)): {i: 3, t: CValTypeInt, c: 1},
|
||||
reflect.TypeOf([]int(nil)): {i: 3, t: CValTypeInt|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() int)(nil)).Elem(): {i: 3, t: CValTypeInt|CValTypeDefer, c: 3},
|
||||
|
||||
// Int8
|
||||
reflect.TypeOf(int8(0)): {i: 4, t: CValTypeInt8, c: 0},
|
||||
reflect.TypeOf(new(int8)): {i: 4, t: CValTypeInt8, c: 1},
|
||||
reflect.TypeOf([]int8(nil)): {i: 4, t: CValTypeInt8|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() int8)(nil)).Elem(): {i: 4, t: CValTypeInt8|CValTypeDefer, c: 3},
|
||||
|
||||
// Int16
|
||||
reflect.TypeOf(int16(0)): {i: 5, t: CValTypeInt16, c: 0},
|
||||
reflect.TypeOf(new(int16)): {i: 5, t: CValTypeInt16, c: 1},
|
||||
reflect.TypeOf([]int16(nil)): {i: 5, t: CValTypeInt16|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() int16)(nil)).Elem(): {i: 5, t: CValTypeInt16|CValTypeDefer, c: 3},
|
||||
|
||||
// Int32
|
||||
reflect.TypeOf(int32(0)): {i: 6, t: CValTypeInt32, c: 0},
|
||||
reflect.TypeOf(new(int32)): {i: 6, t: CValTypeInt32, c: 1},
|
||||
reflect.TypeOf([]int32(nil)): {i: 6, t: CValTypeInt32|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() int32)(nil)).Elem(): {i: 6, t: CValTypeInt32|CValTypeDefer, c: 3},
|
||||
|
||||
// Int64
|
||||
reflect.TypeOf(int64(0)): {i: 7, t: CValTypeInt64, c: 0},
|
||||
reflect.TypeOf(new(int64)): {i: 7, t: CValTypeInt64, c: 1},
|
||||
reflect.TypeOf([]int64(nil)): {i: 7, t: CValTypeInt64|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() int64)(nil)).Elem(): {i: 7, t: CValTypeInt64|CValTypeDefer, c: 3},
|
||||
|
||||
// Uint
|
||||
reflect.TypeOf(uint(0)): {i: 8, t: CValTypeUint, c: 0},
|
||||
reflect.TypeOf(new(uint)): {i: 8, t: CValTypeUint, c: 1},
|
||||
reflect.TypeOf([]uint(nil)): {i: 8, t: CValTypeUint|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() uint )(nil)).Elem(): {i: 8, t: CValTypeUint|CValTypeDefer, c: 3},
|
||||
|
||||
// Uint8
|
||||
// Corregimos para que []uint8 sea bytes, un tipo basico
|
||||
reflect.TypeOf(uint8(0)): {i: 9, t: CValTypeUint8, c: 0},
|
||||
reflect.TypeOf(new(uint8)): {i: 9, t: CValTypeUint8, c: 1},
|
||||
reflect.TypeOf([]uint8(nil)): {i:21, t: CValTypeUint8, c: 0},
|
||||
reflect.TypeOf((*func() uint8 )(nil)).Elem(): {i: 9, t: CValTypeUint8|CValTypeDefer, c: 3},
|
||||
|
||||
// Uint16
|
||||
reflect.TypeOf(uint16(0)): {i: 10, t: CValTypeUint16, c: 0},
|
||||
reflect.TypeOf(new(uint16)): {i: 10, t: CValTypeUint16, c: 1},
|
||||
reflect.TypeOf([]uint16(nil)): {i: 10, t: CValTypeUint16|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() uint16 )(nil)).Elem():{i: 10, t: CValTypeUint16|CValTypeDefer, c: 3},
|
||||
|
||||
// Uint32
|
||||
reflect.TypeOf(uint32(0)): {i: 11, t: CValTypeUint32, c: 0},
|
||||
reflect.TypeOf(new(uint32)): {i: 11, t: CValTypeUint32, c: 1},
|
||||
reflect.TypeOf([]uint32(nil)): {i: 11, t: CValTypeUint32|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() uint32 )(nil)).Elem():{i: 11, t: CValTypeUint32|CValTypeDefer, c: 3},
|
||||
|
||||
// Uint64
|
||||
reflect.TypeOf(uint64(0)): {i: 12, t: CValTypeUint64, c: 0},
|
||||
reflect.TypeOf(new(uint64)): {i: 12, t: CValTypeUint64, c: 1},
|
||||
reflect.TypeOf([]uint64(nil)): {i: 12, t: CValTypeUint64|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() uint64 )(nil)).Elem():{i: 12, t: CValTypeUint64|CValTypeDefer, c: 3},
|
||||
|
||||
// Uintptr
|
||||
reflect.TypeOf(uintptr(0)): {i: 13, t: CValTypeUintptr, c: 0},
|
||||
reflect.TypeOf(new(uintptr)): {i: 13, t: CValTypeUintptr, c: 1},
|
||||
reflect.TypeOf([]uintptr(nil)): {i: 13, t: CValTypeUintptr|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() uintptr)(nil)).Elem():{i: 13, t: CValTypeUintptr|CValTypeDefer, c: 3},
|
||||
|
||||
// Float32
|
||||
reflect.TypeOf(float32(0)): {i: 14, t: CValTypeFloat32, c: 0},
|
||||
reflect.TypeOf(new(float32)): {i: 14, t: CValTypeFloat32, c: 1},
|
||||
reflect.TypeOf([]float32(nil)): {i: 14, t: CValTypeFloat32|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() float32)(nil)).Elem():{i: 14, t: CValTypeFloat32|CValTypeDefer, c: 3},
|
||||
|
||||
// Float64
|
||||
reflect.TypeOf(float64(0)): {i: 15, t: CValTypeFloat64, c: 0},
|
||||
reflect.TypeOf(new(float64)): {i: 15, t: CValTypeFloat64, c: 1},
|
||||
reflect.TypeOf([]float64(nil)): {i: 15, t: CValTypeFloat64|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func() float64)(nil)).Elem():{i: 15, t: CValTypeFloat64|CValTypeDefer, c: 3},
|
||||
|
||||
// Complex64
|
||||
reflect.TypeOf(complex64(0)): {i: 16, t: CValTypeComplex64, c: 0},
|
||||
reflect.TypeOf(new(complex64)): {i: 16, t: CValTypeComplex64, c: 1},
|
||||
reflect.TypeOf([]complex64(nil)): {i: 16, t: CValTypeComplex64|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func()complex64)(nil)).Elem():{i: 16, t: CValTypeComplex64|CValTypeDefer, c: 3},
|
||||
|
||||
// Complex128
|
||||
reflect.TypeOf(complex128(0)): {i: 17, t: CValTypeComplex128, c: 0},
|
||||
reflect.TypeOf(new(complex128)): {i: 17, t: CValTypeComplex128, c: 1},
|
||||
reflect.TypeOf([]complex128(nil)): {i: 17, t: CValTypeComplex128|CValTypeList , c: 2},
|
||||
reflect.TypeOf((*func()complex128)(nil)).Elem():{i: 17, t: CValTypeComplex128|CValTypeDefer, c: 3},
|
||||
|
||||
/* time's */
|
||||
|
||||
reflect.TypeOf(time.Duration(0)): { i: 18, t:CValTypeDuration, c:0 },
|
||||
reflect.TypeOf(new(time.Duration)): { i: 18, t:CValTypeDuration, c:1 },
|
||||
reflect.TypeOf([]time.Duration(nil)): { i: 18, t:CValTypeDuration, c:2 },
|
||||
reflect.TypeOf((*func ()time.Duration)(nil)).Elem():{ i : 18, t:CValTypeDuration, c:3 },
|
||||
|
||||
reflect.TypeOf(time.Time{}): { i: 19, t:CValTypeDate, c:0 },
|
||||
reflect.TypeOf(new (time.Time)): { i: 19, t:CValTypeDate, c:1 },
|
||||
reflect.TypeOf([]time.Time(nil)): { i: 19, t:CValTypeDate, c:2 },
|
||||
reflect.TypeOf((*func ()time.Time)(nil)).Elem():{ i: 19, t:CValTypeDate, c:3 },
|
||||
|
||||
/* Strings, Bytes, Stack */
|
||||
reflect.TypeOf(""): { i: 20, t:CValTypeString, c:0 },
|
||||
reflect.TypeOf(new (string)): { i: 20, t:CValTypeString, c:1 },
|
||||
reflect.TypeOf([]string(nil)): { i: 20, t:CValTypeString, c:2 },
|
||||
reflect.TypeOf((*func ()string)(nil)).Elem(): { i: 20, t:CValTypeString, c:3 },
|
||||
|
||||
reflect.TypeOf([]uint8(nil)): { i: 21, t:CValTypeBytes, c:0 },
|
||||
reflect.TypeOf((*[]uint8)(nil)): { i: 21, t:CValTypeBytes, c:1 },
|
||||
reflect.TypeOf([][]uint8(nil)): { i: 21, t:CValTypeBytes, c:2 },
|
||||
reflect.TypeOf((*func ()[]uint8)(nil)).Elem(): { i: 21, t:CValTypeBytes, c:3 },
|
||||
|
||||
reflect.TypeOf(excs.Stack(nil)): { i: 22, t:CValTypeStack, c:0 },
|
||||
reflect.TypeOf((*excs.Stack)(nil)): { i: 22, t:CValTypeStack, c:1 },
|
||||
reflect.TypeOf([]excs.Stack(nil)): { i: 22, t:CValTypeStack, c:2 },
|
||||
reflect.TypeOf((*func ()excs.Stack)(nil)).Elem():{i: 22, t:CValTypeStack, c:3 },
|
||||
|
||||
reflect.TypeOf(blrs.Baleable(nil)): { i: 23, t:CValTypeBaleable, c:0 },
|
||||
reflect.TypeOf((*blrs.Baleable)(nil)): { i: 23, t:CValTypeBaleable, c:1 },
|
||||
reflect.TypeOf([]blrs.Baleable(nil)): { i: 23, t:CValTypeBaleable, c:2 },
|
||||
reflect.TypeOf((*func ()blrs.Baleable)(nil)).Elem(): { i : 23 , t:CValTypeBaleable, c:3 },
|
||||
|
||||
|
||||
reflect.TypeOf(error(nil)): { i: 24, t:CValTypeError, c:0 },
|
||||
reflect.TypeOf((*error)(nil)): { i: 24, t:CValTypeError, c:1 },
|
||||
reflect.TypeOf([]error(nil)): { i: 24, t:CValTypeError, c:2 },
|
||||
reflect.TypeOf((*func ()error)(nil)).Elem():{ i: 24, t:CValTypeError, c:3 },
|
||||
|
||||
reflect.TypeOf(CVal{}): { i: 26, t:CValTypeCVal, c:0 },
|
||||
reflect.TypeOf((*CVal)(nil)): { i: 26, t:CValTypeCVal, c:1 },
|
||||
reflect.TypeOf([]CVal(nil)): { i: 26, t:CValTypeCVal, c:2 },
|
||||
reflect.TypeOf((*func ()CVal)(nil)): { i: 26, t:CValTypeCVal, c:3 },
|
||||
|
||||
|
||||
reflect.TypeOf(map[string]CVal(nil)): { i: 27, t:CValTypeCVal, c:0 },
|
||||
reflect.TypeOf((*CVal)(nil)): { i: 27, t:CValTypeCVal, c:1 },
|
||||
reflect.TypeOf([]CVal(nil)): { i: 27, t:CValTypeCVal, c:2 },
|
||||
reflect.TypeOf((*func ()CVal)(nil)).Elem(): { i: 27 , t:CValTypeCVal, c:3 },
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,311 @@
|
||||
// =============================================================================
|
||||
// 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 04/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cfls
|
||||
|
||||
import (
|
||||
"core/blrs"
|
||||
"core/excs"
|
||||
"math/bits"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
const(
|
||||
cvalCreatorByValue = iota
|
||||
cvalCreatorByPointer
|
||||
cvalCreatorByList
|
||||
cvalCreatorByDefer
|
||||
|
||||
cValNumCreators = 4
|
||||
)
|
||||
|
||||
|
||||
type (
|
||||
|
||||
cValTypeInfos struct {
|
||||
names [maxCValTypes+1]string
|
||||
creators [maxCValTypes+1][cValNumCreators]func(any)CVal
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func createCValTypeInfos () cValTypeInfos {
|
||||
is := cValTypeInfos{
|
||||
names: [maxCValTypes+1]string{
|
||||
/* 0: */ "invalid",
|
||||
/* 1: */ "any",
|
||||
/* 2: */ "bool",
|
||||
/* 3: */ "int",
|
||||
/* 4: */ "int8",
|
||||
/* 5: */ "int16",
|
||||
/* 6: */ "int32",
|
||||
/* 7: */ "int64",
|
||||
/* 8: */ "uint",
|
||||
/* 9: */ "uint8",
|
||||
/* 10: */ "uint16",
|
||||
/* 11: */ "uint32",
|
||||
/* 12: */ "uint64",
|
||||
/* 13: */ "uintptr",
|
||||
/* 14: */ "float32",
|
||||
/* 15: */ "float64",
|
||||
/* 16: */ "complex64",
|
||||
/* 17: */ "complex128",
|
||||
/* 18: */ "duration",
|
||||
/* 19: */ "date",
|
||||
/* 20: */ "string",
|
||||
/* 21: */ "bytes",
|
||||
/* 22: */ "stack",
|
||||
/* 23: */ "baleable",
|
||||
/* 24: */ "error",
|
||||
/* 25: */ "nil",
|
||||
/* 26: */ "cval",
|
||||
/* 27: */ "fields",
|
||||
/* 28: */ "object",
|
||||
/* 29: */ "defer",
|
||||
/* 30: */ "list",
|
||||
/* 31: */ "map",
|
||||
/* 32: */ "flag",
|
||||
},
|
||||
creators: [maxCValTypes+1][cValNumCreators]func(any)CVal{
|
||||
/* 0: */ createGValCreators[any ](CValTypeInvalid, createCValInvalid),
|
||||
/* 1: */ createGValCreators[any ](CValTypeAny, CreateCValAny),
|
||||
/* 2: */ createGValCreators[bool ](CValTypeBool, CreateCValBool),
|
||||
/* 3: */ createGValCreators[int ](CValTypeInt, CreateCValInt),
|
||||
/* 4: */ createGValCreators[int8 ](CValTypeInt8, CreateCValInt8),
|
||||
/* 5: */ createGValCreators[int16 ](CValTypeInt16, CreateCValInt16),
|
||||
/* 6: */ createGValCreators[int32 ](CValTypeInt32, CreateCValInt32),
|
||||
/* 7: */ createGValCreators[int64 ](CValTypeInt64, CreateCValInt64),
|
||||
/* 8: */ createGValCreators[uint ](CValTypeUint, CreateCValUint),
|
||||
/*
|
||||
caso en el que []uint debe de establecerse como bytes procedemos a construirlo manualmente
|
||||
*/
|
||||
/* 9 :*/ {
|
||||
func(v any) CVal { return CreateCValUint8 (v.(uint8)) },
|
||||
func(v any) CVal { return createGValTypePointer (CValTypeUint8, CreateCValUint8, v.(*uint8)) },
|
||||
func(v any) CVal { return createGValTypeList (CValTypeBytes, v.([]uint8)) },
|
||||
func(v any) CVal { return createGValTypeDefer (CValTypeDefer|CValTypeUint8, v.(func() uint8))},
|
||||
},
|
||||
|
||||
/* 10:*/ createGValCreators[uint16 ](CValTypeUint16, CreateCValUint16),
|
||||
/* 11:*/ createGValCreators[uint32 ](CValTypeUint32, CreateCValUint32),
|
||||
/* 12:*/ createGValCreators[uint64 ](CValTypeUint64, CreateCValUint64),
|
||||
/* 13:*/ createGValCreators[uintptr ](CValTypeUintptr, CreateCValUintptr),
|
||||
|
||||
/* 14:*/ createGValCreators[float32 ](CValTypeFloat32, CreateCValFloat32),
|
||||
/* 15:*/ createGValCreators[float64 ](CValTypeFloat64, CreateCValFloat64),
|
||||
/* 16:*/ createGValCreators[complex64 ](CValTypeComplex64,CreateCValComplex64),
|
||||
/* 17:*/ createGValCreators[complex128 ](CValTypeComplex128,CreateCValComplex128),
|
||||
|
||||
/* 18:*/ createGValCreators[time.Duration](CValTypeDuration,CreateCValDuration),
|
||||
/* 19:*/ createGValCreators[time.Time ](CValTypeDate, CreateCValDate),
|
||||
|
||||
/* 20:*/ createGValCreators[string ](CValTypeString, CreateCValString),
|
||||
/* 21:*/ createGValCreators[[]uint8 ](CValTypeBytes, CreateCValBytes),
|
||||
/* 22:*/ createGValCreators[excs.Stack ](CValTypeStack, CreateCValStack),
|
||||
/* 23:*/ createGValCreators[blrs.Baleable](CValTypeBaleable,CreateCValBaleable),
|
||||
/* 24:*/ createGValCreators[error ](CValTypeError, CreateCValError),
|
||||
/* 25:*/ createGValCreators[any ](CValTypeNil, CreateCValNil),
|
||||
/* 26:*/ createGValCreators[CVal ](CValTypeCVal, CreateCValCVal),
|
||||
/* 27:*/ createGValCreators[any ](CValTypeCFields, CreateCValFields),
|
||||
/* 28:*/ createGValCreators[any ](CValTypeObject, CreateCValObject),
|
||||
/* 29:*/ createGValCreators[any ](CValTypeDefer, CreateCValDefer),
|
||||
/* 30:*/ createGValCreators[any ](CValTypeList, CreateCValList),
|
||||
/* 31:*/ createGValCreators[any ](CValTypeMap, CreateCValMap),
|
||||
/* 32:*/ createGValCreators[any ](CValTypeObject, createCValInvalid),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
return is
|
||||
}
|
||||
|
||||
func (i cValTypeInfos) getCValTypeName (cvalType CValType) string {
|
||||
if cvalType.IsComposite() {
|
||||
if cvalType.IsDefer () {
|
||||
return "defer|" + cvalType.BaseType().String()
|
||||
}
|
||||
if cvalType.IsList () {
|
||||
return "list|" + cvalType.BaseType().String()
|
||||
}
|
||||
if cvalType.IsFields() {
|
||||
return "fields|"+ cvalType.BaseType().String()
|
||||
}
|
||||
if cvalType.IsMap () {
|
||||
k, v := cvalType.MapType()
|
||||
return "map@" + k.String() + "|" + v.String()
|
||||
}
|
||||
}
|
||||
return i.names[i.getCValTypeIndex(cvalType)]
|
||||
}
|
||||
|
||||
|
||||
func (_ cValTypeInfos) getCValTypeIndex(cvalType CValType) int {
|
||||
if cvalType == 0 {
|
||||
return 0
|
||||
}
|
||||
return bits.TrailingZeros32(uint32(cvalType))+1
|
||||
}
|
||||
|
||||
func (i cValTypeInfos) getCreator (value any) (f func(v any) CVal) {
|
||||
switch value.(type) {
|
||||
/* Valores simples */
|
||||
case any : f = i.creators[ 1/* CValTypeAny.Index() */][cvalCreatorByValue]
|
||||
case bool : f = i.creators[ 2/* CValTypeBool.Index() */][cvalCreatorByValue]
|
||||
case int : f = i.creators[ 3/* CValTypeInt.Index() */][cvalCreatorByValue]
|
||||
case int8 : f = i.creators[ 4/* CValTypeInt8.Index() */][cvalCreatorByValue]
|
||||
case int16 : f = i.creators[ 5/* CValTypeInt16.Index() */][cvalCreatorByValue]
|
||||
case int32 : f = i.creators[ 6/* CValTypeInt32.Index() */][cvalCreatorByValue]
|
||||
case int64 : f = i.creators[ 7/* CValTypeInt64.Index() */][cvalCreatorByValue]
|
||||
case uint : f = i.creators[ 8/* CValTypeUint.Index() */][cvalCreatorByValue]
|
||||
case uint8 : f = i.creators[ 9/* CValTypeUint8.Index() */][cvalCreatorByValue]
|
||||
case uint16 : f = i.creators[10/* CValTypeUint16.Index() */][cvalCreatorByValue]
|
||||
case uint32 : f = i.creators[11/* CValTypeUint32.Index() */][cvalCreatorByValue]
|
||||
case uint64 : f = i.creators[12/* CValTypeUint64.Index() */][cvalCreatorByValue]
|
||||
case uintptr : f = i.creators[13/* CValTypeUintptr.Index() */][cvalCreatorByValue]
|
||||
case float32 : f = i.creators[14/* CValTypeFloat32.Index() */][cvalCreatorByValue]
|
||||
case float64 : f = i.creators[15/* CValTypeFloat64.Index() */][cvalCreatorByValue]
|
||||
case complex64 : f = i.creators[16/* CValTypeComplex64.Index() */][cvalCreatorByValue]
|
||||
case complex128 : f = i.creators[17/* CValTypeComplex128.Index()*/][cvalCreatorByValue]
|
||||
case time.Duration : f = i.creators[18/* CValTypeDuration.Index() */][cvalCreatorByValue]
|
||||
case time.Time : f = i.creators[19/* CValTypeDate.Index() */][cvalCreatorByValue]
|
||||
case string : f = i.creators[20/* CValTypeString.Index() */][cvalCreatorByValue]
|
||||
case []uint8 : f = i.creators[21/* CValTypeBytes.Index() */][cvalCreatorByValue]
|
||||
case excs.Stack : f = i.creators[22/* CValTypeStack.Index() */][cvalCreatorByValue]
|
||||
case blrs.Baleable : f = i.creators[23/* CValTypeBaleable.Index() */][cvalCreatorByValue]
|
||||
case error : f = i.creators[24/* CValTypeError.Index() */][cvalCreatorByValue]
|
||||
case CVal : f = i.creators[26/* CValTypeCVal.Index() */][cvalCreatorByValue]
|
||||
case CFields : f = i.creators[27 /* CValTypeCFields.Index() */][cvalCreatorByValue]
|
||||
|
||||
/* Valores Listas */
|
||||
case []any : f = i.creators[ 1/* CValTypeAny.Index() */][cvalCreatorByList]
|
||||
case []bool : f = i.creators[ 2/* CValTypeBool.Index() */][cvalCreatorByList]
|
||||
case []int : f = i.creators[ 3/* CValTypeInt.Index() */][cvalCreatorByList]
|
||||
case []int8 : f = i.creators[ 4/* CValTypeInt8.Index() */][cvalCreatorByList]
|
||||
case []int16 : f = i.creators[ 5/* CValTypeInt16.Index() */][cvalCreatorByList]
|
||||
case []int32 : f = i.creators[ 6/* CValTypeInt32.Index() */][cvalCreatorByList]
|
||||
case []int64 : f = i.creators[ 7/* CValTypeInt64.Index() */][cvalCreatorByList]
|
||||
case []uint : f = i.creators[ 8/* CValTypeUint.Index() */][cvalCreatorByList]
|
||||
// ya establecido como tipo base
|
||||
//case []uint8 : f = i.creators[ 9/* CValTypeUint8.Index() */].listCreator
|
||||
//
|
||||
case []uint16 : f = i.creators[10/* CValTypeUint16.Index() */][cvalCreatorByList]
|
||||
case []uint32 : f = i.creators[11/* CValTypeUint32.Index() */][cvalCreatorByList]
|
||||
case []uint64 : f = i.creators[12/* CValTypeUint64.Index() */][cvalCreatorByList]
|
||||
case []uintptr : f = i.creators[13/* CValTypeUintptr.Index() */][cvalCreatorByList]
|
||||
case []float32 : f = i.creators[14/* CValTypeFloat32.Index() */][cvalCreatorByList]
|
||||
case []float64 : f = i.creators[15/* CValTypeFloat64.Index() */][cvalCreatorByList]
|
||||
case []complex64 : f = i.creators[16/* CValTypeComplex64.Index() */][cvalCreatorByList]
|
||||
case []complex128 : f = i.creators[17/* CValTypeComplex128.Index()*/][cvalCreatorByList]
|
||||
case []time.Duration: f = i.creators[18/* CValTypeDuration.Index() */][cvalCreatorByList]
|
||||
case []time.Time : f = i.creators[19/* CValTypeDate.Index() */][cvalCreatorByList]
|
||||
case []string : f = i.creators[20/* CValTypeString.Index() */][cvalCreatorByList]
|
||||
case []excs.Stack : f = i.creators[22/* CValTypeStack.Index() */][cvalCreatorByList]
|
||||
case []blrs.Baleable: f = i.creators[23/* CValTypeBaleable.Index() */][cvalCreatorByList]
|
||||
case []error : f = i.creators[24/* CValTypeError.Index() */][cvalCreatorByList]
|
||||
case []CVal : f = i.creators[26/* CValTypeCVal.Index() */][cvalCreatorByList]
|
||||
case []CFields : f = i.creators[27 /* CValTypeCFields.Index() */][cvalCreatorByList]
|
||||
|
||||
/* Valores pasados por punteros */
|
||||
case *any : f = i.creators[ 1/* CValTypeAny.Index() */][cvalCreatorByPointer]
|
||||
case *bool : f = i.creators[ 2/* CValTypeBool.Index() */][cvalCreatorByPointer]
|
||||
case *int : f = i.creators[ 3/* CValTypeInt.Index() */][cvalCreatorByPointer]
|
||||
case *int8 : f = i.creators[ 4/* CValTypeInt8.Index() */][cvalCreatorByPointer]
|
||||
case *int16 : f = i.creators[ 5/* CValTypeInt16.Index() */][cvalCreatorByPointer]
|
||||
case *int32 : f = i.creators[ 6/* CValTypeInt32.Index() */][cvalCreatorByPointer]
|
||||
case *int64 : f = i.creators[ 7/* CValTypeInt64.Index() */][cvalCreatorByPointer]
|
||||
case *uint : f = i.creators[ 8/* CValTypeUint.Index() */][cvalCreatorByPointer]
|
||||
case *uint8 : f = i.creators[ 9/* CValTypeUint8.Index() */][cvalCreatorByPointer]
|
||||
case *uint16 : f = i.creators[10/* CValTypeUint16.Index() */][cvalCreatorByPointer]
|
||||
case *uint32 : f = i.creators[11/* CValTypeUint32.Index() */][cvalCreatorByPointer]
|
||||
case *uint64 : f = i.creators[12/* CValTypeUint64.Index() */][cvalCreatorByPointer]
|
||||
case *uintptr : f = i.creators[13/* CValTypeUintptr.Index() */][cvalCreatorByPointer]
|
||||
case *float32 : f = i.creators[14/* CValTypeFloat32.Index() */][cvalCreatorByPointer]
|
||||
case *float64 : f = i.creators[15/* CValTypeFloat64.Index() */][cvalCreatorByPointer]
|
||||
case *complex64 : f = i.creators[16/* CValTypeComplex64.Index() */][cvalCreatorByPointer]
|
||||
case *complex128 : f = i.creators[17/* CValTypeComplex128.Index()*/][cvalCreatorByPointer]
|
||||
case *time.Duration : f = i.creators[18/* CValTypeDuration.Index() */][cvalCreatorByPointer]
|
||||
case *time.Time : f = i.creators[19/* CValTypeDate.Index() */][cvalCreatorByPointer]
|
||||
case *string : f = i.creators[20/* CValTypeString.Index() */][cvalCreatorByPointer]
|
||||
case *[]uint8 : f = i.creators[21/* CValTypeBytes.Index() */][cvalCreatorByPointer]
|
||||
case *excs.Stack : f = i.creators[22/* CValTypeStack.Index() */][cvalCreatorByPointer]
|
||||
case *blrs.Baleable : f = i.creators[23/* CValTypeBaleable.Index() */][cvalCreatorByPointer]
|
||||
case *error : f = i.creators[24/* CValTypeError.Index() */][cvalCreatorByPointer]
|
||||
case *CVal : f = i.creators[26/* CValTypeCVal.Index() */][cvalCreatorByPointer]
|
||||
case *CFields : f = i.creators[27 /* CValTypeCFields.Index() */][cvalCreatorByPointer]
|
||||
|
||||
/* Valores pasados por functions defers */
|
||||
case func()any : f = i.creators[ 1/* CValTypeAny.Index() */][cvalCreatorByDefer]
|
||||
case func()bool : f = i.creators[ 2/* CValTypeBool.Index() */][cvalCreatorByDefer]
|
||||
case func()int : f = i.creators[ 3/* CValTypeInt.Index() */][cvalCreatorByDefer]
|
||||
case func()int8 : f = i.creators[ 4/* CValTypeInt8.Index() */][cvalCreatorByDefer]
|
||||
case func()int16 : f = i.creators[ 5/* CValTypeInt16.Index() */][cvalCreatorByDefer]
|
||||
case func()int32 : f = i.creators[ 6/* CValTypeInt32.Index() */][cvalCreatorByDefer]
|
||||
case func()int64 : f = i.creators[ 7/* CValTypeInt64.Index() */][cvalCreatorByDefer]
|
||||
case func()uint : f = i.creators[ 8/* CValTypeUint.Index() */][cvalCreatorByDefer]
|
||||
case func()uint8 : f = i.creators[ 9/* CValTypeUint8.Index() */][cvalCreatorByDefer]
|
||||
case func()uint16 : f = i.creators[10/* CValTypeUint16.Index() */][cvalCreatorByDefer]
|
||||
case func()uint32 : f = i.creators[11/* CValTypeUint32.Index() */][cvalCreatorByDefer]
|
||||
case func()uint64 : f = i.creators[12/* CValTypeUint64.Index() */][cvalCreatorByDefer]
|
||||
case func()uintptr : f = i.creators[13/* CValTypeUintptr.Index() */][cvalCreatorByDefer]
|
||||
case func()float32 : f = i.creators[14/* CValTypeFloat32.Index() */][cvalCreatorByDefer]
|
||||
case func()float64 : f = i.creators[15/* CValTypeFloat64.Index() */][cvalCreatorByDefer]
|
||||
case func()complex64 : f = i.creators[16/* CValTypeComplex64.Index() */][cvalCreatorByDefer]
|
||||
case func()complex128 : f = i.creators[17/* CValTypeComplex128.Index()*/][cvalCreatorByDefer]
|
||||
case func()time.Duration: f = i.creators[18/* CValTypeDuration.Index() */][cvalCreatorByDefer]
|
||||
case func()time.Time : f = i.creators[19/* CValTypeDate.Index() */][cvalCreatorByDefer]
|
||||
case func()string : f = i.creators[20/* CValTypeString.Index() */][cvalCreatorByDefer]
|
||||
case func()[]uint8 : f = i.creators[21/* CValTypeBytes.Index() */][cvalCreatorByDefer]
|
||||
case func()excs.Stack : f = i.creators[22/* CValTypeStack.Index() */][cvalCreatorByDefer]
|
||||
case func()blrs.Baleable: f = i.creators[23/* CValTypeBaleable.Index() */][cvalCreatorByDefer]
|
||||
case func()error : f = i.creators[24/* CValTypeError.Index() */][cvalCreatorByDefer]
|
||||
case func()CVal : f = i.creators[26/* CValTypeCVal.Index() */][cvalCreatorByDefer]
|
||||
case func()CFields : f = i.creators[27/* CValTypeCFields.Index() */][cvalCreatorByDefer]
|
||||
|
||||
default:
|
||||
|
||||
rv := reflect.ValueOf(value)
|
||||
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func createGValCreators [T any] (valType CValType, createFnc func(value T) CVal) [cValNumCreators]func(any)CVal {
|
||||
return [cValNumCreators]func(any)CVal {
|
||||
func(v any) CVal { return createFnc(v.(T)) },
|
||||
func(v any) CVal { return createGValTypePointer(valType,createFnc,v.(*T))},
|
||||
func(v any) CVal { return createGValTypeList (CValTypeList |valType,v.([]T)) },
|
||||
func(v any) CVal { return createGValTypeDefer(CValTypeDefer|valType,v.(func() T)) },
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
// =============================================================================
|
||||
// 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 05/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cflss
|
||||
@ -0,0 +1,43 @@
|
||||
// =============================================================================
|
||||
// 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 04/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cflss
|
||||
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
CField struct {
|
||||
Name string
|
||||
Value CValue
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,80 @@
|
||||
// =============================================================================
|
||||
// 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 04/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cflss
|
||||
|
||||
type CValue struct {
|
||||
vType CValueType
|
||||
vState CValueState
|
||||
intVal int64
|
||||
strVal string
|
||||
anyVal 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 Duration ) CValue { return CValue{ } }
|
||||
func CreateCValueDate (value Date ) CValue { return CValue{ } }
|
||||
func CreateCValueString (value string ) CValue { return CValue{ } }
|
||||
func CreateCValueBytes (value []uint8 ) CValue { return CValue{ } }
|
||||
func CreateCValueStack (value Stack ) CValue { return CValue{ } }
|
||||
func CreateCValueBaleable (value Baleable ) CValue { return CValue{ } }
|
||||
func CreateCValueError (value error ) CValue { return CValue{ } }
|
||||
func CreateCValueNil (value any ) CValue { return CValue{ } }
|
||||
func CreateCValue (value CValue ) CValue { return CValue{ } }
|
||||
func CreateCValueCField (value CField ) CValue { return CValue{ } }
|
||||
func CreateCValueObject (value any ) CValue { return CValue{ } }
|
||||
|
||||
|
||||
func CreateCValueDefer (value any) CValue { return CValue{ } }
|
||||
func CreateCValueList (value any) CValue { return CValue{ } }
|
||||
func CreateCValueMap (value any) CValue { return CValue{ } }
|
||||
|
||||
|
||||
func createCValueInvalid (value any) CValue {
|
||||
return CValue{}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
// =============================================================================
|
||||
// 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 04/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cflss
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const (
|
||||
|
||||
cValueStateInvalid CValueState = 1 << iota // El valor almacenado es un valor invalido
|
||||
cValueStateNil // Indica que el valor es nulo
|
||||
cValueStateZero // Indica que el valor tiene valor 0
|
||||
cValueStateReflected // Indica que el valor guardado es un value.reflect
|
||||
cValueStateShort // Indica que el valor es la versión corta del valor, por ejemplo: los dates
|
||||
cValueStateSensitive // Indica que el valor es delicado, por ejemplo no mostrar o no serializar
|
||||
cValueStateEncoded // Indica que el valor está codificado
|
||||
cValueStateError // Indica que el valor no ha podido ser establecido por un error que esta representado en el
|
||||
// valor
|
||||
|
||||
cValueStateNone CValueState = 0
|
||||
|
||||
cValueStateOps CValueState = cValueStateEncoded|cValueStateSensitive
|
||||
)
|
||||
|
||||
|
||||
type CValueState uint8
|
||||
|
||||
|
||||
func (s CValueState) HasValueInvalid () bool { return s&cValueStateInvalid != 0 }
|
||||
func (s CValueState) HasValueNil () bool { return s&cValueStateNil != 0 }
|
||||
func (s CValueState) HasValueZero () bool { return s&cValueStateZero != 0 }
|
||||
func (s CValueState) HasValueReflected() bool { return s&cValueStateReflected != 0 }
|
||||
func (s CValueState) HasValueShort () bool { return s&cValueStateShort != 0 }
|
||||
func (s CValueState) HasValueSensitive() bool { return s&cValueStateSensitive != 0 }
|
||||
func (s CValueState) HasValueEncoded () bool { return s&cValueStateEncoded != 0 }
|
||||
func (s CValueState) HasValueError () bool { return s&cValueStateError != 0 }
|
||||
|
||||
|
||||
func (s CValueState) setOption (options CValueState) CValueState { return s|(options&cValueStateOps) }
|
||||
@ -0,0 +1,175 @@
|
||||
// =============================================================================
|
||||
// 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 04/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cflss
|
||||
|
||||
import (
|
||||
"math/bits"
|
||||
)
|
||||
|
||||
|
||||
const (
|
||||
|
||||
maxCValueTypes int = 32
|
||||
|
||||
// CValueType's definidos
|
||||
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
|
||||
|
||||
CValueTypeCValue CValueType = 1 << 25
|
||||
CValueTypeCField CValueType = 1 << 26
|
||||
CValueTypeObject CValueType = 1 << 27
|
||||
|
||||
CValueTypeDefer CValueType = 1 << 28
|
||||
CValueTypeList CValueType = 1 << 29
|
||||
CValueTypeMap CValueType = 1 << 30
|
||||
CValueTypeMapKey CValueType = 1 << 31
|
||||
|
||||
|
||||
maskCValueTypeComposite= CValueTypeDefer|CValueTypeList|CValueTypeMap
|
||||
maskCValueTypeBase = ^(maskCValueTypeComposite | CValueTypeMapKey)
|
||||
)
|
||||
|
||||
|
||||
type (
|
||||
CValueType uint32
|
||||
|
||||
|
||||
)
|
||||
|
||||
func (t CValueType) IsComposite() bool { return t&maskCValueTypeComposite != 0 }
|
||||
|
||||
func (t CValueType) BaseType () CValueType {
|
||||
if t&CValueTypeMap == 0 {
|
||||
return t &maskCValueTypeBase
|
||||
}
|
||||
_,vt := t.MapType()
|
||||
return vt
|
||||
}
|
||||
|
||||
func (t CValueType) MapType () (CValueType,CValueType) {
|
||||
if t&CValueTypeMap == 0 {
|
||||
return CValueTypeInvalid, CValueTypeInvalid
|
||||
}
|
||||
bs := t &maskCValueTypeBase
|
||||
switch bits.OnesCount32(uint32(bs)) {
|
||||
case 1: return bs,bs
|
||||
case 2:
|
||||
if t&CValueTypeMapKey == 0 {
|
||||
return bs&-bs,bs&^(bs&-bs)
|
||||
}
|
||||
return bs&^(bs&-bs),bs&-bs
|
||||
default:
|
||||
return CValueTypeInvalid,CValueTypeInvalid
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (t CValueType) IsTypeInvalid () bool { return t&maskCValueTypeBase == CValueTypeInvalid }
|
||||
func (t CValueType) IsTypeAny () bool { return t&maskCValueTypeBase == CValueTypeAny }
|
||||
func (t CValueType) IsTypeBool () bool { return t&maskCValueTypeBase == CValueTypeBool }
|
||||
func (t CValueType) IsTypeInt () bool { return t&maskCValueTypeBase == CValueTypeInt }
|
||||
func (t CValueType) IsTypeInt8 () bool { return t&maskCValueTypeBase == CValueTypeInt8 }
|
||||
func (t CValueType) IsTypeInt16 () bool { return t&maskCValueTypeBase == CValueTypeInt16 }
|
||||
func (t CValueType) IsTypeInt32 () bool { return t&maskCValueTypeBase == CValueTypeInt32 }
|
||||
func (t CValueType) IsTypeInt64 () bool { return t&maskCValueTypeBase == CValueTypeInt64 }
|
||||
func (t CValueType) IsTypeUint () bool { return t&maskCValueTypeBase == CValueTypeUint }
|
||||
func (t CValueType) IsTypeUint8 () bool { return t&maskCValueTypeBase == CValueTypeUint8 }
|
||||
func (t CValueType) IsTypeUint16 () bool { return t&maskCValueTypeBase == CValueTypeUint16 }
|
||||
func (t CValueType) IsTypeUint32 () bool { return t&maskCValueTypeBase == CValueTypeUint32 }
|
||||
func (t CValueType) IsTypeUint64 () bool { return t&maskCValueTypeBase == CValueTypeUint64 }
|
||||
func (t CValueType) IsTypeUintptr () bool { return t&maskCValueTypeBase == CValueTypeUintptr }
|
||||
func (t CValueType) IsTypeFloat32 () bool { return t&maskCValueTypeBase == CValueTypeFloat32 }
|
||||
func (t CValueType) IsTypeFloat64 () bool { return t&maskCValueTypeBase == CValueTypeFloat64 }
|
||||
func (t CValueType) IsTypeComplex64 () bool { return t&maskCValueTypeBase == CValueTypeComplex64}
|
||||
func (t CValueType) IsTypeComplex128 () bool { return t&maskCValueTypeBase == CValueTypeComplex128}
|
||||
func (t CValueType) IsTypeDuration () bool { return t&maskCValueTypeBase == CValueTypeDuration }
|
||||
func (t CValueType) IsTypeDate () bool { return t&maskCValueTypeBase == CValueTypeDate }
|
||||
func (t CValueType) IsTypeString () bool { return t&maskCValueTypeBase == CValueTypeString }
|
||||
func (t CValueType) IsTypeBytes () bool { return t&maskCValueTypeBase == CValueTypeBytes }
|
||||
func (t CValueType) IsTypeStack () bool { return t&maskCValueTypeBase == CValueTypeStack }
|
||||
func (t CValueType) IsTypeBaleable () bool { return t&maskCValueTypeBase == CValueTypeBaleable }
|
||||
func (t CValueType) IsTypeError () bool { return t&maskCValueTypeBase == CValueTypeError }
|
||||
func (t CValueType) IsTypeNil () bool { return t&maskCValueTypeBase == CValueTypeNil }
|
||||
func (t CValueType) IsTypeCVal () bool { return t&maskCValueTypeBase == CValueTypeCValue }
|
||||
func (t CValueType) IsTypeCField () bool { return t&CValueTypeCField == CValueTypeCField }
|
||||
func (t CValueType) IsTypeObject () bool { return t&maskCValueTypeBase == CValueTypeObject }
|
||||
|
||||
func (t CValueType) IsDefer () bool { return t&CValueTypeDefer != 0 }
|
||||
func (t CValueType) IsList () bool { return t&CValueTypeList != 0 }
|
||||
func (t CValueType) IsMap () bool { return t&CValueTypeMap != 0 }
|
||||
|
||||
|
||||
func buildMapType(keyType, valType CValueType) CValueType {
|
||||
if keyType == CValueTypeInvalid || valType == CValueTypeInvalid {
|
||||
return CValueTypeInvalid
|
||||
}
|
||||
if keyType == valType {
|
||||
return CValueTypeMap|keyType
|
||||
}
|
||||
if keyType < valType {
|
||||
return CValueTypeMap|keyType|valType
|
||||
}
|
||||
return CValueTypeMap|valType|keyType|CValueTypeMapKey
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,335 @@
|
||||
// =============================================================================
|
||||
// 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 05/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cflss
|
||||
|
||||
import (
|
||||
"math/bits"
|
||||
"reflect"
|
||||
|
||||
)
|
||||
|
||||
const(
|
||||
cValueByVal = iota
|
||||
cValueByPtr
|
||||
cValueByLst
|
||||
cValueByDfr
|
||||
|
||||
cValueNumCreators = 4
|
||||
)
|
||||
|
||||
|
||||
type (
|
||||
|
||||
CValueTypeInfos struct {
|
||||
names [maxCValueTypes+1]string
|
||||
creators [maxCValueTypes+1][cValueNumCreators]func(any)CValue
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func createCValueTypeInfos () CValueTypeInfos {
|
||||
is := CValueTypeInfos{
|
||||
names: [maxCValueTypes+1]string{
|
||||
/* 0: */ "invalid",
|
||||
/* 1: */ "any",
|
||||
/* 2: */ "bool",
|
||||
/* 3: */ "int",
|
||||
/* 4: */ "int8",
|
||||
/* 5: */ "int16",
|
||||
/* 6: */ "int32",
|
||||
/* 7: */ "int64",
|
||||
/* 8: */ "uint",
|
||||
/* 9: */ "uint8",
|
||||
/* 10: */ "uint16",
|
||||
/* 11: */ "uint32",
|
||||
/* 12: */ "uint64",
|
||||
/* 13: */ "uintptr",
|
||||
/* 14: */ "float32",
|
||||
/* 15: */ "float64",
|
||||
/* 16: */ "complex64",
|
||||
/* 17: */ "complex128",
|
||||
/* 18: */ "duration",
|
||||
/* 19: */ "date",
|
||||
/* 20: */ "string",
|
||||
/* 21: */ "bytes",
|
||||
/* 22: */ "stack",
|
||||
/* 23: */ "baleable",
|
||||
/* 24: */ "error",
|
||||
/* 25: */ "nil",
|
||||
/* 26: */ "CValue",
|
||||
/* 27: */ "CField",
|
||||
/* 28: */ "object",
|
||||
/* 29: */ "defer",
|
||||
/* 30: */ "list",
|
||||
/* 31: */ "map",
|
||||
/* 32: */ "flag",
|
||||
},
|
||||
creators: [maxCValueTypes+1][cValueNumCreators]func(any)CValue{
|
||||
/* 0: */ createGValCreators[any ](CValueTypeInvalid,createCValueInvalid),
|
||||
/* 1: */ createGValCreators[any ](CValueTypeAny, CreateCValueAny),
|
||||
/* 2: */ createGValCreators[bool ](CValueTypeBool, CreateCValueBool),
|
||||
/* 3: */ createGValCreators[int ](CValueTypeInt, CreateCValueInt),
|
||||
/* 4: */ createGValCreators[int8 ](CValueTypeInt8, CreateCValueInt8),
|
||||
/* 5: */ createGValCreators[int16 ](CValueTypeInt16, CreateCValueInt16),
|
||||
/* 6: */ createGValCreators[int32 ](CValueTypeInt32, CreateCValueInt32),
|
||||
/* 7: */ createGValCreators[int64 ](CValueTypeInt64, CreateCValueInt64),
|
||||
/* 8: */ createGValCreators[uint ](CValueTypeUint, CreateCValueUint),
|
||||
/*
|
||||
caso en el que []uint debe de establecerse como bytes procedemos a construirlo manualmente
|
||||
*/
|
||||
/* 9 :*/ {
|
||||
func(v any) CValue { return CreateCValueUint8 (v.(uint8)) },
|
||||
func(v any) CValue { return createGValTypePointer(CValueTypeUint8, CreateCValueUint8, v.(*uint8)) },
|
||||
func(v any) CValue { return createGValTypeList (CValueTypeBytes, v.([]uint8)) },
|
||||
func(v any) CValue { return createGValTypeDefer (CValueTypeDefer|CValueTypeUint8, v.(func() uint8))},
|
||||
},
|
||||
|
||||
/* 10:*/ createGValCreators[uint16 ](CValueTypeUint16, CreateCValueUint16),
|
||||
/* 11:*/ createGValCreators[uint32 ](CValueTypeUint32, CreateCValueUint32),
|
||||
/* 12:*/ createGValCreators[uint64 ](CValueTypeUint64, CreateCValueUint64),
|
||||
/* 13:*/ createGValCreators[uintptr ](CValueTypeUintptr, CreateCValueUintptr),
|
||||
|
||||
/* 14:*/ createGValCreators[float32 ](CValueTypeFloat32, CreateCValueFloat32),
|
||||
/* 15:*/ createGValCreators[float64 ](CValueTypeFloat64, CreateCValueFloat64),
|
||||
/* 16:*/ createGValCreators[complex64 ](CValueTypeComplex64, CreateCValueComplex64),
|
||||
/* 17:*/ createGValCreators[complex128 ](CValueTypeComplex128, CreateCValueComplex128),
|
||||
|
||||
/* 18:*/ createGValCreators[Duration ](CValueTypeDuration, CreateCValueDuration),
|
||||
/* 19:*/ createGValCreators[Date ](CValueTypeDate, CreateCValueDate),
|
||||
|
||||
/* 20:*/ createGValCreators[string ](CValueTypeString, CreateCValueString),
|
||||
/* 21:*/ createGValCreators[Bytes ](CValueTypeBytes, CreateCValueBytes),
|
||||
/* 22:*/ createGValCreators[Stack ](CValueTypeStack, CreateCValueStack),
|
||||
/* 23:*/ createGValCreators[Baleable ](CValueTypeBaleable, CreateCValueBaleable),
|
||||
/* 24:*/ createGValCreators[error ](CValueTypeError, CreateCValueError),
|
||||
/* 25:*/ createGValCreators[any ](CValueTypeNil, CreateCValueNil),
|
||||
/* 26:*/ createGValCreators[CValue ](CValueTypeCValue, CreateCValue),
|
||||
/* 27:*/ createGValCreators[CField ](CValueTypeCField, CreateCValueCField),
|
||||
/* 28:*/ createGValCreators[any ](CValueTypeObject, CreateCValueObject),
|
||||
/* 29:*/ createGValCreators[any ](CValueTypeDefer, CreateCValueDefer),
|
||||
/* 30:*/ createGValCreators[any ](CValueTypeList, CreateCValueList),
|
||||
/* 31:*/ createGValCreators[any ](CValueTypeMap, CreateCValueMap),
|
||||
/* 32:*/ createGValCreators[any ](CValueTypeObject, createCValueInvalid),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
return is
|
||||
}
|
||||
|
||||
func (i CValueTypeInfos) getName(CValueType CValueType) string {
|
||||
if CValueType.IsComposite() {
|
||||
if CValueType.IsDefer () {
|
||||
return "defer|" + i.getName(CValueType.BaseType())
|
||||
}
|
||||
if CValueType.IsList () {
|
||||
return "list|" + i.getName(CValueType.BaseType())
|
||||
}
|
||||
if CValueType.IsMap () {
|
||||
k, v := CValueType.MapType()
|
||||
return "map@" + i.getName(k) + "|" + i.getName(v)
|
||||
}
|
||||
}
|
||||
return i.names[i.getIndex(CValueType)]
|
||||
}
|
||||
|
||||
func (_ CValueTypeInfos) getIndex(CValueType CValueType) int {
|
||||
if CValueType == 0 {
|
||||
return 0
|
||||
}
|
||||
return bits.TrailingZeros32(uint32(CValueType))+1
|
||||
}
|
||||
|
||||
func (i CValueTypeInfos) getCreator (value any) (f func(v any) CValue) {
|
||||
switch value.(type) {
|
||||
/* Valores simples */
|
||||
case any : f = i.creators[ 1/* Any */][cValueByVal]
|
||||
case bool : f = i.creators[ 2/* Bool */][cValueByVal]
|
||||
case int : f = i.creators[ 3/* Int */][cValueByVal]
|
||||
case int8 : f = i.creators[ 4/* Int8 */][cValueByVal]
|
||||
case int16 : f = i.creators[ 5/* Int16 */][cValueByVal]
|
||||
case int32 : f = i.creators[ 6/* Int32 */][cValueByVal]
|
||||
case int64 : f = i.creators[ 7/* Int64 */][cValueByVal]
|
||||
case uint : f = i.creators[ 8/* Uint */][cValueByVal]
|
||||
case uint8 : f = i.creators[ 9/* Uint8 */][cValueByVal]
|
||||
case uint16 : f = i.creators[10/* Uint16 */][cValueByVal]
|
||||
case uint32 : f = i.creators[11/* Uint32 */][cValueByVal]
|
||||
case uint64 : f = i.creators[12/* Uint64 */][cValueByVal]
|
||||
case uintptr : f = i.creators[13/* Uintptr */][cValueByVal]
|
||||
case float32 : f = i.creators[14/* Float32 */][cValueByVal]
|
||||
case float64 : f = i.creators[15/* Float64 */][cValueByVal]
|
||||
case complex64 : f = i.creators[16/* Complex64 */][cValueByVal]
|
||||
case complex128 : f = i.creators[17/* Complex128*/][cValueByVal]
|
||||
case Duration : f = i.creators[18/* Duration */][cValueByVal]
|
||||
case Date : f = i.creators[19/* Date */][cValueByVal]
|
||||
case string : f = i.creators[20/* String */][cValueByVal]
|
||||
case Bytes : f = i.creators[21/* Bytes */][cValueByVal]
|
||||
case Stack : f = i.creators[22/* Stack */][cValueByVal]
|
||||
case Baleable : f = i.creators[23/* Baleable */][cValueByVal]
|
||||
case error : f = i.creators[24/* Error */][cValueByVal]
|
||||
case CValue : f = i.creators[26/* CVal */][cValueByVal]
|
||||
case CField : f = i.creators[27/* CCField */][cValueByVal]
|
||||
|
||||
/* Valores Listas */
|
||||
case []any : f = i.creators[ 1/* Any */][cValueByLst]
|
||||
case []bool : f = i.creators[ 2/* Bool */][cValueByLst]
|
||||
case []int : f = i.creators[ 3/* Int */][cValueByLst]
|
||||
case []int8 : f = i.creators[ 4/* Int8 */][cValueByLst]
|
||||
case []int16 : f = i.creators[ 5/* Int16 */][cValueByLst]
|
||||
case []int32 : f = i.creators[ 6/* Int32 */][cValueByLst]
|
||||
case []int64 : f = i.creators[ 7/* Int64 */][cValueByLst]
|
||||
case []uint : f = i.creators[ 8/* Uint */][cValueByLst]
|
||||
// ya establecido como tipo base Bytes
|
||||
//case []uint8 : f = i.creators[ 9/* CValueTypeUint8 */].listCreator
|
||||
//
|
||||
case []uint16 : f = i.creators[10/* Uint16 */][cValueByLst]
|
||||
case []uint32 : f = i.creators[11/* Uint32 */][cValueByLst]
|
||||
case []uint64 : f = i.creators[12/* Uint64 */][cValueByLst]
|
||||
case []uintptr : f = i.creators[13/* Uintptr */][cValueByLst]
|
||||
case []float32 : f = i.creators[14/* Float32 */][cValueByLst]
|
||||
case []float64 : f = i.creators[15/* Float64 */][cValueByLst]
|
||||
case []complex64 : f = i.creators[16/* Complex64 */][cValueByLst]
|
||||
case []complex128 : f = i.creators[17/* Complex128*/][cValueByLst]
|
||||
case []Duration : f = i.creators[18/* Duration */][cValueByLst]
|
||||
case []Date : f = i.creators[19/* Date */][cValueByLst]
|
||||
case []string : f = i.creators[20/* String */][cValueByLst]
|
||||
case []Bytes : f = i.creators[21/* String */][cValueByLst]
|
||||
case []Stack : f = i.creators[22/* Stack */][cValueByLst]
|
||||
case []Baleable : f = i.creators[23/* Baleable */][cValueByLst]
|
||||
case []error : f = i.creators[24/* Error */][cValueByLst]
|
||||
case []CValue : f = i.creators[26/* CValue */][cValueByLst]
|
||||
case []CField : f = i.creators[27/* CField */][cValueByLst]
|
||||
|
||||
/* Valores pasados por punteros */
|
||||
case *any : f = i.creators[ 1/* Any */][cValueByPtr]
|
||||
case *bool : f = i.creators[ 2/* Bool */][cValueByPtr]
|
||||
case *int : f = i.creators[ 3/* Int */][cValueByPtr]
|
||||
case *int8 : f = i.creators[ 4/* Int8 */][cValueByPtr]
|
||||
case *int16 : f = i.creators[ 5/* Int16 */][cValueByPtr]
|
||||
case *int32 : f = i.creators[ 6/* Int32 */][cValueByPtr]
|
||||
case *int64 : f = i.creators[ 7/* Int64 */][cValueByPtr]
|
||||
case *uint : f = i.creators[ 8/* Uint */][cValueByPtr]
|
||||
case *uint8 : f = i.creators[ 9/* Uint8 */][cValueByPtr]
|
||||
case *uint16 : f = i.creators[10/* Uint16 */][cValueByPtr]
|
||||
case *uint32 : f = i.creators[11/* Uint32 */][cValueByPtr]
|
||||
case *uint64 : f = i.creators[12/* Uint64 */][cValueByPtr]
|
||||
case *uintptr : f = i.creators[13/* Uintptr */][cValueByPtr]
|
||||
case *float32 : f = i.creators[14/* Float32 */][cValueByPtr]
|
||||
case *float64 : f = i.creators[15/* Float64 */][cValueByPtr]
|
||||
case *complex64 : f = i.creators[16/* Complex64 */][cValueByPtr]
|
||||
case *complex128: f = i.creators[17/* Complex128*/][cValueByPtr]
|
||||
case *Duration : f = i.creators[18/* Duration */][cValueByPtr]
|
||||
case *Date : f = i.creators[19/* Date */][cValueByPtr]
|
||||
case *string : f = i.creators[20/* String */][cValueByPtr]
|
||||
case *Bytes : f = i.creators[21/* Bytes */][cValueByPtr]
|
||||
case *Stack : f = i.creators[22/* Stack */][cValueByPtr]
|
||||
case *Baleable : f = i.creators[23/* Baleable */][cValueByPtr]
|
||||
case *error : f = i.creators[24/* Error */][cValueByPtr]
|
||||
case *CValue : f = i.creators[26/* CValue */][cValueByPtr]
|
||||
case *CField : f = i.creators[27/* CField */][cValueByPtr]
|
||||
|
||||
/* Valores pasados por functions defers */
|
||||
case func()any : f = i.creators[ 1/* Any */][cValueByDfr]
|
||||
case func()bool : f = i.creators[ 2/* Bool */][cValueByDfr]
|
||||
case func()int : f = i.creators[ 3/* Int */][cValueByDfr]
|
||||
case func()int8 : f = i.creators[ 4/* Int8 */][cValueByDfr]
|
||||
case func()int16 : f = i.creators[ 5/* Int16 */][cValueByDfr]
|
||||
case func()int32 : f = i.creators[ 6/* Int32 */][cValueByDfr]
|
||||
case func()int64 : f = i.creators[ 7/* Int64 */][cValueByDfr]
|
||||
case func()uint : f = i.creators[ 8/* Uint */][cValueByDfr]
|
||||
case func()uint8 : f = i.creators[ 9/* Uint8 */][cValueByDfr]
|
||||
case func()uint16 : f = i.creators[10/* Uint16 */][cValueByDfr]
|
||||
case func()uint32 : f = i.creators[11/* Uint32 */][cValueByDfr]
|
||||
case func()uint64 : f = i.creators[12/* Uint64 */][cValueByDfr]
|
||||
case func()uintptr : f = i.creators[13/* Uintptr */][cValueByDfr]
|
||||
case func()float32 : f = i.creators[14/* Float32 */][cValueByDfr]
|
||||
case func()float64 : f = i.creators[15/* Float64 */][cValueByDfr]
|
||||
case func()complex64 : f = i.creators[16/* Complex64 */][cValueByDfr]
|
||||
case func()complex128 : f = i.creators[17/* Complex128*/][cValueByDfr]
|
||||
case func()Duration : f = i.creators[18/* Duration */][cValueByDfr]
|
||||
case func()Date : f = i.creators[19/* Date */][cValueByDfr]
|
||||
case func()string : f = i.creators[20/* String */][cValueByDfr]
|
||||
case func()Bytes : f = i.creators[21/* Bytes */][cValueByDfr]
|
||||
case func()Stack : f = i.creators[22/* Stack */][cValueByDfr]
|
||||
case func()Baleable : f = i.creators[23/* Baleable */][cValueByDfr]
|
||||
case func()error : f = i.creators[24/* Error */][cValueByDfr]
|
||||
case func()CValue : f = i.creators[26/* CVal */][cValueByDfr]
|
||||
case func()CField : f = i.creators[27/* CField */][cValueByDfr]
|
||||
|
||||
default:
|
||||
|
||||
rv := reflect.ValueOf(value)
|
||||
if !rv.IsValid() {
|
||||
f = createCValueInvalid
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func createGValCreators [T any] (valType CValueType, createFnc func(value T) CValue) [cValueNumCreators]func(any)CValue {
|
||||
return [cValueNumCreators]func(any)CValue {
|
||||
func(v any) CValue { return createFnc(v.(T)) },
|
||||
func(v any) CValue { return createGValTypePointer(valType,createFnc,v.(*T))},
|
||||
func(v any) CValue { return createGValTypeList (CValueTypeList |valType,v.([]T)) },
|
||||
func(v any) CValue { return createGValTypeDefer(CValueTypeDefer|valType,v.(func() T)) },
|
||||
}
|
||||
}
|
||||
|
||||
func createGValTypeList [T any](vType CValueType, value []T) CValue {
|
||||
if value == nil {
|
||||
return CValue{vType: vType, vState: cValueStateNil}
|
||||
}
|
||||
var state CValueState
|
||||
if len(value) == 0 {
|
||||
state = cValueStateZero
|
||||
}
|
||||
return CValue{vType: vType, vState: state,anyVal: value}
|
||||
}
|
||||
|
||||
func createGValTypePointer[T any](vType CValueType, createFnc func(value T) CValue, value *T) CValue {
|
||||
if value == nil {
|
||||
return CValue{vType: vType, vState: cValueStateNil}
|
||||
}
|
||||
return createFnc(*value)
|
||||
}
|
||||
|
||||
func createGValTypeDefer[T any](vType CValueType,value func()T) CValue {
|
||||
if value == nil {
|
||||
return CValue{vType: vType, vState: cValueStateInvalid|cValueStateNil|cValueStateError}
|
||||
}
|
||||
return CValue{vType: vType,anyVal: value}
|
||||
}
|
||||
@ -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 05/06/2025
|
||||
// =============================================================================
|
||||
|
||||
package cflss
|
||||
|
||||
import (
|
||||
"core/blrs"
|
||||
"core/excs"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
/* Tipos alias */
|
||||
|
||||
Bytes = []uint8
|
||||
Date = time.Time
|
||||
Duration = time.Duration
|
||||
Stack = excs.Stack
|
||||
Baleable = blrs.Baleable
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in new issue