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 spucopy.py SCRIPT */
|
---|
15 |
|
---|
16 | #include "cr_spu.h"
|
---|
17 | #include "cr_mem.h"
|
---|
18 |
|
---|
19 | void crSPUCopyDispatchTable( SPUDispatchTable *dst, SPUDispatchTable *src )
|
---|
20 | {
|
---|
21 | """
|
---|
22 |
|
---|
23 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
24 | for func_name in keys:
|
---|
25 | print '\tdst->%s = src->%s;' % (func_name, func_name)
|
---|
26 |
|
---|
27 | # if the destination is already a copy of something, we'd better make sure
|
---|
28 | # that we take it off its source's copy list first.
|
---|
29 |
|
---|
30 | print """
|
---|
31 | if (dst->copy_of != NULL)
|
---|
32 | {
|
---|
33 | /*
|
---|
34 | * dst was already a copy, go back to the original,
|
---|
35 | * and remove dst from the original's copyList.
|
---|
36 | */
|
---|
37 | struct _copy_list_node *temp, *prior = NULL;
|
---|
38 | for (temp = dst->copy_of->copyList; temp; prior = temp, temp = temp->next)
|
---|
39 | {
|
---|
40 | if (temp->copy == dst)
|
---|
41 | {
|
---|
42 | if (prior)
|
---|
43 | {
|
---|
44 | prior->next = temp->next;
|
---|
45 | }
|
---|
46 | else
|
---|
47 | {
|
---|
48 | dst->copy_of->copyList = temp->next;
|
---|
49 | }
|
---|
50 | crFree( temp );
|
---|
51 | break;
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|
55 | /*
|
---|
56 | * Now that dst->copy_of is unused, set it to point to our
|
---|
57 | * new original.
|
---|
58 | */
|
---|
59 | if (src->copy_of)
|
---|
60 | {
|
---|
61 | dst->copy_of = src->copy_of;
|
---|
62 | }
|
---|
63 | else
|
---|
64 | {
|
---|
65 | dst->copy_of = src;
|
---|
66 | }
|
---|
67 | /*
|
---|
68 | * Create a new copy node, so the src can keep track of the
|
---|
69 | * new copy (i.e. dst).
|
---|
70 | */
|
---|
71 | {
|
---|
72 | struct _copy_list_node *copynode;
|
---|
73 | copynode = (struct _copy_list_node*)crAlloc( sizeof( *copynode ) );
|
---|
74 | copynode->copy = dst;
|
---|
75 | copynode->next = src->copyList;
|
---|
76 | src->copyList = copynode;
|
---|
77 | }
|
---|
78 | }
|
---|
79 | """
|
---|