Skip to content
Merged
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
8 changes: 5 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: false
AlignTrailingComments:
Kind: Leave
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
Expand Down Expand Up @@ -55,6 +56,7 @@ BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakInheritanceList: BeforeComma
BreakStringLiterals: false
# clang-format 19 BreakTemplateDeclarations: Yes
ColumnLimit: 0
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Expand Down Expand Up @@ -84,7 +86,7 @@ IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: false
# clang-format-16 InsertNewlineAtEOF: true
InsertNewlineAtEOF: true
InsertTrailingCommas: Wrapped
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
Expand All @@ -100,7 +102,7 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
ReflowComments: false
ReflowComments: Always
SortIncludes: CaseInsensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
Expand Down
4 changes: 2 additions & 2 deletions nyan/compiler.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2021 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2016-2025 the nyan authors, LGPLv3+. See copying.md for legal info.

#pragma once

Expand Down Expand Up @@ -34,7 +34,7 @@
#define NYANAPI __declspec(dllexport) // library is built
#else
#define NYANAPI __declspec(dllimport) // library is used
#endif /* nyan_EXPORTS */
#endif
#else
#define NYANAPI __attribute__((visibility("default")))
#endif
6 changes: 3 additions & 3 deletions nyan/database.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2024 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2017-2025 the nyan authors, LGPLv3+. See copying.md for legal info.

#include "database.h"

Expand Down Expand Up @@ -532,7 +532,7 @@ void Database::resolve_types(const std::vector<fqon_t> &new_objects) {
// check if the member we're looking for isn't already typed.
if (unlikely(member_info.is_initial_def())) {
// another parent defines this type,
// which is disallowed!
// which is disallowed!
Copy link
Member

Choose a reason for hiding this comment

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

this should remain one-tab indented, just like the line before.

Copy link
Member Author

Choose a reason for hiding this comment

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

I tested why this is happening and it looks like this is the trade-off of turning ReflowComments on. The multi-line block comments are formatted correctly now (with tabs), but multiple single-line comments get converted to spaces for whatever reason.

Copy link
Member

Choose a reason for hiding this comment

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

oh dear. that surely seems like a bug then. so far i couldn't find an upstream report about this...

Copy link
Member Author

Choose a reason for hiding this comment

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

seems like a bad interaction of ReflowComments and UseTabs...


// TODO: show location of infringing type instead of member
throw LangError{
Expand All @@ -546,7 +546,7 @@ void Database::resolve_types(const std::vector<fqon_t> &new_objects) {
member_info.set_type(new_type, false);
}
// else that member knows the type,
// but we're looking for the initial definition.
// but we're looking for the initial definition.
Copy link
Member

Choose a reason for hiding this comment

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

same here


// we need to traverse all members and never stop early.
return false;
Expand Down
4 changes: 2 additions & 2 deletions nyan/error.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2021 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2016-2025 the nyan authors, LGPLv3+. See copying.md for legal info.

#include "error.h"

Expand All @@ -8,7 +8,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// TODO - CaptureStackBackTrace doesn't report number of frames available
// need to implement increase buffer size
// need to implement increase buffer size
Copy link
Member

Choose a reason for hiding this comment

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

same here

#define backtrace(buffer, buf_size) CaptureStackBackTrace(0, buf_size, buffer, NULL)
#else
#include <execinfo.h>
Expand Down
22 changes: 11 additions & 11 deletions nyan/lexer/bracket.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2020 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2017-2025 the nyan authors, LGPLv3+. See copying.md for legal info.
#pragma once


Expand Down Expand Up @@ -41,22 +41,22 @@ class Bracket {
token_type expected_match() const;

/**
* Indentation level of the line this bracket was in.
*/
* Indentation level of the line this bracket was in.
*/
int indentation;

/**
* Type of this opening bracket.
*/
* Type of this opening bracket.
*/
bracket_type type;

/**
* true if the indentation mode is "hanging",
* that is, if a continuation must happen at the
* indent level of this opening bracket.
* The expected indentation level of contained content is stored
* in the `indentation` member.
*/
* true if the indentation mode is "hanging",
* that is, if a continuation must happen at the
* indent level of this opening bracket.
* The expected indentation level of contained content is stored
* in the `indentation` member.
*/
bool hanging;
};

Expand Down
6 changes: 3 additions & 3 deletions nyan/lexer/impl.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2021 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2017-2025 the nyan authors, LGPLv3+. See copying.md for legal info.
#pragma once

#include <queue>
Expand Down Expand Up @@ -27,8 +27,8 @@ class Impl {
Token generate_token();

/** @name FlexInterfaceMethods
* Methods used by the flex generated lexer.
*/
* Methods used by the flex generated lexer.
*/
///@{

/** Advance the line position by match length. */
Expand Down
10 changes: 6 additions & 4 deletions nyan/namespace_finder.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2023 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2017-2025 the nyan authors, LGPLv3+. See copying.md for legal info.

#include "namespace_finder.h"

Expand Down Expand Up @@ -32,9 +32,11 @@ void NamespaceFinder::add_alias(const Token &alias,


bool NamespaceFinder::check_conflict(const std::string &name) const {
return (this->aliases.find(name) != std::end(this->aliases) // aliases
// importing files from the root directory can be a problem too
or this->imports.find(Namespace{std::vector<std::string>(), name}) != std::end(this->imports));
return (
// aliases must be unique
this->aliases.find(name) != std::end(this->aliases)
// importing files from the root directory can be a problem too
or this->imports.find(Namespace{std::vector<std::string>(), name}) != std::end(this->imports));
}


Expand Down
4 changes: 2 additions & 2 deletions nyan/token_stream.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2020 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2016-2025 the nyan authors, LGPLv3+. See copying.md for legal info.

#include "token_stream.h"

Expand Down Expand Up @@ -26,7 +26,7 @@ const TokenStream::tok_t *TokenStream::next() {

ret = &(*this->iter);

//std::cout << "tok: " << ret->str() << std::endl;
// std::cout << "tok: " << ret->str() << std::endl;

this->iter = std::next(this->iter);
return ret;
Expand Down
4 changes: 2 additions & 2 deletions nyan/transaction.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2020 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2017-2025 the nyan authors, LGPLv3+. See copying.md for legal info.

#include "transaction.h"

Expand Down Expand Up @@ -108,7 +108,7 @@ bool Transaction::add(const Object &patch) {
// apply all patch parents in order (last the patch itself)
target_obj->apply(
// TODO: use the same mechanism as above to get only parent
// obj states of base_state
// obj states of base_state
Copy link
Member

Choose a reason for hiding this comment

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

same, should remain the tab.

view->get_raw(patch_name, this->at),
view->get_info(patch_name),
patch_tracker);
Expand Down
6 changes: 5 additions & 1 deletion nyan/util.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2020 the nyan authors, LGPLv3+. See copying.md for legal info.
// Copyright 2016-2025 the nyan authors, LGPLv3+. See copying.md for legal info.

#include "util.h"

Expand All @@ -18,8 +18,12 @@
#include <mutex>

#define WIN32_LEAN_AND_MEAN
// clang-format off
// prevent clang-format from reordering these includes
// DbgHelp.h must be included AFTER Windows.h
#include <Windows.h>
#include <DbgHelp.h>
// clang-format on


namespace {
Expand Down