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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
56 changes: 56 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# clang-format configuration for KLayout
# -------------------------------------------------------------------------
# The distinctive KLayout idioms are:
# - space before parentheses, including in calls: foo (x)
# - space after unary not: if (! x)
# - space before subscript brackets: arr [i]
# - space after C-style casts: (int) x
# - braces on their own line for functions, classes and namespaces,
# but attached for control statements (Linux brace style)
# - two-space indentation, pointers/references bound to the name
# -------------------------------------------------------------------------
Language: Cpp
BasedOnStyle: LLVM

IndentWidth: 2
TabWidth: 2
UseTab: Never
ContinuationIndentWidth: 2
ConstructorInitializerIndentWidth: 2
AccessModifierOffset: -2
NamespaceIndentation: None

# Do not reflow existing lines: KLayout has many intentionally long lines
ColumnLimit: 0

# Functions / classes / namespaces: brace on its own line.
# Control statements (if/for/while/else): attached brace.
BreakBeforeBraces: Linux

# KLayout spacing idioms
SpaceBeforeParens: Always
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: true
SpaceBeforeSquareBrackets: true

PointerAlignment: Right
ReferenceAlignment: Right

AllowShortFunctionsOnASingleLine: All
AllowShortBlocksOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: No

IndentCaseLabels: false

# Includes are grouped and ordered by hand
SortIncludes: false

# Namespace-closing comments are not used consistently; do not add them.
FixNamespaceComments: false

# Preserve the existing vertical spacing
# Up to three blank lines are used after the licence header
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 3
10 changes: 10 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Files clang-format should skip (clang-format >= 18 honours this file).
# Paths are glob patterns relative to this file.

# Test fixtures and golden reference data: byte-exact content matters.
testdata/

# Qt binding declarations under src/gsiqt are largely machine-emitted from the
# Qt headers (~2000 files). If/when they are confirmed generated they should
# stay out of formatting churn; remove this line if they are hand-maintained.
src/gsiqt/
30 changes: 30 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: clang-format

# Verifies that all C/C++ sources are formatted according to .clang-format.
# Fails if any tracked source would be changed by clang-format.

on:
pull_request:
push:
branches:
- master

permissions:
contents: read

concurrency:
group: clang-format-${{ github.ref }}
cancel-in-progress: true

jobs:
formatting-check:
name: Check C++ formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.18.0
with:
clang-format-version: '21'
exclude-regex: "(testdata|gsiqt)/"
6 changes: 3 additions & 3 deletions scripts/mkqtdecl4/QtCore/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
#include "QtCore/QVariant"
#include "QtCore/QWaitCondition"
#include "QtCore/QWriteLocker"
#include "QtCore/QTextCodec"
#include "QtCore/QTextDecoder"
#include "QtCore/QTextEncoder"
#include "QtCore/QTextCodec"
#include "QtCore/QTextDecoder"
#include "QtCore/QTextEncoder"
#include "QtCore/QBuffer"
#include "QtCore/Qt"
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtCore/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@
#include <QtCore/QtCompare>
#include <QtCore/QtConfig>
#include <QtCore/QtContainerFwd>
//#include <QtCore/QtCore>
//#include <QtCore/QtCoreDepends>
// #include <QtCore/QtCore>
// #include <QtCore/QtCoreDepends>
#include <QtCore/QtCoreVersion>
#include <QtCore/QtDebug>
#include <QtCore/QTemporaryDir>
Expand Down
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtCore5Compat/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <QtCore5Compat/QMutableLinkedListIterator>
#include <QtCore5Compat/QRegExp>
#include <QtCore5Compat/QStringRef>
//#include <QtCore5Compat/QtCore5Compat>
//#include <QtCore5Compat/QtCore5CompatDepends>
// #include <QtCore5Compat/QtCore5Compat>
// #include <QtCore5Compat/QtCore5CompatDepends>
#include <QtCore5Compat/QtCore5CompatVersion>
#include <QtCore5Compat/QTextCodec>
#include <QtCore5Compat/QTextDecoder>
Expand Down
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtDesigner/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
#include <QtDesigner/QExtensionFactory>
#include <QtDesigner/QExtensionManager>
#include <QtDesigner/QFormBuilder>
//#include <QtDesigner/QtDesigner>
//#include <QtDesigner/QtDesignerDepends>
// #include <QtDesigner/QtDesigner>
// #include <QtDesigner/QtDesignerDepends>
#include <QtDesigner/QtDesignerVersion>
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtGui/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@
#include <QtGui/QTextTableCell>
#include <QtGui/QTextTableCellFormat>
#include <QtGui/QTextTableFormat>
//#include <QtGui/QtGui>
//#include <QtGui/QtGuiDepends>
// #include <QtGui/QtGui>
// #include <QtGui/QtGuiDepends>
#include <QtGui/QtGuiVersion>
#include <QtGui/QToolBarChangeEvent>
#include <QtGui/QTouchEvent>
Expand Down
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtMultimedia/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <QtMultimedia/QMediaRecorder>
#include <QtMultimedia/QMediaTimeRange>
#include <QtMultimedia/QSoundEffect>
//#include <QtMultimedia/QtMultimedia>
//#include <QtMultimedia/QtMultimediaDepends>
// #include <QtMultimedia/QtMultimedia>
// #include <QtMultimedia/QtMultimediaDepends>
#include <QtMultimedia/QtMultimediaVersion>
#include <QtMultimedia/QVideoFrame>
#include <QtMultimedia/QVideoFrameFormat>
Expand Down
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtNetwork/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <QtNetwork/QSslSocket>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
//#include <QtNetwork/QtNetwork>
//#include <QtNetwork/QtNetworkDepends>
// #include <QtNetwork/QtNetwork>
// #include <QtNetwork/QtNetworkDepends>
#include <QtNetwork/QtNetworkVersion>
#include <QtNetwork/QUdpSocket>
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtPrintSupport/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <QtPrintSupport/QPrinterInfo>
#include <QtPrintSupport/QPrintPreviewDialog>
#include <QtPrintSupport/QPrintPreviewWidget>
//#include <QtPrintSupport/QtPrintSupport>
//#include <QtPrintSupport/QtPrintSupportDepends>
// #include <QtPrintSupport/QtPrintSupport>
// #include <QtPrintSupport/QtPrintSupportDepends>
#include <QtPrintSupport/QtPrintSupportVersion>
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtSql/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#include <QtSql/QSqlRelationalTableModel>
#include <QtSql/QSqlResult>
#include <QtSql/QSqlTableModel>
//#include <QtSql/QtSql>
//#include <QtSql/QtSqlDepends>
// #include <QtSql/QtSql>
// #include <QtSql/QtSqlDepends>
#include <QtSql/QtSqlVersion>
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtSvg/allofqt.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <QtSvg/QSvgGenerator>
#include <QtSvg/QSvgRenderer>
//#include <QtSvg/QtSvg>
//#include <QtSvg/QtSvgDepends>
// #include <QtSvg/QtSvg>
// #include <QtSvg/QtSvgDepends>
#include <QtSvg/QtSvgVersion>
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtUiTools/allofqt.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#include <QtUiTools/QtUiTools>
//#include <QtUiTools/QtUiToolsDepends>
// #include <QtUiTools/QtUiTools>
// #include <QtUiTools/QtUiToolsDepends>
#include <QtUiTools/QtUiToolsVersion>
#include <QtUiTools/QUiLoader>
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtWidgets/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@
#include <QtWidgets/QTreeWidget>
#include <QtWidgets/QTreeWidgetItem>
#include <QtWidgets/QTreeWidgetItemIterator>
//#include <QtWidgets/QtWidgets>
//#include <QtWidgets/QtWidgetsDepends>
// #include <QtWidgets/QtWidgets>
// #include <QtWidgets/QtWidgetsDepends>
#include <QtWidgets/QtWidgetsVersion>
#include <QtWidgets/QUndoView>
#include <QtWidgets/QVBoxLayout>
Expand Down
4 changes: 2 additions & 2 deletions scripts/mkqtdecl6/QtXml/allofqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#include <QtXml/QDomNotation>
#include <QtXml/QDomProcessingInstruction>
#include <QtXml/QDomText>
//#include <QtXml/QtXml>
//#include <QtXml/QtXmlDepends>
// #include <QtXml/QtXml>
// #include <QtXml/QtXmlDepends>
#include <QtXml/QtXmlVersion>
52 changes: 26 additions & 26 deletions src/ant/ant/antCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
*/


#if !defined(HDR_antCommon_h)
# define HDR_antCommon_h

# if defined _WIN32 || defined __CYGWIN__

# ifdef MAKE_ANT_LIBRARY
# define ANT_PUBLIC __declspec(dllexport)
# else
# define ANT_PUBLIC __declspec(dllimport)
# endif
# define ANT_LOCAL
# define ANT_PUBLIC_TEMPLATE

# else

# if __GNUC__ >= 4 || defined(__clang__)
# define ANT_PUBLIC __attribute__ ((visibility ("default")))
# define ANT_PUBLIC_TEMPLATE __attribute__ ((visibility ("default")))
# define ANT_LOCAL __attribute__ ((visibility ("hidden")))
# else
# define ANT_PUBLIC
# define ANT_PUBLIC_TEMPLATE
# define ANT_LOCAL
# endif

# endif
#if ! defined(HDR_antCommon_h)
#define HDR_antCommon_h

#if defined _WIN32 || defined __CYGWIN__

#ifdef MAKE_ANT_LIBRARY
#define ANT_PUBLIC __declspec (dllexport)
#else
#define ANT_PUBLIC __declspec (dllimport)
#endif
#define ANT_LOCAL
#define ANT_PUBLIC_TEMPLATE

#else

#if __GNUC__ >= 4 || defined(__clang__)
#define ANT_PUBLIC __attribute__ ((visibility ("default")))
#define ANT_PUBLIC_TEMPLATE __attribute__ ((visibility ("default")))
#define ANT_LOCAL __attribute__ ((visibility ("hidden")))
#else
#define ANT_PUBLIC
#define ANT_PUBLIC_TEMPLATE
#define ANT_LOCAL
#endif

#endif

#endif
25 changes: 9 additions & 16 deletions src/ant/ant/antConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ant
// ------------------------------------------------------------
// Helper functions to get and set the configuration

std::string
std::string
StyleConverter::to_string (ant::Object::style_type s)
{
if (s == ant::Object::STY_ruler) {
Expand All @@ -53,8 +53,7 @@ StyleConverter::to_string (ant::Object::style_type s)
}
}

void
StyleConverter::from_string (const std::string &tt, ant::Object::style_type &s)
void StyleConverter::from_string (const std::string &tt, ant::Object::style_type &s)
{
std::string t (tl::trim (tt));
if (t == "ruler") {
Expand All @@ -78,7 +77,7 @@ StyleConverter::from_string (const std::string &tt, ant::Object::style_type &s)
}
}

std::string
std::string
OutlineConverter::to_string (ant::Object::outline_type o)
{
if (o == ant::Object::OL_diag) {
Expand All @@ -104,8 +103,7 @@ OutlineConverter::to_string (ant::Object::outline_type o)
}
}

void
OutlineConverter::from_string (const std::string &s, ant::Object::outline_type &o)
void OutlineConverter::from_string (const std::string &s, ant::Object::outline_type &o)
{
std::string t (tl::trim (s));
if (t == "diag") {
Expand Down Expand Up @@ -147,8 +145,7 @@ PositionConverter::to_string (ant::Object::position_type p)
}
}

void
PositionConverter::from_string (const std::string &s, ant::Object::position_type &p)
void PositionConverter::from_string (const std::string &s, ant::Object::position_type &p)
{
std::string t (tl::trim (s));
if (t == "auto") {
Expand Down Expand Up @@ -180,8 +177,7 @@ AlignmentConverter::to_string (ant::Object::alignment_type a)
}
}

void
AlignmentConverter::from_string (const std::string &s, ant::Object::alignment_type &a)
void AlignmentConverter::from_string (const std::string &s, ant::Object::alignment_type &a)
{
std::string t (tl::trim (s));
if (t == "auto") {
Expand Down Expand Up @@ -217,8 +213,7 @@ RulerModeConverter::to_string (ant::Template::ruler_mode_type m)
}
}

void
RulerModeConverter::from_string (const std::string &s, ant::Template::ruler_mode_type &a)
void RulerModeConverter::from_string (const std::string &s, ant::Template::ruler_mode_type &a)
{
std::string t (tl::trim (s));
if (t == "normal") {
Expand All @@ -239,13 +234,12 @@ RulerModeConverter::from_string (const std::string &s, ant::Template::ruler_mode
}

std::string
TemplatesConverter::to_string (const std::vector <ant::Template> &t)
TemplatesConverter::to_string (const std::vector<ant::Template> &t)
{
return ant::Template::to_string (t);
}

void
TemplatesConverter::from_string (const std::string &s, std::vector <ant::Template> &t)
void TemplatesConverter::from_string (const std::string &s, std::vector<ant::Template> &t)
{
t = ant::Template::from_string (s);
}
Expand All @@ -265,4 +259,3 @@ const std::string cfg_ruler_templates ("ruler-templates-v2");
const std::string cfg_current_ruler_template ("current-ruler-template");

} // namespace ant

Loading
Loading