VirtualBox

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

Last change on this file since 40708 was 21310, checked in by vboxsync, 15 years ago

crOpenGL: host VBOs another file

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