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
33 changes: 33 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 120
AccessModifierOffset: -4
InsertNewlineAtEOF: true


# Brace breaking: Stroustrup style (functions same line, control same, else cuddled)
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: false # "cuddled" } else {
AfterEnum: true
AfterFunction: false # Same line
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false # Cuddled
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true

AllowShortFunctionsOnASingleLine: Empty
KeepEmptyLinesAtTheStartOfBlocks: false

# Naming? Clang-format doesn't enforce naming, clang-tidy does.
# This config handles layout.
39 changes: 39 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
Checks: '
readability-identifier-naming,
readability-named-parameter,
bugprone-argument-comment,
performance-*,
bugprone-*,
modernize-use-override,
modernize-use-nullptr,
-bugprone-narrowing-conversions,
-bugprone-easily-swappable-parameters
'
WarningsAsErrors: ''
CheckOptions:
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.GlobalVariableCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberPrefix
value: _
- key: readability-identifier-naming.PrivateMemberCase
value: camelBack
- key: readability-identifier-naming.ProtectedMemberPrefix
value: _
- key: readability-identifier-naming.ProtectedMemberCase
value: camelBack
- key: readability-identifier-naming.PublicMemberCase
value: camelBack
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.ParameterCase
value: camelBack
- key: readability-named-parameter.IgnoreFailedSplit
value: false
...
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

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

[*.{c,cpp,h,hpp,cc,mm}]
indent_style = space
indent_size = 4

[CMakeLists.txt]
indent_style = space
indent_size = 4
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: local
hooks:
- id: clang-format
name: clang-format
entry: clang-format
language: system
files: \.(cpp|h|c|hpp|cc|mm|m)$
args: ["-style=file:.clang-format", "-i"]
29 changes: 24 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.28)

project(EntropyCore
project(EntropyCore
VERSION 1.0.0
DESCRIPTION "Core utilities and concurrency primitives for Entropy Engine"
LANGUAGES C CXX
Expand Down Expand Up @@ -29,13 +29,24 @@ endif()
# Back-compat shim: mirror to existing variable used throughout the file
set(ENTROPY_BUILD_TESTS ${ENTROPY_ENABLE_TESTS} CACHE BOOL "Build tests for EntropyCore (deprecated; use ENTROPY_ENABLE_TESTS)" FORCE)

# Set C++20 standard with modules support
# Set C++20 standard (modules not used)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Disable automatic C++20 module scanning - this project doesn't use modules
# and the auto-scanning generates Clang-specific flags that GCC doesn't support
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

# MSVC-specific: Enable conforming preprocessor for C++20 __VA_OPT__ support
if(MSVC)
add_compile_options(/Zc:preprocessor)
endif()

# Configure sanitizers
# Configure sanitizers
if(ENABLE_SANITIZERS)
# Always enable ASAN+UBSAN for Debug builds on minimal supported compilers
if(ENABLE_SANITIZERS OR (CMAKE_BUILD_TYPE MATCHES "Debug" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU"))
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
# ThreadSanitizer is mutually exclusive with AddressSanitizer
# To use TSAN instead: cmake -DENABLE_TSAN=ON
Expand Down Expand Up @@ -375,7 +386,7 @@ set_target_properties(EntropyCore PROPERTIES
# Testing
if(ENTROPY_BUILD_TESTS)
enable_testing()

# Test executable
# Test helper sources
set(TEST_HELPERS
Expand Down Expand Up @@ -454,6 +465,14 @@ if(ENTROPY_BUILD_TESTS)
GTest::gtest_main
)

# =============================================================================
# Linting
# =============================================================================
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/EntropyLinting.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/EntropyLinting.cmake")
entropy_enable_linting(EntropyCore)
endif()

target_compile_features(EntropyCoreTests PRIVATE cxx_std_20)

# Enable testing and discover tests automatically
Expand Down Expand Up @@ -502,4 +521,4 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/EntropyCoreConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/EntropyCoreConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/EntropyCore
)
)
18 changes: 11 additions & 7 deletions Examples/CInteropExample.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
#include <stdio.h>
#include <inttypes.h>
#include <Core/entropy_c_api.h>
#include <Logging/CLogger.h>
#include <inttypes.h>
#include <stdio.h>

// Dummy owner and vtable callbacks for demonstration
static int dummy_validate(const void* owner, uint32_t index, uint32_t generation) {
// No backing store; nothing is valid in this minimal example
(void)owner; (void)index; (void)generation;
(void)owner;
(void)index;
(void)generation;
return 0;
}
static EntropyObjectRef* dummy_resolve(const void* owner, uint32_t index, uint32_t generation) {
// No backing store; cannot resolve
(void)owner; (void)index; (void)generation;
(void)owner;
(void)index;
(void)generation;
return NULL;
}

int main(void) {
uint32_t maj=0, min=0, pat=0, abi=0;
uint32_t maj = 0, min = 0, pat = 0, abi = 0;
entropy_get_version(&maj, &min, &pat, &abi);
ENTROPY_LOG_INFO_F("EntropyCore C API version: %u.%u.%u (ABI %u)", maj, min, pat, abi);

Expand All @@ -25,7 +29,7 @@ int main(void) {
entropy_register_owner_vtable(dummy_owner, dummy_resolve, dummy_validate);

// Construct a handle value (no real object behind it in this example)
EntropyHandle h = { dummy_owner, 42u, 7u, 0u };
EntropyHandle h = {dummy_owner, 42u, 7u, 0u};

// Basic handle operations
ENTROPY_LOG_INFO_F("Handle valid? %d", (int)entropy_handle_is_valid(h));
Expand All @@ -44,7 +48,7 @@ int main(void) {
// Allocation helpers
char* buf = (char*)entropy_alloc(32);
if (buf) {
for (int i=0;i<31;i++) buf[i] = (i%10)+'0';
for (int i = 0; i < 31; i++) buf[i] = (i % 10) + '0';
buf[31] = '\0';
ENTROPY_LOG_INFO_F("Allocated buffer: %s", buf);
entropy_free(buf);
Expand Down
Loading
Loading