Skip to content

Commit

Permalink
fix: Ints
Browse files Browse the repository at this point in the history
mrousavy committed Sep 14, 2024
1 parent 15b2275 commit 31fcbe7
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -39,8 +39,8 @@ class KotlinTestObject: HybridKotlinTestObjectSpec() {
map.setString("string", "String!")
map.setBoolean("bool", true)
map.setBigInt("bigint", 893256789)
map.setAnyObject("object", mapOf("first" to 1, "second" to "string", "third" to mapOf("nested" to true)))
map.setAnyArray("array", arrayOf(11, true, 33.5, "string", arrayOf("nested", true)))
map.setAnyObject("object", mapOf("first" to 1.0, "second" to "string", "third" to mapOf("nested" to true)))
map.setAnyArray("array", arrayOf(11.0, true, 33.5, "string", arrayOf("nested", true)))
return map
}

Original file line number Diff line number Diff line change
@@ -46,7 +46,13 @@ struct JSIConverter<jni::JObject> final {
return JSIConverter<jni::JMap<jni::JString, jni::JObject>>::toJSI(
runtime, jni::static_ref_cast<jni::JMap<jni::JString, jni::JObject>>(boxedValue));
} else [[unlikely]] {
throw std::runtime_error("Cannot convert \"" + boxedValue->toString() + "\" to jsi::Value!");
// It's an unknown type! Let's give the developer some hints..
if (boxedValue->isInstanceOf(jni::JInteger::javaClassStatic())) {
throw std::runtime_error("Cannot convert Integer \"" + boxedValue->toString() +
"\" to jsi::Value! JavaScript uses Doubles for numbers.");
} else {
throw std::runtime_error("Cannot convert \"" + boxedValue->toString() + "\" to jsi::Value!");
}
}
}
static inline jni::local_ref<jni::JObject> fromJSI(jsi::Runtime& runtime, const jsi::Value& value) {

0 comments on commit 31fcbe7

Please sign in to comment.