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 | import apiutil
|
---|
8 |
|
---|
9 |
|
---|
10 | apiutil.CopyrightC()
|
---|
11 |
|
---|
12 | print """
|
---|
13 |
|
---|
14 | /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spuchange.py SCRIPT */
|
---|
15 |
|
---|
16 | #include "cr_spu.h"
|
---|
17 | #include "cr_error.h"
|
---|
18 |
|
---|
19 | void crSPUChangeInterface( SPUDispatchTable *table, void *orig_func, void *new_func )
|
---|
20 | {
|
---|
21 | struct _copy_list_node *temp;
|
---|
22 | if (table->mark == 1)
|
---|
23 | {
|
---|
24 | return;
|
---|
25 | }
|
---|
26 | if (orig_func == new_func)
|
---|
27 | {
|
---|
28 | return;
|
---|
29 | }
|
---|
30 | table->mark = 1;
|
---|
31 | """
|
---|
32 |
|
---|
33 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
34 | for func_name in keys:
|
---|
35 | print '\tif ((void *)table->%s == orig_func)' % func_name
|
---|
36 | print '\t{'
|
---|
37 | print '\t\ttable->%s = (%sFunc_t)new_func;' % (func_name, func_name)
|
---|
38 | print '\t\tfor (temp = table->copyList ; temp ; temp = temp->next)'
|
---|
39 | print '\t\t{'
|
---|
40 | print '\t\t\tcrSPUChangeInterface( temp->copy, orig_func, new_func );'
|
---|
41 | print '\t\t}'
|
---|
42 | print '\t}'
|
---|
43 |
|
---|
44 | print """
|
---|
45 | if (table->copy_of != NULL)
|
---|
46 | {
|
---|
47 | crSPUChangeInterface( table->copy_of, orig_func, new_func );
|
---|
48 | }
|
---|
49 | for (temp = table->copyList ; temp ; temp = temp->next)
|
---|
50 | {
|
---|
51 | crSPUChangeInterface( temp->copy, orig_func, new_func );
|
---|
52 | }
|
---|
53 | table->mark = 0;
|
---|
54 | """
|
---|
55 | print '}'
|
---|
56 |
|
---|
57 | print """
|
---|
58 | void crSPUChangeDispatch(SPUDispatchTable *dispatch, const SPUNamedFunctionTable *newtable)
|
---|
59 | {
|
---|
60 | SPUGenericFunction func;
|
---|
61 | """
|
---|
62 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
63 | for func_name in keys:
|
---|
64 | print '\tfunc = crSPUFindFunction(newtable, "%s");' % func_name
|
---|
65 | print '\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name
|
---|
66 | print '\t{'
|
---|
67 | print '\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", dispatch->%s, func);' % (func_name, func_name)
|
---|
68 | print '\t\tcrSPUChangeInterface(dispatch, dispatch->%s, func);' % func_name
|
---|
69 | print '\t}\n'
|
---|
70 | print """
|
---|
71 | }
|
---|
72 | """
|
---|