# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software
import sys
def main():
print """/* This code is AUTOGENERATED!!! */
#include "state.h"
#include "state_internals.h\""""
print """
void crState%(Name)sDiff(CR%(Name)sBits *b, CRbitvalue *bitID,
CRContext *fromCtx, CRContext *toCtx)
{
CR%(Name)sState *from = &(fromCtx->%(name)s);
CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()
print """}
void crState%(Name)sSwitch(CR%(Name)sBits *b, CRbitvalue *bitID,
CRContext *fromCtx, CRContext *toCtx)
{
CR%(Name)sState *from = &(fromCtx->%(name)s);
CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()
print "}\n"
target = "to"
current = "from"
bit = "b"
extrabit = ""
tab = "\t"
current_guard = ""
current_dependency = ""
v_types = {
'l': 'GLboolean',
'b': 'GLbyte',
'ub': 'GLubyte',
's': 'GLshort',
'us': 'GLushort',
'i': 'GLint',
'ui': 'GLuint',
'f': 'GLfloat',
'd': 'GLdouble'
}
print """ unsigned int j, i;
CRbitvalue nbitID[CR_MAX_BITARRAY];
for (j=0;j<CR_MAX_BITARRAY;j++)
nbitID[j] = ~bitID[j];
i = 0; /* silence compiler */"""
import re
continue
## Handle text dump
if m:
if doinvalid:
continue
else:
if m:
if docopy:
continue
if m:
continue
## Handle commands
if m:
if m:
if m:
if m:
if current_guard != "":
print tab+"}"
print tab+"}"
current_guard = ""
current_dependency = ""
continue
## Load the line
## Close the guardbit and dependency
print tab+"}"
print tab+"}"
## Open the dependency if
## Open the guard if
print tab+"glAble able[2];"
print tab+"able[0] = diff_api.Disable;"
print tab+"able[1] = diff_api.Enable;"
## Handle text dump
else:
## Parse the members variable
mainelem = [""]
newelems = []
else:
## Check member values
if guardbit != "extensions":
first = 1
if first != 1:
first = 0
## Handle text function
else:
if func != "":
## Call the glhw function
elif guardbit == "extensions":
print tab+"crState$state_name",
if docopy == 1:
print "Diff",
else:
print "Switch",
print "Extensions( from, to );"
else:
#print "// funcargs:",funcargs
i = 0
i += 1
i = 0
i += 1
## Handle vargs
else:
first = 1
if first != 1:
first = 0
print ");"
## Do the sync if necessary
## Do the clear if necessary
if doinvalid:
if guardbit != "":
if extrabit != "":
## Close the compare
if guardbit != "extensions":
print tab+"}"
## Do final closures
if current_guard != "":
print tab+"}"
main()