Skip to content

Commit

Permalink
handle decode function todo
Browse files Browse the repository at this point in the history
  • Loading branch information
sugarmanz committed Jul 9, 2024
1 parent 3aac131 commit db9a17c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.intuit.playerui.jsi.serialization.encoding

import com.facebook.jni.CppException
import com.intuit.playerui.core.bridge.serialization.encoding.AbstractRuntimeArrayListDecoder
import com.intuit.playerui.core.bridge.serialization.encoding.AbstractRuntimeObjectClassDecoder
import com.intuit.playerui.core.bridge.serialization.encoding.AbstractRuntimeObjectMapDecoder
Expand Down Expand Up @@ -51,9 +52,12 @@ internal sealed class AbstractJSIValueDecoder(
} }

override fun <R> decodeFunction(returnTypeSerializer: KSerializer<R>) = runtime.evaluateInJSThreadBlocking {
// TODO: Probably make sure our decoders wrap up underlying cpp exceptions
// TODO: Not sure the function is the correct thisVal -- maybe value?
currentValue.asObject(runtime).asFunction(runtime).toInvokable(format, value.asObject(runtime), returnTypeSerializer) ?: error("Unable to decode JSI function using return type serializer ${returnTypeSerializer.descriptor}")
try {
currentValue.asObject(runtime).asFunction(runtime)
.toInvokable(format, currentValue.asObject(runtime), returnTypeSerializer)
} catch (exception: CppException) {
error("Unable to decode JSI function using return type serializer ${returnTypeSerializer.descriptor}", exception)
}
}
}

Expand Down

0 comments on commit db9a17c

Please sign in to comment.