void CompactArrayBuilderImpl::addImpl(UIdent Val) { if (Val.isValid()) { sourcekitd_uid_t uid = SKDUIDFromUIdent(Val); addScalar(uid, EntriesBuffer); } else { addScalar(sourcekitd_uid_t(nullptr), EntriesBuffer); } }
UIdent sourcekitd::UIdentFromSKDUID(sourcekitd_uid_t SKDUID) { // This should be used only for debugging/logging purposes. UIdent UID = UIDMap.get(SKDUID); if (UID.isValid()) return UID; xpc_connection_t Peer = MainConnection; if (!Peer) return UIdent(); xpc_object_t contents = xpc_array_create(nullptr, 0); xpc_array_set_uint64(contents, XPC_ARRAY_APPEND, (uint64_t)xpc::Message::UIDSynchronization); xpc_array_set_uint64(contents, XPC_ARRAY_APPEND, uintptr_t(SKDUID)); xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0); xpc_dictionary_set_value(msg, xpc::KeyInternalMsg, contents); xpc_release(contents); xpc_object_t reply = xpc_connection_send_message_with_reply_sync(Peer, msg); xpc_release(msg); if (xpc_get_type(reply) == XPC_TYPE_ERROR) { xpc_release(reply); return UIdent(); } assert(xpc_get_type(reply) == XPC_TYPE_DICTIONARY); const char *Str = xpc_dictionary_get_string(reply, xpc::KeyMsgResponse); UID = UIdent(Str); UID.setTag(SKDUID); UIDMap.set(SKDUID, UID); xpc_release(reply); return UID; }