Commits

Jason McKesson committed cecb1a4

Initial glLoadGen-based dump.

Comments (0)

Files changed (3)

+syntax: glob
+glLoadGen/*

glLoadGen/modules/StyleEnumDB.lua

+local util = require "util"
+local struct = require "Structure"
+local common = require "CommonStyle"
+
+local function CollectEnumParams(func, typemap)
+	local enumParamList = {}
+
+	for i, param in ipairs(func.params) do
+		local paramType = typemap[param.type] or param.type
+		if(param.type == "GLenum") then
+			table.insert(enumParamList, param.name)
+		end
+	end
+	
+	return enumParamList
+end
+
+local my_style = {}
+
+local function PossiblyWriteFile(func, typemap, GetFilePath)
+	local enumParamList = CollectEnumParams(func, typemap)
+	
+	if(#enumParamList ~= 0) then
+		local path = GetFilePath() .. "/"
+		util.EnsurePath(path)
+
+		local filename = path .. "/" .. func.name .. ".lua"
+		
+		local hFile, errorMsg = io.open(filename, "w")
+		if(not hFile) then
+			print("Unable to write " .. filename)
+			return
+		end
+		
+		for _, paramName in ipairs(enumParamList) do
+			hFile:write(paramName, "\n")
+		end
+		
+		hFile:close()
+	end
+end
+
+function my_style.ExtensionFunc(basename, func, typemap, extName, spec, options)
+	PossiblyWriteFile(func, typemap, function()
+		local base, dir = util.ParsePath(basename)
+
+		return dir .. extName
+	end)
+end
+
+function my_style.VersionFunc(basename, func, typemap, version, spec, options)
+	PossiblyWriteFile(func, typemap, function()
+		local base, dir = util.ParsePath(basename)
+
+		return dir .. "Version_" .. version:gsub("%.", "_")
+	end)
+end
+
+local my_struct = 
+{
+{ type="func-seen",
+	{ type="ext-iter",
+		{type="func-iter",
+			{ type="call", name="ExtensionFunc(basename, func, typemap, extName, spec, options)", },
+		},
+	},
+	{ type="version-iter",
+		{type="func-iter",
+			{ type="call", name="VersionFunc(basename, func, typemap, version, spec, options)", },
+		},
+	},
+	ending,
+}
+}
+
+my_struct = struct.BuildStructure(my_struct)
+
+local function Create()
+    return util.DeepCopyTable(my_style), my_struct
+end
+
+return { Create = Create }

glLoadGen/modules/UserStyles.lua

+
+return
+{
+	enumdb = require("StyleEnumDB")
+}