]> git.tdb.fi Git - gldbg.git/blob - source/glwrap.funcs.t
Replace per-file license notices with License.txt
[gldbg.git] / source / glwrap.funcs.t
1 !handcode glBegin
2 !handcode glEnd
3 !handcode glGetError
4 !handcode glXGetProcAddress
5 !handcode glXGetProcAddressARB
6 !handcode eglGetProcAddress
7 wl('%s APIENTRY %s(%s)', ret.ctype, func.name, ", ".join([p.ctype+" "+p.name for p in params]))
8 wl('{')
9 wl('    static %s (*orig)(%s) = NULL;', ret.ctype, ", ".join([p.ctype for p in params]))
10 wl('    GlPacket *pkt;')
11 if ret.ctype!='void':
12         wl('    %s ret;', ret.ctype)
13 wl('    if(!orig)')
14 wl('            orig = glsym("%s");', func.name)
15 wl('    tracepoint(FUNC_%s, BREAK_CALL);', func.name.upper())
16 wl('    pkt = packet_begin(FUNC_%s);', func.name.upper())
17 head_sent = False
18 for p in params:
19         if p.direction=="out" and not head_sent:
20                 wl('    packet_send_partial(pkt, get_out_fd());')
21                 w('     ')
22                 if ret.ctype!='void':
23                         w('ret = ')
24                 wl('orig(%s);', ", ".join([q.name for q in params]))
25                 head_sent = True
26         if p.kind=="value":
27                 wl('    packet_write_%s(pkt, %s);', p.io[0].replace(' ', '_'), p.name)
28         elif p.kind=="array" and p.io and p.io[0]=="string":
29                 wl('    packet_write_string_array(pkt, %s, %s);', p.name, p.csize)
30         elif p.csize:
31                 wl('    packet_write_data(pkt, %s, %s);', p.name, p.csize)
32         else:
33                 wl('    packet_write_pointer(pkt, %s);', p.name)
34 if ret.ctype!='void':
35         if not head_sent:
36                 wl('    packet_send_partial(pkt, get_out_fd());')
37                 wl('    ret = orig(%s);', ", ".join([p.name for p in params]))
38                 head_sent = True
39         wl('    packet_write_%s(pkt, ret);', ret.io[0].replace(' ', '_'))
40 wl('    packet_send(pkt, get_out_fd());')
41 if not head_sent:
42         wl('    orig(%s);', ", ".join([p.name for p in params]))
43 if not func.name.startswith("glX"):
44         wl('    check_error();')
45 wl('    tracepoint(FUNC_%s, BREAK_RETURN);', func.name.upper())
46 if ret.ctype!='void':
47         wl('    return ret;')
48 wl('}')