Commit Graph
56 Commits
Author SHA1 Message Date
Marc RousavyandGitHub 7a801842be perf: Use ASCII instead of UTF8 for PropNames (#1133) 2026-01-07 15:21:39 +01:00
Marc RousavyandGitHub 27dd56795d chore: Type out Object, Promise, Date and Error under CommonGlobals.cpp (#1113)
* chore: Split `Object`, `Promise`, `Date` and `Error` under `CommonGlobals.hpp`

* feat: Use it everywhere

* fix: Implement them

* fix: `resolved` -> `resolve`
2025-12-18 17:14:35 +01:00
Marc RousavyandGitHub 964f705723 fix: Set .configurable = true and .enumerable = true (#978) 2025-10-21 18:01:17 +02:00
Marc RousavyandGitHub 229e7d83db feat: Create ObjectUtils for Object.freeze, Object.defineProperty, ... (#967)
* feat: Create `ObjectUtils` for `Object.freeze`, `Object.defineProperty`, ...

* Use Object.create

* Fix missing obj

* fix: Better error

* Cache

* fix: Actually cache by preventing copy

* Object.create is part of RN 78

* Use `defineProperty(...)` for `Dispatcher` too

* Optimize Dispatcher install

* Create `getGlobalFunction`

* feat: Use `defineGlobal(...)` to define our global props

* fix: Move the globals

* fix: Don't protect/freeze the globals in JS

we already do it in native.
2025-10-17 18:35:16 +02:00
Marc RousavyandGitHub 6dbb34f9d3 fix: Add NON_NULL, NULLABLE and CONTIGUOUS_MEMORY annotations on pointers (#902)
* chore: Add `NON_NULL` and `NULLABLE` annotations on all pointers

* feat: Add `CONTIGUOUS_MEMORY` and `NON_NULL`

* Create `InstanceMethod<...>`

* chore: Use `InstanceMethod<...>`
2025-09-26 13:45:54 +02:00
Marc RousavyandGitHub d66f9d22c9 fix: Access shared() more safely by using jni::global_ref (virtual) (#803)
* fix: Access `shared()` more safely

* Update HybridObject.cpp

* fix: Call `initSharedBase` on JNI init

* fix: Nitrogen

* Revert "fix: Nitrogen"

This reverts commit c794810d2e6247fe4a158e35faa72600a4a0b5de.

* Revert "fix: Call `initSharedBase` on JNI init"

This reverts commit a5a8a66a9de3b9c467b9be067925fe489e22397b.

* fix: Override `shared` with JNI impl

* fix: Call `HybridBase` with `javaThis` to safely do `::shared()`

* fix: stringify can do JSON now

* fix: Lint

* fix: Fix `length` of JS func

* Update getTests.ts

* fix: Pin react properly

* fix: Throw

* Update JHybridObject.cpp
2025-08-11 13:58:44 +02:00
Marc RousavyandGitHub ea39757017 feat: Add dispose() to Kotlin & Swift (#770)
* feat: Add `dispose()` to Kotlin & Swift

* Mark as `noexcept`

* No return

* Test `dispose()`

* fix assignments

* fix: Test `dispose()` over `optionalCallback()`
2025-07-25 12:22:20 +02:00
Jacek PudyszandGitHub 94a702e480 fix: revert Object.freeze (#612) 2025-03-19 21:37:40 +09:00
Marc RousavyandGitHub ca86d9d296 feat: Freeze objects in debug (#602) 2025-03-06 15:12:04 +01:00
Marc RousavyandGitHub b9ce7462a3 fix: Add additional nullptr check to make_shared_from_jni function (#584)
* fix: Add additional nullptr check to `make_shared_from_jni` function

* fix: Allow move `&&` and forward

* Update JNISharedPtr.hpp

* fix: Add copy ctor

* fix: Avoid `emplace` if there can be duplicates

* Update JNISharedPtr.hpp

* fix: Don't call `release()` on global_ref!

* fix: Use `const &` to keep it lvalue

* Also check `cthis()`
2025-02-24 18:09:50 +01:00
Marc Rousavy 29cfa85198 chore: Allow comparing BorrowingReference<T> to nullptr 2025-02-23 16:46:04 +01:00
Marc RousavyandGitHub 9adb7df925 perf: Remove OwningLock<T> (#567)
* perf: Remove `OwningLock<T>`

* fix: Fix Java Class name
2025-02-23 16:33:53 +01:00
Marc RousavyandGitHub d62dbfbed8 feat: Update memorySize when a HybridObject makes a round-trip (#510)
* feat: Update `memorySize` when a HybridObject makes a round-trip

* feat: Add `NitroModules.updateMemorySize(..)` to imperatively update mem size

* feat: Add test for `NitroModules.updateMemorySize`

* feat: Add some more tests for `NitroModules.*`

* feat: Add even more tests

* fix: Use `jsi::Object`

* fix: use `getObject`

* fix: Register `updateMemorySize()`

* Update HybridNitroModulesProxy.cpp
2025-01-22 15:00:01 +01:00
Marc RousavyandGitHub bbbeeaf6b8 feat: Specify RN version as compiler flag (#490)
* feat: Specify RN version in iOS

* Set RN version

* docs

* fix: Adjust scripts and add bootstrap

* fix: Fix react-native path again

* feat: Add `REACT_NATIVE_VERSION` flag to gradle

* fix: Use `tasks.register` to avoid reconfiguration

* fix: Use `project.layout.buildDirectory` instead of `project.buildDir`

* fix: arguments with comma

* fix: Use `buildDir` again

* fix: Pass `YES`

* feat: Add CMake C++ flags now

* fix: Indicate default overridden `HybridObject` constructor

* perf: Make `equals()` a bit faster
2025-01-13 14:13:00 +01:00
Marc RousavyandGitHub 67ee05dc52 chore: Remove unused arg names (#443)
* chore: Remove unused arg names

* More

* chore: Even more

* rename _
2024-12-20 16:00:37 +01:00
Marc RousavyandGitHub 03e1a716cf fix: Fix NITRO_DEBUG debug/release preprocessor directive (#132)
* fix: Use `NITRO_DEBUG` flag to predictably run debug/release code

* feat: Add `NitroModules.buildType`

* fix: Style `debug` label
2024-09-16 16:18:05 +02:00
Marc Rousavy d291f63ec0 fix: Remove LOG_MEMORY_ALLOCATIONS test 2024-09-16 15:47:40 +02:00
Marc RousavyandGitHub 661bea4cec feat: Add dispose() to HybridObject (and registerRawHybridMethod(...)) (#82)
* fix: Fix `SwiftClosure` not reading `void*` properly - use `Unmanaged<T>` again

* feat: Add a `dispose()` method to `HybridObject`

* feat: Split `registerRawHybridMethod` out of `registerHybridMethod`

* fix: Throw better error for when `NativeState` is nullptr

* Better debug info

* `FunctionType` -> `FunctionKind`

* fix: Either dynamically get name, or statically through typeinfo.
2024-08-29 16:51:11 +02:00
Marc RousavyandGitHub b4592244f2 feat: AnyMap for Kotlin/Android (#60)
* feat: Create `JAnyMap` base

* Update JNIOnLoad.cpp

* feat: Create `AnyMap` methods

* fix: Fix wrong name & format

* feat: `setNull`

* log dimmed

* Update README.md
2024-08-27 18:02:39 +02:00
Marc RousavyandGitHub e7b9f412eb fix: Rewrite Logger to use platform NSLog / __android_log_print (#54)
* fix: Fix wrong include..?

* fix: Reimplement NitroLogger as a platform-specific logger

* fix: Copy args, and use proper tag

* fix: Fix sprintf crash because of wrong format argument

* fix: Fix Logger usage on iOS
2024-08-20 16:20:44 +02:00
Marc RousavyandGitHub acca5baaa4 fix: Replace #if DEBUG with #ifndef NDEBUG to make it work on Android (#53)
* fix: Fix `hasNativeState` checks and provide better errors

* fix: Replace `#if DEBUG` with `#ifndef NDEBUG` to make it work on Android
2024-08-20 15:30:03 +02:00
Marc Rousavy f7646c34ba fix: Remove unresolved import on Android 2024-08-09 17:01:42 +02:00
Marc RousavyandGitHub c101faf948 feat: Cache toObject(...) using jsi::WeakObject and correctly set externalExternalMemoryPressure (#13)
* feat: Cache `toObject(...)` using `jsi::WeakObject` and set `externalMemoryPressure` properly

* feat: Support caching different JSI types - strongly typed
2024-08-08 12:28:33 +02:00
Marc Rousavy 0807098c86 Update HybridObject.cpp 2024-08-08 11:48:49 +02:00
Marc RousavyandGitHub 86c3702ffc feat: Make HybridObject a NativeState (#11)
* feat: Make `HybridObject` a `NativeState`

* feat: Get `NativeState` inside `callMethod(...)`, no more passing `this*`

* Update HybridObject.hpp

* fix: Convert NativeState to `jsi::Value` again

* Use `Object.create`

* fix broken test

* feat: Add `__type` hidden state to objects

* chore: Format

* `makeGlobal` -> `makeShared`

* feat: Extract to `HybridObjectPrototype`

* Update HybridObject.hpp

* feat: Properly build Prototype chain

* Cache prototypes

* fix: Fix prototype caching

* Extract to separate file

* fix: Some comments

* chore: Format

* feat: Freeze prototypes

* Remove freeze

* feat: Optimize `NativeState` performance, make it 56x faster (#12)

* fix: Fix `HybridFunction` usage

* Update HybridFunction.hpp

* mark final

* feat: Add new `registerHybrids(...)` API

* fix: Remove logs

* perf: Make `registerHybrids` faster by using function pointer instead of `std::function<...>`

* fix: Turn off memory allocations debugger

* refactor

* Format

* fix: Fix cyclic includes for `JSIConverter+HybridObject`

* DO_NULL_CHECKS

* fix: Use `jsi::Value` directly to avoid down and up casting again

* Add `__type` to `HybridObject` declaration

* feat: Throw `jsi::JSError` again

* feat: Add prototype tests

* feat: Set `__type` on Prototypes as well

* Delete PointerHolder.hpp

* Delete `JSIPrototypeCache`

* fix: Use `jsi::Value` directly
2024-08-08 11:39:17 +02:00
Marc Rousavy 0b7e2b5561 fix: Fix JSICache<T> being recreated each time because of C++ template specialization 2024-08-06 01:37:08 +02:00
Marc Rousavy 49ed078d1e fix: Unify error catching in createMethod 2024-07-31 18:21:42 +02:00
Marc Rousavy 1c19ec8309 chore: Format 2024-07-31 18:11:57 +02:00
Marc Rousavy 1eda72abab feat: Provide object and method name when throwing errors 2024-07-31 18:11:29 +02:00
Marc Rousavy 9d69ba04ab chore: Run clang format 2024-07-31 17:39:56 +02:00
Marc Rousavy 3e0279a71f feat: Create JSICacheReference for safer cache access 2024-07-30 11:41:01 +02:00
Marc Rousavy 0c0de8cbd3 feat: Try to cache jsi::Objects for HybridObjects 2024-07-30 09:48:07 +02:00
Marc Rousavy 916dc5d4a4 fix logs 2024-07-23 01:48:22 +02:00
Marc Rousavy 168a456a32 Properly add Swift size 2024-07-23 01:37:44 +02:00
Marc Rousavy a0c7caa2a8 fix: Properly get memory size including own cache map size 2024-07-23 01:34:44 +02:00
Marc Rousavy 5e7ce5a33e Also log total objects 2024-07-18 00:34:26 +02:00
Marc Rousavy 5c50d02b72 feat: Also log total alive instances 2024-07-18 00:31:14 +02:00
Marc Rousavy 3fe9d784aa fix: Fix Logger 2024-07-18 00:05:15 +02:00
Marc Rousavy 82925dbb3a fix: Fix toString() space 2024-07-17 23:32:08 +02:00
Marc Rousavy 4262b7940e feat: Add name and equals methods to HybridObject 2024-07-17 23:24:10 +02:00
Marc Rousavy eb7282536a Revert "perf: Also cache getPropertyNames"
This reverts commit eddad79f8c.
2024-07-17 23:14:44 +02:00
Marc Rousavy eddad79f8c perf: Also cache getPropertyNames 2024-07-17 23:14:38 +02:00
Marc Rousavy 09b8dea251 FunctionCache -> JSICache 2024-07-17 23:14:25 +02:00
Marc Rousavy 7bc2767348 fix: Move to namespace margelo::nitro 2024-07-17 21:49:11 +02:00
Marc Rousavy 1b2ea4b1ac Move HybridContext into it's own file 2024-07-17 15:32:02 +02:00
Marc Rousavy 24b1fde801 Update HybridObject.cpp 2024-07-16 18:35:33 +02:00
Marc Rousavy 19d3e848d5 fix: Make _mutex a unique ptr so it can be accessed from Swift 2024-07-16 18:30:05 +02:00
Marc Rousavy 4d266e5837 Update HybridObject.cpp 2024-07-13 12:29:15 +02:00
Marc Rousavy a3988c7c08 Update HybridObject.cpp 2024-07-13 12:28:02 +02:00
Marc Rousavy 6b68537fd5 Create Borrowing/Owning reference types 2024-06-23 11:26:33 +02:00