# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.


import sys;
import cPickle;
import types;
import string;
import re;

import stub_common;

parsed_file = open( "../glapi_parser/gl_header.parsed", "rb" )
gl_mapping = cPickle.load( parsed_file )

keys = gl_mapping.keys()
keys.sort();

stub_common.CopyrightC()

print """
/* XXX Do not edit - this file generated by tsfuncs.py script */

#include "stub.h"
"""

for func_name in keys:
	#if stub_common.FindSpecial( "noexport", func_name ): continue
	( return_type, arg_names, arg_types ) = gl_mapping[func_name]

	print "static %s SPULOAD_APIENTRY ts_%s%s" % (return_type, func_name, stub_common.ArgumentString( arg_names, arg_types ) )
	print "{"
	print "\tSPUDispatchTable *tab = (SPUDispatchTable *) crGetTSD(&stub.dispatchTSD);"

	if return_type != "void":
		print "\treturn ",

	print "\ttab->%s%s;" % (func_name, stub_common.CallString( arg_names ))
	print "}"
	print ""


print "SPUDispatchTable stubThreadsafeDispatch = {"

for func_name in keys:
	#if stub_common.FindSpecial( "noexport", func_name ): continue
	( return_type, arg_names, arg_types ) = gl_mapping[func_name]

	print "\tts_%s," % (func_name)

print "};"

# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.


import sys;
import cPickle;
import types;
import string;
import re;

import stub_common;

parsed_file = open( "../glapi_parser/gl_header.parsed", "rb" )
gl_mapping = cPickle.load( parsed_file )

keys = gl_mapping.keys()
keys.sort();

stub_common.CopyrightC()

print """
/* DO NOT EDIT - THIS FILE GENERATED BY THE tsfuncs.py SCRIPT */

#include "stub.h"
"""

for func_name in keys:
	#if stub_common.FindSpecial( "noexport", func_name ): continue
	( return_type, arg_names, arg_types ) = gl_mapping[func_name]

	print "static %s SPULOAD_APIENTRY ts_%s%s" % (return_type, func_name, stub_common.ArgumentString( arg_names, arg_types ) )
	print "{"
	print "\tSPUDispatchTable *tab = (SPUDispatchTable *) crGetTSD(&stub.dispatchTSD);"

	if return_type != "void":
		print "\treturn ",

	print "\ttab->%s%s;" % (func_name, stub_common.CallString( arg_names ))
	print "}"
	print ""


print "SPUDispatchTable stubThreadsafeDispatch = {"

for func_name in keys:
	#if stub_common.FindSpecial( "noexport", func_name ): continue
	( return_type, arg_names, arg_types ) = gl_mapping[func_name]

	print "\tts_%s," % (func_name)

print "};"

fix a description