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
Uh oh!
There was an error while loading. Please reload this page.
-
I have a class method in my Embind bindings that takes a
std::floatas an argument. However, the method doesn't throw when I pass it aStringfrom JS as long as thatStringcontains 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
Strings don't always becomestd::stringon the other side).For what it's worth, I've also found that JS
Strings with text characters are converted toNaNs on C++.Anything I'm missing?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions