]> git.tdb.fi Git - gldbg.git/blob - source/gldecoder.funcs.t
Send as much of a packet as possible before calling the original function
[gldbg.git] / source / gldecoder.funcs.t
1 # $Id$
2 :#define UNUSED __attribute__((unused))
3 wl('static unsigned decode_%s(GlDecoder *dec, GlPacket *pkt UNUSED)', func.name)
4 wl('{')
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 for p in params:
10         if p.kind=="value":
11                 wl('    read_%s((%s *)&p_%s, pkt);', p.io[0].replace(' ', '_'), p.io[0], p.name)
12         elif p.kind=="array" and p.io and p.io[0]=="string":
13                 wl('  read_string_array(&p_%s, pkt);', p.name)
14         elif p.csize:
15                 wl('    read_data((pointer *)&p_%s, pkt);', p.name)
16         else:
17                 wl('    read_pointer((pointer *)&p_%s, pkt);', p.name)
18 if ret.ctype!="void":
19         wl('    read_%s((%s *)&ret, pkt);', ret.io[0].replace(' ', '_'), ret.io[0])
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 0;')
28 wl('}')
29 :static int decode_func(GlDecoder *dec, unsigned short func, GlPacket *pkt)
30 :{
31 :       switch(func)
32 :       {
33 wl('    case FUNC_%s: decode_%s(dec, pkt); break;', func.name.upper(), func.name)
34 :       default: return -1;
35 :       }
36 :       return 0;
37 :}