
local struct = require "Structure"
local common = require "CommonStruct"

local my_struct =
{
	{ type="file", style="header", name="GetFilename",
		{ type="write", name="FilePreamble", optional=true} ,
		{ type="block", name="IncludeGuard(hFile, spec, options)",
			{ type="blank"},
			{ type="write", name="Init(hFile, spec, options)", },
			{ type="blank"},
			{ type="write", name="StdTypedefs(hFile, specData, options)",},
			{ type="blank"},
			{ type="write", name="SpecTypedefs(hFile, specData, options)",},
			{ type="blank"},
			{ type="block", name="Decl(hFile, spec, options)",
				{ type="block", name="ExtVarDecl(hFile, spec, options)",
					{ type="ext-iter",
						{ type="write", name="ExtVariableDecl(hFile, extName, specData, spec, options)" },
						{ type="blank", last=true },
					},
				},
				{ type="block", name="EnumDecl(hFile, spec, options)",
					{ type="enum-seen",
						{ type="ext-iter",
							{type="enum-iter",
								{ type="write", name="EnumDecl(hFile, enum, enumTable, spec, options, enumSeen)", },
								{ type="blank", last=true },
							},
						},
						{ type="version-iter",
							{type="enum-iter",
								{ type="write", name="EnumDecl(hFile, enum, enumTable, spec, options, enumSeen)", },
								{ type="blank", last=true },
							},
						},
					},
				},
				{ type="blank"},
				{ type="block", name="FuncPtrDecl(hFile, spec, options)",
					{ type="func-seen",
						{ type="ext-iter",
							{ type="block", name="ExtFuncPtrDecl(hFile, extName, spec, options)", cond="func-iter",
								{type="func-iter",
									{ type="write", name="FuncPtrDecl(hFile, func, spec, options, funcSeen)", },
								},
							},
							{ type="blank"},
						},
						{ type="version-iter",
							{type="func-iter",
								{ type="write", name="FuncPtrDecl(hFile, func, spec, options, funcSeen)", },
								{ type="blank", last=true },
							},
						},
					},
				},
				{ type="blank"},
				{ type="block", name="FuncDecl(hFile, spec, options)",
					{ type="func-seen",
						{ type="ext-iter",
							{ type="block", name="ExtFuncDecl(hFile, extName, spec, options)", cond="func-iter",
								{type="func-iter",
									{ type="write", name="FuncDecl(hFile, func, spec, options, funcSeen)", },
								},
							},
							{ type="blank"},
						},
						{ type="version-iter",
							{type="func-iter",
								{ type="write", name="FuncDecl(hFile, func, spec, options, funcSeen)", },
								{ type="blank", last=true },
							},
						},
					},
				},
				{ type="blank"},
				{ type="block", name="SysDecl(hFile, spec, options)",
					{ type="write", name="UtilityDecls(hFile, spec, options)",},
					{ type="blank" },
					{ type="write", name="MainLoaderFuncDecl(hFile, spec, options)",},
					{ type="blank" },
					{ type="write", name="VersioningFuncDecls(hFile, spec, options)",},
					{ type="blank" },
				},
			},
		},
	},
	{ type="file", style="source", name="GetFilename",
		{ type="write", name="FilePreamble", optional=true} ,
		{ type="write", name="Includes(hFile, basename, spec, options)",},
		{ type="blank"},
		{ type="write", name="LoaderData(hFile, spec, options)",},
		{ type="blank"},
		{ type="block", name="Def(hFile, spec, options)",
			{ type="block", name="ExtVarDef(hFile, spec, options)",
				{ type="ext-iter",
					{ type="write", name="ExtVariableDef(hFile, extName, specData, spec, options)",},
					{ type="blank", last=true},
				},
			},
			{ type="blank"},
			{ type="block", name="PtrDefs(hFile, spec, options)",
				{ type="func-seen",
					{ type="ext-iter",
						{ type="block", name="ExtFuncPtrDef(hFile, extName, spec, options)", cond="func-iter",
							{ type="func-iter",
								{ type="write", name="FuncPtrDef(hFile, func, spec, options, funcSeen)", },
							},
							{ type="blank"},
							{ type="block", name="ExtLoader(hFile, extName, spec, options)",
								{ type="func-iter",
									{ type="write", name="ExtFuncLoader(hFile, func, spec, options)", }
								}
							},
							{ type="blank"},
						},
					},
					{ type="block", name="CoreFuncPtrDef(hFile, spec, options)",
						cond="core-funcs",
						{ type="version-iter",
							{type="func-iter",
								{ type="write", name="FuncPtrDef(hFile, func, spec, options, funcSeen)", },
								{ type="blank", last=true },
							},
						},
						{ type="block", name="CoreLoader(hFile, spec, options)",
							{ type="version-iter",
								{type="func-iter",
									{ type="write", name="CoreFuncLoader(hFile, func, spec, options)", },
								},
							},
						},
						{ type="blank"},
					},
					{ type="write", name="ExtStringFuncDef(hFile, specData, spec, options, funcSeen)"},
				},
			},
			{ type="blank"},
			{ type="block", name="SysDef(hFile, spec, options)",
				{ type="write", name="UtilityDefs(hFile, specData, spec, options)",},
				{ type="blank" },
				{ type="write", name="MainLoaderFunc(hFile, specData, spec, options)",},
				{ type="blank" },
				{ type="write", name="VersioningFuncs(hFile, specData, spec, options)", cond="version-iter"},
				{ type="blank", cond="version-iter" },
			},
		},
	},
}

my_struct = struct.BuildStructure(my_struct)
return my_struct
