react-native-windows 0.74.44 → 0.74.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Microsoft.ReactNative/CallInvokerWriter.cpp +136 -0
- package/Microsoft.ReactNative/CallInvokerWriter.h +74 -0
- package/Microsoft.ReactNative/TurboModulesProvider.cpp +18 -12
- package/Microsoft.ReactNative.Cxx/JSValue.cpp +19 -3
- package/Microsoft.ReactNative.Cxx/JSValue.h +15 -7
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/Shared/Shared.vcxitems +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#include "pch.h"
|
|
5
|
+
#include "CallInvokerWriter.h"
|
|
6
|
+
#include <JSI/JSIDynamic.h>
|
|
7
|
+
#include <crash/verifyElseCrash.h>
|
|
8
|
+
|
|
9
|
+
namespace winrt::Microsoft::ReactNative {
|
|
10
|
+
|
|
11
|
+
//===========================================================================
|
|
12
|
+
// CallInvokerWriter implementation
|
|
13
|
+
//===========================================================================
|
|
14
|
+
|
|
15
|
+
CallInvokerWriter::CallInvokerWriter(
|
|
16
|
+
const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker,
|
|
17
|
+
std::weak_ptr<LongLivedJsiRuntime> jsiRuntimeHolder) noexcept
|
|
18
|
+
: m_callInvoker(jsInvoker),
|
|
19
|
+
m_jsiRuntimeHolder(std::move(jsiRuntimeHolder)),
|
|
20
|
+
m_threadId(std::this_thread::get_id()) {}
|
|
21
|
+
|
|
22
|
+
CallInvokerWriter::~CallInvokerWriter() {
|
|
23
|
+
if (auto jsiRuntimeHolder = m_jsiRuntimeHolder.lock()) {
|
|
24
|
+
jsiRuntimeHolder->allowRelease();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void CallInvokerWriter::WithResultArgs(
|
|
29
|
+
Mso::Functor<void(facebook::jsi::Runtime &rt, facebook::jsi::Value const *args, size_t argCount)>
|
|
30
|
+
handler) noexcept {
|
|
31
|
+
if (m_threadId == std::this_thread::get_id() && m_fastPath) {
|
|
32
|
+
VerifyElseCrash(!m_dynamicWriter);
|
|
33
|
+
if (auto jsiRuntimeHolder = m_jsiRuntimeHolder.lock()) {
|
|
34
|
+
const facebook::jsi::Value *args{nullptr};
|
|
35
|
+
size_t argCount{0};
|
|
36
|
+
m_jsiWriter->AccessResultAsArgs(args, argCount);
|
|
37
|
+
handler(jsiRuntimeHolder->Runtime(), args, argCount);
|
|
38
|
+
m_jsiWriter = nullptr;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
VerifyElseCrash(!m_jsiWriter);
|
|
42
|
+
folly::dynamic dynValue = m_dynamicWriter->TakeValue();
|
|
43
|
+
VerifyElseCrash(dynValue.isArray());
|
|
44
|
+
m_callInvoker->invokeAsync(
|
|
45
|
+
[handler, dynValue = std::move(dynValue), weakJsiRuntimeHolder = m_jsiRuntimeHolder, self = get_strong()]() {
|
|
46
|
+
std::vector<facebook::jsi::Value> args;
|
|
47
|
+
args.reserve(dynValue.size());
|
|
48
|
+
if (auto jsiRuntimeHolder = weakJsiRuntimeHolder.lock()) {
|
|
49
|
+
auto &runtime = jsiRuntimeHolder->Runtime();
|
|
50
|
+
for (auto const &item : dynValue) {
|
|
51
|
+
args.emplace_back(facebook::jsi::valueFromDynamic(runtime, item));
|
|
52
|
+
}
|
|
53
|
+
handler(runtime, args.data(), args.size());
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void CallInvokerWriter::WriteNull() noexcept {
|
|
60
|
+
GetWriter().WriteNull();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void CallInvokerWriter::WriteBoolean(bool value) noexcept {
|
|
64
|
+
GetWriter().WriteBoolean(value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void CallInvokerWriter::WriteInt64(int64_t value) noexcept {
|
|
68
|
+
GetWriter().WriteInt64(value);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void CallInvokerWriter::WriteDouble(double value) noexcept {
|
|
72
|
+
GetWriter().WriteDouble(value);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void CallInvokerWriter::WriteString(const winrt::hstring &value) noexcept {
|
|
76
|
+
GetWriter().WriteString(value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
void CallInvokerWriter::WriteObjectBegin() noexcept {
|
|
80
|
+
GetWriter().WriteObjectBegin();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
void CallInvokerWriter::WritePropertyName(const winrt::hstring &name) noexcept {
|
|
84
|
+
GetWriter().WritePropertyName(name);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
void CallInvokerWriter::WriteObjectEnd() noexcept {
|
|
88
|
+
GetWriter().WriteObjectEnd();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void CallInvokerWriter::WriteArrayBegin() noexcept {
|
|
92
|
+
GetWriter().WriteArrayBegin();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
void CallInvokerWriter::WriteArrayEnd() noexcept {
|
|
96
|
+
GetWriter().WriteArrayEnd();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
IJSValueWriter CallInvokerWriter::GetWriter() noexcept {
|
|
100
|
+
if (!m_writer) {
|
|
101
|
+
if (m_threadId == std::this_thread::get_id() && m_fastPath) {
|
|
102
|
+
if (auto jsiRuntimeHolder = m_jsiRuntimeHolder.lock()) {
|
|
103
|
+
m_jsiWriter = winrt::make_self<JsiWriter>(jsiRuntimeHolder->Runtime());
|
|
104
|
+
m_writer = m_jsiWriter.as<IJSValueWriter>();
|
|
105
|
+
} else {
|
|
106
|
+
m_writer = winrt::make<JSNoopWriter>();
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
m_dynamicWriter = winrt::make_self<DynamicWriter>();
|
|
110
|
+
m_writer = m_dynamicWriter.as<IJSValueWriter>();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
Debug(VerifyElseCrash(m_dynamicWriter != nullptr || (m_threadId == std::this_thread::get_id() && m_fastPath)));
|
|
114
|
+
return m_writer;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void CallInvokerWriter::ExitCurrentCallInvokeScope() noexcept {
|
|
118
|
+
m_fastPath = false;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//===========================================================================
|
|
122
|
+
// JSNoopWriter implementation
|
|
123
|
+
//===========================================================================
|
|
124
|
+
|
|
125
|
+
void JSNoopWriter::WriteNull() noexcept {}
|
|
126
|
+
void JSNoopWriter::WriteBoolean(bool /*value*/) noexcept {}
|
|
127
|
+
void JSNoopWriter::WriteInt64(int64_t /*value*/) noexcept {}
|
|
128
|
+
void JSNoopWriter::WriteDouble(double /*value*/) noexcept {}
|
|
129
|
+
void JSNoopWriter::WriteString(const winrt::hstring & /*value*/) noexcept {}
|
|
130
|
+
void JSNoopWriter::WriteObjectBegin() noexcept {}
|
|
131
|
+
void JSNoopWriter::WritePropertyName(const winrt::hstring & /*name*/) noexcept {}
|
|
132
|
+
void JSNoopWriter::WriteObjectEnd() noexcept {}
|
|
133
|
+
void JSNoopWriter::WriteArrayBegin() noexcept {}
|
|
134
|
+
void JSNoopWriter::WriteArrayEnd() noexcept {}
|
|
135
|
+
|
|
136
|
+
} // namespace winrt::Microsoft::ReactNative
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <JSI/LongLivedJsiValue.h>
|
|
6
|
+
#include <ReactCommon/CallInvoker.h>
|
|
7
|
+
#include <functional/functor.h>
|
|
8
|
+
#include "DynamicWriter.h"
|
|
9
|
+
#include "JsiWriter.h"
|
|
10
|
+
#include "winrt/Microsoft.ReactNative.h"
|
|
11
|
+
|
|
12
|
+
namespace winrt::Microsoft::ReactNative {
|
|
13
|
+
|
|
14
|
+
// IJSValueWriter to ensure that JsiWriter is always used from a RuntimeExecutor.
|
|
15
|
+
// In case if writing is done outside of RuntimeExecutor, it uses DynamicWriter to create
|
|
16
|
+
// folly::dynamic which then is written to JsiWriter in RuntimeExecutor.
|
|
17
|
+
struct CallInvokerWriter : winrt::implements<CallInvokerWriter, IJSValueWriter> {
|
|
18
|
+
~CallInvokerWriter();
|
|
19
|
+
CallInvokerWriter(
|
|
20
|
+
const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker,
|
|
21
|
+
std::weak_ptr<LongLivedJsiRuntime> jsiRuntimeHolder) noexcept;
|
|
22
|
+
void WithResultArgs(Mso::Functor<void(facebook::jsi::Runtime &rt, facebook::jsi::Value const *args, size_t argCount)>
|
|
23
|
+
handler) noexcept;
|
|
24
|
+
|
|
25
|
+
public: // IJSValueWriter
|
|
26
|
+
void WriteNull() noexcept;
|
|
27
|
+
void WriteBoolean(bool value) noexcept;
|
|
28
|
+
void WriteInt64(int64_t value) noexcept;
|
|
29
|
+
void WriteDouble(double value) noexcept;
|
|
30
|
+
void WriteString(const winrt::hstring &value) noexcept;
|
|
31
|
+
void WriteObjectBegin() noexcept;
|
|
32
|
+
void WritePropertyName(const winrt::hstring &name) noexcept;
|
|
33
|
+
void WriteObjectEnd() noexcept;
|
|
34
|
+
void WriteArrayBegin() noexcept;
|
|
35
|
+
void WriteArrayEnd() noexcept;
|
|
36
|
+
|
|
37
|
+
// This should be called before the code flow exits the scope of the CallInvoker,
|
|
38
|
+
// thus requiring the CallInokerWriter to call m_callInvoker->invokeAsync to call back into JS.
|
|
39
|
+
void ExitCurrentCallInvokeScope() noexcept;
|
|
40
|
+
|
|
41
|
+
private:
|
|
42
|
+
IJSValueWriter GetWriter() noexcept;
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
const std::shared_ptr<facebook::react::CallInvoker> m_callInvoker;
|
|
46
|
+
std::weak_ptr<LongLivedJsiRuntime> m_jsiRuntimeHolder;
|
|
47
|
+
winrt::com_ptr<DynamicWriter> m_dynamicWriter;
|
|
48
|
+
winrt::com_ptr<JsiWriter> m_jsiWriter;
|
|
49
|
+
IJSValueWriter m_writer;
|
|
50
|
+
|
|
51
|
+
// If a callback is invoked synchronously we can call the JS callback directly.
|
|
52
|
+
// However, if we post to another thread, or call the callback on the same thread but after we exit the current
|
|
53
|
+
// RuntimeExecutor callback, then we need to save the callback args in a dynamic and post it back to the CallInvoker
|
|
54
|
+
bool m_fastPath{true};
|
|
55
|
+
const std::thread::id m_threadId;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Special IJSValueWriter that does nothing.
|
|
59
|
+
// We use it instead of JsiWriter when JSI runtime is not available anymore.
|
|
60
|
+
struct JSNoopWriter : winrt::implements<JSNoopWriter, IJSValueWriter> {
|
|
61
|
+
public: // IJSValueWriter
|
|
62
|
+
void WriteNull() noexcept;
|
|
63
|
+
void WriteBoolean(bool value) noexcept;
|
|
64
|
+
void WriteInt64(int64_t value) noexcept;
|
|
65
|
+
void WriteDouble(double value) noexcept;
|
|
66
|
+
void WriteString(const winrt::hstring &value) noexcept;
|
|
67
|
+
void WriteObjectBegin() noexcept;
|
|
68
|
+
void WritePropertyName(const winrt::hstring &name) noexcept;
|
|
69
|
+
void WriteObjectEnd() noexcept;
|
|
70
|
+
void WriteArrayBegin() noexcept;
|
|
71
|
+
void WriteArrayEnd() noexcept;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace winrt::Microsoft::ReactNative
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
#include "pch.h"
|
|
9
9
|
#include "TurboModulesProvider.h"
|
|
10
10
|
#include <ReactCommon/TurboModuleUtils.h>
|
|
11
|
-
#include "
|
|
11
|
+
#include "CallInvokerWriter.h"
|
|
12
|
+
#include "JSValueWriter.h"
|
|
12
13
|
#include "JsiApi.h"
|
|
13
14
|
#include "JsiReader.h"
|
|
14
15
|
#include "JsiWriter.h"
|
|
@@ -188,7 +189,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
188
189
|
runtime,
|
|
189
190
|
propName,
|
|
190
191
|
0,
|
|
191
|
-
[
|
|
192
|
+
[jsInvoker = jsInvoker_,
|
|
192
193
|
method = methodInfo.Method,
|
|
193
194
|
longLivedObjectCollection = m_longLivedObjectCollection](
|
|
194
195
|
facebook::jsi::Runtime &rt,
|
|
@@ -198,11 +199,13 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
198
199
|
VerifyElseCrash(argCount > 0);
|
|
199
200
|
if (auto strongLongLivedObjectCollection = longLivedObjectCollection.lock()) {
|
|
200
201
|
auto jsiRuntimeHolder = LongLivedJsiRuntime::CreateWeak(strongLongLivedObjectCollection, rt);
|
|
202
|
+
auto writer = winrt::make<CallInvokerWriter>(jsInvoker, jsiRuntimeHolder);
|
|
201
203
|
method(
|
|
202
204
|
winrt::make<JsiReader>(rt, args, argCount - 1),
|
|
203
|
-
|
|
205
|
+
writer,
|
|
204
206
|
MakeCallback(rt, strongLongLivedObjectCollection, args[argCount - 1]),
|
|
205
207
|
nullptr);
|
|
208
|
+
winrt::get_self<CallInvokerWriter>(writer)->ExitCurrentCallInvokeScope();
|
|
206
209
|
}
|
|
207
210
|
return facebook::jsi::Value::undefined();
|
|
208
211
|
});
|
|
@@ -211,7 +214,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
211
214
|
runtime,
|
|
212
215
|
propName,
|
|
213
216
|
0,
|
|
214
|
-
[
|
|
217
|
+
[jsInvoker = jsInvoker_,
|
|
215
218
|
method = methodInfo.Method,
|
|
216
219
|
longLivedObjectCollection = m_longLivedObjectCollection](
|
|
217
220
|
facebook::jsi::Runtime &rt,
|
|
@@ -226,11 +229,12 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
226
229
|
auto weakCallback2 = LongLivedJsiFunction::CreateWeak(
|
|
227
230
|
strongLongLivedObjectCollection, rt, args[argCount - 1].getObject(rt).getFunction(rt));
|
|
228
231
|
|
|
232
|
+
auto writer = winrt::make<CallInvokerWriter>(jsInvoker, jsiRuntimeHolder);
|
|
229
233
|
method(
|
|
230
234
|
winrt::make<JsiReader>(rt, args, argCount - 2),
|
|
231
|
-
|
|
235
|
+
writer,
|
|
232
236
|
[weakCallback1, weakCallback2, jsiRuntimeHolder](const IJSValueWriter &writer) noexcept {
|
|
233
|
-
writer.as<
|
|
237
|
+
writer.as<CallInvokerWriter>()->WithResultArgs(
|
|
234
238
|
[weakCallback1, weakCallback2, jsiRuntimeHolder](
|
|
235
239
|
facebook::jsi::Runtime &rt, facebook::jsi::Value const *args, size_t count) {
|
|
236
240
|
if (auto callback1 = weakCallback1.lock()) {
|
|
@@ -246,7 +250,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
246
250
|
});
|
|
247
251
|
},
|
|
248
252
|
[weakCallback1, weakCallback2, jsiRuntimeHolder](const IJSValueWriter &writer) noexcept {
|
|
249
|
-
writer.as<
|
|
253
|
+
writer.as<CallInvokerWriter>()->WithResultArgs(
|
|
250
254
|
[weakCallback1, weakCallback2, jsiRuntimeHolder](
|
|
251
255
|
facebook::jsi::Runtime &rt, facebook::jsi::Value const *args, size_t count) {
|
|
252
256
|
if (auto callback2 = weakCallback2.lock()) {
|
|
@@ -261,6 +265,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
261
265
|
}
|
|
262
266
|
});
|
|
263
267
|
});
|
|
268
|
+
winrt::get_self<CallInvokerWriter>(writer)->ExitCurrentCallInvokeScope();
|
|
264
269
|
}
|
|
265
270
|
return facebook::jsi::Value::undefined();
|
|
266
271
|
});
|
|
@@ -269,7 +274,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
269
274
|
runtime,
|
|
270
275
|
propName,
|
|
271
276
|
0,
|
|
272
|
-
[
|
|
277
|
+
[jsInvoker = jsInvoker_,
|
|
273
278
|
method = methodInfo.Method,
|
|
274
279
|
longLivedObjectCollection = m_longLivedObjectCollection](
|
|
275
280
|
facebook::jsi::Runtime &rt,
|
|
@@ -279,7 +284,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
279
284
|
if (auto strongLongLivedObjectCollection = longLivedObjectCollection.lock()) {
|
|
280
285
|
auto jsiRuntimeHolder = LongLivedJsiRuntime::CreateWeak(strongLongLivedObjectCollection, rt);
|
|
281
286
|
auto argReader = winrt::make<JsiReader>(rt, args, count);
|
|
282
|
-
auto argWriter = winrt::make<
|
|
287
|
+
auto argWriter = winrt::make<CallInvokerWriter>(jsInvoker, jsiRuntimeHolder);
|
|
283
288
|
return facebook::react::createPromiseAsJSIValue(
|
|
284
289
|
rt,
|
|
285
290
|
[method, argReader, argWriter, strongLongLivedObjectCollection, jsiRuntimeHolder](
|
|
@@ -292,7 +297,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
292
297
|
argReader,
|
|
293
298
|
argWriter,
|
|
294
299
|
[weakResolve, weakReject, jsiRuntimeHolder](const IJSValueWriter &writer) {
|
|
295
|
-
writer.as<
|
|
300
|
+
writer.as<CallInvokerWriter>()->WithResultArgs(
|
|
296
301
|
[weakResolve, weakReject, jsiRuntimeHolder](
|
|
297
302
|
facebook::jsi::Runtime &runtime,
|
|
298
303
|
facebook::jsi::Value const *args,
|
|
@@ -311,7 +316,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
311
316
|
});
|
|
312
317
|
},
|
|
313
318
|
[weakResolve, weakReject, jsiRuntimeHolder](const IJSValueWriter &writer) {
|
|
314
|
-
writer.as<
|
|
319
|
+
writer.as<CallInvokerWriter>()->WithResultArgs(
|
|
315
320
|
[weakResolve, weakReject, jsiRuntimeHolder](
|
|
316
321
|
facebook::jsi::Runtime &runtime,
|
|
317
322
|
facebook::jsi::Value const *args,
|
|
@@ -342,6 +347,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
342
347
|
}
|
|
343
348
|
});
|
|
344
349
|
});
|
|
350
|
+
winrt::get_self<CallInvokerWriter>(argWriter)->ExitCurrentCallInvokeScope();
|
|
345
351
|
});
|
|
346
352
|
}
|
|
347
353
|
return facebook::jsi::Value::undefined();
|
|
@@ -394,7 +400,7 @@ class TurboModuleImpl : public facebook::react::TurboModule {
|
|
|
394
400
|
auto weakCallback =
|
|
395
401
|
LongLivedJsiFunction::CreateWeak(longLivedObjectCollection, rt, callback.getObject(rt).getFunction(rt));
|
|
396
402
|
return [weakCallback = std::move(weakCallback)](const IJSValueWriter &writer) noexcept {
|
|
397
|
-
writer.as<
|
|
403
|
+
writer.as<CallInvokerWriter>()->WithResultArgs(
|
|
398
404
|
[weakCallback](facebook::jsi::Runtime &rt, facebook::jsi::Value const *args, size_t count) {
|
|
399
405
|
if (auto callback = weakCallback.lock()) {
|
|
400
406
|
callback->Value().call(rt, args, count);
|
|
@@ -278,7 +278,7 @@ JSValue const &JSValueObject::operator[](std::string_view propertyName) const no
|
|
|
278
278
|
return it->second;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
return JSValue::
|
|
281
|
+
return JSValue::NullRef();
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
bool JSValueObject::Equals(JSValueObject const &other) const noexcept {
|
|
@@ -434,6 +434,22 @@ void JSValueArray::WriteTo(IJSValueWriter const &writer) const noexcept {
|
|
|
434
434
|
/*static*/ JSValue const JSValue::EmptyArray{JSValueArray{}};
|
|
435
435
|
/*static*/ JSValue const JSValue::EmptyString{std::string{}};
|
|
436
436
|
|
|
437
|
+
const JSValue &JSValue::NullRef() noexcept {
|
|
438
|
+
return JSValue::Null;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const JSValue &JSValue::EmptyObjectRef() noexcept {
|
|
442
|
+
return JSValue::EmptyObject;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const JSValue &JSValue::EmptyArrayRef() noexcept {
|
|
446
|
+
return JSValue::EmptyArray;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const JSValue &JSValue::EmptyStringRef() noexcept {
|
|
450
|
+
return JSValue::EmptyString;
|
|
451
|
+
}
|
|
452
|
+
|
|
437
453
|
#pragma warning(push)
|
|
438
454
|
#pragma warning(disable : 26495) // False positive for union member not initialized
|
|
439
455
|
JSValue::JSValue(JSValue &&other) noexcept : m_type{other.m_type} {
|
|
@@ -739,7 +755,7 @@ JSValue const *JSValue::TryGetObjectProperty(std::string_view propertyName) cons
|
|
|
739
755
|
|
|
740
756
|
JSValue const &JSValue::GetObjectProperty(std::string_view propertyName) const noexcept {
|
|
741
757
|
auto result = TryGetObjectProperty(propertyName);
|
|
742
|
-
return result ? *result :
|
|
758
|
+
return result ? *result : NullRef();
|
|
743
759
|
}
|
|
744
760
|
|
|
745
761
|
size_t JSValue::ItemCount() const noexcept {
|
|
@@ -752,7 +768,7 @@ JSValue const *JSValue::TryGetArrayItem(JSValueArray::size_type index) const noe
|
|
|
752
768
|
|
|
753
769
|
JSValue const &JSValue::GetArrayItem(JSValueArray::size_type index) const noexcept {
|
|
754
770
|
auto result = TryGetArrayItem(index);
|
|
755
|
-
return result ? *result :
|
|
771
|
+
return result ? *result : NullRef();
|
|
756
772
|
}
|
|
757
773
|
|
|
758
774
|
bool JSValue::Equals(JSValue const &other) const noexcept {
|
|
@@ -181,17 +181,25 @@ bool operator!=(JSValueArray const &left, JSValueArray const &right) noexcept;
|
|
|
181
181
|
//! For copy operations the explicit Copy() method must be used.
|
|
182
182
|
//! Note that the move operations are not thread safe.
|
|
183
183
|
struct JSValue {
|
|
184
|
-
//! JSValue with JSValueType::Null.
|
|
184
|
+
//! JSValue with JSValueType::Null. - Maybe removed in future version - replaced with NullRef
|
|
185
185
|
static JSValue const Null;
|
|
186
|
+
//! JSValue with JSValueType::Null.
|
|
187
|
+
static const JSValue &NullRef() noexcept;
|
|
186
188
|
|
|
187
|
-
//! JSValue with empty object.
|
|
189
|
+
//! JSValue with empty object. - Maybe removed in future version - replaced with EmptyObjectRef
|
|
188
190
|
static JSValue const EmptyObject;
|
|
191
|
+
//! JSValue with empty object.
|
|
192
|
+
static const JSValue &EmptyObjectRef() noexcept;
|
|
189
193
|
|
|
190
|
-
//! JSValue with empty array.
|
|
194
|
+
//! JSValue with empty array. - Maybe removed in future version - replaced with EmptyArrayRef
|
|
191
195
|
static JSValue const EmptyArray;
|
|
196
|
+
//! JSValue with empty array.
|
|
197
|
+
static const JSValue &EmptyArrayRef() noexcept;
|
|
192
198
|
|
|
193
|
-
//! JSValue with empty string.
|
|
199
|
+
//! JSValue with empty string. - Maybe removed in future version - replaced with EmptyStringRef
|
|
194
200
|
static JSValue const EmptyString;
|
|
201
|
+
//! JSValue with empty string.
|
|
202
|
+
static const JSValue &EmptyStringRef() noexcept;
|
|
195
203
|
|
|
196
204
|
//! Create a Null JSValue.
|
|
197
205
|
JSValue() noexcept;
|
|
@@ -654,11 +662,11 @@ inline double const *JSValue::TryGetDouble() const noexcept {
|
|
|
654
662
|
}
|
|
655
663
|
|
|
656
664
|
inline JSValueObject const &JSValue::AsObject() const noexcept {
|
|
657
|
-
return (m_type == JSValueType::Object) ? m_object :
|
|
665
|
+
return (m_type == JSValueType::Object) ? m_object : EmptyObjectRef().m_object;
|
|
658
666
|
}
|
|
659
667
|
|
|
660
668
|
inline JSValueArray const &JSValue::AsArray() const noexcept {
|
|
661
|
-
return (m_type == JSValueType::Array) ? m_array :
|
|
669
|
+
return (m_type == JSValueType::Array) ? m_array : EmptyArrayRef().m_array;
|
|
662
670
|
}
|
|
663
671
|
|
|
664
672
|
inline int8_t JSValue::AsInt8() const noexcept {
|
|
@@ -860,7 +868,7 @@ inline const JSValueArray &JSValue::Array() const noexcept {
|
|
|
860
868
|
}
|
|
861
869
|
|
|
862
870
|
inline const std::string &JSValue::String() const noexcept {
|
|
863
|
-
return (m_type == JSValueType::String) ? m_string :
|
|
871
|
+
return (m_type == JSValueType::String) ? m_string : EmptyStringRef().m_string;
|
|
864
872
|
}
|
|
865
873
|
|
|
866
874
|
inline bool JSValue::Boolean() const noexcept {
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.74.
|
|
13
|
+
<ReactNativeWindowsVersion>0.74.46</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>46</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
|
-
<ReactNativeWindowsCommitId>
|
|
18
|
+
<ReactNativeWindowsCommitId>146c018d53245bc3292b3ff1def8a0f3c065ccf8</ReactNativeWindowsCommitId>
|
|
19
19
|
</PropertyGroup>
|
|
20
20
|
</Project>
|
package/Shared/Shared.vcxitems
CHANGED
|
@@ -397,7 +397,7 @@
|
|
|
397
397
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IReactDispatcher.cpp">
|
|
398
398
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IReactDispatcher.idl</DependentUpon>
|
|
399
399
|
</ClCompile>
|
|
400
|
-
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\
|
|
400
|
+
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\CallInvokerWriter.cpp">
|
|
401
401
|
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IJSValueWriter.idl</DependentUpon>
|
|
402
402
|
</ClCompile>
|
|
403
403
|
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\Timer.cpp">
|