summarylogtreecommitdiffstats
path: root/protobuf_string_view.patch
blob: 2193c8f1366b7e90eaa451d50000a5a6ef125352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/detail/Node.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/detail/Node.hh
--- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/detail/Node.hh	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/detail/Node.hh	2025-07-07 17:22:46.438115379 +0800
@@ -34,7 +34,7 @@
         const std::string &_topic,
         const AdvertiseMessageOptions &_options)
     {
-      return this->Advertise(_topic, MessageT().GetTypeName(), _options);
+      return this->Advertise(_topic, std::string(MessageT().GetTypeName()), _options);
     }
 
     //////////////////////////////////////////////////
@@ -267,7 +267,7 @@
         this->Shared()->myReplierAddress,
         this->Shared()->replierId.ToString(),
         this->Shared()->pUuid, this->NodeUuid(),
-        RequestT().GetTypeName(), ReplyT().GetTypeName(), _options);
+        std::string(RequestT().GetTypeName()), std::string(ReplyT().GetTypeName()), _options);
 
       if (!this->Shared()->AdvertisePublisher(publisher))
       {
@@ -420,8 +420,8 @@
         std::lock_guard<std::recursive_mutex> lk(this->Shared()->mutex);
         localResponserFound = this->Shared()->repliers.FirstHandler(
               fullyQualifiedTopic,
-              RequestT().GetTypeName(),
-              ReplyT().GetTypeName(),
+              std::string(RequestT().GetTypeName()),
+              std::string(ReplyT().GetTypeName()),
               repHandler);
       }
 
@@ -458,7 +458,7 @@
         if (this->Shared()->TopicPublishers(fullyQualifiedTopic, addresses))
         {
           this->Shared()->SendPendingRemoteReqs(fullyQualifiedTopic,
-            RequestT().GetTypeName(), ReplyT().GetTypeName());
+            std::string(RequestT().GetTypeName()), std::string(ReplyT().GetTypeName()));
         }
         else
         {
@@ -551,7 +551,7 @@
       // If the responser is within my process.
       IRepHandlerPtr repHandler;
       if (this->Shared()->repliers.FirstHandler(fullyQualifiedTopic,
-        _request.GetTypeName(), _reply.GetTypeName(), repHandler))
+        std::string(_request.GetTypeName()), std::string(_reply.GetTypeName()), repHandler))
       {
         // There is a responser in my process, let's use it.
         _result = repHandler->RunLocalCallback(_request, _reply);
@@ -567,7 +567,7 @@
       if (this->Shared()->TopicPublishers(fullyQualifiedTopic, addresses))
       {
         this->Shared()->SendPendingRemoteReqs(fullyQualifiedTopic,
-          _request.GetTypeName(), _reply.GetTypeName());
+          std::string(_request.GetTypeName()), std::string(_reply.GetTypeName()));
       }
       else
       {
diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/RepHandler.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/RepHandler.hh
--- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/RepHandler.hh	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/RepHandler.hh	2025-07-07 17:19:25.149117798 +0800
@@ -142,9 +142,14 @@
         }
 
 #if GOOGLE_PROTOBUF_VERSION >= 4022000
-        auto msgReq =
-          google::protobuf::internal::DownCast<const Req*>(&_msgReq);
-        auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
+        auto msgReq = dynamic_cast<const Req*>(&_msgReq);
+        auto msgRep = dynamic_cast<Rep*>(&_msgRep);
+        if (!msgReq || !msgRep)
+        {
+          std::cerr << "RepHandler::RunLocalCallback() error: "
+                    << "dynamic_cast failed" << std::endl;
+          return false;
+        }
 #elif GOOGLE_PROTOBUF_VERSION > 2999999
         auto msgReq = google::protobuf::down_cast<const Req*>(&_msgReq);
         auto msgRep = google::protobuf::down_cast<Rep*>(&_msgRep);
@@ -193,13 +198,13 @@
       // Documentation inherited.
       public: virtual std::string ReqTypeName() const
       {
-        return Req().GetTypeName();
+        return std::string(Req().GetTypeName());
       }
 
       // Documentation inherited.
       public: virtual std::string RepTypeName() const
       {
-        return Rep().GetTypeName();
+        return std::string(Rep().GetTypeName());
       }
 
       /// \brief Create a specific protobuf message given its serialized data.
diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/ReqHandler.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/ReqHandler.hh
--- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/ReqHandler.hh	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/ReqHandler.hh	2025-07-07 17:14:56.341121030 +0800
@@ -285,13 +285,13 @@
       // Documentation inherited.
       public: virtual std::string ReqTypeName() const
       {
-        return Req().GetTypeName();
+        return std::string(Req().GetTypeName());
       }
 
       // Documentation inherited.
       public: virtual std::string RepTypeName() const
       {
-        return Rep().GetTypeName();
+        return std::string(Rep().GetTypeName());
       }
 
       /// \brief Protobuf message containing the request's parameters.
@@ -382,7 +382,7 @@
       public: virtual std::string ReqTypeName() const
       {
         if (this->reqMsg)
-          return this->reqMsg->GetTypeName();
+          return std::string(this->reqMsg->GetTypeName());
         else
         {
           std::cerr << "ReqHandler::ReqTypeName() Warning: Using ReqTypeName() "
@@ -395,7 +395,7 @@
       public: virtual std::string RepTypeName() const
       {
         if (this->repMsg)
-          return this->repMsg->GetTypeName();
+          return std::string(this->repMsg->GetTypeName());
         else
         {
           std::cerr << "ReqHandler::RepTypeName() Warning: Using RepTypeName() "
diff -uar gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/SubscriptionHandler.hh gz-transport-gz-transport12_12.2.2.new/include/gz/transport/SubscriptionHandler.hh
--- gz-transport-gz-transport12_12.2.2.orig/include/gz/transport/SubscriptionHandler.hh	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/include/gz/transport/SubscriptionHandler.hh	2025-07-07 17:13:08.673122324 +0800
@@ -184,7 +184,7 @@
       // Documentation inherited.
       public: std::string TypeName()
       {
-        return T().GetTypeName();
+        return std::string(T().GetTypeName());
       }
 
       /// \brief Set the callback for this handler.
@@ -211,7 +211,13 @@
           return true;
 
 #if GOOGLE_PROTOBUF_VERSION >= 4022000
-        auto msgPtr = google::protobuf::internal::DownCast<const T*>(&_msg);
+        auto msgPtr = dynamic_cast<const T*>(&_msg);
+        if (!msgPtr)
+        {
+          std::cerr << "SubscriptionHandler::RunLocalCallback() error: "
+                    << "dynamic_cast failed" << std::endl;
+          return false;
+        }
 #elif GOOGLE_PROTOBUF_VERSION >= 3000000
         auto msgPtr = google::protobuf::down_cast<const T*>(&_msg);
 #else
diff -uar gz-transport-gz-transport12_12.2.2.orig/parameters/src/Client.cc gz-transport-gz-transport12_12.2.2.new/parameters/src/Client.cc
--- gz-transport-gz-transport12_12.2.2.orig/parameters/src/Client.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/parameters/src/Client.cc	2025-07-07 17:27:01.814112309 +0800
@@ -216,7 +216,7 @@
     return ParameterResult{
       ParameterResultType::InvalidType,
       _parameterName,
-      _msg.GetDescriptor()->name()};
+      std::string(_msg.GetDescriptor()->name())};
   }
   return ParameterResult{ParameterResultType::Unexpected, _parameterName};
 }
diff -uar gz-transport-gz-transport12_12.2.2.orig/parameters/src/Registry.cc gz-transport-gz-transport12_12.2.2.new/parameters/src/Registry.cc
--- gz-transport-gz-transport12_12.2.2.orig/parameters/src/Registry.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/parameters/src/Registry.cc	2025-07-07 17:28:17.423111400 +0800
@@ -144,7 +144,7 @@
       auto * decl = _res.add_parameter_declarations();
       decl->set_name(paramPair.first);
       decl->set_type(addGzMsgsPrefix(
-        paramPair.second->GetDescriptor()->name()));
+        std::string(paramPair.second->GetDescriptor()->name())));
     }
   }
   return true;
@@ -238,7 +238,7 @@
   const std::string & _parameterName,
   const google::protobuf::Message & _msg)
 {
-  auto protoType = addGzMsgsPrefix(_msg.GetDescriptor()->name());
+  auto protoType = addGzMsgsPrefix(std::string(_msg.GetDescriptor()->name()));
   auto newParam = gz::msgs::Factory::New(protoType);
   if (!newParam) {
     return ParameterResult{
@@ -264,8 +264,8 @@
       ParameterResultType::NotDeclared,
       _parameterName};
   }
-  const auto & newProtoType = _parameter.GetDescriptor()->name();
-  const auto & protoType = it->second->GetDescriptor()->name();
+  const auto & newProtoType = std::string(_parameter.GetDescriptor()->name());
+  const auto & protoType = std::string(it->second->GetDescriptor()->name());
   if (newProtoType != protoType) {
     return ParameterResult{
       ParameterResultType::InvalidType,
@@ -289,7 +289,7 @@
       ParameterResultType::NotDeclared,
       _parameterName};
   }
-  const auto & protoType = it->second->GetDescriptor()->name();
+  const auto & protoType = std::string(it->second->GetDescriptor()->name());
   _parameter = gz::msgs::Factory::New(protoType);
   if (!_parameter) {
     return ParameterResult{
@@ -320,7 +320,7 @@
     return ParameterResult{
       ParameterResultType::InvalidType,
       _parameterName,
-      addGzMsgsPrefix(it->second->GetDescriptor()->name())};
+      addGzMsgsPrefix(std::string(it->second->GetDescriptor()->name()))};
   }
   it->second = std::move(_value);
   return ParameterResult{ParameterResultType::Success};
diff -uar gz-transport-gz-transport12_12.2.2.orig/src/CIface_TEST.cc gz-transport-gz-transport12_12.2.2.new/src/CIface_TEST.cc
--- gz-transport-gz-transport12_12.2.2.orig/src/CIface_TEST.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/src/CIface_TEST.cc	2025-07-07 17:17:13.756119378 +0800
@@ -96,7 +96,7 @@
   msg.SerializeToArray(buffer, size);
 
   EXPECT_EQ(0,
-    gzTransportPublish(node, topic, buffer, msg.GetTypeName().c_str()));
+    gzTransportPublish(node, topic, buffer, std::string(msg.GetTypeName()).c_str()));
 
   EXPECT_EQ(2, count);
 
@@ -105,7 +105,7 @@
   // Unsubscribe
   ASSERT_EQ(0, gzTransportUnsubscribe(node, topic));
   EXPECT_EQ(0,
-    gzTransportPublish(node, topic, buffer, msg.GetTypeName().c_str()));
+    gzTransportPublish(node, topic, buffer, std::string(msg.GetTypeName()).c_str()));
   EXPECT_EQ(0, count);
 
   free(buffer);
@@ -153,12 +153,12 @@
 
   // Publish on "bar" partition
   EXPECT_EQ(0,
-    gzTransportPublish(nodeBar, topic, buffer, msg.GetTypeName().c_str()));
+    gzTransportPublish(nodeBar, topic, buffer, std::string(msg.GetTypeName()).c_str()));
   EXPECT_EQ(1, count);
 
   // Publish on default partition
   EXPECT_EQ(0,
-    gzTransportPublish(nodeBar, topic, buffer, msg.GetTypeName().c_str()));
+    gzTransportPublish(nodeBar, topic, buffer, std::string(msg.GetTypeName()).c_str()));
   EXPECT_EQ(2, count);
 
   count = 0;
@@ -166,7 +166,7 @@
   // Unsubscribe
   ASSERT_EQ(0, gzTransportUnsubscribe(nodeBar, topic));
   EXPECT_EQ(0,
-    gzTransportPublish(nodeBar, topic, buffer, msg.GetTypeName().c_str()));
+    gzTransportPublish(nodeBar, topic, buffer, std::string(msg.GetTypeName()).c_str()));
   EXPECT_EQ(0, count);
 
   free(buffer);
diff -uar gz-transport-gz-transport12_12.2.2.orig/src/cmd/gz.cc gz-transport-gz-transport12_12.2.2.new/src/cmd/gz.cc
--- gz-transport-gz-transport12_12.2.2.orig/src/cmd/gz.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/src/cmd/gz.cc	2025-07-07 17:23:28.582114872 +0800
@@ -162,7 +162,7 @@
   {
     // Create the node and advertise the topic
     Node node;
-    auto pub = node.Advertise(_topic, msg->GetTypeName());
+    auto pub = node.Advertise(_topic, std::string(msg->GetTypeName()));
 
     // Publish the message
     if (pub)
diff -uar gz-transport-gz-transport12_12.2.2.orig/src/HandlerStorage_TEST.cc gz-transport-gz-transport12_12.2.2.new/src/HandlerStorage_TEST.cc
--- gz-transport-gz-transport12_12.2.2.orig/src/HandlerStorage_TEST.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/src/HandlerStorage_TEST.cc	2025-07-07 17:17:46.532118984 +0800
@@ -67,8 +67,8 @@
   msgs::Int32 rep1Msg;
   bool result;
   msgs::Vector3d reqMsg;
-  std::string reqType = reqMsg.GetTypeName();
-  std::string rep1Type = rep1Msg.GetTypeName();
+  std::string reqType = std::string(reqMsg.GetTypeName());
+  std::string rep1Type = std::string(rep1Msg.GetTypeName());
 
   reqMsg.set_x(1.0);
   reqMsg.set_y(2.0);
@@ -232,7 +232,7 @@
   EXPECT_FALSE(subs.FirstHandler(topic, "incorrect type", handler));
 
   // Now try to retrieve the first callback with the correct type.
-  EXPECT_TRUE(subs.FirstHandler(topic, msg.GetTypeName(), handler));
+  EXPECT_TRUE(subs.FirstHandler(topic, std::string(msg.GetTypeName()), handler));
 
   // Verify the handler.
   EXPECT_EQ(handler->TypeName(), sub1HandlerPtr->TypeName());
diff -uar gz-transport-gz-transport12_12.2.2.orig/src/Node.cc gz-transport-gz-transport12_12.2.2.new/src/Node.cc
--- gz-transport-gz-transport12_12.2.2.orig/src/Node.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/src/Node.cc	2025-07-07 17:14:16.412121510 +0800
@@ -418,7 +418,7 @@
     };
 
     if (!this->dataPtr->shared->Publish(this->dataPtr->publisher.Topic(),
-          msgBuffer, msgSize, myDeallocator, _msg.GetTypeName()))
+          msgBuffer, msgSize, myDeallocator, std::string(_msg.GetTypeName())))
     {
       return false;
     }
diff -uar gz-transport-gz-transport12_12.2.2.orig/src/Node_TEST.cc gz-transport-gz-transport12_12.2.2.new/src/Node_TEST.cc
--- gz-transport-gz-transport12_12.2.2.orig/src/Node_TEST.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/src/Node_TEST.cc	2025-07-07 17:20:54.837116720 +0800
@@ -346,8 +346,8 @@
     // Request a valid service using RequestRaw.
     std::string reqStr, repStr, repTypeName;
     req.SerializeToString(&reqStr);
-    EXPECT_TRUE(this->node.RequestRaw(g_topic, reqStr, req.GetTypeName(),
-          rep.GetTypeName(), timeout, repStr, result));
+    EXPECT_TRUE(this->node.RequestRaw(g_topic, reqStr, std::string(req.GetTypeName()),
+          std::string(rep.GetTypeName()), timeout, repStr, result));
     rep.ParseFromString(repStr);
     ASSERT_TRUE(result);
     EXPECT_EQ(rep.data(), data);
@@ -541,7 +541,7 @@
   EXPECT_TRUE(node1.SubscribedTopics().empty());
   EXPECT_TRUE(node1.AdvertisedServices().empty());
 
-  auto pub1 = node1.Advertise(g_topic, msg.GetTypeName());
+  auto pub1 = node1.Advertise(g_topic, std::string(msg.GetTypeName()));
   EXPECT_TRUE(pub1);
 
   auto advertisedTopics = node1.AdvertisedTopics();
@@ -730,7 +730,7 @@
   std::this_thread::sleep_for(std::chrono::milliseconds(100));
 
   // Publish a first message.
-  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName()));
+  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName())));
 
   // Give some time to the subscribers.
   std::this_thread::sleep_for(std::chrono::milliseconds(100));
@@ -741,7 +741,7 @@
   reset();
 
   // Publish a second message on topic.
-  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName()));
+  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName())));
 
   // Give some time to the subscribers.
   std::this_thread::sleep_for(std::chrono::milliseconds(100));
@@ -770,7 +770,7 @@
   std::this_thread::sleep_for(std::chrono::milliseconds(100));
 
   // Publish a first message.
-  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName()));
+  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName())));
 
   // Give some time to the subscribers.
   std::this_thread::sleep_for(std::chrono::milliseconds(100));
@@ -781,7 +781,7 @@
   reset();
 
   // Publish a second message on topic.
-  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName()));
+  EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName())));
 
   // Give some time to the subscribers.
   std::this_thread::sleep_for(std::chrono::milliseconds(100));
diff -uar gz-transport-gz-transport12_12.2.2.orig/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc gz-transport-gz-transport12_12.2.2.new/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc
--- gz-transport-gz-transport12_12.2.2.orig/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/test/integration/test_executables/twoProcsPubSubSubscriber_aux.cc	2025-07-07 17:26:12.086112907 +0800
@@ -100,7 +100,7 @@
 
   // Add a raw subscription to `node`
   EXPECT_TRUE(node.SubscribeRaw(g_topic, cbRaw,
-                                msgs::Vector3d().GetTypeName()));
+                                std::string(msgs::Vector3d().GetTypeName())));
 
   int interval = 100;
 
diff -uar gz-transport-gz-transport12_12.2.2.orig/test/integration/twoProcsPubSub.cc gz-transport-gz-transport12_12.2.2.new/test/integration/twoProcsPubSub.cc
--- gz-transport-gz-transport12_12.2.2.orig/test/integration/twoProcsPubSub.cc	2024-11-08 04:08:54.000000000 +0800
+++ gz-transport-gz-transport12_12.2.2.new/test/integration/twoProcsPubSub.cc	2025-07-07 17:24:30.918114123 +0800
@@ -166,7 +166,7 @@
   // Publish messages for a few seconds
   for (auto i = 0; i < 10; ++i)
   {
-    EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), msg.GetTypeName()));
+    EXPECT_TRUE(pub.PublishRaw(msg.SerializeAsString(), std::string(msg.GetTypeName())));
     std::this_thread::sleep_for(std::chrono::milliseconds(500));
   }
 }
@@ -204,7 +204,7 @@
 
   transport::Node node;
   EXPECT_TRUE(node.SubscribeRaw(g_topic, cbRaw,
-                                msgs::Int32().GetTypeName()));
+                                std::string(msgs::Int32().GetTypeName())));
 
   // Wait some time before publishing.
   std::this_thread::sleep_for(std::chrono::milliseconds(1500));
@@ -290,7 +290,7 @@
   transport::Node node3;
   EXPECT_TRUE(node1.SubscribeRaw(g_topic, wrongCb, "wrong.msg.type"));
   EXPECT_TRUE(node2.SubscribeRaw(g_topic, correctCb,
-                                 msgs::Vector3d().GetTypeName()));
+                                 std::string(msgs::Vector3d().GetTypeName())));
   EXPECT_TRUE(node3.SubscribeRaw(g_topic, genericCb));