oaubert / python-vlc

Python vlc bindings
GNU Lesser General Public License v2.1
381 stars 108 forks source link

Position and signed enums #244

Open mrJean1 opened 1 year ago

mrJean1 commented 1 year ago

This is an attempt to correct (a) the Position enum values, see Parser.FIXME_enums and (b) generate signed and unsigned enums, see PythonGenerator.generate_enums from issue #243.

oaubert commented 1 year ago

For my last comment (about enum values) - my remembering of the C spec is correct, running the following code

#include <stdio.h>
#include <stdlib.h>

#include <vlc/vlc.h>

int main(int argc, char **argv)
{
    printf("libvlc_position_disable = %d\n",      libvlc_position_disable);
    printf("libvlc_position_center = %d\n",       libvlc_position_center);
    printf("libvlc_position_left = %d\n",         libvlc_position_left);
    printf("libvlc_position_right = %d\n",        libvlc_position_right);
    printf("libvlc_position_top = %d\n",          libvlc_position_top);
    printf("libvlc_position_top_left = %d\n",     libvlc_position_top_left);
    printf("libvlc_position_top_right = %d\n",    libvlc_position_top_right);
    printf("libvlc_position_bottom = %d\n",       libvlc_position_bottom);
    printf("libvlc_position_bottom_left = %d\n",  libvlc_position_bottom_left);
    printf("libvlc_position_bottom_right = %d\n", libvlc_position_bottom_right);
      return 0;
}

indeed returns

libvlc_position_disable = -1
libvlc_position_center = 0
libvlc_position_left = 1
libvlc_position_right = 2
libvlc_position_top = 3
libvlc_position_top_left = 4
libvlc_position_top_right = 5
libvlc_position_bottom = 6
libvlc_position_bottom_left = 7
libvlc_position_bottom_right = 8
mrJean1 commented 1 year ago

Please, do use better names instead of the current, acronymic ones.

The top value is 4 in the screenshot in issue #243, the documentation also shows top=4. Using 4 in cocoavlc.py puts the marquee at the top in the middle, 3 puts the marquee on the center left (and not at the top in the middle), and 7 on the top left (and not at the bottom left).

mrJean1 commented 1 year ago

For your consideration, attached is the generator.py and generated vlc.py (from VLC 3.0.18 on macOS) with the new names _EnumSigned, _EnumUnsigned, enum2EnumSigned and hardfixed_enums with a preceeding # FIXME ... comment.

Also, all 9 Position values have been tested with the video_set_marquee_int(VideoMarqueeOption.Position, ...) option and all 9 appear in the proper location with the Position name.

The libvlc_position_bottom_right case was misspelled in the previous generate.py file.

generate1.21.zip