remove a string copy
This commit is contained in:
Родитель
d66e74f10b
Коммит
1053f9981b
|
@ -75,22 +75,22 @@ THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY
|
|||
"as<T>();\r\n return o;\r\n}\r\n\r\ntemplate<typename T>\r\n__declspec(noinline) void Disp" +
|
||||
"atchTheEvent(const EventAttachInfo& eai, const winrt::Windows::Foundation::IInsp" +
|
||||
"ectable& sender, const T& args) {\r\n auto senderAsFE = sender.try_as<FrameworkEl" +
|
||||
"ement>();\r\n auto wEN = winrt::to_hstring(eai.jsEventName);\r\n if (eai.xamlMetad" +
|
||||
"ata.m_callFunctionReturnFlushedQueue.has_value()) {\r\n const auto tag = winrt:" +
|
||||
":unbox_value<int64_t>(eai.obj.as<FrameworkElement>().Tag());\r\n ExecuteJsi(eai" +
|
||||
".context, [metadata = eai.xamlMetadata.shared_from_this(), tag, senderAsFE, args" +
|
||||
", eventName = eai.jsEventName](facebook::jsi::Runtime& rt) {\r\n auto objSend" +
|
||||
"er = std::make_shared<XamlObject>(senderAsFE, metadata);\r\n auto objArgs = s" +
|
||||
"td::make_shared<XamlObject>(args, metadata);\r\n auto obj = std::make_shared<" +
|
||||
"facebook::jsi::Object>(rt);\r\n obj->setProperty(rt, \"sender\", rt.global().cr" +
|
||||
"eateFromHostObject(rt, objSender));\r\n obj->setProperty(rt, \"args\", rt.globa" +
|
||||
"l().createFromHostObject(rt, objArgs));\r\n\r\n metadata->JsiDispatchEvent(rt, " +
|
||||
"tag, std::string(eventName), obj);\r\n });\r\n }\r\n else {\r\n XamlUIService:" +
|
||||
":FromContext(eai.context).DispatchEvent(eai.obj.try_as<xaml::FrameworkElement>()" +
|
||||
", wEN.c_str(),\r\n [senderAsFE, args](const winrt::Microsoft::ReactNative::IJ" +
|
||||
"SValueWriter& evtDataWriter) {\r\n SerializeEventArgs(evtDataWriter, sender" +
|
||||
"AsFE, args);\r\n });\r\n }\r\n};\r\n\r\n/*static*/ const EventInfo EventInfo::xamlEv" +
|
||||
"entMap[] = {\r\n");
|
||||
"ement>();\r\n if (eai.xamlMetadata.m_callFunctionReturnFlushedQueue.has_value()) " +
|
||||
"{\r\n const auto tag = winrt::unbox_value<int64_t>(eai.obj.as<FrameworkElement>" +
|
||||
"().Tag());\r\n ExecuteJsi(eai.context, [metadata = eai.xamlMetadata.shared_from" +
|
||||
"_this(), tag, senderAsFE, args, &eventName = eai.jsEventName](facebook::jsi::Run" +
|
||||
"time& rt) {\r\n auto objSender = std::make_shared<XamlObject>(senderAsFE, met" +
|
||||
"adata);\r\n auto objArgs = std::make_shared<XamlObject>(args, metadata);\r\n " +
|
||||
" auto obj = std::make_shared<facebook::jsi::Object>(rt);\r\n obj->setProper" +
|
||||
"ty(rt, \"sender\", rt.global().createFromHostObject(rt, objSender));\r\n obj->s" +
|
||||
"etProperty(rt, \"args\", rt.global().createFromHostObject(rt, objArgs));\r\n\r\n " +
|
||||
"metadata->JsiDispatchEvent(rt, tag, eventName, obj);\r\n });\r\n }\r\n else {\r\n" +
|
||||
" auto wEN = winrt::to_hstring(eai.jsEventName);\r\n XamlUIService::FromConte" +
|
||||
"xt(eai.context).DispatchEvent(eai.obj.try_as<xaml::FrameworkElement>(), wEN.c_st" +
|
||||
"r(),\r\n [senderAsFE, args](const winrt::Microsoft::ReactNative::IJSValueWrit" +
|
||||
"er& evtDataWriter) {\r\n SerializeEventArgs(evtDataWriter, senderAsFE, args" +
|
||||
");\r\n });\r\n }\r\n};\r\n\r\n/*static*/ const EventInfo EventInfo::xamlEventMap[] =" +
|
||||
" {\r\n");
|
||||
|
||||
#line 58 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TypeEvents.tt"
|
||||
foreach (var evt in Events) {
|
||||
|
|
|
@ -33,20 +33,20 @@ __declspec(noinline) T DoTheTypeChecking(const winrt::Windows::Foundation::IInsp
|
|||
template<typename T>
|
||||
__declspec(noinline) void DispatchTheEvent(const EventAttachInfo& eai, const winrt::Windows::Foundation::IInspectable& sender, const T& args) {
|
||||
auto senderAsFE = sender.try_as<FrameworkElement>();
|
||||
auto wEN = winrt::to_hstring(eai.jsEventName);
|
||||
if (eai.xamlMetadata.m_callFunctionReturnFlushedQueue.has_value()) {
|
||||
const auto tag = winrt::unbox_value<int64_t>(eai.obj.as<FrameworkElement>().Tag());
|
||||
ExecuteJsi(eai.context, [metadata = eai.xamlMetadata.shared_from_this(), tag, senderAsFE, args, eventName = eai.jsEventName](facebook::jsi::Runtime& rt) {
|
||||
ExecuteJsi(eai.context, [metadata = eai.xamlMetadata.shared_from_this(), tag, senderAsFE, args, &eventName = eai.jsEventName](facebook::jsi::Runtime& rt) {
|
||||
auto objSender = std::make_shared<XamlObject>(senderAsFE, metadata);
|
||||
auto objArgs = std::make_shared<XamlObject>(args, metadata);
|
||||
auto obj = std::make_shared<facebook::jsi::Object>(rt);
|
||||
obj->setProperty(rt, "sender", rt.global().createFromHostObject(rt, objSender));
|
||||
obj->setProperty(rt, "args", rt.global().createFromHostObject(rt, objArgs));
|
||||
|
||||
metadata->JsiDispatchEvent(rt, tag, std::string(eventName), obj);
|
||||
metadata->JsiDispatchEvent(rt, tag, eventName, obj);
|
||||
});
|
||||
}
|
||||
else {
|
||||
auto wEN = winrt::to_hstring(eai.jsEventName);
|
||||
XamlUIService::FromContext(eai.context).DispatchEvent(eai.obj.try_as<xaml::FrameworkElement>(), wEN.c_str(),
|
||||
[senderAsFE, args](const winrt::Microsoft::ReactNative::IJSValueWriter& evtDataWriter) {
|
||||
SerializeEventArgs(evtDataWriter, senderAsFE, args);
|
||||
|
|
|
@ -33,20 +33,20 @@ __declspec(noinline) T DoTheTypeChecking(const winrt::Windows::Foundation::IInsp
|
|||
template<typename T>
|
||||
__declspec(noinline) void DispatchTheEvent(const EventAttachInfo& eai, const winrt::Windows::Foundation::IInspectable& sender, const T& args) {
|
||||
auto senderAsFE = sender.try_as<FrameworkElement>();
|
||||
auto wEN = winrt::to_hstring(eai.jsEventName);
|
||||
if (eai.xamlMetadata.m_callFunctionReturnFlushedQueue.has_value()) {
|
||||
const auto tag = winrt::unbox_value<int64_t>(eai.obj.as<FrameworkElement>().Tag());
|
||||
ExecuteJsi(eai.context, [metadata = eai.xamlMetadata.shared_from_this(), tag, senderAsFE, args, eventName = eai.jsEventName](facebook::jsi::Runtime& rt) {
|
||||
ExecuteJsi(eai.context, [metadata = eai.xamlMetadata.shared_from_this(), tag, senderAsFE, args, &eventName = eai.jsEventName](facebook::jsi::Runtime& rt) {
|
||||
auto objSender = std::make_shared<XamlObject>(senderAsFE, metadata);
|
||||
auto objArgs = std::make_shared<XamlObject>(args, metadata);
|
||||
auto obj = std::make_shared<facebook::jsi::Object>(rt);
|
||||
obj->setProperty(rt, "sender", rt.global().createFromHostObject(rt, objSender));
|
||||
obj->setProperty(rt, "args", rt.global().createFromHostObject(rt, objArgs));
|
||||
|
||||
metadata->JsiDispatchEvent(rt, tag, std::string(eventName), obj);
|
||||
metadata->JsiDispatchEvent(rt, tag, eventName, obj);
|
||||
});
|
||||
}
|
||||
else {
|
||||
auto wEN = winrt::to_hstring(eai.jsEventName);
|
||||
XamlUIService::FromContext(eai.context).DispatchEvent(eai.obj.try_as<xaml::FrameworkElement>(), wEN.c_str(),
|
||||
[senderAsFE, args](const winrt::Microsoft::ReactNative::IJSValueWriter& evtDataWriter) {
|
||||
SerializeEventArgs(evtDataWriter, senderAsFE, args);
|
||||
|
|
|
@ -300,7 +300,7 @@ const EventInfo* XamlMetadata::AttachEvent(const winrt::Microsoft::ReactNative::
|
|||
|
||||
}
|
||||
|
||||
void XamlMetadata::JsiDispatchEvent(jsi::Runtime& rt, int64_t viewTag, std::string&& eventName, std::shared_ptr<facebook::jsi::Object>& eventData) const noexcept {
|
||||
void XamlMetadata::JsiDispatchEvent(jsi::Runtime& rt, int64_t viewTag, const std::string& eventName, std::shared_ptr<facebook::jsi::Object>& eventData) const noexcept {
|
||||
auto params = jsi::Array(rt, 3);
|
||||
params.setValueAtIndex(rt, 0, static_cast<int>(viewTag));
|
||||
params.setValueAtIndex(rt, 1, eventName);
|
||||
|
|
|
@ -233,7 +233,7 @@ struct XamlMetadata : std::enable_shared_from_this<XamlMetadata> {
|
|||
void PopulateNativeProps(std::vector<std::string>& names, const winrt::Windows::Foundation::IInspectable& obj) const;
|
||||
void PopulateCommands(const winrt::Windows::Foundation::Collections::IVector<winrt::hstring>& commands) const;
|
||||
|
||||
void JsiDispatchEvent(facebook::jsi::Runtime& rt, int64_t viewTag, std::string&& eventName, std::shared_ptr<facebook::jsi::Object>& eventData) const noexcept;
|
||||
void JsiDispatchEvent(facebook::jsi::Runtime& rt, int64_t viewTag, const std::string& eventName, std::shared_ptr<facebook::jsi::Object>& eventData) const noexcept;
|
||||
std::optional<facebook::jsi::Function> m_callFunctionReturnFlushedQueue;
|
||||
winrt::Microsoft::ReactNative::IReactDispatcher UIDispatcher() const { return m_reactContext.UIDispatcher(); }
|
||||
xaml::DependencyObject ElementFromTag(int64_t tag) const { return winrt::Microsoft::ReactNative::XamlUIService::FromContext(m_reactContext).ElementFromReactTag(tag); }
|
||||
|
|
Загрузка…
Ссылка в новой задаче