-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support
JSIConverter<AnyMap>::canConvert
(+ AnyValue
and `u…
…nordered_map<string, T>`)
- Loading branch information
Showing
7 changed files
with
92 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
// | ||
|
||
#include "JSICache.hpp" | ||
#include "JSIHelpers.hpp" | ||
|
||
namespace margelo::nitro { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/react-native-nitro-modules/cpp/jsi/JSIHelpers.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// JSIHelpers.hpp | ||
// Pods | ||
// | ||
// Created by Marc Rousavy on 07.08.24. | ||
// | ||
|
||
#pragma once | ||
|
||
#include "ThreadUtils.hpp" | ||
#include <jsi/jsi.h> | ||
|
||
namespace margelo::nitro { | ||
|
||
using namespace facebook; | ||
|
||
/** | ||
* Returns whether the given `jsi::Object` is a plain-JS object, or not. | ||
* If it is not a plain-JS object, it could be an Array, ArrayBuffer, Function, | ||
* HostObject or NativeState. | ||
*/ | ||
static inline bool isPlainObject(jsi::Runtime& runtime, const jsi::Object& object) { | ||
if (object.isArray(runtime)) { | ||
return false; | ||
} | ||
if (object.isArrayBuffer(runtime)) { | ||
return false; | ||
} | ||
if (object.isFunction(runtime)) { | ||
return false; | ||
} | ||
if (object.isHostObject(runtime)) { | ||
return false; | ||
} | ||
if (object.hasNativeState(runtime)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Get an ID for the given Runtime. | ||
* | ||
* The ID usually consists of a Runtime description (e.g. "HermesRuntime"), | ||
* and it's Thread (e.g. "com.facebook.react.runtime.JavaScript") | ||
*/ | ||
static inline std::string getRuntimeId(jsi::Runtime& runtime) { | ||
std::string threadName = ThreadUtils::getThreadName(); | ||
return runtime.description() + std::string(" (") + threadName + std::string(")"); | ||
} | ||
|
||
} // namespace margelo::nitro | ||
|
2 changes: 1 addition & 1 deletion
2
packages/react-native-nitro-modules/cpp/threading/Dispatcher.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
packages/react-native-nitro-modules/cpp/utils/GetRuntimeID.hpp
This file was deleted.
Oops, something went wrong.