History log of /expo/packages/expo-modules-core/android/src/main/cpp/JNIFunctionBody.h (Results 1 – 4 of 4)
Revision Date Author Comments
# 5e538c67 26-Sep-2022 Łukasz Kosmaty <[email protected]>

[modules][Android] Simplify unpacking of method results (#19226)

# Why

Simplifies unpacking of method results.
Before, we used a similar approach to the RN when receiving results from Kotlin fun

[modules][Android] Simplify unpacking of method results (#19226)

# Why

Simplifies unpacking of method results.
Before, we used a similar approach to the RN when receiving results from Kotlin functions in Cpp. The result was obtained as a WritableArray, and then it was unpaced. That solution isn't ideal in the long term because we always return a single value.

# How

That change for the sync function was pretty straightforward. Right now, the Kotlin function body returns an arbitrary object which is later unpaced and converted to the jsi value.
Unfortunately, to simplify the flow of async functions, I've to introduce my implementation of the callback and the promise.

# Test Plan

- tests ✅
- bare-expo and NCL ✅

show more ...


# 22d99763 12-Jul-2022 Łukasz Kosmaty <[email protected]>

[core][Android] Fix crashes in async functions (#18206)

# Why

Closes ENG-5686.
A follow-up to the https://github.com/expo/expo/pull/18200.


# How

`local_ref` may not be valid when we capt

[core][Android] Fix crashes in async functions (#18206)

# Why

Closes ENG-5686.
A follow-up to the https://github.com/expo/expo/pull/18200.


# How

`local_ref` may not be valid when we capture them in the lambdas. Therefore, I migrate them to `global_ref`.

Why won't copying references work here?
That solution also is open to the same problem. JNI is constructed in a way where everything is bound to the current stack frame. So when the program leaves a frame where something was allocated, is allowed to clear that. By coping references, we do not ensure that the underlying object will outlive the current scope.

# Test Plan

- NCL ✅
- unit tests ✅

show more ...


# 9ebf31e6 27-Jun-2022 Łukasz Kosmaty <[email protected]>

[sweet API][Kotlin] Move preliminary args conversion to Cpp (#17944)

# Why

Moves preliminary args conversion to Cpp.
Needs to work:
- https://github.com/expo/expo/pull/17938
- https://github.c

[sweet API][Kotlin] Move preliminary args conversion to Cpp (#17944)

# Why

Moves preliminary args conversion to Cpp.
Needs to work:
- https://github.com/expo/expo/pull/17938
- https://github.com/expo/expo/pull/17940
- https://github.com/expo/expo/pull/17942
- https://github.com/expo/expo/pull/17943

# How

- Created the `CachedReferencesRegistry` that stores references to often used Java classes. In the future, we may want to store also jsi object there too.
- Reduced the usage of `folly`.
- Added unit tests.

# Benefits

- You can obtain `JavaScriptValue` and `JavaScriptObject` as a function argument

# Test Plan

- unit tests (that covers sync and async functions call too) ✅

show more ...


# 64f5c95f 17-May-2022 Łukasz Kosmaty <[email protected]>

[module-core][Kotlin] Add basic support for sync function (#16977)

# Why

Closes ENG-4608.
Adds basic support for sync function.

# How

- Created ExpoModulesHostObject that installs into the

[module-core][Kotlin] Add basic support for sync function (#16977)

# Why

Closes ENG-4608.
Adds basic support for sync function.

# How

- Created ExpoModulesHostObject that installs into the runtime as `global.ExpoModules`. A host object is an abstract object where we can define our property getter, allowing us to create JS object for each module lazily.
- Added `isAsync` property to sweet functions and `runSynchronously()` modifier - that will be changed in the future.
- Created `JavaScriptModuleObject` that represents a module in the JS world. It has a map of methods with a cached body.
- All the communication goes via two kotlin methods - `getJavaScriptModuleObject` (which returns a hybrid representation of the module) and `callMethodSync` (which is calling correct implementation). Right now, I'm not using lambdas to pass Kotlin functions into CPP, because I don't see any reason why should I.

# Test Plan

- tested with bare-expo ✅

show more ...