Commits

Jason McKesson committed bf55e2a

Better code generation for program listings.

Comments (0)

Files changed (3)

Command_Line_Options.wiki

 
 With Lua on the path, the command-line should be specified as follows:
 
-{{{lua pathToLoadgen/LoadGen.lua <output filename> <options>}}}
+{{{
+lua pathToLoadgen/LoadGen.lua <output filename> <options>
+}}}
 
 The {{{<output filename>}}} must be specified. The path provided is relative to the current directory. The base filename of the path (everything after the last directory separator) will be decorated as appropriate for generating the output files. You should not provide an extension; the system will provide those as needed. The generated files will append an appropriate prefix, depending on which specifications you are generating (OpenGL, WGL, or GLX), so you can provide the same base filename for all of these.
 
 
 To use the code generator, with Lua in your path (assuming that {{{lua}}} is the name of your Lua executable), type this:
 
-{{{lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=core core_3_3}}}
+{{{
+lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=core core_3_3
+}}}
 
 This tells the system to generate a header/source pair for OpenGL ({{{-spec=gl}}}, as opposed to WGL or GLX), for version 3.3, the core profile. It will generate it in the {{{pointer_c}}} style, which means that it will use function pointer-style, with C linkage and source. Such code is usable from C and C++, or other languages that can interface with C.
 
 
 Note that the above command line will //only// generate enumerators and functions for core OpenGL 3.3. It doesn't offer any extensions. To use extensions, you must ask for them with command line parameters, as follows:
 
-{{{lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=core core_3_3 -exts ARB_texture_view ARB_vertex_attrib_binding EXT_texture_filter_anisotropic -ext=EXT_texture_compression_s3tc -extfile=SomeFile.txt}}}
+{{{
+lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=core core_3_3 -exts ARB_texture_view ARB_vertex_attrib_binding EXT_texture_filter_anisotropic -ext=EXT_texture_compression_s3tc -extfile=SomeFile.txt
+}}}
 
 The {{{-exts}}} option starts a list of space-separated extension names (note: don't try to put the output filename after {{{-exts}}}; the system can't tell the difference between a filename and an extension). The {{{-ext}}} option only specifies a single name.
 

Style_Creation.wiki

 
 The {{{style}}} table will need two sub-tables named {{{source}}} and {{{header}}}. They contain functions for generating material for source and header files, respectively. Most of the functions are in these two sub-tables.
 
-<<<toc>>>
+<<toc>>
 
 ==Naming convention==
 
 
 This is a struct containing functions used to get specification-specific strings. This allows the style of writing to be mostly independent of things like whether it is writing to OpenGL or WGL. For example, if you have the base name of an enumeration, and you want to prefix it with the spec-defined prefix for enumerations, you do this:
 
-{{{spec.EnumNamePrefix() .. enumName}}}
+{{{
+spec.EnumNamePrefix() .. enumName
+}}}
 
 There are a number of spec functions that return prefix strings or other spec-based strings. You can find these in the {{{modules/Specs.lua}}} file, with a comment stating what each one returns.
 
 
 A good way to understand the nature of the functions is to show how the functions will be called by the system to build the header/source file. Here is the structure of a header file, as far as the system is concerned. Each function call represents the system calling that function with those parameters one or more times.
 
-{{{header.CreateFile(basename, options) //Return the name of the file. header.WriteBeginIncludeGuard(hFile, spec, options) header.WriteStdTypedefs(hFile, specData, spec, options) header.WriteSpecTypedefs(hFile, specData, spec, options) header.WriteBeginDecl(hFile, spec, options) //For each user-specified extension header.WriteExtVariableDecl(hFile, extName, specData, spec, options) header.WriteExtVariableDecl(hFile, ..., specData, spec, options) ... header.WriteBeginEnumDeclBlock(hFile, spec, options) //For each enum to be written, in order of extensions/core //Will call one or the other. header.WriteEnumDecl(hFile, enum, enumTable, spec, options) header.WriteEnumPrevDecl(hFile, enum, enumTable, spec, options, extName) header.WriteEndEnumDeclBlock(hFile, spec, options) header.WriteBeginFuncDeclBlock(hFile, spec, options) //For each user-specified extension: header.WriteBeginExtFuncDeclBlock(hFile, extName, spec, options) //For each function in that extension header.WriteFuncDecl(hFile, func, typemap, spec, options) header.WriteFuncDecl(hFile, ..., typemap, spec, options) ... header.WriteEndExtFuncDeclBlock(hFile, extName, spec, options) //For each version, where applicable: //For each core extension that was not user-specified: header.WriteBeginExtFuncDeclBlock(hFile, extName, spec, options) header.WriteFuncDecl(hFile, func, typemap, spec, options) header.WriteFuncDecl(hFile, ..., typemap, spec, options) ... header.WriteEndExtFuncDeclBlock(hFile, extName, spec, options) //For each core function from this version *not* in a core extension. header.WriteFuncDecl(hFile, func, typemap, spec, options) header.WriteFuncDecl(hFile, ..., typemap, spec, options) ... header.WriteBeginFuncDeclBlock(hFile, spec, options) header.WriteUtilityDecls(hFile, spec, options) header.WriteMainLoaderFuncDecl(hFile, spec, options) header.WriteVersioningFuncDecls(hFile, spec, options) //Only if the spec has versions. header.WriteEndDecl(hFile, spec, options) header.WriteEndIncludeGuard(hFile, spec, options)}}}
+{{{
+header.CreateFile(basename, options) //Return the name of the file. header.WriteBeginIncludeGuard(hFile, spec, options) header.WriteStdTypedefs(hFile, specData, spec, options) header.WriteSpecTypedefs(hFile, specData, spec, options) header.WriteBeginDecl(hFile, spec, options) //For each user-specified extension header.WriteExtVariableDecl(hFile, extName, specData, spec, options) header.WriteExtVariableDecl(hFile, ..., specData, spec, options) ... header.WriteBeginEnumDeclBlock(hFile, spec, options) //For each enum to be written, in order of extensions/core //Will call one or the other. header.WriteEnumDecl(hFile, enum, enumTable, spec, options) header.WriteEnumPrevDecl(hFile, enum, enumTable, spec, options, extName) header.WriteEndEnumDeclBlock(hFile, spec, options) header.WriteBeginFuncDeclBlock(hFile, spec, options) //For each user-specified extension: header.WriteBeginExtFuncDeclBlock(hFile, extName, spec, options) //For each function in that extension header.WriteFuncDecl(hFile, func, typemap, spec, options) header.WriteFuncDecl(hFile, ..., typemap, spec, options) ... header.WriteEndExtFuncDeclBlock(hFile, extName, spec, options) //For each version, where applicable: //For each core extension that was not user-specified: header.WriteBeginExtFuncDeclBlock(hFile, extName, spec, options) header.WriteFuncDecl(hFile, func, typemap, spec, options) header.WriteFuncDecl(hFile, ..., typemap, spec, options) ... header.WriteEndExtFuncDeclBlock(hFile, extName, spec, options) //For each core function from this version *not* in a core extension. header.WriteFuncDecl(hFile, func, typemap, spec, options) header.WriteFuncDecl(hFile, ..., typemap, spec, options) ... header.WriteBeginFuncDeclBlock(hFile, spec, options) header.WriteUtilityDecls(hFile, spec, options) header.WriteMainLoaderFuncDecl(hFile, spec, options) header.WriteVersioningFuncDecls(hFile, spec, options) //Only if the spec has versions. header.WriteEndDecl(hFile, spec, options) header.WriteEndIncludeGuard(hFile, spec, options)
+}}}
 
 And here is the equivalent structure for the source files:
 
-{{{source.CreateFile(basename, options) //Name of the file. source.WriteIncludes(hFile, spec, options) #include "HEADER_FILENAME" source.WriteBeginDef(hFile, spec, options) //For each user-specified extension source.WriteExtVariableDef(hFile, extName, specData, spec, options) source.WriteExtVariableDef(hFile, ..., specData, spec, options) ... //For each user-specified extension: source.WriteBeginExtFuncDefBlock(hFile, extName, spec, options) //For each function in the extension: source.WriteFuncDef(hFile, func, typemap, spec, options) source.WriteFuncDef(hFile, ..., typemap, spec, options) ... source.WriteBeginExtLoaderBlock(hFile, extName, spec, options) //For each function in the extension source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteEndExtLoaderBlock(hFile, extName, spec, options) source.WriteEndExtFuncDefBlock(hFile, extName, spec, options) source.WriteBeginCoreFuncDefBlock(hFile, version, spec, options) //For each version, where applicable //For each core extension in that version which was not user-specified { //For each function in that core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteCoreFuncLoader(hFile, .., typemap, spec, options) ... } //For each function from that version not in a core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteCoreFuncLoader(hFile, .., typemap, spec, options) ... source.WriteBeginCoreLoaderBlock(hFile, version, spec, options) //For each version, where applicable //For each core extension in that version which was not user-specified { //For each function in that core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) } //For each function from that version *not* in a core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteEndCoreLoaderBlock(hFile, version, spec, options) source.WriteEndCoreFuncDefBlock(hFile, version, spec, options) source.WriteUtilityDefs(hFile, specData, spec, options) source.WriteMainLoaderFunc(hFile, specData, spec, options) source.WriteVersioningFuncs(hFile, specData, spec, options) //Only if the spec has versions. source.WriteEndDef(hFile, spec, options)}}}
+{{{
+source.CreateFile(basename, options) //Name of the file. source.WriteIncludes(hFile, spec, options) #include "HEADER_FILENAME" source.WriteBeginDef(hFile, spec, options) //For each user-specified extension source.WriteExtVariableDef(hFile, extName, specData, spec, options) source.WriteExtVariableDef(hFile, ..., specData, spec, options) ... //For each user-specified extension: source.WriteBeginExtFuncDefBlock(hFile, extName, spec, options) //For each function in the extension: source.WriteFuncDef(hFile, func, typemap, spec, options) source.WriteFuncDef(hFile, ..., typemap, spec, options) ... source.WriteBeginExtLoaderBlock(hFile, extName, spec, options) //For each function in the extension source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteEndExtLoaderBlock(hFile, extName, spec, options) source.WriteEndExtFuncDefBlock(hFile, extName, spec, options) source.WriteBeginCoreFuncDefBlock(hFile, version, spec, options) //For each version, where applicable //For each core extension in that version which was not user-specified { //For each function in that core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteCoreFuncLoader(hFile, .., typemap, spec, options) ... } //For each function from that version not in a core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteCoreFuncLoader(hFile, .., typemap, spec, options) ... source.WriteBeginCoreLoaderBlock(hFile, version, spec, options) //For each version, where applicable //For each core extension in that version which was not user-specified { //For each function in that core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) } //For each function from that version *not* in a core extension: source.WriteCoreFuncLoader(hFile, func, typemap, spec, options) source.WriteEndCoreLoaderBlock(hFile, version, spec, options) source.WriteEndCoreFuncDefBlock(hFile, version, spec, options) source.WriteUtilityDefs(hFile, specData, spec, options) source.WriteMainLoaderFunc(hFile, specData, spec, options) source.WriteVersioningFuncs(hFile, specData, spec, options) //Only if the spec has versions. source.WriteEndDef(hFile, spec, options)
+}}}
 
 ==Style function reference==
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.