Skip to content

Commit

Permalink
automatically decode numbers as ints for player runtime compat -- 132…
Browse files Browse the repository at this point in the history
… jvm/core tests pass :)
  • Loading branch information
sugarmanz committed Aug 1, 2024
1 parent a62bb4b commit 4d7d167
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions jvm/hermes/src/main/jni/JJSIValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ bool JJSIValue::asBool() {
return value_->asBool();
}

double JJSIValue::asNumber() {
return value_->asNumber();
jint JJSIValue::asNumber() {
return static_cast<jint>(value_->asNumber());
}

// TODO: Ensure this is what we want to do - we can return the JSI String container
Expand Down
2 changes: 1 addition & 1 deletion jvm/hermes/src/main/jni/JJSIValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class JJSIValue : public HybridClass<JJSIValue> {
bool isObject();

bool asBool();
double asNumber();
jint asNumber();
std::string asString(alias_ref<JJSIRuntime::jhybridobject> jRuntime);
jlong asBigInt(alias_ref<JJSIRuntime::jhybridobject> jRuntime);
local_ref<JJSISymbol_jhybridobject> asSymbol(alias_ref<JJSIRuntime::jhybridobject> jRuntime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class Value private constructor(mHybridData: HybridData) : JSIValueContai

public external fun asBoolean(): Boolean
// TODO: Consider making this return Number directly, so there aren't assumptions about what will come out of this?
public external fun asNumber(): Double
public external fun asNumber(): Int // TODO: Doing this for Player runtime compat
/** context(RuntimeThreadContext) */ public external fun asString(runtime: Runtime): String
/** context(RuntimeThreadContext) */ public external fun asBigInt(runtime: Runtime): Long
/** context(RuntimeThreadContext) */ public external fun asSymbol(runtime: Runtime): Symbol
Expand Down

0 comments on commit 4d7d167

Please sign in to comment.