Alternative (and simpler) workflow for binding constants #296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a second way of binding compile-time constants such as enumeration constants, macro values, struct offsets, union sizes, etc..
Bindings written using the old interface can be reused without change. For example, to create a type corresponding to the following C enum declaration
you might write:
Here's how to use the
Types
functor with the existing existing interface (see also #62):Types
functor toCstubs.Types.write_c
to generate a C program
Cstubs.TYPES
.Types
to the generated module to make the compile-time constants available to your program.Here's how to use the
Types
functor with the new interface in this pull request:Types
functor toCstubs_structs.Easy.write_c
and
Cstubs_structs.Easy.write_ml
to generate C stubs and an ML module of type
Cstubs.TYPES
.Types
to the generated module to make the compile-time constants available to your program.There's a tradeoff: the new interface is easier to integrate into a build, since the dependencies are less linear. The existing interface generates slightly faster code, since it inlines the values of the C constants into the ML program.
(This isn't quite ready for merge: it doesn't yet support binding the same constant multiple times under different types.)
Closes #266.