VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap.py@ 63939

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

Build/scripts (bugref:6627): Python build scripts updated to generate the same code when used with Python 2 and 3.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 3.2 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
6from __future__ import print_function
7import sys, string
8
9sys.path.append( "../glapi_parser" )
10import apiutil
11
12
13if len(sys.argv) != 2:
14 print >> sys.stderr, "Usage: %s <filename>" % sys.argv[0]
15 sys.exit(-1)
16
17file = open(sys.argv[1])
18
19print("/* THIS FILE IS AUTOGENERATED FROM %s BY pack_swap.py */\n\n" % sys.argv[1])
20
21for line in file.readlines():
22 line = line.rstrip()
23 if line.find( "crPackAlloc" ) != -1 or line.find( "crPackFree" ) != -1:
24 print(line)
25 continue
26 elif line.find( "crPack" ) != -1:
27 fun_index = line.find( "crPack" )
28 paren_index = line.find( "(", fun_index )
29 space_index = line.find( " ", fun_index )
30 quote_index = line.find( '"', fun_index )
31 if paren_index == -1:
32 paren_index = 1000000; # HACK HACK
33 if space_index == -1:
34 space_index = 1000000; # HACK HACK
35 if quote_index == -1:
36 quote_index = 1000000; # HACK HACK
37 the_index = min( min( paren_index, space_index ), quote_index )
38 print("%sSWAP%s" % (line[:the_index], line[the_index:]))
39 elif line.find("WRITE_DATA_AI") != -1:
40 lparen_index = line.find( "(" )
41 rparen_index = line.rfind( ")" )
42 args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) ))
43 indentation = line[:line.find( "WRITE_DATA_AI" )]
44 if apiutil.sizeof(args[0]) == 1:
45 print("%sWRITE_DATA_AI(%s, %s);" % (indentation, args[0], args[1]))
46 elif apiutil.sizeof(args[0]) == 2:
47 print("%sWRITE_DATA_AI(%s, SWAP16(%s) );" % (indentation, args[0], args[1]))
48 elif args[0] == 'GLfloat' or args[0] == 'GLclampf':
49 print("%sWRITE_DATA_AI(GLuint, SWAPFLOAT(%s) );" % (indentation, args[0]))
50 elif apiutil.sizeof(args[0]) == 4:
51 print("%sWRITE_DATA_AI(%s, SWAP32(%s) );" % (indentation, args[0], args[1]))
52 else:
53 print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1]
54 sys.exit(-1)
55 elif line.find( "WRITE_DATA" ) != -1:
56 lparen_index = line.find( "(" )
57 rparen_index = line.rfind( ")" )
58 args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) ))
59 indentation = line[:line.find( "WRITE_DATA" )]
60 if apiutil.sizeof(args[1]) == 1:
61 print("%sWRITE_DATA( %s, %s, %s );" % (indentation, args[0], args[1], args[2]))
62 elif apiutil.sizeof(args[1]) == 2:
63 print("%sWRITE_DATA( %s, %s, SWAP16(%s) );" % (indentation, args[0], args[1], args[2]))
64 elif args[1] == 'GLfloat' or args[1] == 'GLclampf':
65 print("%sWRITE_DATA( %s, GLuint, SWAPFLOAT(%s) );" % (indentation, args[0], args[2]))
66 elif apiutil.sizeof(args[1]) == 4:
67 print("%sWRITE_DATA( %s, %s, SWAP32(%s) );" % (indentation, args[0], args[1], args[2]))
68 else:
69 print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1]
70 sys.exit(-1)
71 elif line.find( "WRITE_DOUBLE" ) != -1:
72 print(line.replace( "WRITE_DOUBLE", "WRITE_SWAPPED_DOUBLE" ))
73 else:
74 print(line)
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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