Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -24,21 +24,21 @@ struct Watch {
RunLoop::Event watchEvent = RunLoop::Event::None;
switch (event) {
case UV_READABLE:
watchEvent = RunLoop::Event::Read;
break;
case UV_WRITABLE:
watchEvent = RunLoop::Event::Write;
break;
case UV_READABLE | UV_WRITABLE:
watchEvent = RunLoop::Event::ReadWrite;
break;
case UV_READABLE:
watchEvent = RunLoop::Event::Read;
break;
case UV_WRITABLE:
watchEvent = RunLoop::Event::Write;
break;
case UV_READABLE | UV_WRITABLE:
watchEvent = RunLoop::Event::ReadWrite;
break;
}
watch->eventCallback(watch->fd, watchEvent);
};
static void onClose(uv_handle_t *poll) {
static void onClose(uv_handle_t* poll) {
auto watch = reinterpret_cast<Watch*>(poll->data);
watch->closeCallback();
};
@@ -58,16 +58,12 @@ RunLoop* RunLoop::Get() {
class RunLoop::Impl {
public:
void closeHolder() {
uv_close(holderHandle(), [](uv_handle_t* h) {
delete reinterpret_cast<uv_async_t*>(h);
});
uv_close(holderHandle(), [](uv_handle_t* h) { delete reinterpret_cast<uv_async_t*>(h); });
}
uv_handle_t* holderHandle() {
return reinterpret_cast<uv_handle_t*>(holder);
}
uv_handle_t* holderHandle() { return reinterpret_cast<uv_handle_t*>(holder); }
uv_loop_t *loop = nullptr;
uv_loop_t* loop = nullptr;
uv_async_t* holder = new uv_async_t;
RunLoop::Type type;
@@ -76,17 +72,18 @@ public:
std::unordered_map<int, std::unique_ptr<Watch>> watchPoll;
};
RunLoop::RunLoop(Type type) : impl(std::make_unique<Impl>()) {
RunLoop::RunLoop(Type type)
: impl(std::make_unique<Impl>()) {
switch (type) {
case Type::New:
impl->loop = new uv_loop_t;
if (uv_loop_init(impl->loop) != 0) {
throw std::runtime_error("Failed to initialize loop.");
}
break;
case Type::Default:
impl->loop = uv_default_loop();
break;
case Type::New:
impl->loop = new uv_loop_t;
if (uv_loop_init(impl->loop) != 0) {
throw std::runtime_error("Failed to initialize loop.");
}
break;
case Type::Default:
impl->loop = uv_default_loop();
break;
}
// Just for holding a ref to the main loop and keep
@@ -153,7 +150,7 @@ void RunLoop::stop() {
void RunLoop::addWatch(int fd, Event event, std::function<void(int, Event)>&& callback) {
MBGL_VERIFY_THREAD(tid);
Watch *watch = nullptr;
Watch* watch = nullptr;
auto watchPollIter = impl->watchPoll.find(fd);
if (watchPollIter == impl->watchPoll.end()) {
@@ -179,17 +176,17 @@ void RunLoop::addWatch(int fd, Event event, std::function<void(int, Event)>&& ca
int pollEvent = 0;
switch (event) {
case Event::Read:
pollEvent = UV_READABLE;
break;
case Event::Write:
pollEvent = UV_WRITABLE;
break;
case Event::ReadWrite:
pollEvent = UV_READABLE | UV_WRITABLE;
break;
default:
throw std::runtime_error("Unhandled event.");
case Event::Read:
pollEvent = UV_READABLE;
break;
case Event::Write:
pollEvent = UV_WRITABLE;
break;
case Event::ReadWrite:
pollEvent = UV_READABLE | UV_WRITABLE;
break;
default:
throw std::runtime_error("Unhandled event.");
}
if (uv_poll_start(&watch->poll, pollEvent, &Watch::onEvent)) {