Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 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
129 changes: 129 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Common settings
BasedOnStyle: WebKit
TabWidth: 4
IndentWidth: 4
UseTab: Always
ColumnLimit: 100

---
Language: Cpp


AccessModifierOffset: -4
AlignAfterOpenBracket: "DontAlign"
AlignArrayOfStructures: "Right"
AlignConsecutiveAssignments: "Consecutive"
AlignConsecutiveBitFields: "Consecutive"
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: "Consecutive"
AlignEscapedNewlines: "Right"
AlignOperands: "Align"
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: "Empty"
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: "AllIfsAndElse"
AllowShortLambdasOnASingleLine: "All"
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: "Yes"
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: "Both"

# Configure each individual brace in BraceWrapping
BreakBeforeBraces: Custom
# Control of individual brace wrapping cases
BraceWrapping: {
AfterCaseLabel: 'true'
AfterClass: 'true'
AfterControlStatement: 'Always'
AfterEnum : 'true'
AfterFunction : 'true'
AfterNamespace : 'true'
AfterStruct : 'true'
AfterUnion : 'true'
AfterExternBlock: 'true'
BeforeCatch : 'false'
BeforeElse : 'false'
BeforeLambdaBody : 'true'
BeforeWhile : 'false'
IndentBraces : 'false'
SplitEmptyFunction : 'false'
SplitEmptyRecord : 'false'
SplitEmptyNamespace : 'false'
}

BreakAfterJavaFieldAnnotations: true
BreakBeforeBinaryOperators: "None"
BreakBeforeConceptDeclarations : true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: "AfterColon"
BreakInheritanceList: 'AfterComma'
BreakStringLiterals: true
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
EmptyLineAfterAccessModifier: 'Always'
EmptyLineBeforeAccessModifier: 'Always'
FixNamespaceComments: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, RANGES_FOR ]
IfMacros: ['IF']
IncludeBlocks : 'Regroup'
IndentAccessModifiers : false
IndentCaseBlocks : false
IndentCaseLabels: false
IndentExternBlock : "AfterExternBlock"
IndentGotoLabels: true
IndentPPDirectives : None
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks : false
LambdaBodyIndentation : 'Signature'
NamespaceIndentation: 'All'
PackConstructorInitializers : 'NextLine'

PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60

ReferenceAlignment : 'Left'
ReflowComments : true
RemoveBracesLLVM : false
SeparateDefinitionBlocks : 'Leave'
SortIncludes: 'CaseInsensitive'
SortUsingDeclarations : true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot : false
SpaceAfterTemplateKeyword : false
SpaceBeforeAssignmentOperators : true
SpaceBeforeCaseColon : true
SpaceBeforeCtorInitializerColon : true
SpaceBeforeInheritanceColon : true
SpaceBeforeParens : Never
SpaceBeforeRangeBasedForLoopColon: false
SpaceBeforeSquareBrackets : false
SpaceInEmptyBlock : false
SpaceInEmptyParentheses : false
SpacesBeforeTrailingComments: 1
SpacesInAngles : Never
SpacesInCStyleCastParentheses : false
SpacesInConditionalStatement : false
SpacesInContainerLiterals : true
SpacesInParentheses: false
SpacesInSquareBrackets : false
Standard : Latest
PointerAlignment: Left
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
53 changes: 53 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---

Checks: >
-*,
bugprone-*,
google-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-google-readability-namespace-comments,
-google-runtime-int,
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-readability-named-parameter,
-readability-braces-around-statements,
-readability-magic-numbers

WarningsAsErrors: "*"
FormatStyle: file

CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
- { key: readability-identifier-naming.MemberConstantPrefix, value: k }
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }
- { key: cert-dcl16-c.NewSuffixes, value: 'L;LL;LU;LLU' }
- { key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField, value: '0' }
- { key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors, value: '1' }
- { key: google-readability-braces-around-statements.ShortStatementLines, value: '1'}
- { key: google-readability-function-size.StatementThreshold, value: '800'}
- { key: google-readability-namespace-comments.ShortNamespaceLines, value: '10'}
- { key: google-readability-namespace-comments.SpacesBeforeComments, value: '2'}
- { key: modernize-loop-convert.MaxCopySize, value: '16'}
- { key: modernize-loop-convert.MinConfidence, value: reasonable}
- { key: modernize-loop-convert.NamingStyle, value: CamelCase}
- { key: modernize-use-nullptr.NullMacros, value: 'NULL'}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

/.vs
/.vscode
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
/.vs
/.vscode

I feel like adding editor specific folders to the .gitignore is a bad rabbit hole, you end up adding them for every IDE. This belongs in a user level .gitignore instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah you are right. I'll change it then.

*.vcxproj
*.filters
*.recipe
Expand All @@ -15,10 +16,10 @@
*.ipch
*.sln
*.exe
*.txt
*.db-shm
*.db-wal
*.opendb
*.vsidx
*.lock
.editorconfig
[Bb][Uu][Ii][Ll][Dd]
42 changes: 42 additions & 0 deletions CMakelists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.2)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CMake 3.2 predates even C++17, so this minimum is bogus.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am sorry I had no idea that was the case. Thanks For Letting me know.

project(cppfront)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Comment on lines +4 to +5
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is super unfriendly to FetchContent users and totally unnecessary.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am using MSVC cmd line. And the cmd line tool has a tendency to make to obfuscate the build dir imo thats why I added that.

set(CMAKE_REGRESSION_TESTS_DIRECTORY ${CMAKE_SOURCE_DIR}/regression-tests)
set(CMAKE_PASSTHROUGH_TESTS_DIRECTORY ${CMAKE_SOURCE_DIR}/passthrough-tests)
set(RUN_CPPFRONT_TESTS ON)

message(${CMAKE_REGRESSION_TESTS_DIRECTORY})

# Until CMake 3.20.3, if you ask for C++20, using set(CMAKE_CXX_STANDARD 20), you'll get -std:c++latest.
# Since CMake 3.20.4, set(CMAKE_CXX_STANDARD 20) gets you -std:c++20,
# so you need set(CMAKE_CXX_STANDARD 23) to get -std:c++latest --
# assuming that your MSVC compiler version is 16.11 Preview 1 or later (see cmake commit 3aaf1d91bf353).
# issue with the standard library of MSVC
# https://stackoverflow.com/questions/64889383/how-to-enable-stdclatest-in-cmake
set(CMAKE_CXX_STANDARD 23)

set(SRC_FILES
"source/cppfront.cpp"
)

add_executable(${PROJECT_NAME} ${SRC_FILES})
target_include_directories(${PROJECT_NAME} PUBLIC "include")

# Tests are yet to be added
# not exactly sure on how to do it yet
# as it is author computer dependent

# Currently this procject only works on windows
# so right now it's fair to assume a standard relative path?
# cppfront/build/bin/Debug -> cppfront/build/bin/${CMAKE_BUILD_TYPE}
# cppfront/build/bin/Release -> cppfront/build/bin/${CMAKE_BUILD_TYPE}
# ! Regression Tests are being called but the copy of the files are not happening
# not exactly sure why.
# if(WIN32)
# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND cmd /c ${CMAKE_REGRESSION_TESTS_DIRECTORY}/run-tests.bat)
# endif()
# Bad approach

3 changes: 1 addition & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ See [License](LICENSE)

[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)


# Contributor Covenant Code of Conduct
## Contributor Covenant Code of Conduct

## Our Pledge

Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

## Contributing to cppfront
# Contributing to cppfront

cppfront is a personal experimental project of Herb Sutter.

At this time, the license is limited to non-commercial use and no distributed forks/derivatives please.


## Contributor License Agreement

By contributing content to cppfront (i.e., submitting a pull request for inclusion in this repository):

- You warrant that your material is original, or you have the right to contribute it.
- With respect to the material that you own, you grant a worldwide, non-exclusive, irrevocable, transferable, and royalty-free license to your contributed material to Herb Sutter to display, reproduce, perform, distribute, and create derivative works of that material for commercial or non-commercial use.
- With respect to any other material you contribute, such material must be under a worldwide, non-exclusive, irrevocable, transferable, and royalty-free license sufficient to allow Herb Sutter to display, reproduce, perform, distribute, and create derivative works of that material for commercial or non-commercial use.
28 changes: 28 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
workspace "cppfront"
configurations { "Debug", "Release" }

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

project "cppfront"
kind "ConsoleApp"
language "C++" -- "C", "C++", "C#"
cppdialect "C++latest"
targetdir ("bin/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
files { "source/*.cpp", "source/*.h", "include/*.h", "*.*", "passthrough-tests/*.*", "regression-tests/**" }

filter "configurations:Debug"
runtime "Debug"
symbols "on"
defines { "DEBUG" }

filter "configurations:Release"
runtime "Release"
optimize "on" -- "on", "off", "Debug", "Size", "Speed", "Full"
defines { "NDEBUG" }

filter "configurations:*32"
architecture "x86"

filter "configurations:*64"
architecture "x86_64"