Commits

Jason McKesson committed 69e6348

glload: Added a new error variable.
Fixed context actions.
Fixed a problem with enumSeen in glload.

Comments (0)

Files changed (6)

modules/CommonStyle.lua

 	end
 	
 	--Also, certain identifiers can need it because they conflict.
-	local badIdent = {"TRUE", "FALSE", "NO_ERROR", "WAIT_FAILED"}
+	local badIdent = {"TRUE", "FALSE", "NO_ERROR", "WAIT_FAILED", "DOMAIN"}
 	for _, ident in ipairs(badIdent) do
 		if(enumName == ident) then
 			enumName = enumName .. "_"

modules/StructGLLoad.lua

 { type="group",
 	{ type="filter", name="EnumsPerExtInGroup", optional=true, cond="enum-iter",
 		{ type="enum-iter",
-			{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen)", },
+			{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen_)", },
+			{ type="call", name="UpdateEnumSeen(enumSeen_, enum, extName)" },
 		},
 		{ type="blank", cond="enum-iter"},
 	},
 				{ type="block", name="Enumerators(hFile, spec, options)",
 					{ type="ext-iter",
 						{ type="enum-iter",
-							{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen)", },
+							{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen_)", },
+							{ type="call", name="UpdateEnumSeen(enumSeen_, enum, extName)" },
 						},
 					},
 				},
 local decl_header_struct =
 { type="group",
 -- Internal header files.
-{ type="enum-seen",
+{ type="context", key="enumSeen", name="EnumSeen",
 { type="func-seen",
 	--Write the type header file.
 	{ type="file", style="type_hdr", name="GetFilename(basename, spec, options)",
 							{ type="block", name="Enumerators(hFile, spec, options)", optional=true,
 								{ type="enum-iter",
 									{ type="filter", name="CoreEnum(enum)",
-										{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen)", },
+										{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen_)", },
+										{ type="call", name="UpdateEnumSeen(enumSeen_, enum, version)" },
 									},
 								},
 							},
 							{ type="block", name="Enumerators(hFile, spec, options)", optional=true,
 								{ type="enum-iter",
 									{ type="filter", name="CompEnum(enum)",
-										{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen)", },
+										{ type="write", name="Enumerator(hFile, enum, enumTable, spec, options, enumSeen_)", },
+										{ type="call", name="UpdateEnumSeen(enumSeen_, enum, version)" },
 									},
 								},
 							},

modules/Structure.lua

 end
 
 function contextAction:PostProcess(context)
-	local style = context:FindStyleForFunc(self.dispose)
-	self:Assert(style,
-		string.format("Could not find the disposal function %s for %s.",
-		self.dispose, self.key))
-		
-	style[self.dispose](context[self.key])
+	if(self.dispose) then
+		local style = context:FindStyleForFunc(self.dispose)
+		self:Assert(style,
+			string.format("Could not find the disposal function %s for %s.",
+			self.dispose, self.key))
+			
+		style[self.dispose](context[self.key])
+	end
 	context[self.key] = nil
 end
 

modules/StyleGLLoad.lua

 	return func.deprecated
 end
 
+function my_style.UpdateEnumSeen(enumSeen_, enum, value)
+	enumSeen_[enum.name] = value;
+end
+
+function my_style.StateEnumSeen() return {} end
 
 
 local function Create()

modules/StylePointerCPP.lua

 end
 
 	local function GenEnumName(enum)
-		--Note: some enumerators start with characters C++ forbids as initial
-		--identifiers. If we detect such an enum, prefix it with `_`.
-		--Also, certain identifiers can need it.
-		local enumName = enum.name
-		if(not enumName:match("^[a-zA-Z_]")) then
-			enumName = "_" .. enumName
-		end
-		
-		local badIdent = {"TRUE", "FALSE", "NO_ERROR", "WAIT_FAILED"}
-		for _, ident in ipairs(badIdent) do
-			if(enumName == ident) then
-				enumName = enumName .. "_"
-				break
-			end
-		end
-		
-		return enumName
+		return common.GetCppEnumName(enum)
 	end
 
 function my_style.header.WriteEnumDecl(hFile, enum, enumTable, spec, options,

modules/glload_util.lua

 end
 
 function data.cpp.GetCppEnumName(enum)
-	--Note: some enumerators start with characters C++ forbids as initial
-	--identifiers. If we detect such an enum, prefix it with `_`.
-	local enumName = enum.name
-	if(not enumName:match("^[a-zA-Z_]")) then
-		enumName = "_" .. enumName
-	end
-	
-	--Also, certain identifiers can need it because they conflict.
-	local badIdent = {"TRUE", "FALSE", "NO_ERROR", "WAIT_FAILED"}
-	for _, ident in ipairs(badIdent) do
-		if(enumName == ident) then
-			enumName = enumName .. "_"
-			break
-		end
-	end
-	
-	return enumName
+	return common.GetCppEnumName(enum)
 end
 
 local cpp_hdr_extra_spec =