]> git.tdb.fi Git - gldbg.git/blob - source/gldecoder.funcs.t
e02c1e815277fca0833a47489ff0aff3e5fe0e74
[gldbg.git] / source / gldecoder.funcs.t
1 # $Id$
2 wl('static unsigned decode_%s(GlDecoder *dec, const char *data __attribute__((unused)))', func.name)
3 wl('{')
4 wl('    unsigned pos = 0;')
5 if ret.ctype!="void":
6         wl('    %s ret;', ret.ctype)
7 for p in params:
8         wl('    %s p_%s;', p.ctype, p.name)
9 if ret.ctype!="void":
10         wl('    pos += read_%s((%s *)&ret, data+pos);', ret.io[0].replace(' ', '_'), ret.io[0])
11 for p in params:
12         if p.kind=="value":
13                 wl('    pos += read_%s((%s *)&p_%s, data+pos);', p.io[0].replace(' ', '_'), p.io[0], p.name)
14         elif p.kind=="array" and p.io and p.io[0]=="string":
15                 wl('  pos += read_string_array(&p_%s, data+pos);', p.name)
16         elif p.csize:
17                 wl('    pos += read_data((const void **)&p_%s, data+pos);', p.name)
18         else:
19                 wl('    pos += read_pointer((void **)&p_%s, data+pos);', p.name)
20 wl('    if(dec->%s)', func.name)
21 w('             dec->%s(dec->user_data', func.name)
22 if ret.ctype!="void":
23         w(', ret')
24 for p in params:
25         w(', p_%s', p.name)
26 wl(');')
27 wl('    return pos;')
28 wl('}')
29 :static int decode_func(GlDecoder *dec, unsigned short func, const char *data)
30 :{
31 :       switch(func)
32 :       {
33 wl('    case FUNC_%s: return decode_%s(dec, data);', func.name.upper(), func.name)
34 :       default: return -1;
35 :       }
36 :}