VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py@ 55747

Last change on this file since 55747 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6import sys
7import apiutil
8
9
10apiutil.CopyrightC()
11
12print """
13
14/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY dispatch.py SCRIPT */
15
16#include "cr_spu.h"
17#include "cr_string.h"
18#include "cr_error.h"
19
20
21static SPUGenericFunction __findFunc( char *name, SPU *spu )
22{
23 SPUNamedFunctionTable *temp;
24
25 if (spu == NULL)
26 return NULL;
27
28 for (temp = spu->function_table->table ; temp->name != NULL ; temp++)
29 {
30 if (!crStrcmp( name, temp->name ) )
31 {
32 return temp->fn;
33 }
34 }
35 return __findFunc( name, spu->superSPU );
36}
37
38
39/*
40 * This function is not public outside the loader SPU.
41 */
42extern void __buildDispatch( SPU *spu );
43
44void __buildDispatch( SPU *spu )
45{"""
46
47keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
48for func_name in keys:
49 print '\tspu->dispatch_table.%s = (%sFunc_t) __findFunc( "%s", spu );' % (func_name,func_name,func_name)
50print '}'
51
52
53print """
54
55/*
56 * Public function:
57 * Search a SPU named function table for a specific function. Return
58 * a pointer to it or NULL if not found.
59 */
60SPUGenericFunction crSPUFindFunction( const SPUNamedFunctionTable *table, const char *fname )
61{
62 const SPUNamedFunctionTable *temp;
63
64 for (temp = table ; temp->name != NULL ; temp++)
65 {
66 if (!crStrcmp( fname, temp->name ) )
67 {
68 return temp->fn;
69 }
70 }
71 return NULL;
72}
73
74
75/*
76 * Public function:
77 * Initializes the pointers in an SPUDispatchTable by looking for functions
78 * in an SPUNamedFunctionTable.
79 * It doesn't know anything about SPUs and SPU inheritance.
80 */
81void crSPUInitDispatch( SPUDispatchTable *dispatch, const SPUNamedFunctionTable *table )
82{"""
83
84for func_name in keys:
85 print '\tdispatch->%s = (%sFunc_t) crSPUFindFunction(table, "%s");' % (func_name, func_name, func_name)
86print '}'
87
88
89
90print """
91/*
92 * Generic no-op function
93 */
94static int NopFunction(void)
95{
96/*
97 crWarning("Calling generic no-op function in dispatch.c");
98*/
99 return 0;
100}
101
102
103/*
104 * Scan the given dispatch table for NULL pointers. Hook in the generic
105 * no-op function wherever we find a NULL pointer.
106 */
107void crSPUInitDispatchNops(SPUDispatchTable *table)
108{
109 /*
110 * This is a bit tricky. We walk over all the function pointers in
111 * the SPUDispatchTable struct, checking for NULL and setting NULL
112 * pointers to point to NopFunction().
113 * But we have to stop when we get to the copyList pointer!
114 */
115 const int numEntries = (void **) &(table->copyList) - (void **) &(table->Accum);
116 void **ptr = (void **) table;
117 int i;
118 for (i = 0; i < numEntries; i++) {
119 if (ptr[i] == NULL) {
120 /*printf("!!!!!!!Warning entry[%d] = NULL\n", i);*/
121 ptr[i] = (void *)NopFunction;
122 }
123 }
124}
125"""
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette