Closed ShelleyLake closed 1 year ago
I remember this comment was added by fixing the issue (#10).
And after debugging, I found there is mistake in this comment.
Just try the code below:
auto v = CefV8Value::CreateInt(1000);
auto isDouble = v->IsDouble();
logD("isDouble: %d", isDouble); // true
auto isUnint = v->IsUInt();
logD("isUnint: %d", isUnint); // true
auto isInt = v->IsInt();
logD("isInt: %d", isInt); // true
And also, there is a bug in the executeJavascriptWithResult method, I am fixing it now.
Thanks.
Argh! My bad. If I understand correctly in Javascript there is only one value (V8Value) of type "Number" stored as float.
https://www.w3schools.com/js/js_numbers.asp
So that's probably why "1000" will always give true in all three conditions: technically it's a "double", but it can be converted to "uint" and "int".
Excuse me, but if that is the case I see a problem with the order of your conditions: if isDouble()
is always "true", this prevents the other conditions isUint()
, is Int()
from being reached.
So wouldn't it make sense to check the value in the order: isUint(), isInt(), isDouble()
?
uhm..... I think you are correct...will draft a fix
can review this commit: https://github.com/CefView/CefViewCore/commit/aa4b74228ad4ce9b6e1459620e9d00c85251366d
A comment states the following:
My question is, from where do you deduce that those functions tells if the value can be converted, beside testing the type?
Looking in the CEF headers, I read this and (if I am not mistaken) conclude that the functions ONLY check the type. So the order in which the IsDouble, IsInt and IsUint functions are used should be irrelevant.
Thanks