Commit 397b649
Rewrite of the bindings' generator using Tree-sitter (#275)
* entries for python's venv, tree-sitter-c repo and .python-version from pyenv
* export list of project dependencies
* add tree sitter, build c parser and preprocess header files
* utilities for pretty printing a TS node
* better preprocessing: keep comments, remove linemarkers, expand macros from libvlc.h
* fix: missing return
* only preprocess vlc.h to make sure includes and macro expansion are done properly
* treesitter-based parse_enums almost done
* extract the logic for cleaning doxygen comment block in a separate method
* little refactor of parse_version: move the identification of libvlc_version.h in __init__
* parse_struct
* parse_version using Tree-sitter
* fix doc cleaning done in one branch but not the other
* ignore anonymous enums
* don't crash on empty docs, return as is
* comparing outputs obtained with Tree-sitter against those obtained with regexes
* fix wrong file_ in Enums produced
* parse_structs with queries
* update parse_structs_with_ts
* compare output of structs
* merge with parse_structs_with_ts and almost complete implementation of parse_funcs_with_ts
* fix escape sequence warning
* better dumps
* ignore unique param being void
* fix query for actually capturing all function declarations (forgot pointer_declarator nodes!)
* include type qualifiers and pointers in return type
* replacement for Par.parse_param using Tree-sitter, for parsing function parameters and struct fields
* make the assumption about libvlc naming for enums
* use pathlib instead of os.path in Parser
* implementation of parse_callbacks_with_ts
* replace if-raise by assert to make assumptions about TS nodes more concise
* use parse_param_with_ts in parse_structs_with_ts
* move preprocessing out of Parser and change Parser's __init__ slightly to make it more flexible (useful for testing for example)
* tests for parse_enums_with_ts (and define __repr__ and __eq__ for Enum and Val along the way)
* fix incomplete duplication of parse_param_with_ts logic in parse_funcs_with_ts (didn't catch const on pointers)
* tests for parse_funcs_with_ts (and define __repr__ and __eq__ to Func and Par along the way)
* fix: use _INDENT_ instead of tabs
* remove const and spaces from Par types, like parse_param does (fix the tests accordingly)
* remove 'struct' from Par types, as done in parse_param
* tests for parse_structs_with_ts (and define __repr__ and __eq__ for Struct along the way)
* tests for parse_callbacks and fix incomplete duplication of parse_param_with_ts
* tests parse_version_with_ts
* git ignore .venv as well
* add setuptools
* remove code related to parsing with regular expressions, and ignore function pointers and unions within structs for now
* remove extraneous printing
* use assertCountEqual instead of assertListEqual, because order doesn't matter in this case
* feat: parse nested structs/unions; moved parse_param into Parser, created a Union class, tweaked dump methods to allow multiple levels of indentation
* tests for parsing nested structs/unions and split tests for bindings vs. generator (reflected in the Makefile as well)
* formatting using ruff
* recipe to lint using ruff
* fix some lint errors
* feat: parse function pointers as params or fields; factored out type parsing into parse_type, stopped accepting top-level funcs and callbacks in parse_param because made it too difficult to handle function pointers elsewhere
* fix parse_funcs and parse_callbacks to handle function pointers as params and not match function pointers as fields
* test for function pointer as struct field
* test for function pointer as parameter of callback
* no need to name it as private, stay consistent
* add option to Parser controlling whether it should parse nested structs/unions and function pointers as params/fields; it is opt-out, and if opted out, we get the same capabilities/output that the previous regex-based parser
* factor the finding of an associated Doxygen comment into a separate method
* update parse_param docstring in light of recent changes
* tests for function pointers as param of regular functions
* refactor: move clean_doxygen_comment_block out of Parser because it
doesn't really belong there
* tests for clean_doxygen_comment_block
* refactor: format Parser's test input files
* fix: preprocess even if vlc.preprocessed exists, because the output unexpectedly doesn't change when testing on different header files (otherwise need to remember to delete vlc.preprocessed!)
* feat: update preprocessing command to handle cases where vlc headers are included as system headers (like in version 4.0.0)
* fix: ignore enums w/o body instead of crashing (needed for libvlc v4.0.0 because there are typedefed enums w/o body)
* refactor: make attributes constants
* feat: handle deprecated enum values
* install sphinx
* tests from enums with deprecated values
* feat: add docs for enum values
* tests for enums with documented values
* slightly more permissive linter rules + fix two linting errors
* add pre-commit hook running ruff
* sphinx autodoc
* add ruff github action
* add workflow for tests
* install ruff in venv
* function doxygenToSphinx and change epydoc
* fix: workaround to ignore file's doc block on top of enum, struct or else
* feat: format output of PythonGenerator using ruff
* sort parsed items as it proves useful for debugging (makes generated bindings easier to diff)
* parser can't be None now
* sort imports as part of the linting
* feat: run ruff --fix as well when formatting PythonGenerator's output
* run ruff check --fix as part of the format recipe
* feat: a good start for generating nested structs/unions
* fix: pre-commit config was not doing what was expected, it checked any Python file about to be committed
* fix: generate wrapper classes before structs as they can be needed as field type
* fix: can't output structs sorted by name because a struct's class need to be defined before it is used; sorting breaks the (right) order of libvlc's source
* use _Cstruct instead of ctypes.Structure
* fix: base class should be Union, not Structure
* field type being a wrapper class doesn't work because wrapper classes are not ctypes; didn't found a solution not conflicting with the creation process (__new__) of wrapper classes
* increment generator's major version
* feat: generate binding for function pointer as struct/union field
* test bindings for function pointers of DialogCbs
* no need for hardcoded Event and EventUnion anymore
* update the method doxygen2sphinx
* change the doxygen format @ to sphinx :
* fix: generate nested structs/unions within their parent class so that nested structs/unions having the same name don't shadow each other
* fix syntax warnings
* make Tree-sitter C grammar a submodule
* (dev) script to setup the project after cloning
* use dev_setup.py in tests workflow, and test bindings as well
* latest generated dev/vlc.py
* fix: activating venv in subprocess is useless! can call venv's python directly
* fix: fix dev_setup on windows
* fix: fix tests workflow now that dev_setup has changed
* can remove one item from the todolist!
* add ourselves as contributors
* remove pylint, pyflakes, pychecker related stuff; use ruff now
* drop python2 support for the generator
* put _Enum in header.py instead of generating it each time
* fix: ignore Doxygen blocks with a file tag
* better way to output docs: no more N/A, better indentation
* format templates
* strip whitespaces utility function, with unit tests
* better sphinx doc in templates
* don't need the toc
* unit doxygen2sphinx and epydocs into docs_in_sphinx_format, and better sphinx doc generation (cross references, params in italic, note and warning blocks, etc.)
* rename option genums
* rename generate_ctypes
* insert generated functions in the header so that header.py becomes the only place where we decide the order of generation
* docstrings in sphinx format for generator, plus making some names smaller...
* fix: was running insert_code two times, so writing build_date two times when format=True
* add wheel for package builds
* (almost) empty the blacklist and report deprecated functions as well
* snake to camel case utility
* feat: generate decorators for function pointers as parameters (only case is libvlc_set_exit_handler)
* reintroducing EventUnion for backward compatibility
* test execution of dialog cbs (at least the error one)
* test event callbacks bindings
* test exit handler
* convert Doxygen lists to Sphinx lists, and use spaces instead of tabs for generated docs
* generate docs for dev
* latest generated dev/vlc.py
* update generator's README given recent changes
* update 'How to contribute' because no _blacklist anymore
* better error messages
* don't make a venv when one already exists
* quotes in f-string doesn't work in all Python versions
---------
Co-authored-by: wafa harir <wafa.harir@etu.univ-nantes.fr>
Co-authored-by: Yann SALMON <yann.salmon@etu.univ-nantes.fr>1 parent 03cbfde commit 397b649
File tree
35 files changed
+16955
-9139
lines changed- .github/workflows
- docs
- generated/dev
- generator
- templates
- tests
- samples
- test_parser_inputs
- vendor
35 files changed
+16955
-9139
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
65 | 77 | | |
66 | | - | |
67 | | - | |
68 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
76 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
77 | 91 | | |
78 | | - | |
79 | | - | |
80 | | - | |
| 92 | + | |
| 93 | + | |
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
23 | | - | |
| 21 | + | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
| |||
31 | 29 | | |
32 | 30 | | |
33 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
34 | 54 | | |
35 | | - | |
| 55 | + | |
36 | 56 | | |
37 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
38 | 60 | | |
39 | 61 | | |
40 | 62 | | |
41 | | - | |
| 63 | + | |
42 | 64 | | |
43 | | - | |
| 65 | + | |
44 | 66 | | |
45 | | - | |
| 67 | + | |
46 | 68 | | |
47 | 69 | | |
48 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
49 | 73 | | |
50 | 74 | | |
51 | 75 | | |
52 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
53 | 79 | | |
54 | 80 | | |
55 | 81 | | |
56 | 82 | | |
57 | | - | |
58 | | - | |
| 83 | + | |
59 | 84 | | |
60 | 85 | | |
61 | 86 | | |
| |||
67 | 92 | | |
68 | 93 | | |
69 | 94 | | |
70 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
71 | 125 | | |
72 | | - | |
73 | | - | |
74 | 126 | | |
75 | 127 | | |
76 | 128 | | |
77 | 129 | | |
78 | | - | |
79 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
80 | 137 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 138 | + | |
86 | 139 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 140 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
0 commit comments