Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matjson v3.0 #15

Merged
merged 20 commits into from
Nov 10, 2024
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
143 changes: 143 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
IndentWidth: 4

AlignAfterOpenBracket: BlockIndent
AlignEscapedNewlines: Left
AlignConsecutiveAssignments: false
AlignOperands: DontAlign
AlignTrailingComments: false

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false

AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty

AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: false

AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AlwaysBreakAfterReturnType: None

AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes

BinPackArguments: false
BinPackParameters: true

BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false

BeforeCatch: true
BeforeElse: true

BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false

BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 100
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true

DeriveLineEnding: false
UseCRLF: false
UseTab: Never

PointerAlignment: Left
ReferenceAlignment: Pointer

EmptyLineBeforeAccessModifier: Always
FixNamespaceComments: false

IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^".*"'
Priority: 1

- Regex: '^<.*>'
Priority: 2

IndentAccessModifiers: false
AccessModifierOffset: -4
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
IndentRequiresClause: true
IndentWrappedFunctionNames: false
# InsertBraces: true
InsertTrailingCommas: None

KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
LambdaBodyIndentation: Signature
NamespaceIndentation: All

PPIndentWidth: -1

PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakOpenParenthesis: 0
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 10
PenaltyReturnTypeOnItsOwnLine: 1000000
PenaltyIndentedWhitespace: 0

QualifierAlignment: Right

RequiresClausePosition: OwnLine
ReflowComments: true
SeparateDefinitionBlocks: Always

SortIncludes: CaseSensitive
SortUsingDeclarations: true

SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_size = 2
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ jobs:
# - run: sudo apt install ninja-build
- uses: seanmiddleditch/gha-setup-ninja@v4

- name: Install GCC 12
if: matrix.config.os == 'ubuntu-latest'
run: |
sudo apt install -y gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -G Ninja

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
build-*/
.vscode/
.cache/
.cache/
24 changes: 21 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
cmake_minimum_required(VERSION 3.21)

project(mat-json VERSION 2.1.0)
project(mat-json VERSION 3.0.0)

set(SOURCE_FILES
src/json.cpp
src/external/dragonbox.cpp
src/value.cpp
src/impl.cpp
src/parser.cpp
src/dump.cpp
)

if (NOT COMMAND CPMAddPackage)
include(cmake/get_cpm.cmake)
endif()

CPMAddPackage("gh:geode-sdk/result@1.1.1")

# This option is only useful for Geode itself
if (DEFINED MAT_JSON_AS_INTERFACE AND MAT_JSON_AS_INTERFACE)
add_library(mat-json INTERFACE)
Expand All @@ -19,10 +28,19 @@ else()
add_library(mat-json ${SOURCE_FILES})

target_compile_features(mat-json PUBLIC cxx_std_20)

target_include_directories(mat-json PUBLIC include)
target_link_libraries(mat-json PUBLIC GeodeResult)
endif()

if (PROJECT_IS_TOP_LEVEL)
if (NOT WIN32)
add_compile_options("$<$<CONFIG:DEBUG>:-fsanitize=address,undefined>")
add_link_options("$<$<CONFIG:DEBUG>:-fsanitize=address,undefined>")
endif()
target_compile_options(mat-json PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Wno-gnu-statement-expression-from-macro-expansion>
)
add_subdirectory(test)
endif()
34 changes: 18 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
MIT License
Boost Software License - Version 1.0 - August 17th, 2003

Copyright (c) 2023 mat
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Loading
Loading