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
133 changes: 133 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
# Reverse-engineered clang-format configuration for plasma
# Based on analysis of existing code style

Language: Cpp
BasedOnStyle: GNU

# Core indentation
IndentWidth: 2
UseTab: Never
TabWidth: 2
ContinuationIndentWidth: 2

# Custom brace wrapping based on observed style
# GNU-like for control statements (braces indented), but K&R for namespaces
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: true
IndentBraces: true
SplitEmptyFunction: true
SplitEmptyRecord: false
SplitEmptyNamespace: false

# Column limit - appears to be around 80
ColumnLimit: 80

# DISTINCTIVE: Space before ALL parentheses including function calls
# e.g., malloc (sizeof (slabu)), fprintf (stderr, ...)
SpaceBeforeParens: Always

# Pointer/reference alignment - space before pointer, attached to variable name
# e.g., char *buf, not char* buf
PointerAlignment: Right
ReferenceAlignment: Right

# Access modifiers (public:, private:) indented 1 space from class
AccessModifierOffset: -1

# Namespace handling - no indentation inside namespaces
NamespaceIndentation: None

# Switch/case - case labels indented inside switch braces
IndentCaseLabels: true
IndentCaseBlocks: false

# Constructor initializer lists
ConstructorInitializerIndentWidth: 4
BreakConstructorInitializers: BeforeColon
PackConstructorInitializers: NextLine

# Allow short forms
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortLambdasOnASingleLine: Inline

# Breaking and wrapping - keep return type on same line as function name
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true

# Spacing
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

# Include sorting
SortIncludes: false
IncludeBlocks: Preserve

# Macros
# OB_PRIVATE is an alias for private/public access specifiers
StatementMacros:
- OB_PRIVATE
- OB_PROTECTED

# Other
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
FixNamespaceComments: false
IndentGotoLabels: false
IndentPPDirectives: None
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 3
ReflowComments: false
SortUsingDeclarations: false
UseCRLF: false
---
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ obj-*-linux-*/
#ccls
.ccls-cache/

#clang-format
.clang-format

# Common cmake dirs
build

Expand Down
4 changes: 2 additions & 2 deletions bld/delta/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ static int reap_children (void)
int i;
int status;
for (i = 0; i < total_children; i++)
wait (&status);
wait (&status);
}
int main (int argc, char *argv[])
{
get_args (argc, argv);

gettimeofday (&start_time, ((void *)0));
gettimeofday (&start_time, ((void *) 0));
goal_end_time = start_time;
goal_end_time.tv_sec += test_secs;

Expand Down
15 changes: 6 additions & 9 deletions libLoam/c++/ArgParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,10 @@ ArgParse::ArgInfo ArgParse::Query (apstring name) const
OptionHandler *oh = d->findOption (name, &no);

if (isAlias && !oh)
OB_FATAL_BUG_CODE (0x12000006, "Invariant violated (alias '%s' without a "
"real option '%s' "
"behind it)\n",
OB_FATAL_BUG_CODE (0x12000006,
"Invariant violated (alias '%s' without a "
"real option '%s' "
"behind it)\n",
name.utf8 (), ai.aliasFor.utf8 ());

if (oh)
Expand Down Expand Up @@ -712,9 +713,7 @@ OptionHandler::OptionHandler (ArgParse::apstring usage_in, int separator_in)
{
}

OptionHandler::~OptionHandler ()
{
}
OptionHandler::~OptionHandler () {}

bool OptionHandler::takesarg () const
{
Expand All @@ -726,9 +725,7 @@ bool OptionHandler::allownegation () const
return false;
}

void OptionHandler::reset ()
{
}
void OptionHandler::reset () {}

ArgParse::apstring OptionHandler::handleargsplit (ArgParse::apstring arg,
ArgParse::apstring prefix)
Expand Down
4 changes: 1 addition & 3 deletions libLoam/c++/Line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ using namespace oblong::loam;
static const Vect zaxis (0.0, 0.0, 1.0);


Line::Line () : dir (zaxis)
{
}
Line::Line () : dir (zaxis) {}

Line::Line (const Vect &pointOnLine, const Vect &direction)
: point (pointOnLine), dir (direction)
Expand Down
5 changes: 2 additions & 3 deletions libLoam/c++/Mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ Mutex::Mutex (bool recursive)
pthread_mutexattr_t attr;
OB_CHECK_PTHREAD_CODE (0x110b0000, pthread_mutexattr_init (&attr));
if (recursive)
OB_CHECK_PTHREAD_CODE (0x110b0001,
pthread_mutexattr_settype (&attr,
PTHREAD_MUTEX_RECURSIVE));
OB_CHECK_PTHREAD_CODE (
0x110b0001, pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE));
OB_CHECK_PTHREAD_CODE (0x110b0002, pthread_mutex_init (&mutex_, &attr));
OB_CHECK_PTHREAD_CODE (0x110b0003, pthread_mutexattr_destroy (&attr));
}
Expand Down
8 changes: 2 additions & 6 deletions libLoam/c++/ObPseudopod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
using namespace oblong::loam;


ObPseudopod::ObPseudopod () : AnkleObject ()
{
}
ObPseudopod::ObPseudopod () : AnkleObject () {}


ObPseudopod::~ObPseudopod ()
{
}
ObPseudopod::~ObPseudopod () {}
12 changes: 3 additions & 9 deletions libLoam/c++/ObRetortPod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@
using namespace oblong::loam;


ObRetortPod::ObRetortPod () : ObPseudopod (), c_ret (0)
{
}
ObRetortPod::ObRetortPod () : ObPseudopod (), c_ret (0) {}

ObRetortPod::ObRetortPod (ob_retort obr) : ObPseudopod (), c_ret (obr)
{
}
ObRetortPod::ObRetortPod (ob_retort obr) : ObPseudopod (), c_ret (obr) {}

ObRetortPod::ObRetortPod (ob_retort obr, ObRetortPod *ant)
: ObPseudopod (), c_ret (obr), antecedent (ant)
{
}


ObRetortPod::~ObRetortPod ()
{
}
ObRetortPod::~ObRetortPod () {}


ob_retort ObRetortPod::NumericRetort () const
Expand Down
4 changes: 1 addition & 3 deletions libLoam/c++/Plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ using namespace oblong::loam;
static const Vect zaxs (0.0, 0.0, 1.0);


Plane::Plane () : norm (zaxs)
{
}
Plane::Plane () : norm (zaxs) {}

Plane::Plane (const Vect &p, const Vect &normal) : point (p), norm (normal)
{
Expand Down
4 changes: 2 additions & 2 deletions libLoam/c++/Rectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Rectangle::Rectangle (Vect corner_, Vect leg1_, Vect leg2_)

Str Rectangle::AsStr () const
{
return "Rectangle[c=" + corner.AsStr () + ", l1=" + leg1.AsStr () + ", l2="
+ leg2.AsStr () + "]";
return "Rectangle[c=" + corner.AsStr () + ", l1=" + leg1.AsStr ()
+ ", l2=" + leg2.AsStr () + "]";
}

bool Rectangle::IsValid () const
Expand Down
17 changes: 8 additions & 9 deletions libLoam/c++/Str.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ Str::Str () noexcept
_Init ();
}

Str::Str (std::nullptr_t) noexcept : Str ()
{
}
Str::Str (std::nullptr_t) noexcept : Str () {}

Str::Str (const char *text)
{
Expand Down Expand Up @@ -813,7 +811,7 @@ bool Str::Matches (const Str &pattern) const
pattern.utf8 (), mattie.ErrorStr ().utf8 ());
else
mattie.Match ();
return bool(mattie);
return bool (mattie);
}

bool Str::Match (const Str &pattern)
Expand All @@ -827,7 +825,7 @@ bool Str::Match (const Str &pattern)
pattern.utf8 (), match->ErrorStr ().utf8 ());
else
match->Match ();
return bool(*match);
return bool (*match);
}

bool Str::Match ()
Expand All @@ -841,13 +839,13 @@ bool Str::MatchAgain ()
if (!match)
return false;
match->Match ();
return bool(*match);
return bool (*match);
}

bool Str::MatchHasMatched () const
{
if (match)
return bool(*match);
return bool (*match);
return false;
}

Expand Down Expand Up @@ -1282,8 +1280,9 @@ void Str::_EnsureU8Capacity (int64 capacity)
void Str::_SetU8Length (int64 length)
{
if (!u8 || u8ByteCapacity < length)
OB_FATAL_BUG_CODE (0x11000003, "u8 = %p, u8ByteCapacity = %" OB_FMT_64 "d, "
"length = %" OB_FMT_64 "d\n",
OB_FATAL_BUG_CODE (0x11000003,
"u8 = %p, u8ByteCapacity = %" OB_FMT_64 "d, "
"length = %" OB_FMT_64 "d\n",
u8, u8ByteCapacity, length);
u8[length] = 0;
u8ByteLength = length;
Expand Down
4 changes: 3 additions & 1 deletion libLoam/c++/tests/AxisAlignedBoxTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ TEST (AxisAlignedBoxTests, AABB_Constructors)
const std::array<Vect, 8> op_corners = box.Corners ();

// Test construction from an iterator pair.
auto bad_hash = [](const Vect &x) -> size_t { return 0; };
auto bad_hash = [] (const Vect &x) -> size_t {
return 0;
};
std::unordered_set<Vect, decltype (bad_hash)> spoints (0, bad_hash);
spoints.emplace (1, 2, 3);
spoints.emplace (2, 3, 4);
Expand Down
11 changes: 5 additions & 6 deletions libLoam/c++/tests/BasicStrTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,9 @@ TEST_F (BasicStrTest, Format)
* to keep C++11 from complaining? That blows! */

const char eins[] = {0x24, 0x00};
const char zwei[] = {char(0xC2), char(0xA2), 0x00};
const char drei[] = {char(0xE2), char(0x82), char(0xAC), 0x00};
const char vier[] = {char(0xF0), char(0xA4), char(0xAD), char(0xA2), 0x00};
const char zwei[] = {char (0xC2), char (0xA2), 0x00};
const char drei[] = {char (0xE2), char (0x82), char (0xAC), 0x00};
const char vier[] = {char (0xF0), char (0xA4), char (0xAD), char (0xA2), 0x00};

TEST_F (BasicStrTest, FromUTF8)
{
Expand Down Expand Up @@ -960,8 +960,8 @@ TEST_F (BasicStrTest, InvalidUTF8) // bug 2865
{
ob_suppress_message (OBLV_WARN, 0x11000004);

static const char notutf8[] = {82, 101, 121, 107, 106,
97, 118, char(237), 107, 0};
static const char notutf8[] = {82, 101, 121, 107, 106,
97, 118, char (237), 107, 0};
Str unfortunate (notutf8);
EXPECT_EQ (9, unfortunate.Length ());
EXPECT_EQ ('j', unfortunate.At (4));
Expand Down Expand Up @@ -1082,7 +1082,6 @@ TEST_F (BasicStrTest, Char16)

TEST_F (BasicStrTest, DubyaChar)
{

const wchar_t *text = L"beeeep";
const size_t text_length = wcslen (text);

Expand Down
2 changes: 1 addition & 1 deletion libLoam/c++/tests/FatherTimeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static void waste_time ()
vals[i] = i;

#ifdef HAVE_STD_SHUFFLE
std::shuffle(vals + 0, vals + enuf, std::mt19937{std::random_device{}()});
std::shuffle (vals + 0, vals + enuf, std::mt19937{std::random_device{}()});
#else
std::random_shuffle (vals + 0, vals + enuf);
#endif
Expand Down
Loading