Skip to content

Commit 3db73fd

Browse files
authored
Merge pull request swiftlang#76617 from AreaZR/dictionary
Use xpc_dictionary_create_empty to create empty dictionaries
2 parents c21552f + 10107c5 commit 3db73fd

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

tools/SourceKit/tools/sourcekitd/bin/XPC/Client/sourcekitd.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ sourcekitd_response_t sourcekitd_send_request_sync(sourcekitd_object_t req) {
130130
}
131131

132132
xpc_connection_t Conn = getGlobalConnection();
133-
xpc_object_t contents = xpc_array_create(nullptr, 0);
133+
xpc_object_t contents = xpc_array_create_empty();
134134
xpc_array_append_value(contents, req);
135135

136-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
136+
xpc_object_t msg = xpc_dictionary_create_empty();
137137
xpc_dictionary_set_value(msg, xpc::KeyMsg, contents);
138138
xpc_release(contents);
139139

@@ -179,10 +179,10 @@ void sourcekitd_send_request(sourcekitd_object_t req,
179179
}
180180

181181
xpc_connection_t Conn = getGlobalConnection();
182-
xpc_object_t contents = xpc_array_create(nullptr, 0);
182+
xpc_object_t contents = xpc_array_create_empty();
183183
xpc_array_append_value(contents, req);
184184

185-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
185+
xpc_object_t msg = xpc_dictionary_create_empty();
186186
xpc_dictionary_set_value(msg, xpc::KeyMsg, contents);
187187
if (request_handle) {
188188
xpc_dictionary_set_uint64(msg, xpc::KeyCancelToken,
@@ -218,7 +218,7 @@ void sourcekitd_send_request(sourcekitd_object_t req,
218218

219219
void sourcekitd_cancel_request(sourcekitd_request_handle_t handle) {
220220
xpc_connection_t conn = getGlobalConnection();
221-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
221+
xpc_object_t msg = xpc_dictionary_create_empty();
222222
xpc_dictionary_set_uint64(msg, xpc::KeyCancelRequest,
223223
reinterpret_cast<uint64_t>(handle));
224224

@@ -229,7 +229,7 @@ void sourcekitd_cancel_request(sourcekitd_request_handle_t handle) {
229229

230230
void sourcekitd_request_handle_dispose(sourcekitd_request_handle_t handle) {
231231
xpc_connection_t conn = getGlobalConnection();
232-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
232+
xpc_object_t msg = xpc_dictionary_create_empty();
233233
xpc_dictionary_set_uint64(msg, xpc::KeyDisposeRequestHandle,
234234
reinterpret_cast<uint64_t>(handle));
235235

@@ -367,7 +367,7 @@ static xpc_connection_t getGlobalConnection() {
367367
static void pingService(xpc_connection_t ping_conn) {
368368
LOG_WARN_FUNC("pinging service");
369369

370-
xpc_object_t ping_msg = xpc_dictionary_create(nullptr, nullptr, 0);
370+
xpc_object_t ping_msg = xpc_dictionary_create_empty();
371371
xpc_dictionary_set_bool(ping_msg, "ping", true);
372372

373373
dispatch_queue_t queue

tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ static void postNotification(sourcekitd_response_t Notification) {
4141
goto done;
4242

4343
{
44-
xpc_object_t contents = xpc_array_create(nullptr, 0);
44+
xpc_object_t contents = xpc_array_create_empty();
4545
xpc_array_set_uint64(contents, XPC_ARRAY_APPEND,
4646
(uint64_t)xpc::Message::Notification);
4747
xpc_array_set_value(contents, XPC_ARRAY_APPEND, Notification);
4848

49-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
49+
xpc_object_t msg = xpc_dictionary_create_empty();
5050
xpc_dictionary_set_value(msg, xpc::KeyInternalMsg, contents);
5151
xpc_release(contents);
5252

@@ -85,12 +85,12 @@ static sourcekitd_uid_t xpcSKDUIDFromUIdent(UIdent UID) {
8585
if (!peer)
8686
return nullptr;
8787

88-
xpc_object_t contents = xpc_array_create(nullptr, 0);
88+
xpc_object_t contents = xpc_array_create_empty();
8989
xpc_array_set_uint64(contents, XPC_ARRAY_APPEND,
9090
(uint64_t)xpc::Message::UIDSynchronization);
9191
xpc_array_set_string(contents, XPC_ARRAY_APPEND, UID.c_str());
9292

93-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
93+
xpc_object_t msg = xpc_dictionary_create_empty();
9494
xpc_dictionary_set_value(msg, xpc::KeyInternalMsg, contents);
9595
xpc_release(contents);
9696

@@ -122,12 +122,12 @@ static UIdent xpcUIdentFromSKDUID(sourcekitd_uid_t SKDUID) {
122122
if (!Peer)
123123
return UIdent();
124124

125-
xpc_object_t contents = xpc_array_create(nullptr, 0);
125+
xpc_object_t contents = xpc_array_create_empty();
126126
xpc_array_set_uint64(contents, XPC_ARRAY_APPEND,
127127
(uint64_t)xpc::Message::UIDSynchronization);
128128
xpc_array_set_uint64(contents, XPC_ARRAY_APPEND, uintptr_t(SKDUID));
129129

130-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
130+
xpc_object_t msg = xpc_dictionary_create_empty();
131131
xpc_dictionary_set_value(msg, xpc::KeyInternalMsg, contents);
132132
xpc_release(contents);
133133

@@ -324,11 +324,11 @@ static void sourcekitdServer_peer_event_handler(xpc_connection_t peer,
324324
}
325325

326326
static void getInitializationInfo(xpc_connection_t peer) {
327-
xpc_object_t contents = xpc_array_create(nullptr, 0);
327+
xpc_object_t contents = xpc_array_create_empty();
328328
xpc_array_set_uint64(contents, XPC_ARRAY_APPEND,
329329
(uint64_t)xpc::Message::Initialization);
330330

331-
xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
331+
xpc_object_t msg = xpc_dictionary_create_empty();
332332
xpc_dictionary_set_value(msg, xpc::KeyInternalMsg, contents);
333333
xpc_release(contents);
334334

tools/SourceKit/tools/sourcekitd/lib/API/sourcekitdAPI-XPC.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void sourcekitd::printRequestObject(sourcekitd_object_t Obj, raw_ostream &OS) {
166166
//===----------------------------------------------------------------------===//
167167

168168
ResponseBuilder::ResponseBuilder() {
169-
Impl = xpc_dictionary_create(nullptr, nullptr, 0);
169+
Impl = xpc_dictionary_create_empty();
170170
}
171171

172172
ResponseBuilder::~ResponseBuilder() {
@@ -220,7 +220,7 @@ void ResponseBuilder::Dictionary::set(UIdent Key, int64_t val) {
220220
void ResponseBuilder::Dictionary::set(SourceKit::UIdent Key,
221221
ArrayRef<StringRef> Strs) {
222222
llvm::SmallString<128> Buf;
223-
xpc_object_t arr = xpc_array_create(nullptr, 0);
223+
xpc_object_t arr = xpc_array_create_empty();
224224
for (auto Str : Strs) {
225225
Buf = Str;
226226
xpc_array_set_string(arr, XPC_ARRAY_APPEND, Buf.c_str());
@@ -231,7 +231,7 @@ void ResponseBuilder::Dictionary::set(SourceKit::UIdent Key,
231231

232232
void ResponseBuilder::Dictionary::set(SourceKit::UIdent Key,
233233
ArrayRef<std::string> Strs) {
234-
xpc_object_t arr = xpc_array_create(nullptr, 0);
234+
xpc_object_t arr = xpc_array_create_empty();
235235
for (auto Str : Strs) {
236236
xpc_array_set_string(arr, XPC_ARRAY_APPEND, Str.c_str());
237237
}
@@ -241,7 +241,7 @@ void ResponseBuilder::Dictionary::set(SourceKit::UIdent Key,
241241

242242
void ResponseBuilder::Dictionary::set(SourceKit::UIdent Key,
243243
ArrayRef<SourceKit::UIdent> UIDs) {
244-
xpc_object_t arr = xpc_array_create(nullptr, 0);
244+
xpc_object_t arr = xpc_array_create_empty();
245245
for (auto UID : UIDs) {
246246
xpc_array_set_uint64(arr, XPC_ARRAY_APPEND, uintptr_t(SKDUIDFromUIdent(UID)));
247247
}
@@ -255,15 +255,15 @@ void ResponseBuilder::Dictionary::setBool(UIdent Key, bool val) {
255255

256256
ResponseBuilder::Array
257257
ResponseBuilder::Dictionary::setArray(UIdent Key) {
258-
xpc_object_t arr = xpc_array_create(nullptr, 0);
258+
xpc_object_t arr = xpc_array_create_empty();
259259
xpc_dictionary_set_value(Impl, Key.c_str(), arr);
260260
xpc_release(arr);
261261
return Array(arr);
262262
}
263263

264264
ResponseBuilder::Dictionary
265265
ResponseBuilder::Dictionary::setDictionary(UIdent Key) {
266-
xpc_object_t dict = xpc_dictionary_create(nullptr, nullptr, 0);
266+
xpc_object_t dict = xpc_dictionary_create_empty();
267267
xpc_dictionary_set_value(Impl, Key.c_str(), dict);
268268
xpc_release(dict);
269269
return Dictionary(dict);
@@ -278,7 +278,7 @@ void ResponseBuilder::Dictionary::setCustomBuffer(
278278
}
279279

280280
ResponseBuilder::Dictionary ResponseBuilder::Array::appendDictionary() {
281-
xpc_object_t dict = xpc_dictionary_create(nullptr, nullptr, 0);
281+
xpc_object_t dict = xpc_dictionary_create_empty();
282282
xpc_array_append_value(Impl, dict);
283283
xpc_release(dict);
284284
return Dictionary(dict);

0 commit comments

Comments
 (0)