Jason McKesson avatar Jason McKesson committed 3152dc1

Code generation now lives in glLoadGen, not here.

Comments (0)

Files changed (31)

glload/codegen/How it works.txt

-== File sturcture ==
-
-The Lua scripts here use standard Lua API calls and no external modules.
-
-All Lua files that start with an "_" are library files. They usually add at least one global function, usually named the same as the filename (sans "_"). Some are just a collection of miscellaneous functions that do certain things.
-
-Lua files that don't start with the underscore are to be executed on the command line. They may take parameters.
-
-== The generation process ==
-
-The code-generation process is 2-stage. The first stage is the conversion of the .spec and .tm files into a .lua file that returns a giant table containing all of this information. The .lua files responsible for this conversion are:
-
-* ConvertAllSpecFilesToLua.lua: Causes generation of all .lua spec files. It doesn't take parameters.
-** _ExtractSpecsToFile.lua: Generates a single .lua spec file.
-*** _ExtractEnums.lua: Processes enumext.spec to retrieve the enums.
-*** _ExtractExts.lua: Processes enumext.spec to retrieve the extension list.
-*** _ExtractTypes.lua: Processes gl.tm to retrieve the typemap data.
-*** _ExtractFuncs.lua: Processes gl.spec to retrieve the function data.
-*** _TableWriter.lua: Writes a table as a Lua-compileable file. Think LSON.
-
-The second stage uses the .lua file to generate the code. The output from this stage is described above. The files involved are:
-
-* makeAllFiles.lua: Causes the generation of all code-gen files. It doesn't take parameters.
-** _LoadLuaSpec.lua: Loads the spec we created above. However, it does some pre-processing to make the code-generation easier (tables indexed by enum and so forth). It also performs some data fixup that removes some... annoying things that the spec files leave in.
-** _MakeInclTypeFile.lua: Generates a header file that contains the type information (GLuint, etc). Only used for core OpenGL. Always a .h file.
-** _MakeInclCoreFile.lua: Generates header files that contains the enums and functions for a specific version of core OpenGL. It *only* includes those defs that are part of that specific version (and no core extensions). It can also take a parameter that removes removed functionality, up through a certain version. Generates .h and .hpp files.
-** _MakeInclExtFile.lua: Generates a header file that contains the enums and functions for all OpenGL extensions. Generates .h and .hpp files.
-** _MakeInclVersionFile.lua: Generates a header file that includes a number of the files generated by MakeIncl*File. Generates .h and .hpp files.
-** _MakeExtHeaderFile.lua: Generates a header file for a particular OpenGL version. This is used by external code to use OpenGL. Only used for WGL/GLX.
-** _MakeMainHeaderFile.lua: Generates an internal header that is used to load extension function pointers.
-** _MakeMainSourceFile.lua: Generates an internal source file that does the loading of the extension function pointers.
-** _MakeCoreHeaderFile.lua: Generates an internal header file that contains a struct defining all of the internal function pointers.
-** _MakeCoreSourceFile.lua: Generates an internal source file that will fill this struct with function pointers from the standard gl.h.
-
-== The gl.h issue ==
-
-Different versions of OpenGL libraries have different base implementations. On Windows, 1.1 is the base, so all of those functions are statically defined. On other platforms, there will be different levels of GL.
-
-What we will do is have a source file that includes the standard gl.h. It has a function that copies all the 1.1 function pointers into a prepared struct. Then, if a core function fails to get a function pointer, it can try to get it from the prepared struct. The struct is there to keep down name polution.
-
-In order to make this work, core functions ''must'' be #defined with their name, rather than defined as variables. If you don't do this, you get linker errors (multiple definition). Thus, all core OpenGL functions (including core extensions) must #define the name as a variable, with the variable name being externed instead. The variable name will be of the form "__gle*", where "*" is the rest of the function name.
-
-== The generated files ==
-
-The code-generation process will generate a number of files. The types of these files is as follows.
-
-* ''Include headers:'' These are the header files that the user #includes into their project. They define OpenGL entrypoints and enums for a particular OpenGL version/profile pair.
-
-* ''Main internal header:'' This header exposes the extension function loading functions to the non-code-generated GLE runtime.
-
-* ''Main source file:'' This implements the functions exposed by the Main internal header.
-
-* ''Core internal header:'' This header exposes a struct containing all of the core entrypoints. It also has a function to load standard core function pointers from this.
-
-* ''Core source header:'' Implements the functions from the Core internal header.
-
-=== External headers ===
-
-The standard generation process will create headers for the following combination of GL versions and profiles:
-
-* GL 2.1
-* GL 3.0
-* GL 3.1 core
-* GL 3.1 compatibility
-* GL 3.2 core
-* GL 3.2 compatibility
-* etc.
-
-The external code simply includes one of these header files. That will get them access to what they need.
-
-These files will have the following in them:
-
-* Core and extension #defines, as appropriate to the version.
-* Core and extension entrypoints, as appropriate to the version.
-* For each extension, a variable extern; if the variable is GL_FALSE, then the extension is not defined.
-
-=== Main internal header ===
-
-There will be a single internal header to the main loading functions. This file contains the following declarations:
-
-* A mapping table. An array of map objects, where the map object contains a string extension name, an integer pointer to the "is extension loaded" variable for that extension, and a function pointer to a loader for that extension (NULL if has no functions).
-* The size of the mapping table.
-* A function to clear all of the extension variables.
-* For each of the possible version/profile combinations, a function that loads the core entrypoints, including core extensions appropriate to the verison/profile (but not including regular extensions). Returns 1 if the function pointers could be loaded, and 0 otherwise. Will set the extension variables for any core extensions it loads.
-* A function to load the "base" entrypoints. See below.
-* The "base" entrypoint declarations, as well as "base" enum defines.
-
-All internal functions have the prefix "gleInt_".
-
-==== Base declarations ====
-
-The "base" declarations are those that the basic system needs to function. These are:
-
-* ''glGetString'': Used to get the version number and extensions, possibly.
-* ''glGetStringi'': Used to get the extensions in 3.x versions. Can be NULL.
-* ''glGetIntegerv'': Used to get the number of extensions in 3.x versions.
-* ''GL_VERSION'': Enum needed to version numbers.
-* ''GL_EXTENSIONS'': Enum needed to get extensions.
-* ''GL_NUM_EXTENSIONS'': Enum used to get the number of extensions.
-* ''GL_CONTEXT_PROFILE_MASK'': Enum used to test the profile type.
-* ''GL_CONTEXT_CORE_PROFILE_BIT'': Enum for the core profile.
-* ''GL_CONTEXT_COMPATIBILITY_PROFILE_BIT'': Enum for the compatibility profile.
-* ''GL_TRUE'' and ''GL_FALSE'': so that we can use them.
-
-=== Core internal header ===
-
-This header file exposes a struct (with an expected name) that stores function pointers for ''all'' core functions. It also exposes a single function that will clear this struct, then load the standard function pointers into it.
-
-=== Core source file ===
-
-This file the standard #includes "gl/gl.h". It also implements the function above.
-
-The first phase of the function will clear the struct. The second phase is platform-specific. Each platform in the code generator will have a define to #ifdef around, and it will also specify which core versions need to be looked at.
-
-Note: the struct in question may require some defines for the functions to be placed in the source file.
-
-=== Main source file ===
-
-This file does the following:
-
-* Define all of the externed extension variables.
-* Define all of the externed function pointers.
-* Initialize the mapping table from extension name to extension variable.
-* Implement the function that clears extension variables.
-* For each extension with function pointers, implement a ''static'' function to load the function pointers for it.
-* For each of the version/profile pairs, implement a function that loads the core function pointers for that version/profile pair. This includes core extensions, but only those appropriate to the verison. If a core function pointer is not found, then check the core internal struct for one.
-* Implement the function that loads the "base" stuff.
-
-==== Extension loading ====
-
-The functions that load extensions will return 0 if some of the function pointers were not there, and 1 otherwise. Unfortunately, to see if a function pointer is there, it must be tested against the values -1, 0, 1, 2, and 3.
-
-==== Core loading ====
-
-The first thing any of these functions will do is clear the Core Function struct.
-
-The function that loads core entrypoints will also load entrypoints for appropriate core extensions. If a core extension loads successfully, its extension variable will be set.
-
-If a core function pointer is not available, check the struct of core functions from the Core header. If it's in there, then use that. Otherwise, fail and return 0.
-
-Loading a core extension is slightly different from loading a regular extension in this respect. If a core extension is being loaded as a core extension, then it should be loaded as a core extension, which requires checking variables in the struct on failure. Also, when a core extension is loaded as a core extension, the extension variable should be set.
-
-===== Generating core loaders =====
-
-To keep from regenerating the same loading code over and over again, the process will work as follows.
-
-First, we will scan all the functions and collect a list of the individual version numbers of the "deprecated" field.
-
-Then, we generate a number of loader functions for core functions. There will be one "base" function that loads all entrypoints. Then, for each of the version numbers collected above, generate a set of alternative core loader functions up to and including that version number that write functions that haven't been removed up to that version.
-
-As a further optimization, we will have the lower versions call the higher versions. So the base can call the lowest version (where available), the lowest version can call the next-lowest version (where available), and so on. Thus, the base version would only need to store the ''non'' deprecated ones.
-
-Note that these functions must include core ''and'' core extension functions.
-
-So, let's say you have removal on only one verison: 3.1. Therefore, you will write:
-
-* base loader functions for every available GL version. Calling these will have the effect of loading *all* function pointers for that version (and only that version) of OpenGL. Internally, it will load only those functions which were removed in 3.1, and then call the equivalent 3.1 function (if any).
-* loader functions for every GL version up to but not including 3.1. These functions will load only those functions which were *not* removed in 3.1. There will not be functions for GL version 3.1 and 3.2; the base versions will qualify.
-
-To load the core 3.2 context, you call the base 3.2 loader, then call the 3.1 removal functions for everything else.
-
-== Algorithm of gleLoadFunction ==
-
-This function is hand-written, for now.
-
-# Call the function to clear entrypoints.
-# Call the base loading function to get the base entrypoints.
-# Get the OpenGL version.
-# Load the core entrypoints.
-## If version is 2.1 or less, load 2_1.
-## If version is 3.0, load 3.0.
-## If the version is 3.1, check the extension string. If ARB_compatibility is defined, load 3.1 compatibility. Otherwise, load 3.1 core.
-## If the version is 3.2 or greater, check the profile bit and load 3.2 accordingly.
-# For each extension in the string:
-## If the extension has no entry in the map table, continue.
-## If the extension variable for it has already been set to GL_TRUE, do nothing. (it can be set to that because it's a core extension).
-## If the extension has a loader, call it. If the loader returns 1, set the variable to GL_TRUE.
-## If the extension doesn't have a loader, set the variable to GL_TRUE.
-
-== Using the library ==
-
-To initialize the OpenGL core function pointers, the user calls "gleLoadFunctions". This function takes no parameters, and it will load all available extensions and core functions for the [i]actual[/i] version of the OpenGL implementation. This is guaranteed to be greater than or equal to the version the user asked to be created.
-
-The "gleLoadFunctions" will return GL_FALSE if the loading failed.
-
-== Adding new spec files ==
-
-Adding spec files uses the following procedure. The gl-xml-spec project is where the specification and conversion utilities are maintained. Once the gl-xml-spec project has generated new .lua spec files:
-
-# Update the repo to the "latest-spec" tag. Change to the "glspec" branch.
-# Drop the new spec files in the glload/codegen/glspecs directory.
-# Commit these into the "glspec" branch. Include the changelist of the data from gl-xml-spec.
-# Update the "latest-spec" tag to point to this newest commit.
-# Merge the "glspec" head with the "default" branch.
-# If the .spec files include a new OpenGL version:
-## In codegen/MakeAllFiles.lua, add lines to the `glOutputs` function to handle the new OpenGL version.
-## In codegen/data/coreExtList.lua, add a new table to contain the core ARB extensions for the new version. Then add an entry into the `masterTable` table to reference it. Make sure to take the `GL_` prefixes out.
-## In codegen/data/listOfCoreVersions.lua, add a new core version.
-## Modify `gl_all.h` and `gl_all.hpp` to include the most recent compatibility header.
-## If the new version removed (not just deprecated) functionality:
-### In codegen/MakeAllFiles, add the version to the list `removalVersions`.
-# In the glload/codegen directory, run 'lua MakeAllFiles.lua'
-# Verify that the tests and examples work.
-# Add new files from `glload/include/glload` to Mercurial.
-# Check this into the "default" branch.
-
-Any .spec file bugs that we need to fix should be fixed in gl-xml-spec project. That is where the .spec files are maintained.

glload/codegen/LuaAndXMLSpecFormat.txt

-== GL Extensions ==
-
-Here is how the extension loading library will work:
-
-=== Convert to Lua-Form ===
-
-The current extension data format is pretty primitive. So instead, we want to convert it into a Lua-based form.
-
-enumext.spec now contains all of the enumerators, so the format conversion shouldn't be so bad.
-
-Basically, the format should be not entirely unlike what the "collation" functions do. Except that they need to be more true to the .spec format. If we are to replace .specs with this type (or an XML-ized version of it) then we need to deal with the format.
-
-There should also be a converter that converts back to the old format.
-
-==== Format ====
-
-The format is written out by ExtractSpecsToFile.lua. The result is a lua file that, when run will return a table with the following elements:
-
-* extensions: An array of extension name strings, ordered as in enumext.spec.
-* typemap: A table. The keys are the GL types that are used by functions; the values are the actual C types for them.
-* enumerations: An array of enumerators, ordered as in enumext.spec. Each enumerator is a struct defined as:
-** name: String containing the name of the enumerator.
-** value: String number containing the value of the enumerator, or the name of an enumerator to copy from.
-** copy: True if the value is an enumerator to copy from; false if it's a number.
-** version: String in A.B format contining the core version for this enumerator.
-** deprecated: String in A.B format for the version where the enumerator was deprecated.
-** removed: String in A.B format when the enumerator was removed from GL.
-** extension: An array of extension names.
-* funcData: A table containing the following fields:
-** properties: A table of property values. It is a map between property name and values. The value can either be "*" or an array of possible string values that the property can take.
-** passthru: An array of line strings, in the order in gl.spec, for the preamble passthrough data.
-** functions: An array of functions. Each function is a table with:
-*** name: The name of the function.
-*** any of the properties defined in the properties table. This will have values culled from the list of possibles, except if the property was defined as "*", in which case it will be any string.
-*** params: An array of parameters, in the order that they appear in the function prototype. Each parameter is a table with:
-**** name: the name of the parameter.
-**** type: The basic type. Something in the type-map.
-**** input: True if it is an input variable, valse otherwise.
-**** array: True if it is a pointer; false otehrwise.
-**** other: A string containing the other data. Kept for backwards compatibility.
-
-==== Post-Convert ====
-
-The above format is nice, compact and tidy. But there are some useful permutations we can add to make later processing easier. Calling LoadLuaSpec.lua will load the given lua file and add the following entries to the table:
-
-* enumtable: A table of enumerators, indexed by their names. The value are the entries in the main enum array.
-* extdefs: This is a table of extensions, indexed by extension name. Each extension contains:
-** enums: An array of enumerators. These enumerators are the entries in the main enum array.
-** funcs: An array of functions. These functions are the entries in the main funcData.functions array.
-* coredefs: This is a table of core versions, indexed by version name string. Each core contains:
-** enums: An array of enumerators. These enumerators are the entries in the main enum array.
-** funcs: An array of functions. These functions are the entries in the main funcData.functions array.
-* coreexts: A table of core extensions, indexed by extension name. The value of these entries are:
-** name: The core extension's name.
-** version: the version that extension became core in. The version is a string.
-

glload/codegen/MakeAllFiles.lua

---[[
-Calling dofile on this will generate all of the header and source files needed
-for GLE.
-]]
-
-require "_LoadLuaSpec"
-require "_MakeExtHeaderFile"
-require "_MakeMainHeaderFile"
-require "_MakeMainSourceFile"
-require "_MakeCoreHeaderFile"
-require "_MakeCoreSourceFile"
-require "_MakeInclTypeFile"
-require "_MakeInclCoreFile"
-require "_MakeInclExtFile"
-require "_MakeInclVersionFile"
-require "_util"
-
-local specFileLoc = GetSpecFilePath();
-
-
-
----------------------------
---Create standard OpenGL files.
-local specData = LoadLuaSpec(specFileLoc .. "glspec.lua");
-	
-local glPreceedData = {
-		dofile(GetDataFilePath() .. "headerGlProtect.lua"),
-		dofile(GetDataFilePath() .. "glDefStr.lua"),
-		dofile(GetDataFilePath() .. "headerFunc.lua"),
-	}
-
---Write the external headers.
-local glOutputs = {
-	{"gl_2_1", "2.1", true},
-	{"gl_3_0", "3.0", true},
-	{"gl_3_1", "3.1", true},
-	{"gl_3_1_comp", "3.1", false},
-	{"gl_3_2", "3.2", true},
-	{"gl_3_2_comp", "3.2", false},
-	{"gl_3_3", "3.3", true},
-	{"gl_3_3_comp", "3.3", false},
-	{"gl_4_0", "4.0", true},
-	{"gl_4_0_comp", "4.0", false},
-	{"gl_4_1", "4.1", true},
-	{"gl_4_1_comp", "4.1", false},
-	{"gl_4_2", "4.2", true},
-	{"gl_4_2_comp", "4.2", false},
-	{"gl_4_3", "4.3", true},
-	{"gl_4_3_comp", "4.3", false},
-};
-
-local glTruncPreceedData = {}
-
-local removalVersions = { "3.1" }
-local listOfCoreVersions = dofile(GetDataFilePath() .. "listOfCoreVersions.lua");
-local newGlOutputs = {};
-
-local function GetCoreInclBasename(coreVersion, removalVersion)
-	local baseName = "_int_gl_" .. coreVersion:gsub("%.", "_");
-	if(removalVersion) then
-		baseName = baseName .. "_rem_" .. removalVersion:gsub("%.", "_");
-	end
-	return baseName;
-end
-
-for i, coreVersion in ipairs(listOfCoreVersions) do
-	local baseFilename = GetCoreInclBasename(coreVersion);
-	local output = {};
-	output[1] = baseFilename;
-	output[2] = coreVersion;
-	output[3] = nil;
-	newGlOutputs[baseFilename] = output;
-	for i, removalVersion in ipairs(removalVersions) do
-		output = {};
-		local newFilename = GetCoreInclBasename(coreVersion, removalVersion);
-		output[1] = newFilename;
-		output[2] = coreVersion;
-		output[3] = removalVersion;
-		newGlOutputs[newFilename] = output;
-	end
-end
-
-local typeHeaderName = "_int_gl_type";
-local extHeaderName = "_int_gl_exts";
-
-MakeInclTypeFile(typeHeaderName, specData, glPreceedData);
-
-for baseFilename, output in pairs(newGlOutputs) do
-	output[4] = MakeInclCoreFile(output[1], specData, "GL", "gl",
-		output[2], output[3], glTruncPreceedData);
-end
-
-MakeInclExtFile(extHeaderName, specData, "GL", "gl", glTruncPreceedData);
-
-----------------------------------
--- Write include files for the new headers.
-for i, output in ipairs(glOutputs) do
-	local outVersion = output[2];
-	local numOutVersion = tonumber(outVersion);
-	local includeList = {typeHeaderName, extHeaderName};
-	
-	for i, version in ipairs(listOfCoreVersions) do
-		local numVersion = tonumber(version);
-		if(numVersion > numOutVersion) then
-			break;
-		end
-		
-		local coreName = GetCoreInclBasename(version);
-		if(newGlOutputs[coreName][4]) then
-			includeList[#includeList + 1] = coreName;
-		end
-		
-		if(not output[3]) then
-			for i, removalVersion in ipairs(removalVersions) do
-				local baseName = GetCoreInclBasename(version, removalVersion)
-				if(newGlOutputs[baseName][4]) then
-					includeList[#includeList + 1] = baseName;
-				end
-			end
-		else
-			for i, removalVersion in ipairs(removalVersions) do
-				if(tonumber(removalVersion) > numOutVersion) then
-					--Has been removed from core, but not this version.
-					local baseName = GetCoreInclBasename(version, removalVersion)
-					if(newGlOutputs[baseName][4]) then
-						includeList[#includeList + 1] = baseName;
-					end
-				end
-			end
-		end
-	end
-
-	MakeInclVersionFile(output[1], includeList);
-end
-
-
-
-local function GetVersionProfIterator()
-	local currIx = 1;
-	
-	return function()
-		if(currIx > #glOutputs) then return nil, nil; end;
-		
-		local currValue = glOutputs[currIx];
-		currIx = currIx + 1;
-		local profile = nil;
-		
-		if(currValue[3]) then profile = "core"; else profile = "compatibility"; end;
-		
-		return currValue[2], profile;
-	end
-end
-
---Write the internal headers.
-local baseData = {
-	enums = {"VERSION", "EXTENSIONS", "NUM_EXTENSIONS", "CONTEXT_PROFILE_MASK", "CONTEXT_CORE_PROFILE_BIT", "CONTEXT_COMPATIBILITY_PROFILE_BIT", "TRUE", "FALSE"},
-	
-	funcs = {"GetString", "GetStringi", "GetIntegerv"},
-
-	bFuncsAreCore = true,
-	
-	enumPrefix = "GL",
-	
-	preceedData = glPreceedData,
-};
-
-MakeMainHeaderFile("gll_gl_ext", specData, "gl", GetVersionProfIterator(), baseData);
-
---MakeCoreHeaderFile("gll_gl_core", specData, "gl");
-
---Write the internal source files.
-
-local platformDef = dofile(GetDataFilePath() .. "stdPlatformDef.lua");
-
-MakeMainSourceFile("gll_gl_ext", specData, "GL", "gl", GetVersionProfIterator(), glPreceedData,
-	baseData, nil);
-
---MakeCoreSourceFile("gll_gl_core", specData, "gl", platformDef);
-
----------------------------
---Create WGL files.
-local wglSpecData = LoadLuaSpec(specFileLoc .. "wglspec.lua");
-
-local wglPreceedData = {
-	dofile(GetDataFilePath() .. "wglPreceed.lua"),
-	dofile(GetDataFilePath() .. "wglHeaderFunc.lua"),
-	dofile(GetDataFilePath() .. "glDefStr.lua"),
-}
-
-local wglbaseData = {
-	enums = {},
-	funcs = {"GetExtensionsStringARB"},
-	bFuncsAreCore = false,
-	enumPrefix = "WGL",
-	preceedData = wglPreceedData
-};
-
-
-MakeExtHeaderFile("wgl_exts", wglSpecData, "WGL", "wgl", nil, false, wglPreceedData);
-
-MakeMainHeaderFile("wgll_ext", wglSpecData, "wgl", nil, wglbaseData);
-
-MakeMainSourceFile("wgll_ext", wglSpecData, "WGL", "wgl", nil, wglPreceedData,
-	wglbaseData, nil);
-	
-	
----------------------------
---Create GLX files.
-local glxSpecData = LoadLuaSpec(specFileLoc .. "glxspec.lua");
-
-local glxPreceedData = {
-	dofile(GetDataFilePath() .. "glxPreceed.lua"),
-	dofile(GetDataFilePath() .. "glxHeaderFunc.lua"),
-	dofile(GetDataFilePath() .. "glDefStr.lua"),
-}
-
-MakeExtHeaderFile("glx_exts", glxSpecData, "GLX", "glX", nil, false, glxPreceedData);
-
-MakeMainHeaderFile("glxl_ext", glxSpecData, "glX", nil, glxbaseData);
-
-MakeMainSourceFile("glxl_ext", glxSpecData, "GLX", "glX", nil, glxPreceedData,
-	glxbaseData, nil);
-	
-	
-	
-	
-	
-	
-	

glload/codegen/_LoadLuaSpec.lua

---[[
-The function, LoadLuaSpec exposed here will load a spec.lua file. It takes a filename
-pointing to a spec.lua file.
-
-This function will also add some features to the object before returning it.
-
-The format will be as defined in ConvertAllSpecFilesToLua, except for the following:
-
-- extdefs: This is a table of extensions, indexed by extension name.
-	Each entry contains:
--- enums: An array of enumerators. These enumerators are the entries in the main enum array.
--- funcs: An array of functions. These functions are the entries in the main funcData array.
-- coredefs: This is a table of core versions, indexed by version name string
-	"1.1" is the first.
--- enums: An array of enumerators. These enumerators are the entries in the main enum array.
--- funcs: An array of functions. These functions are the entries in the main funcData array.
-- enumtable: A table of enumerators, indexed by their names.
-- coreexts: A table of core extensions, indexed by extension name. The value of these entries are:
--- name: The core extension's name.
--- version: the version that extension became core in. The version is a string.
-
-
-All enumerators and functions are found in one of these two lists. Some of them are in both.
-
-Other changes are:
-- All functions that would have the 1.0 version have it changed to 1.1. This makes the data match the enums.
-- The "void" type in the typemap maps to "void".
-- Fixes for certain extensions. Certain extensions are non-core, but the enums and functions
-	have no suffixes as if they were core.
-]]
-
-local listOfCoreVersions = dofile("data/listOfCoreVersions.lua");
-
-local listOfNonCoreFixes = 
-{
---	"ARB_sample_shading",
---	"ARB_draw_buffers_blend",
---	"ARB_texture_cube_map_array",
-};
-
-local listOfExtensionsToRemove =
-{
-    "SGIX_video_source",
-    "SGIX_dmbuffer",
-    "SGIX_hyperpipe",
-};
-
-function LoadLuaSpec(luaFilename)
-	local specData = dofile(luaFilename);
-
-	specData.extdefs = {};
-	specData.coredefs = {};
-	specData.enumtable = {};
-	local extdefs = specData.extdefs;
-	local coredefs = specData.coredefs;
-	local enumtable = specData.enumtable;
-	
-	--HACK! Change 1.0 version in functions to 1.1, to match enums.
-	for i, func in ipairs(specData.funcData.functions) do
-		if(func.version == "1.0") then func.version = "1.1"; end;
-	end
-	
-	--HACK! Change "void" in the typemap to map to "void".
-	specData.typemap.void = "void";
-	
-	--HACK! Add suffixes to functions and enums for these extensions.
-	for i, extName in ipairs(listOfNonCoreFixes) do
-		for j, func in ipairs(specData.funcData.functions) do
-			if(func.category == extName) then
-				func.name = func.name .. "ARB";
-			end
-		end
-		for j, enum in ipairs(specData.enumerations) do
-			if(enum.extensions) then
-				for k, enumExt in ipairs(enum.extensions) do
-					if(enumExt == extName) then
-						enum.name = enum.name .. "_ARB";
-					end
-				end
-			end
-		end
-	end
-	
-	--HACK! Remove certain offensive extensions.
-	local toRemove = {}
-	for i, ext in ipairs(specData.extensions) do
-	    for j, test in ipairs(listOfExtensionsToRemove) do
-	        if(ext == test) then
-	            table.insert(toRemove, 1, i);
-	            break;
-	        end
-	    end
-	end
-	
-	for i, index in ipairs(toRemove) do
-	    table.remove(specData.extensions, index);
-	end
-	
-	toRemove = {}
-	for i, enum in ipairs(specData.enumerations) do
-		if(enum.extensions) then
-		    for j, enumExt in ipairs(enum.extensions) do
-		        local bBreak = false;
-	            for k, test in ipairs(listOfExtensionsToRemove) do
-	                if(enumExt == test) then
-	                    table.insert(toRemove, 1, i);
-	                    bBreak = true;
-	                    break;
-	                end
-	            end
-	            if(bBreak) then break; end
-		    end
-		end
-	end
-	
-	for i, index in ipairs(toRemove) do
-	    table.remove(specData.enumerations, index);
-	end
-	
-	toRemove = {}
-    for i, func in ipairs(specData.funcData.functions) do
-	    for j, test in ipairs(listOfExtensionsToRemove) do
-	        if(ext == func.category) then
-	            table.insert(toRemove, 1, i);
-	            break;
-	        end
-	    end
-    end
-
-	for i, index in ipairs(toRemove) do
-	    table.remove(specData.funcData.functions, index);
-	end
-	
-	
-	
-	
-	local function GetCore(version)
-		if(not coredefs[version]) then
-			local coredef = {};
-			coredefs[version] = coredef;
-			coredef.enums = {};
-			coredef.funcs = {};
-		end
-		
-		return coredefs[version];
-	end
-	
-	local function GetExt(extName)
-		if(not extdefs[extName]) then
-			local extdef = {};
-			extdefs[extName] = extdef;
-			extdef.enums = {};
-			extdef.funcs = {};
-		end
-		
-		return extdefs[extName];
-	end
-
-	--Add all extensions to the extdefs.
-	for	i, extName in ipairs(specData.extensions) do
-		GetExt(extName);
-	end
-	
-	for i, enum in ipairs(specData.enumerations) do
-		enumtable[enum.name] = enum;
-		
-		if(enum.extensions) then
-			for k, extName in ipairs(enum.extensions) do
-				table.insert(GetExt(extName).enums, enum);
-			end
-		end
-		
-		if(enum.version) then
-			table.insert(GetCore(enum.version).enums, enum);
-		end
-	end
-
-	for i, func in ipairs(specData.funcData.functions) do
-		--This is here to make sure that the category is an actual extension,
-		--not a verison number.
-		if(extdefs[func.category]) then
-			table.insert(GetExt(func.category).funcs, func);
-		end
-	
-		if(func.version) then
-			if(not func.category or string.match(func.category, "^VERSION")) then
-				local versionVal = string.gsub(func.category, "VERSION_(%d+)_(%d+).*", "%1%.%2");
-				--HACK!
-				if(versionVal == "1.0") then versionVal = "1.1" end;
-				table.insert(GetCore(versionVal).funcs, func);
-			end
-		end
-	end
-	
-	specData.coreexts = dofile(GetDataFilePath() .. "coreExtList.lua");
-
-	return specData;
-end
-

glload/codegen/_MakeCoreHeaderFile.lua

---[[
-The function MakeCoreHeaderFile will generate the core source file.
-
-This file will contain all of the core function pointers (including core extensions) in a big struct. It also exposes a function that will set these function pointers from the default version of OpenGL.
-
-The function is called "void [funcPrefix]eIntCoreInit();"
-
-This exists to fix the "core function" problem. Windows, for examples, defines all of the 1.1 entrypoints as regular functions. Thus, calling wglGetProcAddress will not retrieve those functions. We must instead get pointers to those functions manually. They get put into this struct.
-
-The above function will fill in the pointers that standard GL provides, while NULL-ing out things that aren't statically defined.
-
-You MUST include a file that has all of the typedefs before including this file.
-]]
-
-require "_makeHelpers"
-require "_util"
-
-function MakeCoreHeaderFile(outFilename, specData, funcPrefix)
-	local hFile = io.open(GetSourcePath() .. outFilename .. ".h", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetSourcePath() .. outFilename .. "\".\n");
-		return;
-	end
-	
-	local defineName = string.upper(outFilename) .. "_H";
-
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-	
-	hFile:write(GetExternCStart());
-	hFile:write("\n");
-	
-	hFile:write("\n");
-
-	--Collect all of the appropriate functions.
-	local funcList = Make.FetchAllCoreFunctions(specData);
-	
-	hFile:write(string.format("typedef struct %s_s\n", Make.GetCoreStructType(funcPrefix)));
-	hFile:write("{\n");
-	
-	--Write out the struct values.
-	for i, func in ipairs(funcList) do
-		hFile:write(string.format("\tvoid *%s;\n",
-			Make.GetCoreStructMemberName(func, funcPrefix)
-		));
-	end
-
-	WriteForm(hFile, "}%s;\n", Make.GetCoreStructType(funcPrefix));
-	hFile:write("\n");
-	
-	--Write the extern of the struct definition.
-	hFile:write(string.format("extern %s %s;\n", Make.GetCoreStructType(funcPrefix),
-		Make.GetCoreStructVarName(funcPrefix)));
-
-	hFile:write("\n");
-	
-	WriteFormatted(hFile, "void %s();\n", Make.GetCoreInitFuncName(funcPrefix));
-		
-	hFile:write("\n");
-
-	hFile:write(GetExternCEnd());
-	hFile:write("\n");
-
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-	hFile:write("\n");
-	
-	hFile:close();
-end

glload/codegen/_MakeCoreSourceFile.lua

---[[
-The function MakeCoreSourceFile will generate the core source file.
-
-The file will implement the function exposed by MakeCoreHeaderFile.
-
-Because the implementation of this is platform-specific, there must be a way to determine which versions are available in the core gl.h file. To do this, you provide a special parameter: platformDef.
-
-The platformDef parameter is an array of platform definitions. Each entry in the array has the following:
-
-* define: the string name of the #define that is used to control this.
-* statements: a list of strings, each of which is a statement. These should be added towards the top of the file; they must include the standard gl.h.
-* versions: a list of versions (in string form) that the included files define.
-]]
-
-require "_makeHelpers"
-require "_util"
-
-
-function MakeCoreSourceFile(outFilename, specData, funcPrefix, platformDef)
-	local hFile = io.open(GetSourcePath() .. outFilename .. ".c", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetSourcePath() .. outFilename .. ".c\".\n");
-		return;
-	end
-	
-	hFile:write([[#include <stdlib.h>
-#include <string.h>
-]]);
-
-	hFile:write("\n");
-
-	--Collect all of the appropriate functions.
-	local funcList = Make.FetchAllCoreFunctions(specData);
-
-	--Include the header file.
-	hFile:write("#include \"" .. outFilename .. ".h\"\n");
-	
-	--Define the struct variable.
-	hFile:write(string.format("%s %s;\n", Make.GetCoreStructType(funcPrefix),
-		Make.GetCoreStructVarName(funcPrefix)));
-
-	--Now, write the platform-specific statements.
-	for i, platform in ipairs(platformDef) do
-		if(platform.statements and #platform.statements ~= 0) then
-			WriteFormatted(hFile, "#ifdef %s\n", platform.define);
-			for j, statement in ipairs(platform.statements) do
-				hFile:write(statement);
-				hFile:write("\n");
-			end
-			WriteFormatted(hFile, "#endif //%s\n", platform.define);
-		end
-	end
-	
-	--Write the implementation of the function.
-	hFile:write("\n");
-	
-	WriteFormatted(hFile, "void %s()\n", Make.GetCoreInitFuncName(funcPrefix));
-	hFile:write("{\n");
-	
-	-- Pre-platform-specific.
-	WriteFormatted(hFile, [[
-	memset(&%s, 0, sizeof(%s));
-]], Make.GetCoreStructVarName(funcPrefix), Make.GetCoreStructType(funcPrefix));
-	
-	-- Write platform-specifics: retrieving the function pointers.
-	for i, platform in ipairs(platformDef) do
-		if(platform.versions and #platform.versions ~= 0) then
-			WriteFormatted(hFile, "#ifdef %s\n", platform.define);
-			for j, strVersion in ipairs(platform.versions) do
-				local testVersion = string.gsub(strVersion, "(%d+)%.(%d+)", "VERSION_%1_%2");
-				local testVersionDep = testVersion .. "_DEPRECATED";
-				for k, func in ipairs(funcList) do
-					if((func.category == testVersion) or (func.category == testVersionDep)) then
-						WriteFormatted(hFile, "\t%s.%s = (void*)%s;\n",
-							Make.GetCoreStructVarName(funcPrefix),
-							Make.GetCoreStructMemberName(func, funcPrefix),
-							Make.GetFuncPtrNameStr(func, funcPrefix)
-						)
-					end
-				end
-			end
-			WriteFormatted(hFile, "#endif //%s\n", platform.define);
-		end
-	end
-	
-	hFile:write("}\n");
-	hFile:write("\n");
-
-	hFile:close();
-end

glload/codegen/_MakeExtHeaderFile.lua

---[[ The function, MakeExtHeaderFile, will create a header file containing the enums, extension
-test values, and the list of function pointers.
-
-It takes these parameters:
-- the name of the output file. Without the path.
-- the specData, as formatted by LoadLuaSpec.
-- the prefix (without the underscore) to prepend to enumerators.
-- the prefix to prepend to functions.
-- a string representing the target GL version to export. If nil, gets everything.
-- a boolean. If true, means that this should output only the core stuff.
-- an array of strings to write to the front of the header file.
-]]
-
-require "_util"
-require "_makeHelpers"
-
-local function ProcessCoreVersion(hFile, core, specData, enumPrefix, funcPrefix,
-									version, targetVersion, bIsCore)
-	WriteFormatted(hFile, GetSectionHeading(string.format("Version: %s", version)));
-	hFile:write("\n");
-	
-	local bDidWrite = false;
-	for i, enum in ipairs(core.enums) do
-		local bShouldWrite = true;
-		if(bIsCore) then
-			if(enum.removed and (tonumber(enum.removed) <= tonumber(targetVersion))) then
-				bShouldWrite = false;
-			end
-		end
-		
-		--We'll write it as an extension
-		if(enum.extension) then
-			bShouldWrite = false;
-			--TODO: Make this write something saying that it comes from the extension.
-		end
-		
-		if(bShouldWrite) then
-			hFile:write(Make.GetEnumerator(enum, specData.enumtable, enumPrefix));
-			hFile:write("\n");
-			bDidWrite = true;
-		end
-	end
-	
-	--Collate the functions we want to write.
-	local funcs = {};
-	for i, func in ipairs(core.funcs) do
-		local bShouldWrite = true;
-		if(bIsCore) then
-			if(func.deprecated and
-					(tonumber(func.deprecated) <= tonumber(targetVersion))) then
-				bShouldWrite = false;
-			end
-		end
-		
-		--Exts don't start with "VERSION"; don't write extension
-		--functions here. Write them in the extension
-		if(func.category and not string.match(func.category, "^VERSION")) then
-			bShouldWrite = false;
-		end
-		
-		if(bShouldWrite) then
-			table.insert(funcs, func);
-		end
-	end
-	
-	if(bDidWrite and #funcs ~= 0) then
-		hFile:write("\n\n");
-	end
-	
-	local bWroteAnything = bDidWrite;
-	bDidWrite = false;
-	
-	--Write the typedefs.
-	for i, func in ipairs(funcs) do
-		bDidWrite = true;
-		hFile:write(Make.GetFuncTypedef(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-	end
-	
-	if(bDidWrite) then
-		hFile:write("\n");
-	end
-	
-	--Write the function pointers.
-	for i, func in ipairs(funcs) do
-		bDidWrite = true;
-		hFile:write(Make.GetCoreFuncExternPtr(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-		hFile:write(Make.GetCoreFuncPtrDefine(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-	end
-
-	bWroteAnything = bDidWrite or bWroteAnything;
-
-	if(bWroteAnything) then
-		hFile:write("\n\n");
-	end
-end
-
-local function ProcessExtension(hFile, ext, extName, specData, enumPrefix, funcPrefix)
-	WriteFormatted(hFile, GetSectionHeading(string.format("Extension: %s_%s",
-		enumPrefix, extName)));
-	hFile:write("\n");
-	
-	--Write the enumerators.
-	local bDidWrite = false;
-	for i, enum in ipairs(ext.enums) do
-		bDidWrite = true;
-		hFile:write(Make.GetEnumerator(enum, specData.enumtable, enumPrefix));
-		hFile:write("\n");
-	end
-
-	if(bDidWrite and #ext.funcs ~= 0) then
-		hFile:write("\n\n");
-	end
-	
-	local bWroteAnything = bDidWrite;
-	bDidWrite = false;
-
-	--Write the typedefs.
-	local extDefine = nil;
-	if(#ext.funcs > 0) then
-	    --Write the #ifdef for the function pointers, so that they are only
-	    --available if something hasn't defined over them.
-	    extDefine = string.format("%s_%s", enumPrefix, extName);
-	    hFile:write(string.format("#ifndef %s\n#define %s 1\n\n",
-	        extDefine, extDefine));
-	end
-	for i, func in ipairs(ext.funcs) do
-		bDidWrite = true;
-		hFile:write(Make.GetFuncTypedef(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-	end
-	
-	if(bDidWrite) then
-		hFile:write("\n");
-	end
-	
-	--Write the function pointers.
-	for i, func in ipairs(ext.funcs) do
-		bDidWrite = true;
-		
-		if(specData.coreexts[extName]) then
-			hFile:write(Make.GetCoreFuncExternPtr(func, funcPrefix, specData.typemap));
-			hFile:write("\n");
-			hFile:write(Make.GetCoreFuncPtrDefine(func, funcPrefix, specData.typemap));
-		else
-			hFile:write(Make.GetFuncExternPtr(func, funcPrefix, specData.typemap));
-		end
-		hFile:write("\n");
-	end
-	
-	if(extDefine) then
-	    hFile:write(string.format("#endif /*%s*/", extDefine));
-	end
-	
-	bWroteAnything = bDidWrite or bWroteAnything;
-
-	if(bWroteAnything) then
-		hFile:write("\n\n");
-	end
-end
-
-function MakeExtHeaderFile(outFilename, specData, enumPrefix, funcPrefix,
-							targetVersion, bIsCore, preceedData)
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".h", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return;
-	end
-	
-	local defineName = string.upper(outFilename) .. "_H";
-	
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-	
-	if(preceedData) then
-		for i, preceed in ipairs(preceedData) do
-			hFile:write(preceed);
-			hFile:write("\n");
-		end
-	end
-	
-	--Write the passthru data.
-	for i, passthru in ipairs(specData.funcData.passthru) do
-		hFile:write(passthru);
-		hFile:write("\n");
-	end
-	hFile:write("\n");
-
-	hFile:write(GetExternCStart());
-	hFile:write("\n");
-	
-	--Write all of the extension query variables.
-	for i, extName in ipairs(specData.extensions) do
-		hFile:write(Make.GetExtensionVarExtern(extName, funcPrefix));
-		hFile:write("\n");
-	end
-
-	hFile:write("\n\n");
-
-	--Process all of the cores, up to and including targetVersion.
-	local coreVersions = dofile(GetDataFilePath() .. "listOfCoreVersions.lua");
-	if(not targetVersion) then targetVersion = coreVersions[#coreVersions]; end;
-	
-	for i, version in ipairs(coreVersions) do
-		if(tonumber(version) > tonumber(targetVersion)) then
-			break;
-		end
-
-		if(specData.coredefs[version]) then
-			ProcessCoreVersion(hFile, specData.coredefs[version], specData,
-				enumPrefix, funcPrefix, version, targetVersion, bIsCore);
-		end
-	end
-	
-	hFile:write("\n\n");
-
-	--Process all of the extensions.
-	for extName, ext in sortPairs(specData.extdefs, CompLess) do
-		ProcessExtension(hFile, ext, extName, specData, enumPrefix, funcPrefix);
-	end
-	
-	
-	hFile:write(GetExternCEnd());
-	hFile:write("\n");
-	
-	if(preceedData and preceedData.footer) then
-		for i, footer in ipairs(preceedData.footer) do
-			hFile:write(footer);
-			hFile:write("\n");
-		end
-	end
-	
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-	
-	hFile:close();
-end
-

glload/codegen/_MakeInclCoreFile.lua

---[[The function, MakeInclCoreFile, will create a C and C++ header file containing the enums and function pointers for a given core version. It will only put those definitions which were added to that particular core version. So definitions that were added to OpenGL in past versions are not included. Core extensions are also not included.
-
-If it is given a removal version, then it will only output the enums and functions that were both a part of the given core version *and* removed in the given removal version. If no removal version is given, then it will only output the definitions that are still core in the most recent OpenGL version.
-
-If the function returns false, then there are no enums and functions for the given core and removal versions. Otherwise, it will return true.
-
-It takes these parameters:
-- the name of the output file. Without the path.
-- the specData, as formatted by LoadLuaSpec.
-- the prefix (without the underscore) to prepend to enumerators.
-- the prefix to prepend to functions.
-- a string representing the specific GL version to export. Only those funcs and enums will be written.
-- a string representing the removal version. It will only write funcs and enums that were removed in that version. If nil, then will write only core.
-- an array of strings to write to the front of the header file.
-]]
-
-require "_util"
-require "_makeHelpers"
-
-local function ProcessCoreVersionC(hFile, enumList, funcList, specData, enumPrefix,
-									funcPrefix, targetVersion)
-	hFile:write("\n");
-end
-
-local function CollateWrittenData(hFile, core, specData, targetVersion, removeVersion)
-	local enumList = {};
-	if(removeVersion) then
-		removeVersion = tonumber(removeVersion);
-	end
-	for i, enum in ipairs(core.enums) do
-		local bShouldWrite = true;
-		if(removeVersion) then
-			--We're writing only enums from targetVersion that were removed
-			--in removeVersion.
-			if(not enum.removed or
-				(tonumber(enum.removed) ~= removeVersion))
-			then
-				bShouldWrite = false;
-			end
-		else
-			--We're writing core only. If it was removed in any version, don't write.
-			if(enum.removed) then
-				bShouldWrite = false;
-			end
-		end
-		
-		--We'll write it as an extension
-		if(enum.extensions) then
-			bShouldWrite = false;
-		end
-		
-		if(bShouldWrite) then
-			enumList[#enumList + 1] = enum;
-		end
-	end
-	
-	--Collate the functions we want to write.
-	local funcList = {};
-	for i, func in ipairs(core.funcs) do
-		local bShouldWrite = true;
-		if(removeVersion) then
-			--We're writing only functions from targetVersion that were removed
-			--in removeVersion.
-			if(not func.deprecated or
-				(tonumber(func.deprecated) ~= removeVersion))
-			then
-				bShouldWrite = false;
-			end
-		else
-			--We're writing core only. If it was removed in any version, don't write.
-			if(func.deprecated) then
-				bShouldWrite = false;
-			end
-		end
-		
-		--Exts don't start with "VERSION"; don't write extension
-		--functions here. Write them in the extension
-		if(func.category and not string.match(func.category, "^VERSION")) then
-			bShouldWrite = false;
-		end
-		
-		if(bShouldWrite) then
-			funcList[#funcList + 1] = func;
-		end
-	end
-	
-	return enumList, funcList;
-end
-
-local function WriteFileC(outFilename, enumList, funcList, specData, enumPrefix,
-					funcPrefix, targetVersion, removeVersion, preceedData)
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".h", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return false;
-	end
-	
-	--Write the basic starting data.
-	local defineName = string.upper(outFilename) .. "_H";
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-	
-	if(preceedData) then
-		for i, preceed in ipairs(preceedData) do
-			hFile:write(preceed);
-			hFile:write("\n");
-		end
-	end
-	hFile:write("\n");
-
-	hFile:write(GetExternCStart());
-	hFile:write("\n");
-	
-	--Write the enumerators.
-	for i, enum in ipairs(enumList) do
-		hFile:write(Make.GetEnumerator(enum, specData.enumtable, enumPrefix));
-		hFile:write("\n");
-	end
-	
-	--Write the typedefs.
-	for i, func in ipairs(funcList) do
-		hFile:write(Make.GetFuncTypedef(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-	end
-
-	hFile:write("\n");
-	
-	--Write the function pointers.
-	for i, func in ipairs(funcList) do
-		hFile:write(Make.GetCoreFuncExternPtr(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-		hFile:write(Make.GetCoreFuncPtrDefine(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-	end
-	
-	hFile:write("\n\n");
-	
-	--End the file.
-	hFile:write(GetExternCEnd());
-	hFile:write("\n");
-	
-	if(preceedData and preceedData.footer) then
-		for i, footer in ipairs(preceedData.footer) do
-			hFile:write(footer);
-			hFile:write("\n");
-		end
-	end
-	
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-	
-	hFile:close();
-end
-
-local function WriteFileCpp(outFilename, enumList, funcList, specData,
-					enumPrefix, funcPrefix, targetVersion, removeVersion,
-					preceedData)
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".hpp", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return false;
-	end
-	
-	--Write the basic starting data.
-	local defineName = string.upper(outFilename) .. "_HPP";
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-	
-	if(preceedData) then
-		for i, preceed in ipairs(preceedData) do
-			hFile:write(preceed);
-			hFile:write("\n");
-		end
-	end
-	hFile:write("\n");
-	
-	hFile:write(GetExternCStart(), "\n");
-
-	--Write C function pointers.
-	for i, func in ipairs(funcList) do
-		hFile:write(Make.GetCoreFuncPtrDecl(func, "gl", specData.typemap), "\n");
-	end
-	
-	hFile:write(GetExternCEnd(), "\n");
-
-	hFile:write("\nnamespace " .. funcPrefix .. "\n{\n");
-
-	--Write the enumerators.
-	hFile:write("\tenum " .. outFilename .. "\n\t{\n");
-
-	for i, enum in ipairs(enumList) do
-		hFile:write("\t\t",
-			Make.GetEnumeratorCpp(enum, specData.enumtable, enumPrefix),
-			"\n");
-	end
-
-	hFile:write("\t};\n\n");
-	
-	--Write the inline functions.
-	for i, func in ipairs(funcList) do
-		hFile:write("\t",
-			Make.GetFuncDefCpp(func, funcPrefix, specData.typemap, true),
-			"\n");
-	end
-
-	hFile:write("\n}\n\n");
-	
-	--End the file.
-	if(preceedData and preceedData.footer) then
-		for i, footer in ipairs(preceedData.footer) do
-			hFile:write(footer);
-			hFile:write("\n");
-		end
-	end
-	
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-	
-	hFile:close();
-end
-
-
-function MakeInclCoreFile(outFilename, specData, enumPrefix, funcPrefix,
-							targetVersion, removeVersion, preceedData)
-	local enumList, funcList;
-
-	local coreVersions = dofile(GetDataFilePath() .. "listOfCoreVersions.lua");
-	if(not targetVersion) then targetVersion = coreVersions[#coreVersions]; end;
-
-	for i, version in ipairs(coreVersions) do
-		if(specData.coredefs[version] and
-			(tonumber(version) == tonumber(targetVersion)))
-		then
-			enumList, funcList = 
-				CollateWrittenData(hFile, specData.coredefs[version], specData,
-				targetVersion, removeVersion);
-			break;
-		end
-	end
-	
-	if(#enumList == 0 and #funcList == 0) then
-		return false;
-	end
-
-	WriteFileC(outFilename, enumList, funcList, specData, enumPrefix,
-		funcPrefix, targetVersion, removeVersion, preceedData);
-	
-	WriteFileCpp(outFilename, enumList, funcList, specData, enumPrefix,
-		funcPrefix, targetVersion, removeVersion, preceedData);
-	
-	return true;
-end
-

glload/codegen/_MakeInclExtFile.lua

---[[ The function, MakeInclExtFile, will create a header file containing the enums, extension test values, and the list of function pointers for all OpenGL extensions. It will create a C and C++ version
-
-It takes these parameters:
-- the name of the output file. Without the path.
-- the specData, as formatted by LoadLuaSpec.
-- the prefix (without the underscore) to prepend to enumerators.
-- the prefix to prepend to functions.
-- an array of strings to write to the front of the header file.
-]]
-
-require "_util"
-require "_makeHelpers"
-
-local function ProcessExtensionC(hFile, ext, extName, specData,
-							enumPrefix, funcPrefix)
-	WriteFormatted(hFile, GetSectionHeading(string.format("Extension: %s_%s",
-		enumPrefix, extName)));
-	hFile:write("\n");
-	
-	--Write the enumerators.
-	for i, enum in ipairs(ext.enums) do
-		hFile:write(Make.GetEnumerator(enum, specData.enumtable, enumPrefix), "\n");
-	end
-
-	if(#ext.funcs ~= 0) then
-		if(#ext.enums ~= 0 and #ext.funcs ~= 0) then
-			hFile:write("\n\n");
-		end
-		
-		--Write the typedefs.
-
-		--Write the #ifdef for the function pointers, so that they are only
-		--available if something hasn't defined over them.
-		local extDefine = string.format("%s_%s", enumPrefix, extName);
-		hFile:write(string.format("#ifndef %s\n#define %s 1\n\n",
-			extDefine, extDefine));
-		
-		for i, func in ipairs(ext.funcs) do
-			hFile:write(Make.GetFuncTypedef(func, funcPrefix, specData.typemap));
-			hFile:write("\n");
-		end
-		
-		hFile:write("\n");
-		
-		--Write the function pointers.
-		for i, func in ipairs(ext.funcs) do
-			if(specData.coreexts[extName]) then
-				hFile:write(Make.GetCoreFuncExternPtr(func, funcPrefix, specData.typemap));
-				hFile:write("\n");
-				hFile:write(Make.GetCoreFuncPtrDefine(func, funcPrefix, specData.typemap));
-			else
-				hFile:write(Make.GetFuncExternPtr(func, funcPrefix, specData.typemap));
-			end
-			hFile:write("\n");
-		end
-		
-		hFile:write(string.format("#endif /*%s*/", extDefine));
-	end
-		
-	if(#ext.enums ~= 0 or #ext.funcs ~= 0) then
-		hFile:write("\n\n");
-	end
-end
-
-local function WriteFileC(outFilename, specData, enumPrefix, funcPrefix, preceedData)
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".h", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return;
-	end
-	
-	--Write the basic starting data.
-	local defineName = string.upper(outFilename) .. "_H";
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-	
-	if(preceedData) then
-		for i, preceed in ipairs(preceedData) do
-			hFile:write(preceed);
-			hFile:write("\n");
-		end
-	end
-	
-	--Write the passthru data.
-	for i, passthru in ipairs(specData.funcData.passthru) do
-		hFile:write(passthru);
-		hFile:write("\n");
-	end
-	hFile:write("\n");
-
-	hFile:write(GetExternCStart());
-	hFile:write("\n");
-	
-	--Write all of the extension query variables.
-	for i, extName in ipairs(specData.extensions) do
-		hFile:write(Make.GetExtensionVarExtern(extName, funcPrefix));
-		hFile:write("\n");
-	end
-
-	hFile:write("\n\n");
-
-	--Process all of the extensions.
-	for extName, ext in sortPairs(specData.extdefs, CompLess) do
-		ProcessExtensionC(hFile, ext, extName, specData, enumPrefix, funcPrefix);
-	end
-	
-	hFile:write(GetExternCEnd());
-	hFile:write("\n");
-	
-	if(preceedData and preceedData.footer) then
-		for i, footer in ipairs(preceedData.footer) do
-			hFile:write(footer);
-			hFile:write("\n");
-		end
-	end
-	
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-	
-	hFile:close();
-end
-
-local function WriteExtCFunctions(hFile, ext, extName, specData, funcPrefix)
-	--Write the typedefs.
-	for i, func in ipairs(ext.funcs) do
-		if(specData.coreexts[extName]) then
-			hFile:write(Make.GetCoreFuncPtrDecl(func, funcPrefix, specData.typemap));
-		else
-			hFile:write(Make.GetFuncPtrDecl(func, funcPrefix, specData.typemap));
-		end
-		hFile:write("\n");
-	end
-end
-
-local function WriteExtEnums(hFile, ext, extName, specData, enumPrefix, writtenEnum)
-	if(#ext.enums ~= 0) then
-		WriteFormatted(hFile, GetSectionHeading(string.format("Extension: %s_%s",
-			enumPrefix, extName)));
-	end
-		
-	for i, enum in ipairs(ext.enums) do
-		if(writtenEnum[enum.name]) then
-			hFile:write("//\t\t", 
-				Make.GetEnumeratorCpp(enum, specData.enumtable, "GL"),
-				" From: ",
-				writtenEnum[enum.name],
-				"\n");
-		else
-			hFile:write("\t\t",
-				Make.GetEnumeratorCpp(enum, specData.enumtable, enumPrefix),
-				"\n");
-				writtenEnum[enum.name] = extName;
-		end
-	end
-	
-	if(#ext.enums ~= 0) then
-		hFile:write("\n");
-	end
-end
-
-local function WriteExtFunctions(hFile, ext, extName, specData,
-						enumPrefix, funcPrefix)
-	if(#ext.funcs ~= 0) then
-		WriteFormatted(hFile, GetSectionHeading(string.format("Extension: %s_%s",
-			enumPrefix, extName)));
-	end
-	
-	for i, func in ipairs(ext.funcs) do
-		if(specData.coreexts[extName]) then
-			hFile:write("\t",
-				Make.GetFuncDefCpp(func, funcPrefix, specData.typemap, true),
-				"\n");
-		else
-			hFile:write("\t",
-				Make.GetFuncDefCpp(func, funcPrefix, specData.typemap, false),
-				"\n");
-		end
-	end
-	
-	if(#ext.funcs ~= 0) then hFile:write("\n") end
-end
-
-local function WriteFileCpp(outFilename, specData, enumPrefix,
-					funcPrefix, preceedData)
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".hpp", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return false;
-	end
-	
-	--Write the basic starting data.
-	local defineName = string.upper(outFilename) .. "_HPP";
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-	
-	if(preceedData) then
-		for i, preceed in ipairs(preceedData) do
-			hFile:write(preceed);
-			hFile:write("\n");
-		end
-	end
-	hFile:write("\n");
-	
-	hFile:write(GetExternCStart(), "\n");
-
-	--Write all of the extension query variables.
-	for i, extName in ipairs(specData.extensions) do
-		hFile:write(Make.GetExtensionVarExtern(extName, "gl"));
-		hFile:write("\n");
-	end
-	
-	--Process all of the extensions, creating all of the function pointer varaibles for them.
-	for extName, ext in sortPairs(specData.extdefs, CompLess) do
-		WriteExtCFunctions(hFile, ext, extName, specData, funcPrefix);
-	end
-
-	hFile:write(GetExternCEnd(), "\n");
-
-	hFile:write("\nnamespace " .. funcPrefix .. "\n{\n");
-
-	--Write the enumerators.
-	hFile:write("\tenum " .. outFilename .. "\n\t{\n");
-
-	local writtenEnum = {}
-	for extName, ext in sortPairs(specData.extdefs, CompLess) do
-		WriteExtEnums(hFile, ext, extName, specData, enumPrefix, writtenEnum);
-	end
-
-	hFile:write("\t};\n\n");
-	
-	for extName, ext in sortPairs(specData.extdefs, CompLess) do
-		WriteExtFunctions(hFile, ext, extName, specData, enumPrefix, funcPrefix);
-	end
-
-	hFile:write("\n}\n\n");
-
-	--[=[
-	for i, enum in ipairs(enumList) do
-		hFile:write("\t\t",
-			Make.GetEnumeratorCpp(enum, specData.enumtable, enumPrefix),
-			"\n");
-	end
-
-	hFile:write("\t};\n\n");
-	
-	--Write the inline functions.
-	for i, func in ipairs(funcList) do
-		hFile:write("\t",
-			Make.GetFuncDefCpp(func, funcPrefix, specData.typemap, true),
-			"\n");
-	end
-
-	hFile:write("\n}\n\n");
-	]=]
-	
-	--End the file.
-	if(preceedData and preceedData.footer) then
-		for i, footer in ipairs(preceedData.footer) do
-			hFile:write(footer);
-			hFile:write("\n");
-		end
-	end
-	
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-	
-	hFile:close();
-end
-
-function MakeInclExtFile(outFilename, specData, enumPrefix, funcPrefix, preceedData)
-	WriteFileC(outFilename, specData, enumPrefix, funcPrefix, preceedData);
-	WriteFileCpp(outFilename, specData, enumPrefix, funcPrefix, preceedData);
-end
-

glload/codegen/_MakeInclTypeFile.lua

---[[ The function, MakeInclTypeFile, will create a header file containing the OpenGL typdefs and preprocessor machinery
-
-
-
-It takes these parameters:
-- the name of the output file. Without the path.
-- the specData, as formatted by LoadLuaSpec.
-- an array of strings to write to the front of the header file.
-]]
-
-require "_util"
-require "_makeHelpers"
-
-
-function MakeInclTypeFile(outFilename, specData, preceedData)
-	
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".h", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return;
-	end
-	
-	local defineName = string.upper(outFilename) .. "_H";
-	
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-	
-	if(preceedData) then
-		for i, preceed in ipairs(preceedData) do
-			hFile:write(preceed);
-			hFile:write("\n");
-		end
-	end
-	
-	--Write the passthru data.
-	for i, passthru in ipairs(specData.funcData.passthru) do
-		hFile:write(passthru);
-		hFile:write("\n");
-	end
-	hFile:write("\n");
-
-	--Write post data.
-	if(preceedData and preceedData.footer) then
-		for i, footer in ipairs(preceedData.footer) do
-			hFile:write(footer);
-			hFile:write("\n");
-		end
-	end
-	
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-	
-	hFile:close();
-end
-

glload/codegen/_MakeInclVersionFile.lua

---[[ The function, MakeInclVersionFile, will create a header file that includes all of the headers it is given. It will create a C and C++ version
-
-It takes these parameters:
-- the name of the output file. Without the path.
-- the list of files to include. Without the file name extension.
-]]
-
-require "_util"
-require "_makeHelpers"
-
-local function WriteFileC(outFilename, includeList)
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".h", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return false;
-	end
-
-	local defineName = string.upper(outFilename) .. "_H";
-	hFile:write(GetFileIncludeGuardStart(defineName));
-
-	for i, include in ipairs(includeList) do
-		hFile:write("#include \"", include, ".h\"\n");
-	end
-	
-	hFile:write("\n", GetFileIncludeGuardEnd(defineName));
-	hFile:close();
-end
-
-local function WriteFileCpp(outFilename, includeList)
-	local hFile = io.open(GetIncludePath() .. outFilename .. ".hpp", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetIncludePath() .. outFilename .. "\".\n");
-		return false;
-	end
-	
-	local defineName = string.upper(outFilename) .. "_HPP";
-	hFile:write(GetFileIncludeGuardStart(defineName));
-
-	for i, include in ipairs(includeList) do
-		--HACK! The first one is always a .h.
-		if(i == 1) then
-			hFile:write("#include \"", include, ".h\"\n");
-		else
-			hFile:write("#include \"", include, ".hpp\"\n");
-		end
-	end
-	
-	hFile:write("\n", GetFileIncludeGuardEnd(defineName));
-	hFile:close();
-end
-
-
-function MakeInclVersionFile(outFilename, includeList)
-	WriteFileC(outFilename, includeList)
-	WriteFileCpp(outFilename, includeList)
-end

glload/codegen/_MakeMainHeaderFile.lua

---[[
-MakeMainHeaderFile will generate the internal header file that GLE uses to load 
-the extension functions for this spec data. This header exposes the following:
-
-== Mapping table and size ==
-
-The mapping table structure is defined in "gll_util.h". This variable is an array of these structs, one per extension. The entry structure contains a string name of the extension, a pointer to an int that represents the extension variable, and a function pointer (possibly NULL) to the function loader for that extension.
-
-The function loader is a function that takes no parameters and returns an integer. The return value is GL_TRUE if all of the function pointers are loaded, and GL_FALSE otherwise.
-
-Naturally, there will also be a size variable exposed.
-
-== Extension clear function ==
-
-This function, "[funcPrefix]eIntClear()" will clear all of the extension variables.
-
-== Version/profile entrypoints ==
-
-The parameter, "VersionFunc" should be an interator function that returns 2 parameters: a string containing the version to generate, and a string containing the profile. This is either "core" or "compatibility". For each value returned, there will be one function prototype generated.
-
-The functions are defined as follows:
-
-int [funcPrefix]eIntLoad_Version_[major]_[minor][profile]();
-
-== Base entrypoints and data ==
-
-If you provide this function with a "baseData" field, then it will generate an additional file called <filename>_base.h. This additional file will contain a number of OpenGL enumerators and function pointers. This file will also have a function called: "[funcPrefix]eIntLoad_BaseFuncs". That function will load only the function pointers for the base functions.
-
-The baseData field should be structured like:
-
-* enums: a list of enumerator names.
-* funcs: a list of function names.
-* bFuncsAreCore: true if the names in funcs are core functions. False if extension functions.
-* preceedData: a list of strings to write at the beginning of the file.
-* enumPrefix: the prefix for enumerator names.
-]]
-
-require "_makeHelpers"
-require "_util"
-
-local function WriteExtFuncLoaderPrototype(hFile, extName, funcPrefix)
-	hFile:write(Make.GetExtLoaderFuncPrototype(extName, funcPrefix));
-	hFile:write("\n");
-end
-
-local function WriteCoreLoaderPrototype(hFile, version, profile, funcPrefix)
-	hFile:write(Make.GetCoreLoaderFuncPrototype(version, profile, funcPrefix));
-	hFile:write("\n");
-end
-
-local function WriteBaseDataValues(hFile, specData, funcPrefix, baseData)
-	for i, enumName in ipairs(baseData.enums) do
-		hFile:write(Make.GetEnumerator(
-			specData.enumtable[enumName], specData.enumTable, baseData.enumPrefix));
-		hFile:write("\n");
-	end
-	
-	hFile:write("\n");
-	
-	for i, funcName in ipairs(baseData.funcs) do
-		--find the function.
-		local func = nil;
-		for i, funcTest in ipairs(specData.funcData.functions) do
-			if(funcTest.name == funcName) then
-				func = funcTest;
-				break;
-			end
-		end
-		
-		if(func) then
-			if(baseData.bFuncsAreCore) then
-				WriteForm(hFile, "%s\n%s\n%s\n",
-					Make.GetFuncTypedef(func, funcPrefix, specData.typemap),
-					Make.GetCoreFuncExternPtr(func, funcPrefix, specData.typemap),
-					Make.GetCoreFuncPtrDefine(func, funcPrefix, specData.typemap));
-			else
-				WriteForm(hFile, "%s\n%s\n",
-					Make.GetFuncTypedef(func, funcPrefix, specData.typemap),
-					Make.GetFuncExternPtr(func, funcPrefix, specData.typemap));
-			end
-		end
-	end
-end
-
-function MakeMainHeaderFile(outFilename, specData, funcPrefix, VersionFunc, baseData)
-	local hFile = io.open(GetSourcePath() .. outFilename .. ".h", "w");
-	if(not hFile) then
-		print("Could not open the output file\"" .. GetSourcePath() .. outFilename .. "\".\n");
-		return;
-	end
-	
-	local defineName = string.upper(outFilename) .. "_H";
-	
-	hFile:write(GetFileIncludeGuardStart(defineName));
-	hFile:write("\n");
-
-	hFile:write("#include \"gll_util.h\"\n");
-	hFile:write("\n");
-
-	hFile:write(GetExternCStart());
-	hFile:write("\n");
-	
-	hFile:write("\n");
-	
-	--Write the extension mapping table.
-	hFile:write(Make.GetMapTableExtern(funcPrefix));
-	hFile:write("\n");
-	hFile:write(Make.GetMapTableSizeExtern(funcPrefix));
-	hFile:write("\n");
-
-	hFile:write("\n");
-	
-	--Write the clear function.
-	hFile:write(Make.GetClearFunctionDecl(funcPrefix));
-	hFile:write("\n");
-
-	hFile:write("\n");
-
-	--Write the version-based loading funcs.
-	if(VersionFunc) then
-		for version, profile in VersionFunc do
-			WriteCoreLoaderPrototype(hFile, version, profile, funcPrefix);
-		end
-	end
-
-	hFile:write("\n");
-	
-	--Write the baseData, if there.
-	if(baseData) then
-    	local hFile = io.open(GetSourcePath() .. outFilename .. "_base.h", "w");
-	    local defineName = string.upper(outFilename) .. "_BASE_H";
-	
-	    hFile:write(GetFileIncludeGuardStart(defineName));
-	    hFile:write("\n");
-	    
-	    hFile:write(GetExternCStart());
-	    hFile:write("\n");
-
-		if(baseData.preceedData) then
-			for i, preceed in ipairs(baseData.preceedData) do
-				hFile:write(preceed);
-				hFile:write("\n");
-			end
-		end
-		
-		for i, passthru in ipairs(specData.funcData.passthru) do
-			hFile:write(passthru);
-			hFile:write("\n");
-		end
-		hFile:write("\n");
-	
-		WriteBaseDataValues(hFile, specData, funcPrefix, baseData);
-		hFile:write("\n");
-		WriteForm(hFile, "void %s();\n", Make.GetBaseLoaderFuncName(funcPrefix));
-		hFile:write("\n");
-
-		if(baseData.preceedData and baseData.preceedData.footer) then
-			for i, footer in ipairs(baseData.preceedData.footer) do
-				hFile:write(footer);
-				hFile:write("\n");
-			end
-		end
-	    hFile:write("\n");
-	    hFile:write(GetExternCEnd());
-	    hFile:write("\n");
-    	hFile:write(GetFileIncludeGuardEnd(defineName));
-	    hFile:write("\n");
-
-		hFile:close();
-	end
-	
-	hFile:write(GetExternCEnd());
-	hFile:write("\n");
-	
-	if(baseData and baseData.funcs) then
-	end
-
-	
-	hFile:write(GetFileIncludeGuardEnd(defineName));
-
-	hFile:close();
-end
-

glload/codegen/_MakeMainSourceFile.lua

---[[
-The function MakeMainSourceFile will generate the main source file. It will generate the definitions declared in the header.
-
-It takes the parameters that MakeMainHeaderFile does, with the addition of enumPrefix, preceedData, and coreData.
-
-preceedData is a list of strings to write after the initial includes.
-
-The coreData can be nil or a table containing the following:
-
-* file: the filename (no .h) of the core data header to load.
-
-If there is no coreData, then the core loading functions will not try to get data from the core stuff.
-]]
-
-require "_makeHelpers"
-require "_util"
-
--- Bad form, I know, but necessary.
-local glob_HasCore = nil;
-
-local function GetRemovedVersionList(specData)
-	local depTable = {};
-	
-	for i, func in ipairs(specData.funcData.functions) do
-		if(func.deprecated) then
-			depTable[func.deprecated] = true;
-		end
-	end
-	
-	local ret = {};
-	
-	for version, bool in pairs(depTable) do
-		table.insert(ret, version);
-	end
-	
-	table.sort(ret, function(lhs, rhs) return tonumber(lhs) < tonumber(rhs) end);
-	
-	return ret;
-end
-
-local function WriteTestFunc(hFile)
-	hFile:write([[
-#include <stddef.h>	
-	
-static int TestPointer(const void *pTest)
-{
-	ptrdiff_t iTest;
-	if(!pTest) return 0;
-	iTest = (ptrdiff_t)pTest;
-	
-	if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0;
-	
-	return 1;
-}
-
-]]);
-end
-
-local function GetExtLoaderName(extName, funcPrefix)
-	return string.format("%seIntLoad_%s", funcPrefix, extName);
-end
-
-local function WriteExtVarClear(hFile, specData, funcPrefix)
-	WriteFormatted(hFile, "void %s()\n", Make.GetClearFunctionName(funcPrefix));
-	hFile:write("{\n");
-	
-	for i, extName in ipairs(specData.extensions) do
-		WriteFormatted(hFile, "\t%s = 0;\n",
-			Make.GetExtensionVarName(extName, funcPrefix));
-	end
-	
-	hFile:write("}\n");
-end
-
-local function WriteFuncPointers(hFile, ext, extName, specData, enumPrefix, funcPrefix)
-	if(#ext.funcs == 0) then return; end;
-	
-    local extDefine = string.format("%s_%s", enumPrefix, extName);
-    hFile:write(string.format("#ifndef %s\n", extDefine));
-
-	--Write the typedefs.
-	for i, func in ipairs(ext.funcs) do
-		hFile:write(Make.GetFuncTypedef(func, funcPrefix, specData.typemap));
-		hFile:write("\n");
-	end
-	
-	hFile:write("\n");
-	
-	--Write the function pointers.
-	for i, func in ipairs(ext.funcs) do
-		if(specData.coreexts[extName]) then
-			hFile:write(Make.GetCoreFuncPtr(func, funcPrefix, specData.typemap));
-		else
-			hFile:write(Make.GetFuncPtr(func, funcPrefix, specData.typemap));
-		end
-		hFile:write("\n");
-	end
-
-    hFile:write(string.format("#endif /*%s*/\n", extDefine));
-end
-
-local function WriteFuncLoad(hFile, func, funcPrefix, bIsCoreExt)
-	local funcPtrName = nil;
-	
-	if(bIsCoreExt) then
-		funcPtrName = Make.GetCoreFuncPtrNameStr(func, funcPrefix);
-	else
-		funcPtrName = Make.GetFuncPtrNameStr(func, funcPrefix);
-	end
-	
-	WriteForm(hFile, "\t%s = (%s)gleIntGetProcAddress(\"%s\");\n",
-		funcPtrName,
-		Make.GetFuncTypedefNameStr(func, funcPrefix),
-		Make.GetFuncPtrNameStr(func, funcPrefix)
-	);
-	
-	WriteForm(hFile, "\tif(!%s) bIsLoaded = 0;\n", funcPtrName);
-end
-
-local function WriteLoaderFunc(hFile, ext, extName, specData, funcPrefix, enumPrefix)
-	if(not ext.funcs or #ext.funcs == 0) then return; end;
-	
-	WriteForm(hFile, "static int %s()\n", GetExtLoaderName(extName, funcPrefix));
-	hFile:write("{\n");
-	
-	hFile:write("\tint bIsLoaded = 1;\n");
-
-	local bIsCoreExt = specData.coreexts[extName] ~= nil;
-	
-    local extDefine = string.format("%s_%s", enumPrefix, extName);
-    hFile:write(string.format("#ifndef %s\n", extDefine));
-	
-	for i, func in ipairs(ext.funcs) do
-		WriteFuncLoad(hFile, func, funcPrefix, bIsCoreExt)
-	end
-	
-    hFile:write(string.format("#endif /*%s*/\n", extDefine));
-
-	hFile:write("\treturn bIsLoaded;\n");
-	
-	hFile:write("}\n");
-end
-
-local function WriteMappingTable(hFile, specData, enumPrefix, funcPrefix)
-	WriteForm(hFile, "StrToExtMap %s[] = {\n", Make.GetMapTableName(funcPrefix));
-	
-	local iNumEntries = 0;
-	
-	for extName, ext in sortPairs(specData.extdefs, CompLess) do
-		local extLoadFuncName = "NULL";
-		
-		if(ext.funcs and #ext.funcs ~= 0) then
-			extLoadFuncName = GetExtLoaderName(extName, funcPrefix);
-		end
-		
-		WriteForm(hFile, "\t{\"%s_%s\", &%s, %s},\n",
-			enumPrefix,
-			extName,
-			Make.GetExtensionVarName(extName, funcPrefix),
-			extLoadFuncName
-		);
-		
-		iNumEntries = iNumEntries + 1;
-	end
-	
-	hFile:write("};\n\n");
-	
-	--Write the variable that stores the size of the mapping table.
-	hFile:write(Make.GetMapTableSizeDef(iNumEntries, funcPrefix));
-	hFile:write("\n");
-end
-
-local function GetStaticCoreRemovedSuffix(removedVersion)
-	if(removedVersion) then
-