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