VirtualBox

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

Last change on this file since 19223 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 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" ) != -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" )]
43 if apiutil.sizeof(args[1]) == 1:
44 print "%sWRITE_DATA( %s, %s, %s );" % (indentation, args[0], args[1], args[2])
45 elif apiutil.sizeof(args[1]) == 2:
46 print "%sWRITE_DATA( %s, %s, SWAP16(%s) );" % (indentation, args[0], args[1], args[2])
47 elif args[1] == 'GLfloat' or args[1] == 'GLclampf':
48 print "%sWRITE_DATA( %s, GLuint, SWAPFLOAT(%s) );" % (indentation, args[0], args[2])
49 elif apiutil.sizeof(args[1]) == 4:
50 print "%sWRITE_DATA( %s, %s, SWAP32(%s) );" % (indentation, args[0], args[1], args[2])
51 else:
52 print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1]
53 sys.exit(-1)
54 elif line.find( "WRITE_DOUBLE" ) != -1:
55 print line.replace( "WRITE_DOUBLE", "WRITE_SWAPPED_DOUBLE" )
56 else:
57 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