Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update code style with clang-format #120

Merged
merged 8 commits into from
Dec 10, 2019
Merged
47 changes: 0 additions & 47 deletions .clang-format

This file was deleted.

21 changes: 21 additions & 0 deletions Library/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# https://releases.llvm.org/8.0.0/tools/clang/docs/ClangFormatStyleOptions.html
---
BasedOnStyle: LLVM
---
Language: Cpp

AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignOperands: false
AlwaysBreakTemplateDeclarations: true
BreakBeforeBraces: Allman
BreakConstructorInitializers: BeforeComma
ColumnLimit: 0
FixNamespaceComments: false
IndentCaseLabels: true
IndentWidth: 4
NamespaceIndentation: All
PointerAlignment: Left
SortIncludes: false
SpaceAfterTemplateKeyword: false
---
15 changes: 8 additions & 7 deletions Library/Include/Babylon/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Babylon
class Console final : public Napi::ObjectWrap<Console>
{
public:
static inline constexpr char* JS_INSTANCE_NAME{ "console" };
static inline constexpr char* JS_INSTANCE_NAME{"console"};

/**
* Importance level of messages sent via logging callbacks.
Expand All @@ -27,7 +27,7 @@ namespace Babylon

static void CreateInstance(Napi::Env env, CallbackT callback)
{
Napi::HandleScope scope{ env };
Napi::HandleScope scope{env};

Napi::Function func = ParentT::DefineClass(
env,
Expand All @@ -38,14 +38,15 @@ namespace Babylon
ParentT::InstanceMethod("error", &Console::Error),
});

Napi::Object console = func.New({ Napi::External<CallbackT>::New(env, new CallbackT(std::move(callback))) });
Napi::Object console = func.New({Napi::External<CallbackT>::New(env, new CallbackT(std::move(callback)))});
env.Global().Set(JS_INSTANCE_NAME, console);
}

explicit Console(const Napi::CallbackInfo& info)
: ParentT{ info }
, m_callback{ *info[0].As<Napi::External<CallbackT>>().Data() }
{}
: ParentT{info}
, m_callback{*info[0].As<Napi::External<CallbackT>>().Data()}
{
}

private:
void Log(const Napi::CallbackInfo& info)
Expand Down
2 changes: 1 addition & 1 deletion Library/Include/Babylon/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Babylon
{
class RuntimeImpl;
class Env;

/**
* This class represents an instance of Babylon Native. It holds and manages all program
* state and behavior relevant to Babylon Native's functionality, including the JavaScript
Expand Down
2 changes: 1 addition & 1 deletion Library/Include/Babylon/RuntimeUWP.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Babylon

// TODO: Allow creation from swap chain, which is required by XAML apps.
// explicit RuntimeUWP(ABI::Windows::UI::Xaml::Controls::ISwapChainPanel* panel, const std::string& rootUrl = {});

RuntimeUWP(const Runtime&) = delete;
~RuntimeUWP();

Expand Down
2 changes: 1 addition & 1 deletion Library/Source/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <arcana/threading/dispatcher.h>

#if defined( __APPLE__) || defined(__ANDROID__)
#if defined(__APPLE__) || defined(__ANDROID__)
struct Filepath : public std::string
{
const std::string& u8string() const
Expand Down
2 changes: 1 addition & 1 deletion Library/Source/CommonAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Babylon
{
Filepath GetModulePath()
{
return Filepath{ "." };
return Filepath{"."};
}

std::string GetUrlFromPath(const Filepath& path)
Expand Down
2 changes: 1 addition & 1 deletion Library/Source/CommonUWP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Babylon
{
char buffer[1024];
::GetModuleFileNameA(nullptr, buffer, ARRAYSIZE(buffer));
return std::filesystem::path{ buffer };
return std::filesystem::path{buffer};
}

std::string GetUrlFromPath(const std::filesystem::path& path)
Expand Down
4 changes: 2 additions & 2 deletions Library/Source/CommonWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Babylon
{
char buffer[1024];
::GetModuleFileNameA(nullptr, buffer, ARRAYSIZE(buffer));
return std::filesystem::path{ buffer };
return std::filesystem::path{buffer};
}

std::string GetUrlFromPath(const std::filesystem::path& path)
Expand All @@ -21,6 +21,6 @@ namespace Babylon
throw std::exception("Failed to create url from path", hr);
}

return { url };
return {url};
}
}