Skip to content

Commit

Permalink
Extract enums and defines from pg_trigger.h and lockdefs.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lelit committed Mar 15, 2019
1 parent af1d6f9 commit 753640e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# :Created: gio 03 ago 2017 14:52:45 CEST
# :Author: Lele Gaifax <lele@metapensiero.it>
# :License: GNU General Public License version 3 or later
# :Copyright: © 2017, 2018 Lele Gaifax
# :Copyright: © 2017, 2018, 2019 Lele Gaifax
#

export TOPDIR := $(CURDIR)
Expand Down Expand Up @@ -63,9 +63,10 @@ help::
@printf "enums\n\textract Python enums from PG sources\n"

PY_ENUMS_DIR := pglast/enums
PY_ENUMS := $(PY_ENUMS_DIR)/lockoptions.py $(PY_ENUMS_DIR)/nodes.py \
$(PY_ENUMS_DIR)/parsenodes.py $(PY_ENUMS_DIR)/primnodes.py \
$(PY_ENUMS_DIR)/pg_class.py
PY_ENUMS := $(PY_ENUMS_DIR)/lockoptions.py $(PY_ENUMS_DIR)/lockdefs.py \
$(PY_ENUMS_DIR)/nodes.py $(PY_ENUMS_DIR)/parsenodes.py \
$(PY_ENUMS_DIR)/pg_class.py $(PY_ENUMS_DIR)/pg_trigger.py \
$(PY_ENUMS_DIR)/primnodes.py
PG_INCLUDE_DIR := libpg_query/src/postgres/include

.PHONY: enums
Expand All @@ -74,8 +75,12 @@ enums: $(PY_ENUMS)
$(PY_ENUMS): tools/extract_enums.py libpg_query/pg_query.h
$(PY_ENUMS_DIR)/%.py: $(PG_INCLUDE_DIR)/nodes/%.h
$(PYTHON) tools/extract_enums.py -I $(PG_INCLUDE_DIR) $< $@ docs/$(basename $(notdir $@)).rst
$(PY_ENUMS_DIR)/lockdefs.py: $(PG_INCLUDE_DIR)/storage/lockdefs.h
$(PYTHON) tools/extract_enums.py -I $(PG_INCLUDE_DIR) $< $@ docs/$(basename $(notdir $@)).rst
$(PY_ENUMS_DIR)/pg_class.py: $(PG_INCLUDE_DIR)/catalog/pg_class.h
$(PYTHON) tools/extract_enums.py -I $(PG_INCLUDE_DIR) $< $@ docs/$(basename $(notdir $@)).rst
$(PY_ENUMS_DIR)/pg_trigger.py: $(PG_INCLUDE_DIR)/catalog/pg_trigger.h
$(PYTHON) tools/extract_enums.py -I $(PG_INCLUDE_DIR) $< $@ docs/$(basename $(notdir $@)).rst

help::
@printf "keywords\n\textract Python keyword sets from PG sources\n"
Expand Down
16 changes: 2 additions & 14 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.. :Created: gio 10 ago 2017 09:56:59 CEST
.. :Author: Lele Gaifax <lele@metapensiero.it>
.. :License: GNU General Public License version 3 or later
.. :Copyright: © 2017, 2018 Lele Gaifax
.. :Copyright: © 2017, 2018, 2019 Lele Gaifax
..
========
Expand Down Expand Up @@ -58,26 +58,14 @@ __ https://github.com/lfittl/libpg_query/tree/10-latest
nodes require that knowledge to determine their textual representation

- avoid introducing arbitrary renames of tags and attributes, so what you read in PostgreSQL
documentation/sources\ [*]_ is available without the hassle of guessing how a symbol has been
documentation/sources is available without the hassle of guessing how a symbol has been
mapped

- use a `zero copy`__ approach, keeping the original parse tree returned from the underlying
libpg_query functions and have each node just borrow a reference to its own subtree

__ https://en.wikipedia.org/wiki/Zero-copy

.. [*] Currently what you can find in the following headers:
- `nodes.h`__
- `primnodes.h`__
- `parsenodes.h`__
- `lockoptions.h`__
__ https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/nodes.h;hb=HEAD
__ https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/primnodes.h;hb=HEAD
__ https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/parsenodes.h;hb=HEAD
__ https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/lockoptions.h;hb=HEAD


.. toctree::
:maxdepth: 2
Expand Down

0 comments on commit 753640e

Please sign in to comment.