// Copyright © 2021-present 650 Industries, Inc. (aka Expo) #pragma once #include "ExpoHeader.pch" #include "JSIObjectWrapper.h" #include "JavaScriptRuntime.h" #include "types/ExpectedType.h" namespace jni = facebook::jni; namespace jsi = facebook::jsi; namespace expo { class JavaScriptObject; /** * Represents any JavaScript function. Its purpose is to expose the `jsi::Function` API back to Kotlin. */ class JavaScriptFunction : public jni::HybridClass, JSIFunctionWrapper { public: static auto constexpr kJavaDescriptor = "Lexpo/modules/kotlin/jni/JavaScriptFunction;"; static auto constexpr TAG = "JavaScriptFunction"; static void registerNatives(); static jni::local_ref newInstance( JSIContext *jsiContext, std::weak_ptr runtime, std::shared_ptr jsFunction ); JavaScriptFunction( std::weak_ptr runtime, std::shared_ptr jsFunction ); std::shared_ptr get() override; private: friend HybridBase; std::weak_ptr runtimeHolder; std::shared_ptr jsFunction; jobject invoke( jni::alias_ref::javaobject> jsThis, jni::alias_ref> args, jni::alias_ref expectedReturnType ); }; } // namespace expo