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

API: New macros for version 2 #210

Merged
merged 2 commits into from
May 28, 2023
Merged

API: New macros for version 2 #210

merged 2 commits into from
May 28, 2023

Conversation

tlsa
Copy link
Owner

@tlsa tlsa commented May 28, 2023

This adds new schema building macros for version 2.

The old macros are still available, but they are now implemented as wrappers around the new v2 macros.

The problem with the old macros was that they required a fixed number of parameters, and to handle optional fields in the schema, would have required multiple variants. Since more optional features are planned for v2, the multiple variants would have got out of hand. Alternatively the new macros could have contained arguments for setting every field, however this would have made them cumbersome and less attractive than using a struct initialiser directly.

The new macros are a compromise. The new macros take the CYAML_[TYPE] as a first parameter, and a struct initialiser for the type-specific anonymous union member may be provided as the last parameter.

tlsa added 2 commits May 28, 2023 12:25
The old macros are re-implemented as wrappers for the new ones.
This means old code will continue to build.

The new macros enable greater flexibility, allowing
initialisers to be passed for type-specific schema data.
@tlsa tlsa added this to the Version 2 milestone May 28, 2023
@codecov
Copy link

codecov bot commented May 28, 2023

Codecov Report

Merging #210 (24ceac4) into main (01139ba) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #210   +/-   ##
=======================================
  Coverage   96.88%   96.88%           
=======================================
  Files           9        9           
  Lines        1637     1637           
  Branches      347      347           
=======================================
  Hits         1586     1586           
  Misses         24       24           
  Partials       27       27           
Flag Coverage Δ
unittests 96.88% <ø> (ø)

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

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tlsa tlsa merged commit e285d74 into main May 28, 2023
@tlsa tlsa deleted the tlsa/refactor-macros branch May 28, 2023 11:54
@tlsa tlsa mentioned this pull request May 29, 2023
9 tasks
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.

1 participant