]> git.tdb.fi Git - gldbg.git/blob - source/gldecoder.funcs.t
Enhance the object-orientedness of genwrap.py
[gldbg.git] / source / gldecoder.funcs.t
1 # $Id$
2 wl('static unsigned decode_%s(GlDecoder *dec, const char *data)', 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(&ret, data+pos);', ret.io[0])
11 for p in params:
12         if p.kind=="value":
13                 wl('    pos += read_%s(&p_%s, data+pos);', p.io[0], p.name)
14         elif p.csize:
15                 wl('    pos += read_data((const void **)&p_%s, data+pos);', p.name)
16         else:
17                 wl('    pos += read_pointer((void **)&p_%s, data+pos);', p.name)
18 wl('    if(dec->%s)', func.name)
19 w('             dec->%s(dec->user_data', func.name)
20 if ret.ctype!="void":
21         w(', ret')
22 for p in params:
23         w(', p_%s', p.name)
24 wl(');')
25 wl('    return pos;')
26 wl('}')
27 :static int decode_func(GlDecoder *dec, short func, const char *data)
28 :{
29 :       switch(func)
30 :       {
31 wl('    case FUNC_%s: return decode_%s(dec, data);', func.name.upper(), func.name)
32 :       default: return -1;
33 :       }
34 :}