1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | import sys
|
---|
7 |
|
---|
8 | import apiutil
|
---|
9 |
|
---|
10 |
|
---|
11 | apiutil.CopyrightC()
|
---|
12 |
|
---|
13 | print """
|
---|
14 | /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_retval.py SCRIPT */
|
---|
15 | #include "chromium.h"
|
---|
16 | #include "cr_mem.h"
|
---|
17 | #include "cr_net.h"
|
---|
18 | #include "server_dispatch.h"
|
---|
19 | #include "server.h"
|
---|
20 |
|
---|
21 | void crServerReturnValue( const void *payload, unsigned int payload_len )
|
---|
22 | {
|
---|
23 | CRMessageReadback *rb;
|
---|
24 | int msg_len = sizeof( *rb ) + payload_len;
|
---|
25 |
|
---|
26 | /* Don't reply to client if we're loading VM snapshot*/
|
---|
27 | if (cr_server.bIsInLoadingState)
|
---|
28 | return;
|
---|
29 |
|
---|
30 | if (cr_server.curClient->conn->type == CR_FILE)
|
---|
31 | {
|
---|
32 | return;
|
---|
33 | }
|
---|
34 |
|
---|
35 | rb = (CRMessageReadback *) crAlloc( msg_len );
|
---|
36 |
|
---|
37 | rb->header.type = CR_MESSAGE_READBACK;
|
---|
38 | crMemcpy( &(rb->writeback_ptr), &(cr_server.writeback_ptr), sizeof( rb->writeback_ptr ) );
|
---|
39 | crMemcpy( &(rb->readback_ptr), &(cr_server.return_ptr), sizeof( rb->readback_ptr ) );
|
---|
40 | crMemcpy( rb+1, payload, payload_len );
|
---|
41 | crNetSend( cr_server.curClient->conn, NULL, rb, msg_len );
|
---|
42 | crFree( rb );
|
---|
43 | }
|
---|
44 | """
|
---|
45 |
|
---|
46 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
47 |
|
---|
48 | for func_name in keys:
|
---|
49 | params = apiutil.Parameters(func_name)
|
---|
50 | return_type = apiutil.ReturnType(func_name)
|
---|
51 | if apiutil.FindSpecial( "server", func_name ):
|
---|
52 | continue
|
---|
53 | if return_type != 'void':
|
---|
54 | print '%s SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( return_type, func_name, apiutil.MakeDeclarationString(params))
|
---|
55 | print '{'
|
---|
56 | print '\t%s retval;' % return_type
|
---|
57 | print '\tretval = cr_server.head_spu->dispatch_table.%s( %s );' % (func_name, apiutil.MakeCallString(params) );
|
---|
58 | print '\tcrServerReturnValue( &retval, sizeof(retval) );'
|
---|
59 | print '\treturn retval; /* WILL PROBABLY BE IGNORED */'
|
---|
60 | print '}'
|
---|