summaryrefslogtreecommitdiffstats
path: root/src/VBox/Additions/common/crOpenGL/pack/pack.py
blob: e25066becce2c867439d70bd0ad47f9bf86391ce (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
# 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


keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")


apiutil.CopyrightC()

print("""
/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY pack.py SCRIPT */
#include <stdio.h>
#include "cr_string.h"
#include "cr_spu.h"
#include "packspu.h"
#include "cr_packfunctions.h"
#include "packspu_proto.h"
""")

num_funcs = len(keys) - len(apiutil.AllSpecials('packspu_unimplemented'))
print('SPUNamedFunctionTable _cr_pack_table[%d];' % (num_funcs+1))

print("""
static void __fillin(int offset, char *name, SPUGenericFunction func)
{
    _cr_pack_table[offset].name = crStrdup(name);
    _cr_pack_table[offset].fn = func;
}""")

pack_specials = []

for func_name in keys:
    if ("get" in apiutil.Properties(func_name) or
        apiutil.FindSpecial( "packspu", func_name ) or
        apiutil.FindSpecial( "packspu_flush", func_name ) or
        apiutil.FindSpecial( "packspu_vertex", func_name )):
      pack_specials.append( func_name )

print('\nvoid packspuCreateFunctions( void )')
print('{')
for index in range(len(keys)):
    func_name = keys[index]
    if apiutil.FindSpecial( "packspu_unimplemented", func_name ):
        continue
    if func_name in pack_specials:
        print('\t__fillin(%3d, "%s", (SPUGenericFunction) packspu_%s);' % (index, func_name, func_name ))
    else:
        print('\t__fillin(%3d, "%s", (SPUGenericFunction) (pack_spu.swap ? crPack%sSWAP : crPack%s));' % (index, func_name, func_name, func_name ))
print('\t__fillin(%3d, NULL, NULL);' % num_funcs)
print('}')