Browse Source

Re-indenting files with Clang-Format.

Sam Jaffe 6 years ago
parent
commit
a434f1a90c

+ 108 - 0
.clang-format

@@ -0,0 +1,108 @@
+---
+Language:        Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Right
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: true
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:   
+  AfterClass:      false
+  AfterControlStatement: false
+  AfterEnum:       false
+  AfterFunction:   false
+  AfterNamespace:  false
+  AfterObjCDeclaration: false
+  AfterStruct:     false
+  AfterUnion:      false
+  BeforeCatch:     false
+  BeforeElse:      false
+  IndentBraces:    false
+  SplitEmptyFunction: true
+  SplitEmptyRecord: true
+  SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Attach
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit:     80
+CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: true
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: false
+ForEachMacros:   
+  - foreach
+  - Q_FOREACH
+  - BOOST_FOREACH
+IncludeCategories: 
+  - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
+    Priority:        2
+  - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
+    Priority:        3
+  - Regex:           '.*'
+    Priority:        1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+IndentWidth:     2
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: All
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Middle
+ReflowComments:  true
+SortIncludes:    true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        8
+UseTab:          Never
+...
+

+ 2 - 3
danmaku/AppDelegate.m

@@ -15,8 +15,7 @@
 NSWindowStyleMask const resizable = NSWindowStyleMaskResizable;
 NSWindowStyleMask const borderless = NSWindowStyleMaskBorderless;
 
-- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
-{
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
   gameview = [[GameView alloc] initWithFrame:[[self window] frame]];
   
   // Insert code here to initialize your application
@@ -25,7 +24,7 @@ NSWindowStyleMask const borderless = NSWindowStyleMaskBorderless;
   [[self window] makeMainWindow];
 }
 
-- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app {
   return YES;
 }
 

+ 8 - 5
danmaku/GameView.mm

@@ -32,7 +32,8 @@ static std::shared_ptr<engine::game_dispatch> game;
   };
   
   // create pixel format
-  NSOpenGLPixelFormat *nsglFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
+  NSOpenGLPixelFormat *nsglFormat = [[NSOpenGLPixelFormat alloc]
+                                     initWithAttributes:attr];
 
   // create the context...
   if (!(self = [super initWithFrame:aRect pixelFormat:nsglFormat])) {
@@ -144,13 +145,14 @@ static std::shared_ptr<engine::game_dispatch> game;
   [self press_key:LEFT_ARROW forEvent:theEvent ns_key:0x007b down:YES];
   [self press_key:RIGHT_ARROW forEvent:theEvent ns_key:0x007c down:YES];
 
-//  NSLog(@"keyDown -> { 0x%04x, 0x%08lx, 0x%02x=%c }", [theEvent keyCode],
-//        [theEvent modifierFlags], c, c);
+  NSLog(@"keyDown -> { 0x%04x, 0x%08lx, 0x%02x=%c }", [theEvent keyCode],
+        [theEvent modifierFlags], c, c);
   game->process_key_event(c, true);
 }
 
 - (void)keyUp:(NSEvent *)theEvent {
-  //  NSLog(@"keyUp -> { 0x%04x, 0x%08lx }", [theEvent keyCode], [theEvent modifierFlags]);
+  NSLog(@"keyUp -> { 0x%04x, 0x%08lx }", [theEvent keyCode],
+        [theEvent modifierFlags]);
   NSString *str = [theEvent charactersIgnoringModifiers];
   unichar c = [str characterAtIndex:0];
   
@@ -224,7 +226,8 @@ static NSTimeInterval const FRAME_INTERVAL = 1.0 / 60.0;
     (NSOpenGLPixelFormatAttribute)0
   };
   
-  NSOpenGLPixelFormat *pf = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
+  NSOpenGLPixelFormat *pf = [[NSOpenGLPixelFormat alloc]
+                             initWithAttributes:attributes];
   [self setPixelFormat:pf];
 }
 

+ 0 - 1
include/danmaku/actor.hpp

@@ -7,4 +7,3 @@
 //
 
 #pragma once
-

+ 0 - 1
include/danmaku/bullet.hpp

@@ -7,4 +7,3 @@
 //
 
 #pragma once
-

+ 8 - 7
include/danmaku/bullet_pattern.hpp

@@ -17,20 +17,21 @@ namespace objects { namespace prototype {
 
 namespace danmaku {
   class actor;
-  
+
   struct bullet_timer {
     float const interval;
     float remaining{0.f};
   };
-  
+
   struct bullet_pattern {
     virtual ~bullet_pattern() = default;
     virtual void update(float delta) = 0;
   };
-  
-  using bullet_pattern_factory = objects::prototype::factory<
-      std::shared_ptr<bullet_pattern>, actor*, Json::Value const &>;
+
+  using bullet_pattern_factory =
+      objects::prototype::factory<std::shared_ptr<bullet_pattern>, actor *,
+                                  Json::Value const &>;
 }
 
-#define BIND_BULLET_PATTERN(name, function)                              \
-  bool const _ = bullet_pattern_factory::instance().bind(name, function) \
+#define BIND_BULLET_PATTERN(name, function)                                    \
+  bool const _ = bullet_pattern_factory::instance().bind(name, function)\

+ 0 - 1
include/danmaku/enemy.hpp

@@ -7,4 +7,3 @@
 //
 
 #pragma once
-

+ 0 - 1
include/danmaku/level.hpp

@@ -7,4 +7,3 @@
 //
 
 #pragma once
-

+ 0 - 1
include/danmaku/player.hpp

@@ -7,4 +7,3 @@
 //
 
 #pragma once
-

+ 9 - 10
src/pattern/burstshot_pattern.cxx

@@ -20,18 +20,18 @@ using namespace danmaku;
 using shot = std::pair<math::vec2, float>;
 
 struct burstshot : public danmaku::bullet_pattern {
-  static std::shared_ptr<burstshot> create(danmaku::actor*,
+  static std::shared_ptr<burstshot> create(danmaku::actor *,
                                            Json::Value const &);
-  
+
   burstshot(danmaku::actor *, float shot_interval, std::vector<shot> shots);
   void update(float delta) override;
-  
+
   danmaku::actor * actor;
   danmaku::bullet_timer shot_timer;
   float last_fired{std::numeric_limits<float>::lowest()};
   std::vector<shot> shots;
 };
-  
+
 std::vector<shot> shot_vector(std::size_t count, float facing, float covered,
                               float speed, bool clockwise) {
   if (covered == 360.f) { ++count; }
@@ -39,7 +39,7 @@ std::vector<shot> shot_vector(std::size_t count, float facing, float covered,
   float start = facing + (.5f * covered);
   float end = start - covered;
   if (clockwise != (end < start)) { std::swap(start, end); }
-  
+
   float const delta = (end - start) / count;
   float current = start;
   for (std::size_t i = 0; i < count; ++i, current += delta) {
@@ -53,14 +53,13 @@ burstshot::burstshot(danmaku::actor * actor, float shot_interval,
                      std::vector<shot> shots)
     : actor(actor), shot_timer{shot_interval}, shots(shots) {}
 
-std::shared_ptr<burstshot> burstshot::create(danmaku::actor* actor,
+std::shared_ptr<burstshot> burstshot::create(danmaku::actor * actor,
                                              Json::Value const & json) {
-  return std::make_shared<burstshot>(actor, 0.f, shot_vector(0, 0.f, 0.f, 0.f, false));
+  return std::make_shared<burstshot>(actor, 0.f,
+                                     shot_vector(0, 0.f, 0.f, 0.f, false));
 }
 
-void burstshot::update(float delta) {
-  
-}
+void burstshot::update(float delta) {}
 
 namespace danmaku {
   BIND_BULLET_PATTERN("burstshot", &burstshot::create);