VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/opcodes.py@ 50973

最後變更 在這個檔案從50973是 50973,由 vboxsync 提交於 11 年 前

crOpenGL: command blocks (disabled for now)

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 3.5 KB
 
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# This script generates include/cr_opcodes.h from the gl_header.parsed file.
7
8import sys;
9import cPickle;
10import string;
11import re;
12
13import apiutil
14
15apiutil.CopyrightC()
16
17print ""
18print "/* DO NOT EDIT - THIS FILE GENERATED BY THE opcodes.py SCRIPT */"
19print ""
20print "#ifndef CR_OPCODES_H"
21print "#define CR_OPCODES_H"
22print ""
23
24keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
25assert len(keys) > 0
26
27print "/* Functions with no return value and input-only parameters */"
28print "typedef enum {"
29
30enum_index = 0
31for func in keys:
32 if "pack" in apiutil.ChromiumProps(func):
33 print "\t%s = %d," % ( apiutil.OpcodeName(func), enum_index )
34 enum_index = enum_index + 1
35
36print "\tCR_EXTEND_OPCODE=%d," % enum_index
37enum_index = enum_index + 1
38print "\tCR_CMDBLOCKBEGIN_OPCODE=%d," % enum_index
39enum_index = enum_index + 1
40print "\tCR_CMDBLOCKEND_OPCODE=%d," % enum_index
41print "\tCR_NOP_OPCODE=255"
42if enum_index > 254:
43 # This would have saved Mike some grief if it had been here earlier.
44 print >> sys.stderr, "You have more than 255 opcodes! You've been adding functions to"
45 print >> sys.stderr, "glapi_parser/APIspec! Each new function you add"
46 print >> sys.stderr, "gets an opcode assigned to it. Fortunately for you, we have"
47 print >> sys.stderr, "an ``extend'' opcode. Please mark the function as"
48 print >> sys.stderr, "'extpack' in APIspec so as to keep the main opcode pool"
49 print >> sys.stderr, "less than 255! THIS IS A CATASTROPHIC FAILURE, and I WILL NOT CONTINUE!"
50 print >> sys.stderr, "I'm putting an error in the generated header file so you won't miss"
51 print >> sys.stderr, "this even if you're doing a 'make -k.'"
52 print "#error -- more than 255 opcodes!"
53 sys.exit(-1)
54print "} CROpcode;\n"
55
56# count up number of extended opcode commands
57num_extends = 0
58num_auto_codes = 0
59for func in keys:
60 if "extpack" in apiutil.ChromiumProps(func):
61 num_extends += 1
62 if apiutil.ChromiumRelOpCode(func) < 0:
63 num_auto_codes += 1
64
65# sanity check for compatibility breakage
66# we currently have 304
67if num_auto_codes != 304:
68 print >> sys.stderr, "number of auto-generated op-codes should be 304, but is " + str(num_auto_codes)
69 print >> sys.stderr, "which breaks backwards compatibility"
70 print >> sys.stderr, "if this is really what you want to do, please adjust this script"
71 print >> sys.stderr, "to handle a new auto-generated opcodes count"
72 print "#error -- num_auto_codes should be 304, but is " + str(num_auto_codes)
73 sys.exit(-1)
74
75print "/* Functions with a return value or output parameters */"
76print "typedef enum {"
77
78opcode_index = 0
79enum_index = 0
80chrelopcodes = {}
81for func in keys:
82 if "extpack" in apiutil.ChromiumProps(func):
83 opcodeName = apiutil.ExtendedOpcodeName(func)
84 chrelopcode = apiutil.ChromiumRelOpCode(func)
85 opcode = -1
86 if chrelopcode >= 0:
87 if not chrelopcode in chrelopcodes.keys():
88 chrelopcodes[chrelopcode] = chrelopcode
89 else:
90 print >> sys.stderr, "non-unique chrelopcode: " + str(chrelopcode)
91 print "#error -- non-unique chrelopcode: " + str(num_auto_codes)
92 sys.exit(-1)
93 opcode = num_auto_codes + chrelopcode
94 else:
95 opcode = opcode_index
96 opcode_index = opcode_index + 1
97
98 if enum_index != num_extends-1:
99 print "\t%s = %d," % (opcodeName, opcode )
100 else:
101 print "\t%s = %d" % (opcodeName, opcode )
102 enum_index = enum_index + 1
103print "} CRExtendOpcode;\n"
104print "#endif /* CR_OPCODES_H */"
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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