Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
AccessModifierOffset: '-4'
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlinesLeft: 'false'
AlignOperands: 'true'
AlignTrailingComments: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'true'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakAfterJavaFieldAnnotations: 'false'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializersBeforeComma: 'false'
BreakStringLiterals: 'false'
ColumnLimit: '0'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'false'
DerivePointerAlignment: 'false'
DisableFormat: 'false'
ExperimentalAutoDetectBinPacking: 'false'
IndentCaseLabels: 'true'
IndentWidth: '4'
IndentWrappedFunctionNames: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: All
PointerAlignment: Left
ReflowComments: 'false'
SortIncludes: 'true'
SpaceAfterCStyleCast: 'true'
SpaceAfterLogicalNot: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'true'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Never

...
69 changes: 51 additions & 18 deletions blueprint/core/blueprint_AppHarness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

#include "blueprint_AppHarness.h"


namespace blueprint
{

//==============================================================================
AppHarness::AppHarness(ReactApplicationRoot& _appRoot)
: appRoot(_appRoot)
Expand All @@ -25,11 +23,17 @@ namespace blueprint
appRoot.reset();
appRoot.bindNativeRenderingHooks();

if (onBeforeAll) { onBeforeAll(); }
if (onBeforeAll)
{
onBeforeAll();
}

for (const auto& f : fileWatcher->getWatchedFiles())
{
if (onBeforeEach) { onBeforeEach(f); }
if (onBeforeEach)
{
onBeforeEach(f);
}

try
{
Expand All @@ -52,22 +56,27 @@ namespace blueprint
}
}

if (onAfterEach) { onAfterEach(f); }
if (onAfterEach)
{
onAfterEach(f);
}
}

if (onAfterAll) { onAfterAll(); }
if (onAfterAll)
{
onAfterAll();
}
});

}

//==============================================================================
void AppHarness::watch (const juce::File& f)
void AppHarness::watch(const juce::File& f)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we trying to stick to the juce style guide? If so I think non-empty parens would have a preceding space (i.e. SpaceBeforeParens: NonEmptyParentheses instead of SpaceBeforeParens: ControlStatements)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh. Hopefully we don't need to fully comply .... I hate that leading space.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, such a can of worms this business. I'm in the not caring so long as a tool is doing it for me camp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, I'll admit, I'm also not a fan of that leading space. Generally though, I too am in the "i don't care let's just standardize it" camp.

I think generally if we can reach a small consensus of "yea looks good enough for me" then we should go for it

{
if (fileWatcher)
fileWatcher->watch(f);
}

void AppHarness::watch (const std::vector<juce::File>& fs)
void AppHarness::watch(const std::vector<juce::File>& fs)
{
if (fileWatcher)
{
Expand All @@ -84,11 +93,17 @@ namespace blueprint
if (fileWatcher == nullptr)
return;

if (onBeforeAll) { onBeforeAll(); }
if (onBeforeAll)
{
onBeforeAll();
}

for (const auto& f : fileWatcher->getWatchedFiles())
{
if (onBeforeEach) { onBeforeEach(f); }
if (onBeforeEach)
{
onBeforeEach(f);
}

try
{
Expand All @@ -111,10 +126,16 @@ namespace blueprint
}
}

if (onAfterEach) { onAfterEach(f); }
if (onAfterEach)
{
onAfterEach(f);
}
}

if (onAfterAll) { onAfterAll(); }
if (onAfterAll)
{
onAfterAll();
}

// Finally, kick off the file watch process
fileWatcher->start();
Expand All @@ -132,16 +153,28 @@ namespace blueprint
if (fileWatcher == nullptr)
return;

if (onBeforeAll) { onBeforeAll(); }
if (onBeforeAll)
{
onBeforeAll();
}

for (const auto& f : fileWatcher->getWatchedFiles())
{
if (onBeforeEach) { onBeforeEach(f); }
if (onBeforeEach)
{
onBeforeEach(f);
}
appRoot.evaluate(f);
if (onAfterEach) { onAfterEach(f); }
if (onAfterEach)
{
onAfterEach(f);
}
}

if (onAfterAll) { onAfterAll(); }
if (onAfterAll)
{
onAfterAll();
}
}

}
} // namespace blueprint
10 changes: 4 additions & 6 deletions blueprint/core/blueprint_AppHarness.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
#include "blueprint_FileWatcher.h"
#include "blueprint_ReactApplicationRoot.h"


namespace blueprint
{

/** The AppHarness is a simple class which composes over your ReactApplicationRoot
* to provide file watching and hot reloading behavior for the bundle files your app evaluates.
*
Expand All @@ -37,8 +35,8 @@ namespace blueprint
AppHarness(ReactApplicationRoot& _appRoot);

//==============================================================================
void watch (const juce::File& f);
void watch (const std::vector<juce::File>& fs);
void watch(const juce::File& f);
void watch(const std::vector<juce::File>& fs);

/** Run the initial evaluation step and then watch for file changes. */
void start();
Expand Down Expand Up @@ -222,7 +220,7 @@ namespace blueprint
std::unique_ptr<FileWatcher> fileWatcher;

//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AppHarness)
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AppHarness)
};

}
} // namespace blueprint
Loading