JS String
to std::float
conversion
#21479
Unanswered
jmarcosfer
asked this question in
Q&A
Replies: 1 comment 4 replies
-
I suspect this is just an artifact of the automatic conversion rules that apply when calling from JavaScript into Wasm. I believe the same thing would happen if you directly called an export C function from JS (i.e. without embind at all). Assuming I'm correct, then the next question might be: Should emscripten attempt to do more strict type checking at the boundary than the normal JavaScript API does? I guess it could provide more debugging in debug build perhaps? @brendandahl @kripken WDYT? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a class method in my Embind bindings that takes a
std::float
as an argument. However, the method doesn't throw when I pass it aString
from JS as long as thatString
contains numeric characters. Is there some sort of implicit type casting done under the hood that I'm missing?I've checked this part of the docs about type conversions, but the table makes it look like it's about C++ to JS conversions and not the other way around (plus with the behaviour I've found I know definitely that JS
String
s don't always becomestd::string
on the other side).For what it's worth, I've also found that JS
String
s with text characters are converted toNaN
s on C++.Anything I'm missing?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions