Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,6 @@

namespace facebook::react {

static jsi::Value deepCopyJSIValue(jsi::Runtime& rt, const jsi::Value& value) {
if (value.isNull()) {
return jsi::Value::null();
}

if (value.isBool()) {
return jsi::Value(value.getBool());
}

if (value.isNumber()) {
return jsi::Value(value.getNumber());
}

if (value.isString()) {
return value.getString(rt);
}

if (value.isObject()) {
jsi::Object o = value.getObject(rt);
if (o.isArray(rt)) {
return deepCopyJSIArray(rt, o.getArray(rt));
}
if (o.isFunction(rt)) {
return o.getFunction(rt);
}
return deepCopyJSIObject(rt, o);
}

return jsi::Value::undefined();
}

jsi::Object deepCopyJSIObject(jsi::Runtime& rt, const jsi::Object& obj) {
jsi::Object copy(rt);
jsi::Array propertyNames = obj.getPropertyNames(rt);
size_t size = propertyNames.size(rt);
for (size_t i = 0; i < size; i++) {
jsi::String name = propertyNames.getValueAtIndex(rt, i).getString(rt);
jsi::Value value = obj.getProperty(rt, name);
copy.setProperty(rt, name, deepCopyJSIValue(rt, value));
}
return copy;
}

jsi::Array deepCopyJSIArray(jsi::Runtime& rt, const jsi::Array& arr) {
size_t size = arr.size(rt);
jsi::Array copy(rt, size);
for (size_t i = 0; i < size; i++) {
copy.setValueAtIndex(
rt, i, deepCopyJSIValue(rt, arr.getValueAtIndex(rt, i)));
}
return copy;
}

Promise::Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject)
: LongLivedObject(rt),
resolve_(std::move(resolve)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@

#pragma once

#include <cassert>
#include <string>

#include <jsi/jsi.h>
#include <react/bridging/CallbackWrapper.h>
#include <react/bridging/LongLivedObject.h>
#include <cassert>
#include <functional>
#include <string>

namespace facebook::react {

jsi::Object deepCopyJSIObject(jsi::Runtime& rt, const jsi::Object& obj);
jsi::Array deepCopyJSIArray(jsi::Runtime& rt, const jsi::Array& arr);

struct Promise : public LongLivedObject {
Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject);

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Refer to packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.h for a concrete example.
See: https://reactnative.dev/docs/the-new-architecture/pure-cxx-modules

This file was deleted.

Loading
Loading