summaryrefslogtreecommitdiff
path: root/utils/rockbox_api/update.php
blob: 5fb46c9d581515bf1984f15e208e9b47fa34777e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/usr/bin/php
<?
require_once("functions.php");

$input = file_get_contents($argv[1]);

$input = parse_documentation($input);

/* Format input */
foreach($input as $rootname => $rootel)
{
    foreach($rootel as $name => $el)
        $input[$name] = $el;
    unset($input[$rootname]);
}

$new = get_newest();

/* Format new */
foreach($new as $name => $el)
{
    unset($new[$name]);
    $name = clean_func($el["func"]);
    
    $new[$name] = array(
                    "group" => array($el["group"]),
                    "description" => array("")
    );
    
    if(strlen($el["cond"]) > 2)
        $new[$name]["conditions"][0] = $el["cond"];
    
    $args = get_args($el["func"]);
    if(count($args) > 0)
    {
        foreach($args as $n => $arg)
        {
            $tmp = split_var($arg);
            $args[$n] = $tmp[1];
        }
        $new[$name]["param"] = $args;
    }
    
    if(get_return($el["func"]) !== false)
        $new[$name]["return"][0] = "";
}

/* Compare and merge both */
$merged = array();
foreach($new as $name => $el)
{
    if(isset($input[$name]))
    {
        $merged[$name] = $input[$name];
        $merged[$name]["conditions"] = $new[$name]["conditions"];
        
        if(strlen($el["group"][0]) > 0)
            $merged[$name]["group"] = $el["group"];
        
        if(isset($el["param"]))
        {
            foreach($el["param"] as $nr => $parel)
            {
                if($parel != $input[$name]["param"][$nr])
                {
                    $param = trim($parel);
                    $p1 = substr($param, 0, strpos($param, " "));
                    
                    $param = trim($input[$name]["param"][$nr]);
                    $p2 = substr($param, strpos($param, " "));
                    $merged[$name]["params"][] = $p1." ".$p2." [AUTO-ADDED]";
                }
                else
                    $merged[$name]["params"][] = $parel;
            }
        }
        
        if(!isset($el["return"]) && isset($merged[$name]["return"]))
            unset($merged[$name]["return"]);
        
        unset($input[$name]);
    }
    else
        $merged[$name] = $el;
}

/* Now to the rest of input */
foreach($input as $name => $el)
    $merged[$name." [DEPRECATED]"] = $el;

uksort($merged, "func_sort");

echo   '# Auto generated documentation by Rockbox plugin API generator v2'."\n";
echo   '# Made by Maurus Cuelenaere'."\n";
echo <<<MOO
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# \$Id$
#
# Generated from $svn\x61pps/plugin.h
#
# Format:
# \\group memory and strings
# \\conditions defined(HAVE_BACKLIGHT)
# \\param fmt
# \\return
# \\description
# \\see func1 func2 [S[apps/plugin.c]]
#
# Markup:
# [W[wiki url]]
# [S[svn url]]
# [F[function]]
# [[url]]
# %BR%
# =code=

MOO;

foreach($merged as $func => $line)
{
    echo "\n".clean_func($func)."\n";

    if(strlen($line["group"]) > 0)
        echo "    \\group ".trim($line["group"][0])."\n";

    if(strlen($line["conditions"]) > 2)
        echo "    \\conditions ".trim(_simplify($line["conditions"][0]))."\n";

    if(isset($line["param"]))
    {
        foreach($line["param"] as $param)
        {
            if($param != "...")
                echo "    \\param ".trim($param)."\n";
        }
    }

    if(isset($line["return"]))
    {
        if(trim($line["return"]) == "")
            echo "    \\return\n";
        else
            echo "    \\return ".trim($line["return"][0])."\n";
    }
    
    if(trim($line["description"]) == "")
        echo "    \\description\n";
    else
        echo "    \\description ".trim($line["description"][0])."\n";
    
    if(isset($line["see"]))
        echo "    \\see ".trim($line["see"][0])."\n";
}

echo "\n# END\n";
?>
nt tmp; OPEN_READER(re, s) UPDATE_CACHE(re, s) tmp= SHOW_UBITS(re, s, n); LAST_SKIP_BITS(re, s, n) CLOSE_READER(re, s) return tmp; } unsigned int get_bits_long(GetBitContext *s, int n) ICODE_ATTR_FLAC; /** * shows 0-17 bits. * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't */ static inline unsigned int show_bits(GetBitContext *s, int n){ register int tmp; OPEN_READER(re, s) UPDATE_CACHE(re, s) tmp= SHOW_UBITS(re, s, n); // CLOSE_READER(re, s) return tmp; } unsigned int show_bits_long(GetBitContext *s, int n) ICODE_ATTR_FLAC; static inline void skip_bits(GetBitContext *s, int n){ //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) OPEN_READER(re, s) UPDATE_CACHE(re, s) LAST_SKIP_BITS(re, s, n) CLOSE_READER(re, s) } static inline unsigned int get_bits1(GetBitContext *s){ int index= s->index; uint8_t result= s->buffer[ index>>3 ]; #ifdef ALT_BITSTREAM_READER_LE result>>= (index&0x07); result&= 1; #else result<<= (index&0x07); result>>= 8 - 1; #endif index++; s->index= index; return result; } static inline unsigned int show_bits1(GetBitContext *s){ return show_bits(s, 1); } static inline void skip_bits1(GetBitContext *s){ skip_bits(s, 1); } /** * init GetBitContext. * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end * @param bit_size the size of the buffer in bits */ static inline void init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size) { int buffer_size= (bit_size+7)>>3; if(buffer_size < 0 || bit_size < 0) { buffer_size = bit_size = 0; buffer = 0; } s->buffer= buffer; s->size_in_bits= bit_size; s->buffer_end= buffer + buffer_size; s->index=0; { OPEN_READER(re, s) UPDATE_CACHE(re, s) UPDATE_CACHE(re, s) CLOSE_READER(re, s) } } void align_get_bits(GetBitContext *s) ICODE_ATTR_FLAC; #endif /* BITSTREAM_H */