Commit 365408f9 authored by Olivier Aubert's avatar Olivier Aubert

python-ctypes: check at load time the availability of symbols before trying to wrap them

parent 4b8fd642
...@@ -65,14 +65,16 @@ blacklist=[ ...@@ -65,14 +65,16 @@ blacklist=[
"libvlc_media_list_view_remove_at_index", "libvlc_media_list_view_remove_at_index",
"libvlc_media_list_view_add_item", "libvlc_media_list_view_add_item",
# In svn but not in current 1.0.0 # In svn but not in current 1.0.0.
"libvlc_media_add_option_flag", #"libvlc_media_add_option_flag",
'libvlc_video_set_deinterlace', #'libvlc_video_set_deinterlace',
'libvlc_video_get_marquee_option_as_int', #'libvlc_video_get_marquee_option_as_int',
'libvlc_video_get_marquee_option_as_string', #'libvlc_video_get_marquee_option_as_string',
'libvlc_video_set_marquee_option_as_int', #'libvlc_video_set_marquee_option_as_int',
'libvlc_video_set_marquee_option_as_string', #'libvlc_video_set_marquee_option_as_string',
'libvlc_vlm_get_event_manager', #'libvlc_vlm_get_event_manager',
#"libvlc_media_list_player_event_manager",
#'libvlc_media_player_next_frame',
'mediacontrol_PlaylistSeq__free', 'mediacontrol_PlaylistSeq__free',
] ]
...@@ -478,25 +480,26 @@ class PythonGenerator(object): ...@@ -478,25 +480,26 @@ class PythonGenerator(object):
# FIXME # FIXME
return return
self.output("""if hasattr(dll, '%s'):""" % method)
if params: if params:
self.output("prototype=ctypes.CFUNCTYPE(%s, %s)" % (self.type2class.get(rtype, 'FIXME_%s' % rtype), self.output(" prototype=ctypes.CFUNCTYPE(%s, %s)" % (self.type2class.get(rtype, 'FIXME_%s' % rtype),
",".join( self.type2class[p[0]] for p in params ))) ",".join( self.type2class[p[0]] for p in params )))
else: else:
self.output("prototype=ctypes.CFUNCTYPE(%s)" % self.type2class.get(rtype, 'FIXME_%s' % rtype)) self.output(" prototype=ctypes.CFUNCTYPE(%s)" % self.type2class.get(rtype, 'FIXME_%s' % rtype))
if not params: if not params:
flags='paramflags= tuple()' flags=' paramflags= tuple()'
elif len(params) == 1: elif len(params) == 1:
flags="paramflags=( (%d, ), )" % parameter_passing[params[0][0]] flags=" paramflags=( (%d, ), )" % parameter_passing[params[0][0]]
else: else:
flags="paramflags=%s" % ",".join( '(%d,)' % parameter_passing[p[0]] for p in params ) flags=" paramflags=%s" % ",".join( '(%d,)' % parameter_passing[p[0]] for p in params )
self.output(flags) self.output(flags)
self.output('%s = prototype( ("%s", dll), paramflags )' % (method, method)) self.output(' %s = prototype( ("%s", dll), paramflags )' % (method, method))
if '3' in flags: if '3' in flags:
# A VLCException is present. Process it. # A VLCException is present. Process it.
self.output("%s.errcheck = check_vlc_exception" % method) self.output(" %s.errcheck = check_vlc_exception" % method)
self.output('%s.__doc__ = """%s"""' % (method, comment)) self.output(' %s.__doc__ = """%s"""' % (method, comment))
self.output() self.output()
def parse_override(self, name): def parse_override(self, name):
...@@ -613,6 +616,7 @@ class PythonGenerator(object): ...@@ -613,6 +616,7 @@ class PythonGenerator(object):
else: else:
args=", ".join( p[1] for p in params ) args=", ".join( p[1] for p in params )
self.output(" if hasattr(dll, '%s'):" % method)
self.output(" def %s(%s):" % (name, args)) self.output(" def %s(%s):" % (name, args))
self.output(' """%s\n """' % self.fix_python_comment(comment)) self.output(' """%s\n """' % self.fix_python_comment(comment))
if params and params[-1][0] == 'libvlc_exception_t*': if params and params[-1][0] == 'libvlc_exception_t*':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment