Skip to content

Commit

Permalink
Braces style: Linux -> WebKit
Browse files Browse the repository at this point in the history
  • Loading branch information
sbarzowski committed Jul 24, 2017
1 parent df7691b commit be8c7a2
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Linux
BreakBeforeBraces: WebKit
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
Expand Down
6 changes: 2 additions & 4 deletions core/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,7 @@ struct Var : public AST {

/** Allocates ASTs on demand, frees them in its destructor.
*/
class Allocator
{
class Allocator {
std::map<UString, const Identifier *> internedIdentifiers;
ASTs allocated;

Expand Down Expand Up @@ -941,8 +940,7 @@ class Allocator
}
};

namespace
{
namespace {
// Precedences used by various compilation units are defined here.
const int APPLY_PRECEDENCE = 2; // Function calls and indexing.
const int UNARY_PRECEDENCE = 4; // Logical and bitwise negation, unary + -
Expand Down
6 changes: 2 additions & 4 deletions core/desugarer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ static constexpr char STD_CODE[] = {
* Temporary variables introduced here should be prefixed with $ to ensure they do not clash with
* variables used in user code.
*/
class Desugarer
{
class Desugarer {
Allocator *alloc;

template <class T, class... Args>
Expand Down Expand Up @@ -316,8 +315,7 @@ class Desugarer
*
* Returns all variables and original expressions via super_vars.
*/
class SubstituteSelfSuper : public CompilerPass
{
class SubstituteSelfSuper : public CompilerPass {
Desugarer *desugarer;
SuperVars &superVars;
unsigned &counter;
Expand Down
42 changes: 14 additions & 28 deletions core/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ static void fodder_count(unsigned &column, const Fodder &fodder, bool space_befo
column++;
}

class Unparser
{
class Unparser {
public:
private:
std::ostream &o;
Expand Down Expand Up @@ -640,17 +639,15 @@ static void fodder_move_front(Fodder &a, Fodder &b)

/** A generic Pass that does nothing but can be extended to easily define real passes.
*/
class FmtPass : public CompilerPass
{
class FmtPass : public CompilerPass {
protected:
FmtOpts opts;

public:
FmtPass(Allocator &alloc, const FmtOpts &opts) : CompilerPass(alloc), opts(opts) {}
};

class EnforceStringStyle : public FmtPass
{
class EnforceStringStyle : public FmtPass {
using FmtPass::visit;

public:
Expand Down Expand Up @@ -685,8 +682,7 @@ class EnforceStringStyle : public FmtPass
}
};

class EnforceCommentStyle : public FmtPass
{
class EnforceCommentStyle : public FmtPass {
public:
bool firstFodder;
EnforceCommentStyle(Allocator &alloc, const FmtOpts &opts)
Expand Down Expand Up @@ -726,8 +722,7 @@ class EnforceCommentStyle : public FmtPass
}
};

class EnforceMaximumBlankLines : public FmtPass
{
class EnforceMaximumBlankLines : public FmtPass {
public:
EnforceMaximumBlankLines(Allocator &alloc, const FmtOpts &opts) : FmtPass(alloc, opts) {}
void fodderElement(FodderElement &f)
Expand All @@ -738,8 +733,7 @@ class EnforceMaximumBlankLines : public FmtPass
}
};

class StripComments : public FmtPass
{
class StripComments : public FmtPass {
public:
StripComments(Allocator &alloc, const FmtOpts &opts) : FmtPass(alloc, opts) {}
void fodder(Fodder &fodder)
Expand All @@ -753,8 +747,7 @@ class StripComments : public FmtPass
}
};

class StripEverything : public FmtPass
{
class StripEverything : public FmtPass {
public:
StripEverything(Allocator &alloc, const FmtOpts &opts) : FmtPass(alloc, opts) {}
void fodder(Fodder &fodder)
Expand All @@ -763,8 +756,7 @@ class StripEverything : public FmtPass
}
};

class StripAllButComments : public FmtPass
{
class StripAllButComments : public FmtPass {
public:
StripAllButComments(Allocator &alloc, const FmtOpts &opts) : FmtPass(alloc, opts) {}
Fodder comments;
Expand Down Expand Up @@ -814,8 +806,7 @@ bool contains_newline(const Fodder &fodder)
}

/* Commas should appear at the end of an object/array only if the closing token is on a new line. */
class FixTrailingCommas : public FmtPass
{
class FixTrailingCommas : public FmtPass {
using FmtPass::visit;

public:
Expand Down Expand Up @@ -889,8 +880,7 @@ class FixTrailingCommas : public FmtPass
};

/* Remove nested parens. */
class FixParens : public FmtPass
{
class FixParens : public FmtPass {
using FmtPass::visit;

public:
Expand All @@ -908,8 +898,7 @@ class FixParens : public FmtPass
};

/* Ensure ApplyBrace syntax sugar is used in the case of A + { }. */
class FixPlusObject : public FmtPass
{
class FixPlusObject : public FmtPass {
using FmtPass::visit;

public:
Expand All @@ -933,8 +922,7 @@ class FixPlusObject : public FmtPass
};

/* Remove final colon in slices. */
class NoRedundantSliceColon : public FmtPass
{
class NoRedundantSliceColon : public FmtPass {
using FmtPass::visit;

public:
Expand All @@ -954,8 +942,7 @@ class NoRedundantSliceColon : public FmtPass
};

/* Ensure syntax sugar is used where possible. */
class PrettyFieldNames : public FmtPass
{
class PrettyFieldNames : public FmtPass {
using FmtPass::visit;

public:
Expand Down Expand Up @@ -1024,8 +1011,7 @@ class PrettyFieldNames : public FmtPass
}
};

class FixIndentation
{
class FixIndentation {
FmtOpts opts;
unsigned column;

Expand Down
3 changes: 1 addition & 2 deletions core/lexer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ limitations under the License.
#include <list>
#include "gtest/gtest.h"

namespace
{
namespace {
void testLex(const char* name, const char* input, const std::list<Token>& tokens,
const std::string& error)
{
Expand Down
3 changes: 1 addition & 2 deletions core/libjsonnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ char *jsonnet_fmt_snippet(JsonnetVm *vm, const char *filename, const char *snipp
return nullptr; // Never happens.
}

namespace
{
namespace {
enum EvalKind { REGULAR, MULTI, STREAM };
} // namespace

Expand Down
6 changes: 2 additions & 4 deletions core/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ std::string jsonnet_unparse_number(double v)
return ss.str();
}

namespace
{
namespace {
static bool op_is_unary(const std::string &op, UnaryOp &uop)
{
auto it = unary_map.find(op);
Expand Down Expand Up @@ -82,8 +81,7 @@ LocationRange span(const Token &begin, AST *end)

/** Holds state while parsing a given token list.
*/
class Parser
{
class Parser {
// The private member functions are utilities for dealing with the token stream.

StaticError unexpected(const Token &tok, const std::string &while_)
Expand Down
3 changes: 1 addition & 2 deletions core/parser_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ limitations under the License.
#include "gtest/gtest.h"
#include "lexer.h"

namespace
{
namespace {
// Checks whether the provided snippet parses successfully.
// TODO(dzc): Update this test to check the parsed AST against an expected AST.
void testParse(const char* snippet)
Expand Down
3 changes: 1 addition & 2 deletions core/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ void CompilerPass::file(AST *&body, Fodder &final_fodder)
}

/** A pass that clones the AST it is given. */
class ClonePass : public CompilerPass
{
class ClonePass : public CompilerPass {
public:
ClonePass(Allocator &alloc) : CompilerPass(alloc) {}
virtual void expr(AST *&ast);
Expand Down
3 changes: 1 addition & 2 deletions core/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ limitations under the License.

/** A generic Pass that does nothing but can be extended to easily define real passes.
*/
class CompilerPass
{
class CompilerPass {
public:
protected:
Allocator &alloc;
Expand Down
6 changes: 2 additions & 4 deletions core/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ limitations under the License.
#ifndef JSONNET_STATE_H
#define JSONNET_STATE_H

namespace
{
namespace {
/** Mark & sweep: advanced by 1 each GC cycle.
*/
typedef unsigned char GarbageCollectionMark;
Expand Down Expand Up @@ -261,8 +260,7 @@ struct HeapString : public HeapEntity {
};

/** The heap does memory management, i.e. garbage collection. */
class Heap
{
class Heap {
/** How many objects must exist in the heap before we bother doing garbage collection?
*/
unsigned gcTuneMinObjects;
Expand Down
3 changes: 1 addition & 2 deletions core/unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ static inline UString decode_utf8(const std::string &s)
/** A stringstream-like class capable of holding unicode codepoints.
* The C++ standard does not support std::basic_stringstream<char32_t.
*/
class UStringStream
{
class UStringStream {
UString buf;

public:
Expand Down
9 changes: 3 additions & 6 deletions core/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ limitations under the License.
#include "string_utils.h"
#include "vm.h"

namespace
{
namespace {
/** Turn a path e.g. "/a/b/c" into a dir, e.g. "/a/b/". If there is no path returns "".
*/
std::string dir_name(const std::string &path)
Expand Down Expand Up @@ -204,8 +203,7 @@ struct Frame {
};

/** The stack holds all the stack frames and manages the stack frame limit. */
class Stack
{
class Stack {
/** How many call frames are on the stack. */
unsigned calls;

Expand Down Expand Up @@ -446,8 +444,7 @@ typedef const AST *(Interpreter::*BuiltinFunc)(const LocationRange &loc,
* All reachable entities have their mark field incremented. Then all entities with the old
* mark are removed from the heap.
*/
class Interpreter
{
class Interpreter {
/** The heap. */
Heap heap;

Expand Down
6 changes: 2 additions & 4 deletions cpp/libjsonnet++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ limitations under the License.

#include "libjsonnet++.h"

namespace jsonnet
{
namespace jsonnet {
Jsonnet::Jsonnet() {}

Jsonnet::~Jsonnet()
Expand Down Expand Up @@ -111,8 +110,7 @@ bool Jsonnet::evaluateSnippet(const std::string& filename, const std::string& sn
return true;
}

namespace
{
namespace {
void parseMultiOutput(const char* jsonnet_output, std::map<std::string, std::string>* outputs)
{
for (const char* c = jsonnet_output; *c != '\0';) {
Expand Down
3 changes: 1 addition & 2 deletions cpp/libjsonnet++_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ limitations under the License.

#include "gtest/gtest.h"

namespace jsonnet
{
namespace jsonnet {
std::string readFile(const std::string& filename)
{
std::ifstream in(filename);
Expand Down
6 changes: 2 additions & 4 deletions include/libjsonnet++.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ extern "C" {
#include "libjsonnet.h"
}

namespace jsonnet
{
class Jsonnet
{
namespace jsonnet {
class Jsonnet {
public:
Jsonnet();
~Jsonnet();
Expand Down

0 comments on commit be8c7a2

Please sign in to comment.