Commit Graph
15 Commits
Author SHA1 Message Date
Marc RousavyandGitHub c0af3f603f feat: Attach jsi::MutableBuffer as jsi::NativeState to allow native buffer roundtrips (#736)
* feat: Attach `jsi::MutableBuffer` as `jsi::NativeState` for native buffer roundtrips

* feat: Cast to JS too

* Lint C++

* feat: Add `bounceArrayBuffer(...)` tests

* Update getTests.ts
2025-07-15 16:51:53 +02:00
Marc RousavyandGitHub 52ff673034 feat: Add ArrayBuffer.wrap(HardwareBuffer) API (#691)
* feat: Add `ArrayBuffer.wrap(HardwareBuffer)` API

* fix: Rename it

* Add `#if __ANDROID_API__ >= 26` check to C++

* Format

* feat: Implement `copyHardwareBuffer(..)`

* fix: Throw runtime error

* feat: Add `isHardwareBuffer` and `getHardwareBuffer()` for Kotlin

* fix: Register `copyHardwareBuffer` static JNI method properly

* feat: Add tests for "native" buffer

* Fix `_isLocked`

* chore: Move ArrayBuffer + HardwareBuffer to `HardwareBufferUtils`

* fix: It's called `getHardwareBufferBoxed()`

* fix: `@JvmStatic`

* feat: Implement `copyBuffer()` tests

* fix: Compile below API 26

* fix: Add SDK 26 check to `isHardwareBuffer` fast path

* fix: `getHardwareBufferBoxed` API 26

* fix: Slap good ol' API 26 `@RequiresApi` on it
2025-06-11 15:58:33 +02:00
Marc RousavyandGitHub 13e9977e9a fix: Make ArrayBuffer::copy(..) methods const (#596) 2025-03-03 16:12:11 +01:00
Marc RousavyandGitHub 7f54e269e9 chore: Remove deprecated ArrayBuffer::makeBuffer(...) (#575) 2025-02-24 15:42:39 +01:00
Marc RousavyandGitHub 0c5e716ab1 fix: Fix a case where a nullptr BorrowingReference<T> could be accessed (#568)
* fix: Fix a case where a `nullptr` `BorrowingReference<T>` could be accessed

* Update HybridObjectPrototype.cpp

* chore: Replace `jsi::Runtime*` with `jsi::Runtime&` in `JSArrayBuffer`

* Update ArrayBuffer.cpp
2025-02-23 17:16:50 +01:00
Marc RousavyandGitHub 6998588b70 chore: Rename BorrowingReference<T> -> WeakReference<T>, and OwningReference<T> -> BorrowingReference<T> (#523)
* chore: Rename `BorrowingReference<T>` -> `WeakReference<T>`, and `OwningReference<T>` -> `BorrowingReference<T>`

* chore: Remove unused flag

* chore: Lint

* fix: remove unnecessary nullptr compare
2025-02-03 18:30:04 +01:00
Marc RousavyandGitHub a06c7d44af feat: Add new ArrayBuffer APIs (copy(), wrap(), allocate(), toData()) (#463)
* feat: Add `ArrayBuffer::copyBuffer(..)` API

* feat: Add `wrap` API for Kotlin

* feat: Add `ArrayBuffer.copy(data:)`

* perf: Copy Data a bit more effectively

* fix: Rename a bunch of things

* docs: Add creating docs

* feat: Add `ArrayBufferHolder.toData()`

* feat: Add `ArrayBuffer::copy(std::vector&)`

* perf: Change type of `.data` to `uint8_t*` to avoid upcast

* feat: Add `copyIfNeeded` flag

* Update array-buffers.md
2025-01-07 16:35:59 +01:00
Marc Rousavy 563ad61611 fix: Delete unused _deleteFuncContext member 2024-09-16 15:47:29 +02:00
Marc RousavyandGitHub 992c709caf feat: Safely wrap a Swift closure in a C++ accessible SwiftClosure struct and allow parameters bi-directionally (#81)
* feat: Safely wrap a Swift closure in a `SwiftClosure` struct callable from C++

* Unsafely unwrap (`!`)

* fix: Fix visibility modifiers

* fix: Rename `ClosureWrapper` -> `SwiftClosure`

* Update SwiftClosure.hpp

* Update SwiftClosure.hpp

* Create `SwiftFunction` base

* regen

* feat: Properly create `std::function` from Swift closure

* fix: Forward params I think

* Update SwiftCxxBridgedType.ts

* feat: Use static function pointer to allow for C++ types

* fix: Only do this for Swift

* Update SwiftCxxBridgedType.ts

* fix: Properly unwrap using `Unmanaged`

* fix: Fix Swift compiler crash by moving function to `std::shared_ptr` before capturing it

* feat: Properly share func before capturing it

* Update SwiftCxxTypeHelper.ts
2024-08-29 15:21:25 +02:00
Marc RousavyandGitHub 065736dc2e feat: Base for Kotlin modules (#45)
* feat: Base for Kotlin modules

* fix: Properly make sure Nitro C++ is initialized

* Update JNIOnLoad.java

* feat: Set up `initHybrid()` in JHybridObject

* chore: Fix a bunch of linter issues

* fix: Fix fbjni codegen

* Update JHybridObject.hpp

* fix: Make `initHybrid()` JVM static

* feat: Make `mHybridData` private member of each in inheritance chain

* Generate specs

* feat: Set up proper inheritance graph in FBJNI using virtual inheritance `HybridObject` (#46)

* feat: Try to set up proper inheritance in FBJNI

* Virtual inheritance

* Update JHybridImageFactorySpec.cpp

* It works...

* feat: Virtual base

* Update HybridTestObject.hpp

* Update CMakeLists.txt

* Update JHybridObject.hpp

* Virtual dtor

* Dynamic cast to NativeState 🤔

* Virtual proper

* feat: Generate as virtual base?

* chore: Change to `updateNative`

* feat: Cannot default-construct HybridObject

* fix: Use `dynamic` pointer cast for `HybridContext` because `HybridObject` is now a virtual base

* Update README.md
2024-08-19 12:40:44 +02:00
Marc RousavyandGitHub 2c277fe6f0 feat: Support Promise<T> in Swift (#43)
* fix: Rename `wrap(wrappingDataWithoutCopy)`

* Update ArrayBufferHolder.swift

* Update ArrayBufferHolder.swift

* feat: Move to `utils/`

* feat: Create `Promise` base

* feat: Make `Promise` templated

* Delete HybridContext.cpp

* feat: Create `Promise<T>` in Swift

* Update Promise.swift

* feat: Add docs

* feat: Create `PromiseHolder`

* feat: Create

* `ArrayBuffer` ctors

* Create `PromiseHolder`

* feat: Convert from and to `PromiseHolder<T>`?

* fix: Remove wrong `Promise` declaration

* Update JSIConverter+Promise.hpp

* Update HybridSwiftKotlinTestObject.swift

* Update NitroModules.podspec
2024-08-15 18:30:43 +02:00
Marc RousavyandGitHub c31936286d feat: Support ArrayBuffer in Swift 🥳 (#37)
* feat: Support `ArrayBuffer` in Swift

* feat: Create `ArrayBufferHolder` that holds a `std::shared_ptr<ArrayBuffer>`

* fix: Fix `void*` cast in Swift

* feat: Create `.allocate(..)` helper init

* fix: Fix `initializeToZero`

* feat: Add `createNewBuffer`

* fix: regenerate missing specs

* fix: Move import to iOS only, on Android we dont have that

* chore: Format
2024-08-14 19:34:31 +02:00
Marc Rousavy 0e51985a82 feat: Add tests for ArrayBuffer 2024-08-06 00:33:00 +02:00
Marc Rousavy 592ceb94ff feat: Support ArrayBuffers from JS, and fix JSIConverter<T> template 2024-08-06 00:22:26 +02:00
Marc Rousavy 87eae31207 feat: Move to templates 2024-08-02 21:45:48 +02:00