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