<commit_before>#! /usr/bin/python
debug=False

#
# Code generator for python ctypes bindings for VLC
# Copyright (C) 2009 the VideoLAN team
# $Id: $
#
# Authors: <NAME> <olivier.aubert at liris.cnrs.fr>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
#

"""This module parses VLC public API include files and generates
corresponding python/ctypes code. Moreover, it generates class
wrappers for most methods.
"""

import sys
import os
import re
import time
import operator
import itertools
from optparse import OptionParser

# DefaultDict from ASPN python cookbook
import copy
class DefaultDict(dict):
    """Dictionary with a default value for unknown keys."""
    def __init__(self, default=None, **items):
        dict.__init__(self, **items)
        self.default = default

    def __getitem__(self, key):
        if key in self:
            return self.get(key)
        else:
            ## Need copy in case self.default is something like []
            return self.setdefault(key, copy.deepcopy(self.default))

    def __copy__(self):
        return DefaultDict(self.default, **self)

# Methods not decorated/not referenced
blacklist=[
    "libvlc_exception_raise",
    "libvlc_exception_raised",
    "libvlc_exception_get_message",
    "libvlc_get_vlc_instance",

    "libvlc_media_list_view_index_of_item",
    "libvlc_media_list_view_insert_at_index",
    "libvlc_media_list_view_remove_at_index",
    "libvlc_media_list_view_add_item",

    # In svn but not in current 1.0.0.
    #"libvlc_media_add_option_flag",
    #'libvlc_video_set_deinterlace',
    #'libvlc_video_get_marquee_option_as_int',
    #'libvlc_video_get_marquee_option_as_string',
    #'libvlc_video_set_marquee_option_as_int',
    #'libvlc_video_set_marquee_option_as_string',
    #'libvlc_vlm_get_event_manager',
    #"libvlc_media_list_player_event_manager",
    #'libvlc_media_player_next_frame',

    'mediacontrol_PlaylistSeq__free',
    ]

# Precompiled regexps
api_re=re.compile('VLC_PUBLIC_API\s+(\S+\s+.+?)\s*\(\s*(.+?)\s*\)')
param_re=re.compile('\s*(const\s*|unsigned\s*|struct\s*)?(\S+\s*\**)\s+(.+)')
paramlist_re=re.compile('\s*,\s*')
comment_re=re.compile('\\param\s+(\S+)')
python_param_re=re.compile('(@param\s+\S+)(.+)')
forward_re=re.compile('.+\(\s*(.+?)\s*\)(\s*\S+)')
enum_re=re.compile('typedef\s+(enum)\s*(\S+\s*)?\{\s*(.+)\s*\}\s*(\S+);')
special_enum_re=re.compile('^(enum)\s*(\S+\s*)?\{\s*(.+)\s*\};')
event_def_re=re.compile('^DEF\(\s*(\w+)\s*\)')

# Definition of parameter passing mode for types.  This should not be
# hardcoded this way, but works alright ATM.
parameter_passing=DefaultDict(default=1)
parameter_passing['libvlc_exception_t*']=3
<commit_msg>Update bindings for marquee change (untested).<commit_after>#! /usr/bin/python
debug=False

#
# Code generator for python ctypes bindings for VLC
# Copyright (C) 2009 the VideoLAN team
# $Id: $
#
# Authors: <NAME> <olivier.aubert at liris.cnrs.fr>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
#

"""This module parses VLC public API include files and generates
corresponding python/ctypes code. Moreover, it generates class
wrappers for most methods.
"""

import sys
import os
import re
import time
import operator
import itertools
from optparse import OptionParser

# DefaultDict from ASPN python cookbook
import copy
class DefaultDict(dict):
    """Dictionary with a default value for unknown keys."""
    def __init__(self, default=None, **items):
        dict.__init__(self, **items)
        self.default = default

    def __getitem__(self, key):
        if key in self:
            return self.get(key)
        else:
            ## Need copy in case self.default is something like []
            return self.setdefault(key, copy.deepcopy(self.default))

    def __copy__(self):
        return DefaultDict(self.default, **self)

# Methods not decorated/not referenced
blacklist=[
    "libvlc_exception_raise",
    "libvlc_exception_raised",
    "libvlc_exception_get_message",
    "libvlc_get_vlc_instance",

    "libvlc_media_list_view_index_of_item",
    "libvlc_media_list_view_insert_at_index",
    "libvlc_media_list_view_remove_at_index",
    "libvlc_media_list_view_add_item",

    # In svn but not in current 1.0.0.
    #"libvlc_media_add_option_flag",
    #'libvlc_video_set_deinterlace',
    #'libvlc_video_get_marquee_int',
    #'libvlc_video_get_marquee_string',
    #'libvlc_video_set_marquee_int',
    #'libvlc_video_set_marquee_string',
    #'libvlc_vlm_get_event_manager',
    #"libvlc_media_list_player_event_manager",
    #'libvlc_media_player_next_frame',

    'mediacontrol_PlaylistSeq__free',
    ]

# Precompiled regexps
api_re=re.compile('VLC_PUBLIC_API\s+(\S+\s+.+?)\s*\(\s*(.+?)\s*\)')
param_re=re.compile('\s*(const\s*|unsigned\s*|struct\s*)?(\S+\s*\**)\s+(.+)')
paramlist_re=re.compile('\s*,\s*')
comment_re=re.compile('\\param\s+(\S+)')
python_param_re=re.compile('(@param\s+\S+)(.+)')
forward_re=re.compile('.+\(\s*(.+?)\s*\)(\s*\S+)')
enum_re=re.compile('typedef\s+(enum)\s*(\S+\s*)?\{\s*(.+)\s*\}\s*(\S+);')
special_enum_re=re.compile('^(enum)\s*(\S+\s*)?\{\s*(.+)\s*\};')
event_def_re=re.compile('^DEF\(\s*(\w+)\s*\)')

# Definition of parameter passing mode for types.  This should not be
# hardcoded this way, but works alright ATM.
parameter_passing=DefaultDict(default=1)
parameter_passing['libvlc_exception_t*']=3

{'fraction_non_alphanumeric': 0.13386538171962054, 'fraction_numerical': 0.006324348742659238, 'mean_word_length': 4.466666666666667, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6662746', 'n_tokens_mistral': 2323, 'n_tokens_neox': 2217, 'n_words': 575}