From 6950d96b4694a124b04608826cdb0e388b7e308a Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 12 Nov 2017 21:19:49 -1000 Subject: [PATCH] Linux build fixes --- include/boo/graphicsdev/Vulkan.hpp | 2 +- lib/graphicsdev/Vulkan.cpp | 4 ++-- lib/inputdev/HIDDeviceUdev.cpp | 14 +++++++------- lib/x11/ApplicationUnix.cpp | 8 ++++---- lib/x11/ApplicationWayland.hpp | 16 ++++++++-------- lib/x11/ApplicationXlib.hpp | 18 +++++++++--------- lib/x11/WindowWayland.cpp | 4 ++-- lib/x11/WindowXlib.cpp | 8 ++++---- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/include/boo/graphicsdev/Vulkan.hpp b/include/boo/graphicsdev/Vulkan.hpp index 28a8e20..3226d95 100644 --- a/include/boo/graphicsdev/Vulkan.hpp +++ b/include/boo/graphicsdev/Vulkan.hpp @@ -75,7 +75,7 @@ struct VulkanContext }; std::unordered_map> m_windows; - void initVulkan(const char* appName); + void initVulkan(std::string_view appName); bool enumerateDevices(); void initDevice(); void initSwapChain(Window& windowCtx, VkSurfaceKHR surface, VkFormat format, VkColorSpaceKHR colorspace); diff --git a/lib/graphicsdev/Vulkan.cpp b/lib/graphicsdev/Vulkan.cpp index 1d3151d..47a98aa 100644 --- a/lib/graphicsdev/Vulkan.cpp +++ b/lib/graphicsdev/Vulkan.cpp @@ -260,7 +260,7 @@ static void demo_check_layers(const std::vector& } } -void VulkanContext::initVulkan(const char* appName) +void VulkanContext::initVulkan(std::string_view appName) { if (!glslang::InitializeProcess()) Log.report(logvisor::Fatal, "unable to initialize glslang"); @@ -346,7 +346,7 @@ void VulkanContext::initVulkan(const char* appName) VkApplicationInfo appInfo = {}; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appInfo.pNext = nullptr; - appInfo.pApplicationName = appName; + appInfo.pApplicationName = appName.data(); appInfo.applicationVersion = 1; appInfo.pEngineName = "Boo"; appInfo.engineVersion = 1; diff --git a/lib/inputdev/HIDDeviceUdev.cpp b/lib/inputdev/HIDDeviceUdev.cpp index 6e99be2..4a35410 100644 --- a/lib/inputdev/HIDDeviceUdev.cpp +++ b/lib/inputdev/HIDDeviceUdev.cpp @@ -82,7 +82,7 @@ class HIDDeviceUdev final : public IHIDDevice int i; char errStr[256]; std::unique_lock lk(device->m_initMutex); - udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.c_str()); + udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.data()); /* Get device file */ const char* dp = udev_device_get_devnode(udevDev); @@ -90,7 +90,7 @@ class HIDDeviceUdev final : public IHIDDevice if (fd < 0) { snprintf(errStr, 256, "Unable to open %s@%s: %s\n", - device->m_token.getProductName().c_str(), dp, strerror(errno)); + device->m_token.getProductName().data(), dp, strerror(errno)); device->m_devImp->deviceError(errStr); lk.unlock(); device->m_initCond.notify_one(); @@ -155,7 +155,7 @@ class HIDDeviceUdev final : public IHIDDevice static void _threadProcBTLL(std::shared_ptr device) { std::unique_lock lk(device->m_initMutex); - udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.c_str()); + udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.data()); /* Return control to main thread */ device->m_runningTransferLoop = true; @@ -177,7 +177,7 @@ class HIDDeviceUdev final : public IHIDDevice { char errStr[256]; std::unique_lock lk(device->m_initMutex); - udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.c_str()); + udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.data()); /* Get device file */ const char* dp = udev_device_get_devnode(udevDev); @@ -185,7 +185,7 @@ class HIDDeviceUdev final : public IHIDDevice if (fd < 0) { snprintf(errStr, 256, "Unable to open %s@%s: %s\n", - device->m_token.getProductName().c_str(), dp, strerror(errno)); + device->m_token.getProductName().data(), dp, strerror(errno)); device->m_devImp->deviceError(errStr); lk.unlock(); device->m_initCond.notify_one(); @@ -204,7 +204,7 @@ class HIDDeviceUdev final : public IHIDDevice if (ioctl(fd, HIDIOCGRDESCSIZE, &reportDescSize) == -1) { snprintf(errStr, 256, "Unable to ioctl(HIDIOCGRDESCSIZE) %s@%s: %s\n", - device->m_token.getProductName().c_str(), dp, strerror(errno)); + device->m_token.getProductName().data(), dp, strerror(errno)); device->m_devImp->deviceError(errStr); close(fd); return; @@ -216,7 +216,7 @@ class HIDDeviceUdev final : public IHIDDevice if (ioctl(fd, HIDIOCGRDESC, &reportDesc) == -1) { snprintf(errStr, 256, "Unable to ioctl(HIDIOCGRDESC) %s@%s: %s\n", - device->m_token.getProductName().c_str(), dp, strerror(errno)); + device->m_token.getProductName().data(), dp, strerror(errno)); device->m_devImp->deviceError(errStr); close(fd); return; diff --git a/lib/x11/ApplicationUnix.cpp b/lib/x11/ApplicationUnix.cpp index 9871dae..e4afbc9 100644 --- a/lib/x11/ApplicationUnix.cpp +++ b/lib/x11/ApplicationUnix.cpp @@ -50,13 +50,13 @@ namespace boo IApplication* APP = NULL; int ApplicationRun(IApplication::EPlatformType platform, IApplicationCallback& cb, - const std::string& uniqueName, - const std::string& friendlyName, - const std::string& pname, + std::string_view uniqueName, + std::string_view friendlyName, + std::string_view pname, const std::vector& args, bool singleInstance) { - std::string thrName = friendlyName + " Main Thread"; + std::string thrName = std::string(friendlyName) + " Main Thread"; logvisor::RegisterThreadName(thrName.c_str()); if (APP) return 1; diff --git a/lib/x11/ApplicationWayland.hpp b/lib/x11/ApplicationWayland.hpp index f6df2a1..6d44b4b 100644 --- a/lib/x11/ApplicationWayland.hpp +++ b/lib/x11/ApplicationWayland.hpp @@ -10,7 +10,7 @@ DBusConnection* RegisterDBus(const char* appName, bool& isFirst); namespace boo { -std::shared_ptr _WindowWaylandNew(const std::string& title); +std::shared_ptr _WindowWaylandNew(std::string_view title); class ApplicationWayland final : public IApplication { @@ -28,9 +28,9 @@ class ApplicationWayland final : public IApplication public: ApplicationWayland(IApplicationCallback& callback, - const std::string& uniqueName, - const std::string& friendlyName, - const std::string& pname, + std::string_view uniqueName, + std::string_view friendlyName, + std::string_view pname, const std::vector& args, bool singleInstance) : m_callback(callback), @@ -51,17 +51,17 @@ public: return 0; } - const std::string& getUniqueName() const + std::string_view getUniqueName() const { return m_uniqueName; } - const std::string& getFriendlyName() const + std::string_view getFriendlyName() const { return m_friendlyName; } - const std::string& getProcessName() const + std::string_view getProcessName() const { return m_pname; } @@ -71,7 +71,7 @@ public: return m_args; } - std::shared_ptr newWindow(const std::string& title, uint32_t drawSamples) + std::shared_ptr newWindow(std::string_view title, uint32_t drawSamples) { return _WindowWaylandNew(title); } diff --git a/lib/x11/ApplicationXlib.hpp b/lib/x11/ApplicationXlib.hpp index 801dc08..c4e305b 100644 --- a/lib/x11/ApplicationXlib.hpp +++ b/lib/x11/ApplicationXlib.hpp @@ -219,9 +219,9 @@ class ApplicationXlib final : public IApplication public: ApplicationXlib(IApplicationCallback& callback, - const std::string& uniqueName, - const std::string& friendlyName, - const std::string& pname, + std::string_view uniqueName, + std::string_view friendlyName, + std::string_view pname, const std::vector& args, bool singleInstance) : m_callback(callback), @@ -254,7 +254,7 @@ public: /* DBus single instance registration */ bool isFirst; - m_dbus = RegisterDBus(uniqueName.c_str(), isFirst); + m_dbus = RegisterDBus(uniqueName.data(), isFirst); if (m_singleInstance) { if (!isFirst) @@ -433,7 +433,7 @@ public: std::unique_lock innerLk(initmt); innerLk.unlock(); initcv.notify_one(); - std::string thrName = getFriendlyName() + " Client Thread"; + std::string thrName = std::string(getFriendlyName()) + " Client Thread"; logvisor::RegisterThreadName(thrName.c_str()); clientReturn = m_callback.appMain(this); pthread_kill(mainThread, SIGUSR2); @@ -507,17 +507,17 @@ public: return clientReturn; } - const std::string& getUniqueName() const + std::string_view getUniqueName() const { return m_uniqueName; } - const std::string& getFriendlyName() const + std::string_view getFriendlyName() const { return m_friendlyName; } - const std::string& getProcessName() const + std::string_view getProcessName() const { return m_pname; } @@ -527,7 +527,7 @@ public: return m_args; } - std::shared_ptr newWindow(const std::string& title, uint32_t drawSamples) + std::shared_ptr newWindow(std::string_view title, uint32_t drawSamples) { #if BOO_HAS_VULKAN std::shared_ptr newWindow = _WindowXlibNew(title, m_xDisp, m_xcbConn, m_xDefaultScreen, m_xIM, diff --git a/lib/x11/WindowWayland.cpp b/lib/x11/WindowWayland.cpp index 3b90574..0cdb71f 100644 --- a/lib/x11/WindowWayland.cpp +++ b/lib/x11/WindowWayland.cpp @@ -130,7 +130,7 @@ struct WindowWayland : IWindow return ""; } - void setTitle(const std::string& title) + void setTitle(std::string_view title) { } @@ -244,7 +244,7 @@ struct WindowWayland : IWindow }; -std::shared_ptr _WindowWaylandNew(const std::string& title) +std::shared_ptr _WindowWaylandNew(std::string_view title) { return std::make_shared(title); } diff --git a/lib/x11/WindowXlib.cpp b/lib/x11/WindowXlib.cpp index 27e0724..ac8053d 100644 --- a/lib/x11/WindowXlib.cpp +++ b/lib/x11/WindowXlib.cpp @@ -704,7 +704,7 @@ public: vk::init_dispatch_table_top(PFN_vkGetInstanceProcAddr(getVkProc)); if (m_ctx->m_instance == VK_NULL_HANDLE) - m_ctx->initVulkan(APP->getUniqueName().c_str()); + m_ctx->initVulkan(APP->getUniqueName()); vk::init_dispatch_table_middle(m_ctx->m_instance, false); if (!m_ctx->enumerateDevices()) @@ -1042,7 +1042,7 @@ public: XSetWMProtocols(m_xDisp, m_windowId, &S_ATOMS->m_wmDeleteWindow, 1); /* Set the title of the window */ - const unsigned char* c_title = (unsigned char*)title.c_str(); + const unsigned char* c_title = (unsigned char*)title.data(); XChangeProperty(m_xDisp, m_windowId, XA_WM_NAME, XA_STRING, 8, PropModeReplace, c_title, title.length()); /* Set the title of the window icon */ @@ -1133,7 +1133,7 @@ public: void setTitle(std::string_view title) { - const unsigned char* c_title = (unsigned char*)title.c_str(); + const unsigned char* c_title = (unsigned char*)title.data(); XLockDisplay(m_xDisp); XChangeProperty(m_xDisp, m_windowId, XA_WM_NAME, XA_STRING, 8, PropModeReplace, c_title, title.length()); @@ -2011,7 +2011,7 @@ public: } }; -std::shared_ptr _WindowXlibNew(const std::string& title, +std::shared_ptr _WindowXlibNew(std::string_view title, Display* display, void* xcbConn, int defaultScreen, XIM xIM, XIMStyle bestInputStyle, XFontSet fontset, GLXContext lastCtx, void* vulkanHandle, uint32_t drawSamples)