Commits

Jason McKesson  committed ef5e4d1

Fixed an order of passthru issue.
Passthru typedefs will now always be ordered based on the XML file's ordering.

  • Participants
  • Parent commits 14475ca

Comments (0)

Files changed (2)

File LuaFormat.txt

+
+The raw spec.lua files are formatted as follows:
+
+- `funcData`: A table containing:
+	- `passthru`: An array of C definitions that should be defined before anything else. They should be defined in the given order.
+	- `functions`: An array of function definitions for all functions.
+- `enumerators`: An array of all enumerators.
+- `versions`: An array of version strings. These are numerical: "1.0", "1.3", etc.
+- `extensions`: An array of extension string names.

File _BuildDataFromXml.lua

 
 local function BuildAllLists(xmlData, api)
 	local allTypes = {}
+	allTypes._order = {}
 	
 	local typesNode = FindElementByName(xmlData, "types")
 	assert(typesNode, "Could not find the `types` node.")
 				if(typeNode.name) then
 					assert(allTypes[typeNode.name] == nil, "Multiply defined type " .. typeNode.name)
 					allTypes[typeNode.name] = typeNode
+					table.insert(allTypes._order, typeNode.name)
 				else
 					--Get the node name.
 					local nameElem = FindElementByName(typeNode, "name")
 					assert(type(nameElem[1]) == "string", "Name element of `type` is irregular.")
 					assert(allTypes[nameElem[1]] == nil, "Multiply defined type " .. nameElem[1])
 					allTypes[nameElem[1]] = typeNode
+					table.insert(allTypes._order, nameElem[1])
 				end
 			end
 		end
 		for _, typeName in ipairs(lastTypes) do
 			if(allTypes[typeName].requires) then
 				reqTypes[#reqTypes + 1] = allTypes[typeName].requires
+--				print(allTypes[typeName].requires)
 			end
 		end
 		
 	
 	local inList = {}
 	
+	print(#typeHierarchy)
 	for i = #typeHierarchy, 1, -1 do
 		local reqTypes = typeHierarchy[i]
 		for _, typeName in ipairs(reqTypes) do
 			if(not inList[typeName]) then
 				inList[typeName] = true
-				local str = ""
-				for _, node in ipairs(allTypes[typeName]) do
-					if(type(node) == "string") then
-						str = str .. node
+				print(typeName)
+			end
+		end
+	end
+	
+	--Print them in the order specified in the XML file.
+	for _, typeName in ipairs(allTypes._order) do
+		if(inList[typeName]) then
+			--Build the string from the different text pieces.
+			local str = ""
+			for _, node in ipairs(allTypes[typeName]) do
+				if(type(node) == "string") then
+					str = str .. node
+				else
+					if(node._elem == "apientry") then
+						str = str .. "APIENTRY"
 					else
-						if(node._elem == "apientry") then
-							str = str .. "APIENTRY"
-						else
-							str = str .. node[1]
-						end
+						str = str .. node[1]
 					end
 				end
-				
-				if(#str > 0) then
-					passthru[#passthru + 1] = str
-				end
+			end
+			
+			if(#str > 0) then
+				passthru[#passthru + 1] = str
 			end
 		end
 	end