3 vlc to jna almost-automatized interface converter.
5 This program is free software. It comes without any warranty, to
6 the extent permitted by applicable law. You can redistribute it
7 and/or modify it under the terms of the Do What The Fuck You Want
8 To Public License, Version 2, as published by Sam Hocevar. See
9 http://sam.zoy.org/wtfpl/COPYING for more details.
15 file = open('libvlc.h', 'r')
17 parameter_parsing = False
18 prototype_parsing = False
22 ["VLC_PUBLIC_API ", ""],
23 ["char**", "String[] "],
24 ["char **" , "String[] "],
25 ["char*" , "String "],
26 ["char *" , "String "],
27 ["libvlc_instance_t *", "LibVlcInstance "],
28 ["libvlc_exception_t *", "libvlc_exception_t "],
29 ["libvlc_log_t *", "LibVlcLog "],
30 ["libvlc_log_iterator_t *", "LibVlcLogIterator "],
31 ["libvlc_log_message_t *", "libvlc_log_message_t "],
35 def convert_prototype(proto, parameters):
38 tokens = proto.split(",")
39 last = tokens.pop().split(")")
42 param = parameters.pop(0)
44 res += i + " " + param + ","
48 param = parameters.pop(0)
49 if last[0].find(param)==-1:
50 res += last[0] + " " + param + ")" + last[1]
52 res += last[0] + ")" + last[1]
55 res = res.replace(k,v)
58 for line in file.readlines():
59 if line.find("/**")!=-1:
61 parameter_parsing = True
63 if line.find("VLC_PUBLIC_API")!=-1:
67 prototype_parsing = True
70 param_index = line.find("\param ")
71 if not param_index==-1:
72 parameter = line.split()[2]
73 parameters.append(parameter)
74 if line.find("*/")!=-1:
75 parameter_parsing = False
78 prototype_line += line.strip()
79 if line.find(");")!=-1:
80 prototype_parsing = False
81 convert_prototype(prototype_line, parameters)
85 #sys.stdout.write(line)