]> git.tdb.fi Git - gldbg.git/blob - source/glprint.funcs.t
Quick hack to not crash when printing enum arrays
[gldbg.git] / source / glprint.funcs.t
1 # $Id$
2 w('static void print_%s(void *user_data', func.name)
3 if ret.ctype!="void":
4         w(', %s ret', ret.ctype)
5 for p in params:
6         w(', %s %s', p.ctype, p.name)
7 wl(')')
8 wl('{')
9 wl('    GlPrintData *gpd = (GlPrintData *)user_data;')
10 w('     snprintf(gpd->buffer, gpd->bufsize, "%s(', func.name)
11 first = True
12 for p in params:
13         if not first:
14                 w(', ')
15         if p.kind=="value":
16                 w('%s', p.io[1])
17         elif p.kind=="reference":
18                 if p.io:
19                         w('{%s}', p.io[1])
20                 else:
21                         w('<ref:%s %%p>', p.type)
22         elif p.kind=="array":
23                 w('%%s')
24         first = False
25 w(')')
26 if ret.ctype!="void":
27         w(' = %s', ret.io[1])
28 w('"')
29 for p in params+[ret]:
30         if p.ctype!="void":
31                 if p.kind=="value":
32                         if len(p.io)>=3 and p.io[2]:
33                                 f = p.io[2].split(':')
34                                 w(', %s(%s)', f[0], ", ".join(eval(x) for x in f[1:]))
35                         else:
36                                 w(', %s', p.name)
37                 elif p.kind=="reference":
38                         if p.io:
39                                 w(', *%s', p.name)
40                         else:
41                                 w(', %s', p.name)
42                 elif p.kind=="array":
43                         if not p.csize:
44                                 w(', print_data(%s, 0)', p.name)
45                         elif p.base_ctype=="GLvoid" or p.base_ctype=="void":
46                                 w(', print_data(%s, %s)', p.name, p.csize)
47                         else:
48                                 f = p.io[1]
49                                 if len(p.io)>=3 and p.io[2]:
50                                         f = "%x"
51                                 w(', print_array("%s", %s, sizeof(%s), %s)', f, p.name, p.base_ctype, p.csize)
52 wl(');')
53 wl('}')
54 :static void init_print(GlDecoder *dec)
55 :{
56 wl('    dec->%s = print_%s;', func.name, func.name)
57 :}