node: Introduce new module for working with postgres Node types #68
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.
Requires #67
Closes #66
Postgres sources use tagging and the
Node
(andNodeTag
) types for many internal types. Unfortunately the macros did not translate well to Zig, which makes it annoying to work with the low level types.We introduce the
pgzx.node
module that provides a list of helper functions likepgzx.node.make
,pgzx.node.create
,pgzx.node.tag
, orpgzx.node.isA
.We also wrap the constants into our own
pgzx.node.Tag
enum, so you can usepgzx.node.isA(node, .Query)
in code.Postgres uses code generation to collect the node tags and supported types into
nodetags.h
. We also use code generation to produce the list of tags and type mappings. The generated module is then imported bypgzx.node
.The
tools/gennodetags
tool imports thenodes/nodes.h
header file at compile time and uses comptime to collect all known tags into anArrayList
which is then used to produce the sources for the anonymous module imported intopgzx
.