Skip to content

Commit 77e1596

Browse files
committed
fix: Value.Assign should work with int32 and int64.
This applies to: * `Value.Assign(int32)` * `Value.Assign(uint32)` * `Value.Assign(int64)` * `Value.Assign(uint32)` * `Value.Assign(int)` * `Value.Assign(uint)` refs #286
1 parent 6146c79 commit 77e1596

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

value.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,13 @@ func (v *Value) Release() {
6666
// Assign go value to Sciter Value
6767
// currently supported go types: bool integer float string and NativeFunctor
6868
func (v *Value) Assign(val interface{}) {
69-
const is64Bit = uint64(^uintptr(0)) == ^uint64(0)
7069
switch val.(type) {
7170
case string:
7271
s := val.(string)
7372
v.SetString(s)
7473
case int32:
7574
i := val.(int32)
7675
v.SetInt(i)
77-
case int64:
78-
i := val.(int64)
79-
v.SetInt64(i)
8076
case float64:
8177
f := val.(float64)
8278
// valueInit(this); valueFloatDataSet(this, v, T_FLOAT, 0)
@@ -91,19 +87,15 @@ func (v *Value) Assign(val interface{}) {
9187
case float32:
9288
v.Assign(float64(val.(float32)))
9389
case int:
94-
if is64Bit {
95-
v.Assign(int64(val.(int)))
96-
} else {
97-
v.Assign(int32(val.(int)))
98-
}
90+
// TODO: should we check if it's too big?
91+
v.Assign(int32(val.(int)))
9992
case uint:
100-
if is64Bit {
101-
v.Assign(uint64(val.(uint)))
102-
} else {
103-
v.Assign(uint32(val.(uint)))
104-
}
93+
v.Assign(uint32(val.(uint)))
10594
case uint32:
10695
v.Assign(int32(val.(uint32)))
96+
case int64:
97+
// TODO: should we check if it's too big?
98+
v.Assign(int32(val.(int64)))
10799
case uint64:
108100
v.Assign(int64(val.(uint64)))
109101
case Value:

0 commit comments

Comments
 (0)