sciter-sdk / go-sciter

Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development
https://sciter.com
2.57k stars 268 forks source link

sciter.Value.Int() should return int32 #286

Open AshfordN opened 3 years ago

AshfordN commented 3 years ago

According to the docs, sciter integers are always 32-bit; however, sciter.Value.Int() returns int, which may be either 32-bit or 64-bit, depending on the system architecture (see here). This causes inconsistencies in the way negative numbers are parsed on different architectures. That is, -1 gets interpreted as 4294967295 on a 64-bit system; while it gets interpreted correctly (as -1) on a 32 bit system.

pravic commented 3 years ago

@AshfordN Well, I've fixed the Value.Int() and Value.SetInt().

However, what about Value.Assign(val interface{})? Currently, it accepts uint64 and just truncates it to uint32 (originally, to uint). Should we return an error instead? Or just not accept the uint64 as an interface?

AshfordN commented 3 years ago

I think it's appropriate to do the truncation, as long you're confident it wouldn't be a source of confusion in the future. In my opinion, the sciter docs justifies that behavior and should make it obvious.