summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/packer/pack_header.py
blob: d86d0789f043c360aa8dc20beb8a9fc0485f1f70 (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
81
82
83
84
85
86
87
88
89
90
91
# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.

# This script generates the cr/include/cr_packfunctions.h file from the
# gl_header.parsed file.

from __future__ import print_function
import sys
import string

import apiutil


apiutil.CopyrightC()

print("""#ifndef CR_PACKFUNCTIONS_H
#define CR_PACKFUNCTIONS_H

/* DO NOT EDIT - THIS FILE GENERATED BY THE pack_header.py SCRIPT */

/* Prototypes for the OpenGL packer functions in packer.c and pack_bbox.c */

#include "chromium.h"
#include "state/cr_client.h"
#include "cr_pack.h"

#ifdef WINDOWS
#define PACK_APIENTRY __stdcall
#else
#define PACK_APIENTRY
#endif

#ifdef __cplusplus
extern "C" {
#endif
""")

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


for func_name in keys:
	if ("pack" in apiutil.ChromiumProps(func_name) or
		"extpack" in apiutil.ChromiumProps(func_name) or
		apiutil.NonVectorFunction(func_name) != '' or
		apiutil.FindSpecial('packer', func_name)):

		# OK, generate a crPackFooBar() prototype for this function
		return_type = apiutil.ReturnType(func_name)
		args = apiutil.Parameters(func_name)
		if return_type != 'void':
			if apiutil.IsPointer(return_type):
				args.append(("return_value", return_type, 0))
			else:
				args.append(("return_value", return_type + "*", 0))
		elif "pixelstore" in apiutil.Properties(func_name):
			args.append(("packstate", "const CRPixelPackState *", 0))

		if "get" in apiutil.Properties(func_name):
			args.append(("writeback", "int *", 0))

		print('void PACK_APIENTRY crPack%s(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args)))
		print('void PACK_APIENTRY crPack%sSWAP(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args)))



# Now generate special BBOX, COUNT, SWAP variations on the glVertex and
# glVertexAttrib functions.
for func_name in keys:
	if (func_name[0:6] == "Vertex" and
		"pervertex" in apiutil.Properties(func_name) and
		("pack" in apiutil.ChromiumProps(func_name) or
		 apiutil.NonVectorFunction(func_name) != '')):

		assert apiutil.ReturnType(func_name) == "void"

		args = apiutil.Parameters(func_name)
		print('void PACK_APIENTRY crPack%sBBOX(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
		print('void PACK_APIENTRY crPack%sBBOX_COUNT(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
		print('void PACK_APIENTRY crPack%sBBOXSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
		print('void PACK_APIENTRY crPack%sBBOX_COUNTSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args)))


print("""
#ifdef __cplusplus
}
#endif

#endif /* CR_PACKFUNCTIONS_H */
""")