mirror of
https://github.com/zoriya/nitro.git
synced 2026-10-13 00:05:23 +00:00
* perf: Make `BoxedHybridObject` a tiny bit faster * Update BoxedHybridObject.cpp * feat: Add `PropNameIDCache::names(...)`
31 lines
900 B
C++
31 lines
900 B
C++
//
|
|
// BoxedHybridObject.cpp
|
|
// NitroModules
|
|
//
|
|
// Created by Marc Rousavy on 17.09.24.
|
|
//
|
|
|
|
#include "BoxedHybridObject.hpp"
|
|
#include "PropNameIDCache.hpp"
|
|
|
|
namespace margelo::nitro {
|
|
|
|
std::vector<jsi::PropNameID> BoxedHybridObject::getPropertyNames(jsi::Runtime& runtime) {
|
|
return PropNameIDCache::names(runtime, "unbox");
|
|
}
|
|
|
|
jsi::Value BoxedHybridObject::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) {
|
|
if (jsi::PropNameID::compare(runtime, propName, PropNameIDCache::get(runtime, "unbox"))) {
|
|
// .unbox()
|
|
return jsi::Function::createFromHostFunction(
|
|
runtime, PropNameIDCache::get(runtime, "unbox"), 0,
|
|
[hybridObject = _hybridObject](jsi::Runtime& runtime, const jsi::Value&, const jsi::Value*, size_t) -> jsi::Value {
|
|
return hybridObject->toObject(runtime);
|
|
});
|
|
}
|
|
|
|
return jsi::Value::undefined();
|
|
}
|
|
|
|
} // namespace margelo::nitro
|