energy/cef/cef-v8-js-double.go

42 lines
727 B
Go
Raw Normal View History

2022-10-04 13:21:05 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
2022-10-04 16:38:43 +08:00
// Licensed under GNU General Public License v3.0
2022-10-04 13:21:05 +08:00
//
//----------------------------------------
package cef
import (
"fmt"
2022-10-04 22:34:57 +08:00
"github.com/energye/energy/consts"
2022-10-04 13:21:05 +08:00
)
type JSDouble struct {
ICEFv8Value
}
func (m *JSDouble) AsDouble() (*JSDouble, error) {
return m, nil
}
func (m *JSDouble) Value() float64 {
if val, err := m.DoubleValue(); err == nil {
return val
} else {
return 0.0
}
}
func (m *JSDouble) SetValue(value float64) {
2022-10-04 22:34:57 +08:00
m.valueType = consts.V8_VALUE_DOUBLE
2022-10-04 13:21:05 +08:00
m.value = value
}
func (m *JSDouble) ToString() string {
if val, err := m.DoubleValue(); err == nil {
return fmt.Sprintf("%v", val)
}
return ""
}