Fix build with C++20 including nat's changes to fsyspath
parent
94a4442660
commit
635c34a17b
|
|
@ -34,38 +34,6 @@
|
|||
#include "llmath.h"
|
||||
#include "llapr.h"
|
||||
|
||||
//#if LL_DARWIN
|
||||
// MBW -- XXX -- Getting rid of SecondLifeVorbis for now
|
||||
#if 0
|
||||
#include "VorbisFramework.h"
|
||||
|
||||
#define vorbis_analysis mac_vorbis_analysis
|
||||
#define vorbis_analysis_headerout mac_vorbis_analysis_headerout
|
||||
#define vorbis_analysis_init mac_vorbis_analysis_init
|
||||
#define vorbis_encode_ctl mac_vorbis_encode_ctl
|
||||
#define vorbis_encode_setup_init mac_vorbis_encode_setup_init
|
||||
#define vorbis_encode_setup_managed mac_vorbis_encode_setup_managed
|
||||
|
||||
#define vorbis_info_init mac_vorbis_info_init
|
||||
#define vorbis_info_clear mac_vorbis_info_clear
|
||||
#define vorbis_comment_init mac_vorbis_comment_init
|
||||
#define vorbis_comment_clear mac_vorbis_comment_clear
|
||||
#define vorbis_block_init mac_vorbis_block_init
|
||||
#define vorbis_block_clear mac_vorbis_block_clear
|
||||
#define vorbis_dsp_clear mac_vorbis_dsp_clear
|
||||
#define vorbis_analysis_buffer mac_vorbis_analysis_buffer
|
||||
#define vorbis_analysis_wrote mac_vorbis_analysis_wrote
|
||||
#define vorbis_analysis_blockout mac_vorbis_analysis_blockout
|
||||
|
||||
#define ogg_stream_packetin mac_ogg_stream_packetin
|
||||
#define ogg_stream_init mac_ogg_stream_init
|
||||
#define ogg_stream_flush mac_ogg_stream_flush
|
||||
#define ogg_stream_pageout mac_ogg_stream_pageout
|
||||
#define ogg_page_eos mac_ogg_page_eos
|
||||
#define ogg_stream_clear mac_ogg_stream_clear
|
||||
|
||||
#endif
|
||||
|
||||
S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& error_msg)
|
||||
{
|
||||
U16 num_channels = 0;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@
|
|||
#if ! defined(LL_FSYSPATH_H)
|
||||
#define LL_FSYSPATH_H
|
||||
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
// While std::filesystem::path can be directly constructed from std::string on
|
||||
// both Posix and Windows, that's not what we want on Windows. Per
|
||||
|
|
@ -33,42 +36,55 @@
|
|||
// char"), the "native narrow encoding" isn't UTF-8, so file paths containing
|
||||
// non-ASCII characters get mangled.
|
||||
//
|
||||
// Once we're building with C++20, we could pass a UTF-8 std::string through a
|
||||
// vector<char8_t> to engage std::filesystem::path's own UTF-8 conversion. But
|
||||
// sigh, as of 2024-04-03 we're not yet there.
|
||||
//
|
||||
// Anyway, encapsulating the important UTF-8 conversions in our own subclass
|
||||
// allows us to migrate forward to C++20 conventions without changing
|
||||
// referencing code.
|
||||
// Encapsulating the important UTF-8 conversions in our own subclass allows us
|
||||
// to migrate forward to C++20 conventions without changing referencing code.
|
||||
|
||||
class fsyspath: public std::filesystem::path
|
||||
{
|
||||
using super = std::filesystem::path;
|
||||
|
||||
// In C++20 (__cpp_lib_char8_t), std::filesystem::u8path() is deprecated.
|
||||
// std::filesystem::path(iter, iter) performs UTF-8 conversions when the
|
||||
// value_type of the iterators is char8_t. While we could copy into a
|
||||
// temporary std::u8string and from there into std::filesystem::path, to
|
||||
// minimize string copying we'll define a transform_iterator that accepts
|
||||
// a std::string_view::iterator and dereferences to char8_t.
|
||||
struct u8ify
|
||||
{
|
||||
char8_t operator()(char c) const { return char8_t(c); }
|
||||
};
|
||||
using u8iter = boost::transform_iterator<u8ify, std::string_view::iterator>;
|
||||
|
||||
public:
|
||||
// default
|
||||
fsyspath() {}
|
||||
// construct from UTF-8 encoded std::string
|
||||
fsyspath(const std::string& path): super(std::filesystem::u8path(path)) {}
|
||||
// construct from UTF-8 encoded const char*
|
||||
fsyspath(const char* path): super(std::filesystem::u8path(path)) {}
|
||||
// construct from UTF-8 encoded string
|
||||
fsyspath(const std::string& path): fsyspath(std::string_view(path)) {}
|
||||
fsyspath(const char* path): fsyspath(std::string_view(path)) {}
|
||||
fsyspath(std::string_view path):
|
||||
super(u8iter(path.begin(), u8ify()), u8iter(path.end(), u8ify()))
|
||||
{}
|
||||
// construct from existing path
|
||||
fsyspath(const super& path): super(path) {}
|
||||
|
||||
fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
|
||||
fsyspath& operator=(const std::string& p)
|
||||
fsyspath& operator=(const super& p) { super::operator=(p); return *this; }
|
||||
fsyspath& operator=(const std::string& p) { return (*this) = std::string_view(p); }
|
||||
fsyspath& operator=(const char* p) { return (*this) = std::string_view(p); }
|
||||
fsyspath& operator=(std::string_view p)
|
||||
{
|
||||
super::operator=(std::filesystem::u8path(p));
|
||||
return *this;
|
||||
}
|
||||
fsyspath& operator=(const char* p)
|
||||
{
|
||||
super::operator=(std::filesystem::u8path(p));
|
||||
assign(u8iter(p.begin(), u8ify()), u8iter(p.end(), u8ify()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
// shadow base-class string() method with UTF-8 aware method
|
||||
std::string string() const { return super::u8string(); }
|
||||
std::string string() const
|
||||
{
|
||||
// Short of forbidden type punning, I see no way to avoid copying this
|
||||
// std::u8string to a std::string.
|
||||
auto u8str{ super::u8string() };
|
||||
// from https://github.com/tahonermann/char8_t-remediation/blob/master/char8_t-remediation.h#L180-L182
|
||||
return { u8str.begin(), u8str.end() };
|
||||
}
|
||||
// On Posix systems, where value_type is already char, this operator
|
||||
// std::string() method shadows the base class operator string_type()
|
||||
// method. But on Windows, where value_type is wchar_t, the base class
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ size_t LLQueuedThread::updateQueue(F32 max_time_ms)
|
|||
// schedule a call to threadedUpdate for every call to updateQueue
|
||||
if (!isQuitting())
|
||||
{
|
||||
mRequestQueue.post([=]()
|
||||
mRequestQueue.post([=, this]()
|
||||
{
|
||||
LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("qt - update");
|
||||
mIdleThread = false;
|
||||
|
|
@ -474,7 +474,7 @@ void LLQueuedThread::processRequest(LLQueuedThread::QueuedRequest* req)
|
|||
#else
|
||||
using namespace std::chrono_literals;
|
||||
auto retry_time = LL::WorkQueue::TimePoint::clock::now() + 16ms;
|
||||
mRequestQueue.post([=]
|
||||
mRequestQueue.post([=, this]
|
||||
{
|
||||
LL_PROFILE_ZONE_NAMED("processRequest - retry");
|
||||
if (LL::WorkQueue::TimePoint::clock::now() < retry_time)
|
||||
|
|
|
|||
|
|
@ -715,7 +715,7 @@ void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, ll
|
|||
if (error == FT_Err_Out_Of_Memory)
|
||||
{
|
||||
LLError::LLUserWarningMsg::showOutOfMemory();
|
||||
LL_ERRS() << "Out of memory loading glyph for character " << wch << LL_ENDL;
|
||||
LL_ERRS() << "Out of memory loading glyph for character " << U32(wch) << LL_ENDL;
|
||||
}
|
||||
|
||||
std::string message = llformat(
|
||||
|
|
|
|||
|
|
@ -1773,7 +1773,7 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name)
|
|||
ref();
|
||||
LL::WorkQueue::postMaybe(
|
||||
mMainQueue,
|
||||
[=]()
|
||||
[=, this]()
|
||||
{
|
||||
LL_PROFILE_ZONE_NAMED("cglt - delete callback");
|
||||
syncTexName(new_tex_name);
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ F32 LLWindowMacOSX::getGamma()
|
|||
&greenGamma,
|
||||
&blueMin,
|
||||
&blueMax,
|
||||
&blueGamma) == noErr)
|
||||
&blueGamma) == kCGErrorSuccess)
|
||||
{
|
||||
// So many choices...
|
||||
// Let's just return the green channel gamma for now.
|
||||
|
|
@ -1111,7 +1111,7 @@ bool LLWindowMacOSX::setGamma(const F32 gamma)
|
|||
&greenGamma,
|
||||
&blueMin,
|
||||
&blueMax,
|
||||
&blueGamma) != noErr)
|
||||
&blueGamma) != kCGErrorSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1126,7 +1126,7 @@ bool LLWindowMacOSX::setGamma(const F32 gamma)
|
|||
gamma,
|
||||
blueMin,
|
||||
blueMax,
|
||||
gamma) != noErr)
|
||||
gamma) != kCGErrorSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1178,7 +1178,7 @@ bool LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)
|
|||
newPosition.y = screen_pos.mY;
|
||||
|
||||
CGSetLocalEventsSuppressionInterval(0.0);
|
||||
if(CGWarpMouseCursorPosition(newPosition) == noErr)
|
||||
if(CGWarpMouseCursorPosition(newPosition) == kCGErrorSuccess)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -500,7 +500,7 @@ void GLTFSceneManager::update()
|
|||
LLNewBufferedResourceUploadInfo::uploadFinish_f finish = [this, buffer](LLUUID assetId, LLSD response)
|
||||
{
|
||||
LLAppViewer::instance()->postToMainCoro(
|
||||
[=]()
|
||||
[=, this]()
|
||||
{
|
||||
if (mUploadingAsset)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -548,8 +548,8 @@ LLViewerFetchedTexture* LLMeshUploadThread::FindViewerTexture(const LLImportMate
|
|||
return ppTex ? (*ppTex).get() : NULL;
|
||||
}
|
||||
|
||||
volatile S32 LLMeshRepoThread::sActiveHeaderRequests = 0;
|
||||
volatile S32 LLMeshRepoThread::sActiveLODRequests = 0;
|
||||
std::atomic<S32> LLMeshRepoThread::sActiveHeaderRequests = 0;
|
||||
std::atomic<S32> LLMeshRepoThread::sActiveLODRequests = 0;
|
||||
U32 LLMeshRepoThread::sMaxConcurrentRequests = 1;
|
||||
S32 LLMeshRepoThread::sRequestLowWater = REQUEST2_LOW_WATER_MIN;
|
||||
S32 LLMeshRepoThread::sRequestHighWater = REQUEST2_HIGH_WATER_MIN;
|
||||
|
|
@ -3916,7 +3916,7 @@ void LLMeshRepository::notifyLoadedMeshes()
|
|||
}
|
||||
|
||||
// erase from background thread
|
||||
mThread->mWorkQueue.post([=]()
|
||||
mThread->mWorkQueue.post([=, this]()
|
||||
{
|
||||
mThread->mSkinMap.erase(id);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -256,8 +256,8 @@ class LLMeshRepoThread : public LLThread
|
|||
{
|
||||
public:
|
||||
|
||||
volatile static S32 sActiveHeaderRequests;
|
||||
volatile static S32 sActiveLODRequests;
|
||||
static std::atomic<S32> sActiveHeaderRequests;
|
||||
static std::atomic<S32> sActiveLODRequests;
|
||||
static U32 sMaxConcurrentRequests;
|
||||
static S32 sRequestLowWater;
|
||||
static S32 sRequestHighWater;
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ void LLPanelEmojiComplete::updateConstraints()
|
|||
{
|
||||
mRenderRect = getLocalRect();
|
||||
|
||||
mEmojiWidth = (U16)(mIconFont->getWidthF32(u8"\U0001F431") + mPadding * 2);
|
||||
mEmojiWidth = (U16)(mIconFont->getWidthF32(LLWString(1, 0x1F431).c_str()) + mPadding * 2);
|
||||
if (mVertical)
|
||||
{
|
||||
mEmojiHeight = mIconFont->getLineHeight() + mPadding * 2;
|
||||
|
|
|
|||
|
|
@ -2843,7 +2843,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, S3
|
|||
bool LLTextureFetch::updateRequestPriority(const LLUUID& id, F32 priority)
|
||||
{
|
||||
LL_PROFILE_ZONE_SCOPED;
|
||||
mRequestQueue.tryPost([=]()
|
||||
mRequestQueue.tryPost([=, this]()
|
||||
{
|
||||
LLTextureFetchWorker* worker = getWorker(id);
|
||||
if (worker)
|
||||
|
|
@ -3571,8 +3571,8 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
|
|||
//if (! gViewerAssetStatsThread1)
|
||||
// return true;
|
||||
|
||||
static volatile bool reporting_started(false);
|
||||
static volatile S32 report_sequence(0);
|
||||
static std::atomic_bool reporting_started(false);
|
||||
static std::atomic_int report_sequence(0);
|
||||
|
||||
// In mStatsSD, we have a copy we own of the LLSD representation
|
||||
// of the asset stats. Add some additional fields and ship it off.
|
||||
|
|
|
|||
|
|
@ -2902,14 +2902,14 @@ void LLViewerMediaImpl::update()
|
|||
media_tex->ref();
|
||||
main_queue->postTo(
|
||||
mTexUpdateQueue, // Worker thread queue
|
||||
[=]() // work done on update worker thread
|
||||
[=, this]() // work done on update worker thread
|
||||
{
|
||||
#if LL_IMAGEGL_THREAD_CHECK
|
||||
media_tex->getGLTexture()->mActiveThread = LLThread::currentID();
|
||||
#endif
|
||||
doMediaTexUpdate(media_tex, data, data_width, data_height, x_pos, y_pos, width, height, true);
|
||||
},
|
||||
[=]() // callback to main thread
|
||||
[=, this]() // callback to main thread
|
||||
{
|
||||
#if LL_IMAGEGL_THREAD_CHECK
|
||||
media_tex->getGLTexture()->mActiveThread = LLThread::currentID();
|
||||
|
|
|
|||
|
|
@ -1331,7 +1331,7 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi
|
|||
// Check the whitelist, if there's media (otherwise just show it)
|
||||
if (te->getMediaData() == NULL || te->getMediaData()->checkCandidateUrl(url))
|
||||
{
|
||||
if ( obj != mDragHoveredObject)
|
||||
if ( obj != mDragHoveredObject.get())
|
||||
{
|
||||
// Highlight the dragged object
|
||||
LLSelectMgr::getInstance()->unhighlightObjectOnly(mDragHoveredObject);
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ void LLWebRTCVoiceClient::voiceConnectionCoro()
|
|||
}
|
||||
}
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=] {
|
||||
[=, this] {
|
||||
if (sShuttingDown)
|
||||
{
|
||||
return;
|
||||
|
|
@ -674,7 +674,7 @@ void LLWebRTCVoiceClient::OnDevicesChanged(const llwebrtc::LLWebRTCVoiceDeviceLi
|
|||
{
|
||||
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=]
|
||||
[=, this]
|
||||
{
|
||||
OnDevicesChangedImpl(render_devices, capture_devices);
|
||||
});
|
||||
|
|
@ -2211,7 +2211,7 @@ LLVoiceWebRTCConnection::~LLVoiceWebRTCConnection()
|
|||
void LLVoiceWebRTCConnection::OnIceGatheringState(llwebrtc::LLWebRTCSignalingObserver::EIceGatheringState state)
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=] {
|
||||
[=, this] {
|
||||
LL_DEBUGS("Voice") << "Ice Gathering voice account. " << state << LL_ENDL;
|
||||
|
||||
switch (state)
|
||||
|
|
@ -2234,7 +2234,7 @@ void LLVoiceWebRTCConnection::OnIceGatheringState(llwebrtc::LLWebRTCSignalingObs
|
|||
// callback from llwebrtc
|
||||
void LLVoiceWebRTCConnection::OnIceCandidate(const llwebrtc::LLWebRTCIceCandidate& candidate)
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue, [=] { mIceCandidates.push_back(candidate); });
|
||||
LL::WorkQueue::postMaybe(mMainQueue, [=, this] { mIceCandidates.push_back(candidate); });
|
||||
}
|
||||
|
||||
void LLVoiceWebRTCConnection::processIceUpdates()
|
||||
|
|
@ -2352,7 +2352,7 @@ void LLVoiceWebRTCConnection::processIceUpdatesCoro(connectionPtr_t connection)
|
|||
void LLVoiceWebRTCConnection::OnOfferAvailable(const std::string &sdp)
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=] {
|
||||
[=, this] {
|
||||
if (mShutDown)
|
||||
{
|
||||
return;
|
||||
|
|
@ -2379,7 +2379,7 @@ void LLVoiceWebRTCConnection::OnOfferAvailable(const std::string &sdp)
|
|||
void LLVoiceWebRTCConnection::OnAudioEstablished(llwebrtc::LLWebRTCAudioInterface* audio_interface)
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=] {
|
||||
[=, this] {
|
||||
if (mShutDown)
|
||||
{
|
||||
return;
|
||||
|
|
@ -2401,7 +2401,7 @@ void LLVoiceWebRTCConnection::OnAudioEstablished(llwebrtc::LLWebRTCAudioInterfac
|
|||
void LLVoiceWebRTCConnection::OnRenegotiationNeeded()
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=] {
|
||||
[=, this] {
|
||||
LL_DEBUGS("Voice") << "Voice channel requires renegotiation." << LL_ENDL;
|
||||
if (!mShutDown)
|
||||
{
|
||||
|
|
@ -2415,7 +2415,7 @@ void LLVoiceWebRTCConnection::OnRenegotiationNeeded()
|
|||
void LLVoiceWebRTCConnection::OnPeerConnectionClosed()
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=] {
|
||||
[=, this] {
|
||||
LL_DEBUGS("Voice") << "Peer connection has closed." << LL_ENDL;
|
||||
if (mVoiceConnectionState == VOICE_STATE_WAIT_FOR_CLOSE)
|
||||
{
|
||||
|
|
@ -2843,9 +2843,13 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
|
|||
}
|
||||
// else was already posted by llwebrtc::terminate().
|
||||
break;
|
||||
}
|
||||
|
||||
case VOICE_STATE_WAIT_FOR_CLOSE:
|
||||
break;
|
||||
|
||||
case VOICE_STATE_CLOSED:
|
||||
{
|
||||
if (!mShutDown)
|
||||
{
|
||||
mVoiceConnectionState = VOICE_STATE_START_SESSION;
|
||||
|
|
@ -2888,7 +2892,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
|
|||
// llwebrtc callback
|
||||
void LLVoiceWebRTCConnection::OnDataReceived(const std::string& data, bool binary)
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue, [=] { LLVoiceWebRTCConnection::OnDataReceivedImpl(data, binary); });
|
||||
LL::WorkQueue::postMaybe(mMainQueue, [=, this] { LLVoiceWebRTCConnection::OnDataReceivedImpl(data, binary); });
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -3044,7 +3048,7 @@ void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool b
|
|||
void LLVoiceWebRTCConnection::OnDataChannelReady(llwebrtc::LLWebRTCDataInterface *data_interface)
|
||||
{
|
||||
LL::WorkQueue::postMaybe(mMainQueue,
|
||||
[=] {
|
||||
[=, this] {
|
||||
if (mShutDown)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params)
|
|||
// Launch a coroutine with our login_() method. Run the coroutine until
|
||||
// its first wait; at that point, return here.
|
||||
std::string coroname =
|
||||
LLCoros::instance().launch("LLLogin::Impl::login_", [=]() { loginCoro(uri, login_params); });
|
||||
LLCoros::instance().launch("LLLogin::Impl::login_", [=, this]() { loginCoro(uri, login_params); });
|
||||
|
||||
LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue