summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py
blob: bf1990a17f7cf8d56e13dd553f753be303b11755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.

from __future__ import print_function
import sys
import apiutil


apiutil.CopyrightC()

print("""

/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spucopy.py SCRIPT */

#include "cr_spu.h"
#include "cr_mem.h"

void crSPUCopyDispatchTable( SPUDispatchTable *dst, SPUDispatchTable *src )
{
""")

keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
for func_name in keys:
	print('\tdst->%s = src->%s;' % (func_name, func_name))

# if the destination is already a copy of something, we'd better make sure
# that we take it off its source's copy list first.

print("""
	if (dst->copy_of != NULL)
	{
		/*
		 * dst was already a copy, go back to the original, 
		 * and remove dst from the original's copyList.
		 */
		struct _copy_list_node *temp, *prior = NULL;
		for (temp = dst->copy_of->copyList; temp; prior = temp, temp = temp->next)
		{
			if (temp->copy == dst)
			{
				if (prior)
				{
					prior->next = temp->next;
				}
				else
				{
					dst->copy_of->copyList = temp->next;
				}
				crFree( temp );
				break;
			}
		}
	}
	/*
	 * Now that dst->copy_of is unused, set it to point to our
	 * new original.
	 */
	if (src->copy_of)
	{
		dst->copy_of = src->copy_of;
	}
	else
	{
		dst->copy_of = src;
	}
	/*
	 * Create a new copy node, so the src can keep track of the 
	 * new copy (i.e. dst).
	 */
	{
		struct _copy_list_node *copynode;
		copynode = (struct _copy_list_node*)crAlloc( sizeof( *copynode ) );
		copynode->copy = dst;
		copynode->next = src->copyList;
		src->copyList = copynode;
	}
}
""")