Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
25c18f6
entries for python's venv, tree-sitter-c repo and .python-version fro…
yanns1 Jan 11, 2024
5df6197
export list of project dependencies
yanns1 Jan 11, 2024
685eead
add tree sitter, build c parser and preprocess header files
yanns1 Jan 13, 2024
108a8b4
utilities for pretty printing a TS node
yanns1 Jan 15, 2024
aec2ade
better preprocessing: keep comments, remove linemarkers, expand macro…
yanns1 Jan 15, 2024
48aa41b
fix: missing return
yanns1 Jan 25, 2024
d12c617
only preprocess vlc.h to make sure includes and macro expansion are d…
yanns1 Jan 25, 2024
948a52c
treesitter-based parse_enums almost done
yanns1 Jan 31, 2024
7b41def
extract the logic for cleaning doxygen comment block in a separate me…
yanns1 Jan 31, 2024
92a286f
little refactor of parse_version: move the identification of libvlc_v…
yanns1 Feb 1, 2024
01b7b3e
parse_struct
wafa-harir Feb 1, 2024
4a6e5f2
Merge branch 'master' of https://github.com/yanns1/python-vlc
wafa-harir Feb 1, 2024
17bcdc1
parse_version using Tree-sitter
yanns1 Feb 18, 2024
5c6413e
fix doc cleaning done in one branch but not the other
Feb 18, 2024
ea712b2
ignore anonymous enums
Feb 18, 2024
b8aeb9e
don't crash on empty docs, return as is
Feb 18, 2024
e86a227
comparing outputs obtained with Tree-sitter against those obtained wi…
Feb 18, 2024
d65ec6d
fix wrong file_ in Enums produced
Feb 18, 2024
3df4935
parse_structs with queries
wafa-harir Feb 18, 2024
9493490
Merge branch 'master' of https://github.com/yanns1/python-vlc
wafa-harir Feb 18, 2024
e540df5
update parse_structs_with_ts
wafa-harir Feb 18, 2024
be3e7dd
compare output of structs
wafa-harir Feb 19, 2024
976d70b
merge with parse_structs_with_ts and almost complete implementation o…
Feb 19, 2024
497eadf
fix escape sequence warning
Feb 19, 2024
d1a96cf
better dumps
Feb 19, 2024
dddeab3
ignore unique param being void
Feb 19, 2024
0d9ea7e
fix query for actually capturing all function declarations (forgot po…
Feb 19, 2024
8a6474b
include type qualifiers and pointers in return type
Feb 21, 2024
2f5d2fe
replacement for Par.parse_param using Tree-sitter, for parsing functi…
Feb 21, 2024
7e90fd0
make the assumption about libvlc naming for enums
Feb 21, 2024
dd42488
use pathlib instead of os.path in Parser
Feb 21, 2024
4123e8e
implementation of parse_callbacks_with_ts
Mar 9, 2024
4091209
replace if-raise by assert to make assumptions about TS nodes more co…
Mar 9, 2024
cfa3d9f
use parse_param_with_ts in parse_structs_with_ts
wafa-harir Mar 11, 2024
3150acc
move preprocessing out of Parser and change Parser's __init__ slightl…
yanns1 Mar 11, 2024
ff0a697
tests for parse_enums_with_ts (and define __repr__ and __eq__ for Enu…
yanns1 Mar 11, 2024
f8aad13
fix incomplete duplication of parse_param_with_ts logic in parse_func…
yanns1 Mar 11, 2024
9753ad8
tests for parse_funcs_with_ts (and define __repr__ and __eq__ to Func…
yanns1 Mar 11, 2024
d0fb740
fix: use _INDENT_ instead of tabs
yanns1 Mar 11, 2024
ce7cc30
remove const and spaces from Par types, like parse_param does (fix th…
yanns1 Mar 11, 2024
30ce0b6
remove 'struct' from Par types, as done in parse_param
yanns1 Mar 11, 2024
d4e82a4
tests for parse_structs_with_ts (and define __repr__ and __eq__ for S…
wafa-harir Mar 14, 2024
fdd3bc3
tests for parse_callbacks and fix incomplete duplication of parse_par…
yanns1 Mar 14, 2024
1f0df68
tests parse_version_with_ts
yanns1 Mar 14, 2024
db61d47
git ignore .venv as well
yanns1 Apr 6, 2024
0f69a40
add setuptools
yanns1 Apr 7, 2024
8956e70
remove code related to parsing with regular expressions, and ignore f…
yanns1 Apr 7, 2024
fa888fb
remove extraneous printing
yanns1 Apr 7, 2024
7f2ed33
use assertCountEqual instead of assertListEqual, because order doesn'…
yanns1 Apr 7, 2024
53614ba
feat: parse nested structs/unions; moved parse_param into Parser, cre…
yanns1 Apr 8, 2024
d84da1f
tests for parsing nested structs/unions and split tests for bindings …
yanns1 Apr 8, 2024
133f447
formatting using ruff
yanns1 Apr 8, 2024
18772f6
recipe to lint using ruff
yanns1 Apr 8, 2024
6c3c8f3
fix some lint errors
yanns1 Apr 8, 2024
edcb66d
feat: parse function pointers as params or fields; factored out type …
yanns1 Apr 8, 2024
dd89ab9
fix parse_funcs and parse_callbacks to handle function pointers as pa…
yanns1 Apr 8, 2024
94e9e62
test for function pointer as struct field
yanns1 Apr 8, 2024
7c092cb
test for function pointer as parameter of callback
yanns1 Apr 8, 2024
2167e5a
no need to name it as private, stay consistent
yanns1 Apr 8, 2024
55aee4f
add option to Parser controlling whether it should parse nested struc…
yanns1 Apr 9, 2024
aebaead
factor the finding of an associated Doxygen comment into a separate m…
yanns1 Apr 9, 2024
59bbd59
update parse_param docstring in light of recent changes
yanns1 Apr 9, 2024
f411e80
tests for function pointers as param of regular functions
yanns1 Apr 24, 2024
8fccef5
refactor: move clean_doxygen_comment_block out of Parser because it
yanns1 Apr 24, 2024
235a8f1
tests for clean_doxygen_comment_block
yanns1 Apr 24, 2024
fac8d13
refactor: format Parser's test input files
yanns1 Apr 24, 2024
f139591
fix: preprocess even if vlc.preprocessed exists, because the output u…
yanns1 Apr 24, 2024
d5282c6
feat: update preprocessing command to handle cases where vlc headers …
yanns1 Apr 24, 2024
f039373
fix: ignore enums w/o body instead of crashing (needed for libvlc v4.…
yanns1 Apr 24, 2024
090953a
refactor: make attributes constants
yanns1 Apr 24, 2024
1bef7dd
feat: handle deprecated enum values
yanns1 Apr 24, 2024
78b2787
install sphinx
wafa-harir Apr 25, 2024
1a23961
tests from enums with deprecated values
yanns1 Apr 25, 2024
05423bd
feat: add docs for enum values
yanns1 Apr 25, 2024
bcf9e9d
tests for enums with documented values
yanns1 Apr 25, 2024
b3b0507
slightly more permissive linter rules + fix two linting errors
yanns1 Apr 25, 2024
f696308
add pre-commit hook running ruff
yanns1 Apr 25, 2024
2471758
sphinx autodoc
wafa-harir Apr 25, 2024
81d9ee5
Merge branch 'master' of https://github.com/yanns1/python-vlc
wafa-harir Apr 25, 2024
95c594c
add ruff github action
yanns1 Apr 25, 2024
d715141
add workflow for tests
yanns1 Apr 25, 2024
4ccebc0
install ruff in venv
wafa-harir Apr 25, 2024
2f79e2a
Merge branch 'master' of https://github.com/yanns1/python-vlc
wafa-harir Apr 25, 2024
e5f4178
function doxygenToSphinx and change epydoc
wafa-harir Apr 25, 2024
8ea7db4
fix: workaround to ignore file's doc block on top of enum, struct or …
yanns1 Apr 26, 2024
5d25a89
feat: format output of PythonGenerator using ruff
yanns1 Apr 26, 2024
fbd2156
Merge branch 'master' of https://github.com/yanns1/python-vlc
yanns1 Apr 26, 2024
ade2b7b
sort parsed items as it proves useful for debugging (makes generated …
yanns1 Apr 26, 2024
5a5b992
parser can't be None now
yanns1 Apr 27, 2024
b25201e
sort imports as part of the linting
yanns1 Apr 27, 2024
7aa9f9a
feat: run ruff --fix as well when formatting PythonGenerator's output
yanns1 Apr 27, 2024
ddcaee5
run ruff check --fix as part of the format recipe
yanns1 Apr 27, 2024
8ecb25a
feat: a good start for generating nested structs/unions
yanns1 Apr 27, 2024
d2b6c1d
fix: pre-commit config was not doing what was expected, it checked an…
yanns1 Apr 27, 2024
18abd6e
fix: generate wrapper classes before structs as they can be needed as…
yanns1 Apr 27, 2024
72686dc
fix: can't output structs sorted by name because a struct's class nee…
yanns1 Apr 27, 2024
64e7df9
use _Cstruct instead of ctypes.Structure
yanns1 Apr 28, 2024
3f7bd16
fix: base class should be Union, not Structure
yanns1 Apr 28, 2024
6ae629d
field type being a wrapper class doesn't work because wrapper classes…
yanns1 Apr 28, 2024
445746a
increment generator's major version
yanns1 Apr 28, 2024
1f7f393
feat: generate binding for function pointer as struct/union field
yanns1 Apr 28, 2024
f754252
test bindings for function pointers of DialogCbs
yanns1 Apr 28, 2024
24d5c5e
no need for hardcoded Event and EventUnion anymore
yanns1 Apr 28, 2024
f932cfb
update the method doxygen2sphinx
wafa-harir Apr 28, 2024
7684b6e
Merge branch 'master' of https://github.com/yanns1/python-vlc
wafa-harir Apr 28, 2024
50bd207
change the doxygen format @ to sphinx :
wafa-harir Apr 28, 2024
c657924
fix: generate nested structs/unions within their parent class so that…
yanns1 Apr 28, 2024
034fc75
Merge branch 'master' of https://github.com/yanns1/python-vlc
yanns1 Apr 28, 2024
633b054
fix syntax warnings
yanns1 Apr 28, 2024
8a2e636
make Tree-sitter C grammar a submodule
yanns1 Apr 28, 2024
7b22532
(dev) script to setup the project after cloning
yanns1 Apr 28, 2024
84562cf
use dev_setup.py in tests workflow, and test bindings as well
yanns1 Apr 28, 2024
f1fb190
latest generated dev/vlc.py
yanns1 Apr 28, 2024
45e20a1
fix: activating venv in subprocess is useless! can call venv's python…
yanns1 Apr 29, 2024
841076f
fix: fix dev_setup on windows
wafa-harir Apr 29, 2024
717deb7
fix: fix tests workflow now that dev_setup has changed
yanns1 Apr 29, 2024
362fe5a
can remove one item from the todolist!
yanns1 Apr 29, 2024
bc2c38d
add ourselves as contributors
yanns1 Apr 30, 2024
ece4178
remove pylint, pyflakes, pychecker related stuff; use ruff now
yanns1 Apr 30, 2024
8c59922
drop python2 support for the generator
yanns1 Apr 30, 2024
c73d59f
put _Enum in header.py instead of generating it each time
yanns1 May 1, 2024
d24fe04
fix: ignore Doxygen blocks with a file tag
yanns1 May 1, 2024
ec0fa31
better way to output docs: no more N/A, better indentation
yanns1 May 1, 2024
cdf571d
format templates
yanns1 May 4, 2024
7040340
strip whitespaces utility function, with unit tests
yanns1 May 4, 2024
7dc0f0c
better sphinx doc in templates
yanns1 May 4, 2024
4866669
don't need the toc
yanns1 May 4, 2024
a1a763d
unit doxygen2sphinx and epydocs into docs_in_sphinx_format, and bette…
yanns1 May 4, 2024
0601f1d
rename option genums
yanns1 May 5, 2024
138aeea
rename generate_ctypes
yanns1 May 5, 2024
07199d4
insert generated functions in the header so that header.py becomes th…
yanns1 May 5, 2024
06d5f2b
docstrings in sphinx format for generator, plus making some names sma…
yanns1 May 5, 2024
a304153
fix: was running insert_code two times, so writing build_date two tim…
yanns1 May 5, 2024
0f8ffff
add wheel for package builds
yanns1 May 5, 2024
d82ed83
(almost) empty the blacklist and report deprecated functions as well
yanns1 May 8, 2024
8f74819
snake to camel case utility
yanns1 May 8, 2024
2f2b166
feat: generate decorators for function pointers as parameters (only c…
yanns1 May 14, 2024
22d0c32
reintroducing EventUnion for backward compatibility
yanns1 May 14, 2024
034a550
test execution of dialog cbs (at least the error one)
yanns1 May 16, 2024
f83d647
test event callbacks bindings
yanns1 May 17, 2024
fd94e74
test exit handler
yanns1 May 17, 2024
8c54416
convert Doxygen lists to Sphinx lists, and use spaces instead of tabs…
yanns1 May 17, 2024
b29d5b6
generate docs for dev
yanns1 May 17, 2024
0b22fd1
latest generated dev/vlc.py
yanns1 May 17, 2024
0e0f237
update generator's README given recent changes
yanns1 May 17, 2024
044d1b4
update 'How to contribute' because no _blacklist anymore
yanns1 May 17, 2024
99b824c
better error messages
yanns1 May 17, 2024
fdb3345
don't make a venv when one already exists
yanns1 May 17, 2024
e4d9d97
quotes in f-string doesn't work in all Python versions
yanns1 May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reintroducing EventUnion for backward compatibility
  • Loading branch information
yanns1 committed May 14, 2024
commit 22d0c32632fcf02a6d39baceb442c7e2bdc3a032
39 changes: 39 additions & 0 deletions generator/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,34 @@ def generate_func_pointer_decorator(
self.output(f"{indent}{name}.__doc__ = '''{docs}'''")
self.output("")

def generate_event_union_wrapper(self, wrapper_classname: str):
self.output(
f'''class {wrapper_classname}(ctypes.Union):
"""A wrapper around the nested union :class:`Event.U` for backard compatibility."""

_fields_ = [
("meta_type", ctypes.c_uint),
("new_child", ctypes.c_uint),
("new_duration", ctypes.c_longlong),
("new_status", ctypes.c_int),
("media", ctypes.c_void_p),
("new_state", ctypes.c_uint),
# FIXME: Media instance
("new_cache", ctypes.c_float),
("new_position", ctypes.c_float),
("new_time", ctypes.c_longlong),
("new_title", ctypes.c_int),
("new_seekable", ctypes.c_longlong),
("new_pausable", ctypes.c_longlong),
("new_scrambled", ctypes.c_longlong),
("new_count", ctypes.c_longlong),
# FIXME: Skipped MediaList and MediaListView...
("filename", ctypes.c_char_p),
("new_length", ctypes.c_longlong),
]
'''
)

def generate_struct(self, struct: Struct, indent_lvl: int = 0):
"""Outputs a binding for *struct*.

Expand Down Expand Up @@ -2337,6 +2365,14 @@ def generate_struct(self, struct: Struct, indent_lvl: int = 0):
# Assume the overriding definition contains all code in .codes
self.output(self.overrides.codes[cls])
else:
# For backward-compatibility, we make a wrapper around
# the nested union in 'Event' so as to flatten/ignore
# the nested structs within it, as was done in
# the harcoded 'EventUnion' before.
event_union_wrapper = "EventUnion"
if cls == "Event":
self.generate_event_union_wrapper(event_union_wrapper)

self.output(f"{indent}{cls}._fields_ = (")

for field in struct.fields:
Expand All @@ -2363,6 +2399,9 @@ def generate_struct(self, struct: Struct, indent_lvl: int = 0):
# be applied generally.
if cls == "Event" and field.name == "type":
field_type = "EventType"
# Use wrapper for the nested union for backward compatibility.
if cls == "Event" and field.name == "u":
field_type = event_union_wrapper

# FIXME: For now, ignore field if it's type is one of the wrapper classes.
if field_type in self.defined_classes:
Expand Down