Skip to content

Conversation

yunzheng
Copy link
Member

@yunzheng yunzheng commented Jul 18, 2025

This quality of life improvement allows the user to directly initialize a cstruct object using a c-definition.

This change also enforces that endian or pointer arguments (and future arguments) must be passed using keyword arguments only. It seems that no code base used positional arguments for this before (checked using github codesearch), but this is a breaking change if someone did.

Tests are included.

resolves #133

Copy link

codecov bot commented Jul 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.21%. Comparing base (f802d41) to head (aaacb1b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #134   +/-   ##
=======================================
  Coverage   92.20%   92.21%           
=======================================
  Files          21       21           
  Lines        2515     2517    +2     
=======================================
+ Hits         2319     2321    +2     
  Misses        196      196           
Flag Coverage Δ
unittests 92.21% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yunzheng
Copy link
Member Author

Note that it doesn't have a compiled= kwarg or other kwargs like load() does.

I don't think it's necessary but it would be possible to add.

@Schamper
Copy link
Member

This change also enforces that endian or pointer arguments (and future arguments) must be passed using keyword arguments only. It seems that no code base used positional arguments for this before (checked using github codesearch), but this is a breaking change if someone did.

Can you add it to the CHANGELOG.md?

@Schamper
Copy link
Member

Note that it doesn't have a compiled= kwarg or other kwargs like load() does.

I don't think it's necessary but it would be possible to add.

Don't think it's necessary either, if you require it (or another possible future/advanced argument for load()) you should use that method instead. This is a shortcut.

@yunzheng
Copy link
Member Author

This change also enforces that endian or pointer arguments (and future arguments) must be passed using keyword arguments only. It seems that no code base used positional arguments for this before (checked using github codesearch), but this is a breaking change if someone did.

Can you add it to the CHANGELOG.md?

Done, please check if it describes the change well enough.

Co-authored-by: Erik Schamper <[email protected]>
@Schamper Schamper merged commit a7ec0a3 into main Jul 18, 2025
23 checks passed
@Schamper Schamper deleted the improvement/cstruct-init-def branch July 18, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow cstruct class initialization directly with a definition
2 participants