Make sure that sorting works both for signed and unsigned char (it depends on the...
[kugel-rb.git] / utils / rockbox_api / update.php
blob5fb46c9d581515bf1984f15e208e9b47fa34777e
1 #!/usr/bin/php
2 <?
3 require_once("functions.php");
5 $input = file_get_contents($argv[1]);
7 $input = parse_documentation($input);
9 /* Format input */
10 foreach($input as $rootname => $rootel)
12 foreach($rootel as $name => $el)
13 $input[$name] = $el;
14 unset($input[$rootname]);
17 $new = get_newest();
19 /* Format new */
20 foreach($new as $name => $el)
22 unset($new[$name]);
23 $name = clean_func($el["func"]);
25 $new[$name] = array(
26 "group" => array($el["group"]),
27 "description" => array("")
30 if(strlen($el["cond"]) > 2)
31 $new[$name]["conditions"][0] = $el["cond"];
33 $args = get_args($el["func"]);
34 if(count($args) > 0)
36 foreach($args as $n => $arg)
38 $tmp = split_var($arg);
39 $args[$n] = $tmp[1];
41 $new[$name]["param"] = $args;
44 if(get_return($el["func"]) !== false)
45 $new[$name]["return"][0] = "";
48 /* Compare and merge both */
49 $merged = array();
50 foreach($new as $name => $el)
52 if(isset($input[$name]))
54 $merged[$name] = $input[$name];
55 $merged[$name]["conditions"] = $new[$name]["conditions"];
57 if(strlen($el["group"][0]) > 0)
58 $merged[$name]["group"] = $el["group"];
60 if(isset($el["param"]))
62 foreach($el["param"] as $nr => $parel)
64 if($parel != $input[$name]["param"][$nr])
66 $param = trim($parel);
67 $p1 = substr($param, 0, strpos($param, " "));
69 $param = trim($input[$name]["param"][$nr]);
70 $p2 = substr($param, strpos($param, " "));
71 $merged[$name]["params"][] = $p1." ".$p2." [AUTO-ADDED]";
73 else
74 $merged[$name]["params"][] = $parel;
78 if(!isset($el["return"]) && isset($merged[$name]["return"]))
79 unset($merged[$name]["return"]);
81 unset($input[$name]);
83 else
84 $merged[$name] = $el;
87 /* Now to the rest of input */
88 foreach($input as $name => $el)
89 $merged[$name." [DEPRECATED]"] = $el;
91 uksort($merged, "func_sort");
93 echo '# Auto generated documentation by Rockbox plugin API generator v2'."\n";
94 echo '# Made by Maurus Cuelenaere'."\n";
95 echo <<<MOO
96 # __________ __ ___.
97 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
98 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
99 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
100 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
101 # \/ \/ \/ \/ \/
102 # \$Id$
104 # Generated from $svn\x61pps/plugin.h
106 # Format:
107 # \\group memory and strings
108 # \\conditions defined(HAVE_BACKLIGHT)
109 # \\param fmt
110 # \\return
111 # \\description
112 # \\see func1 func2 [S[apps/plugin.c]]
114 # Markup:
115 # [W[wiki url]]
116 # [S[svn url]]
117 # [F[function]]
118 # [[url]]
119 # %BR%
120 # =code=
122 MOO;
124 foreach($merged as $func => $line)
126 echo "\n".clean_func($func)."\n";
128 if(strlen($line["group"]) > 0)
129 echo " \\group ".trim($line["group"][0])."\n";
131 if(strlen($line["conditions"]) > 2)
132 echo " \\conditions ".trim(_simplify($line["conditions"][0]))."\n";
134 if(isset($line["param"]))
136 foreach($line["param"] as $param)
138 if($param != "...")
139 echo " \\param ".trim($param)."\n";
143 if(isset($line["return"]))
145 if(trim($line["return"]) == "")
146 echo " \\return\n";
147 else
148 echo " \\return ".trim($line["return"][0])."\n";
151 if(trim($line["description"]) == "")
152 echo " \\description\n";
153 else
154 echo " \\description ".trim($line["description"][0])."\n";
156 if(isset($line["see"]))
157 echo " \\see ".trim($line["see"][0])."\n";
160 echo "\n# END\n";