Exemple #1
0
func readerForPitch(v types.Value) []types.Value {
	values := []types.Value{}
	s := v.(Pitch)
	values = append(values, types.Float64(s._X))
	values = append(values, types.Float64(s._Z))
	return values
}
func New__unionOfEOfFloat64AndFOfString() __unionOfEOfFloat64AndFOfString {
	return __unionOfEOfFloat64AndFOfString{
		__unionIndex: 0,
		__unionValue: types.Float64(0),
		ref:          &ref.Ref{},
	}
}
func NewStructWithUnionField() StructWithUnionField {
	return StructWithUnionField{
		_a:           float32(0),
		__unionIndex: 0,
		__unionValue: types.Float64(0),
		ref:          &ref.Ref{},
	}
}
Exemple #4
0
// StringToType takes a piece of data as a string and attempts to convert it to a types.Value of the appropriate types.NomsKind.
func StringToType(s string, k types.NomsKind) types.Value {
	switch k {
	case types.Uint8Kind:
		ival, err := strconv.ParseUint(s, 10, 8)
		d.Chk.NoError(err)
		return types.Uint8(ival)
	case types.Uint16Kind:
		ival, err := strconv.ParseUint(s, 10, 16)
		d.Chk.NoError(err)
		return types.Uint16(ival)
	case types.Uint32Kind:
		ival, err := strconv.ParseUint(s, 10, 32)
		d.Chk.NoError(err)
		return types.Uint32(ival)
	case types.Uint64Kind:
		ival, err := strconv.ParseUint(s, 10, 64)
		d.Chk.NoError(err)
		return types.Uint64(ival)
	case types.Int8Kind:
		ival, err := strconv.ParseInt(s, 10, 8)
		d.Chk.NoError(err)
		return types.Int8(ival)
	case types.Int16Kind:
		ival, err := strconv.ParseInt(s, 10, 16)
		d.Chk.NoError(err)
		return types.Int16(ival)
	case types.Int32Kind:
		ival, err := strconv.ParseInt(s, 10, 32)
		d.Chk.NoError(err)
		return types.Int32(ival)
	case types.Int64Kind:
		ival, err := strconv.ParseInt(s, 10, 64)
		d.Chk.NoError(err)
		return types.Int64(ival)
	case types.Float32Kind:
		fval, err := strconv.ParseFloat(s, 32)
		d.Chk.NoError(err)
		return types.Float32(fval)
	case types.Float64Kind:
		fval, err := strconv.ParseFloat(s, 64)
		d.Chk.NoError(err)
		return types.Float64(fval)
	case types.BoolKind:
		bval, err := strconv.ParseBool(s)
		d.Chk.NoError(err)
		return types.Bool(bval)
	case types.StringKind:
		return types.NewString(s)
	default:
		d.Exp.Fail("Invalid column type kind:", k)
	}
	panic("not reached")
}
func (s StructPrimitives) ChildValues() (ret []types.Value) {
	ret = append(ret, types.Uint64(s._uint64))
	ret = append(ret, types.Uint32(s._uint32))
	ret = append(ret, types.Uint16(s._uint16))
	ret = append(ret, types.Uint8(s._uint8))
	ret = append(ret, types.Int64(s._int64))
	ret = append(ret, types.Int32(s._int32))
	ret = append(ret, types.Int16(s._int16))
	ret = append(ret, types.Int8(s._int8))
	ret = append(ret, types.Float64(s._float64))
	ret = append(ret, types.Float32(s._float32))
	ret = append(ret, types.Bool(s._bool))
	ret = append(ret, types.NewString(s._string))
	ret = append(ret, s._blob)
	ret = append(ret, s._value)
	return
}
func readerForStructPrimitives(v types.Value) []types.Value {
	values := []types.Value{}
	s := v.(StructPrimitives)
	values = append(values, types.Uint64(s._uint64))
	values = append(values, types.Uint32(s._uint32))
	values = append(values, types.Uint16(s._uint16))
	values = append(values, types.Uint8(s._uint8))
	values = append(values, types.Int64(s._int64))
	values = append(values, types.Int32(s._int32))
	values = append(values, types.Int16(s._int16))
	values = append(values, types.Int8(s._int8))
	values = append(values, types.Float64(s._float64))
	values = append(values, types.Float32(s._float32))
	values = append(values, types.Bool(s._bool))
	values = append(values, types.NewString(s._string))
	values = append(values, s._blob)
	values = append(values, s._value)
	return values
}
Exemple #7
0
func (suite *LibTestSuite) TestPrimitiveTypes() {
	suite.EqualValues(types.NewString("expected"), NomsValueFromDecodedJSON("expected"))
	suite.EqualValues(types.Bool(false), NomsValueFromDecodedJSON(false))
	suite.EqualValues(types.Float64(1.7), NomsValueFromDecodedJSON(1.7))
	suite.False(NomsValueFromDecodedJSON(1.7).Equals(types.Bool(true)))
}
Exemple #8
0
func (suite *WalkAllTestSuite) TestWalkPrimitives() {
	suite.walkWorker(suite.storeAndRef(types.Float64(0.0)), 2)
	suite.walkWorker(suite.storeAndRef(types.NewString("hello")), 2)
}
func (def __unionOfEOfFloat64AndFOfStringDef) SetE(val float64) __unionOfEOfFloat64AndFOfStringDef {
	def.__unionIndex = 0
	def.__unionValue = types.Float64(val)
	return def
}
func (s __unionOfEOfFloat64AndFOfString) SetE(val float64) __unionOfEOfFloat64AndFOfString {
	s.__unionIndex = 0
	s.__unionValue = types.Float64(val)
	s.ref = &ref.Ref{}
	return s
}
Exemple #11
0
func (s Pitch) ChildValues() (ret []types.Value) {
	ret = append(ret, types.Float64(s._X))
	ret = append(ret, types.Float64(s._Z))
	return
}
func (def StructWithUnionFieldDef) SetB(val float64) StructWithUnionFieldDef {
	def.__unionIndex = 0
	def.__unionValue = types.Float64(val)
	return def
}
func (s StructWithUnionField) SetB(val float64) StructWithUnionField {
	s.__unionIndex = 0
	s.__unionValue = types.Float64(val)
	s.ref = &ref.Ref{}
	return s
}