protected override void TypesRead(IO.XmlStream s)
			{
				Types = new List<Type>(s.Cursor.ChildNodes.Count);

				foreach (XmlNode node in s.Cursor.ChildNodes)
				{
					if (node.Name != "type") continue;

					s.SaveCursor(node);
					Types.Add(new Type(s));
					s.RestoreCursor();
				}
				Types.TrimExcess();
			}
Esempio n. 2
0
			public void Read(BlamLib.CheApe.ProjectState state, IO.XmlStream s)
			{
				int array_start_depth = 0;

				foreach (XmlNode n in s.Cursor.ChildNodes)
				{
					if (n.Name != "field") continue;

					Field f;
					s.SaveCursor(n);
					fields.Add(f = new Field(state, s));
					s.RestoreCursor();

					if (f.TypeIndex == state.kTypeIndexArrayStart) array_start_depth++;
					else if (f.TypeIndex == state.kTypeIndexArrayEnd) array_start_depth--;
				}

				if (array_start_depth != 0)
					throw new Debug.ExceptionLog("Unterminated ArrayStart or extra ArrayEnd in '{0}'.{1}{2}", 
						s.FileName, Program.NewLine, s.Cursor.OuterXml);
			}
			protected override void DefinitionsRead(VertexBuffers owner, IO.XmlStream s)
			{
				Definitions = new List<Definition>(s.Cursor.ChildNodes.Count);

				foreach (XmlNode node in s.Cursor.ChildNodes)
				{
					if (node.Name != "definition") continue;

					s.SaveCursor(node);
					Definitions.Add(new Definition(owner, s));
					s.RestoreCursor();
				}
				Definitions.TrimExcess();
			}
				public Definition(VertexBuffers owner, IO.XmlStream s) : base(owner, s)
				{
					//s.ReadAttribute("size", 16, ref Size);

					if (s.Cursor.ChildNodes.Count > 0)
					{
						var elems = new List<Element>(s.Cursor.ChildNodes.Count);

						foreach (XmlNode node in s.Cursor.ChildNodes)
						{
							if (node.Name != "element") continue;

							s.SaveCursor(node);
							elems.Add(new Element(owner, this, s));
							s.RestoreCursor();
						}

						elems.TrimExcess();
						Elements = elems.ToArray();
						foreach (Element e in Elements) Size += GetElementSize(e);
					}
				}
Esempio n. 5
0
			public FieldType(IO.XmlStream s)
			{
				s.ReadAttribute("opcode", 16, ref opcode);
				s.ReadAttribute("size", 16, ref sizeOf);
				s.ReadAttribute("name", ref name);
				s.ReadAttributeOpt("needsDefinition", ref requiresDefinition);

				#region Read byte swap codes
				foreach (XmlNode n in s.Cursor.ChildNodes)
					if (n.Name == "byteSwap")
					{
						s.SaveCursor(n);
						int code = 0;
						foreach (XmlNode n2 in s.Cursor.ChildNodes)
						{
							if (n2.Name != "code") continue;

							s.SaveCursor(n2);
							s.ReadAttribute("value", 10, ref code);
							byteSwapCodes.Add(code);
							s.RestoreCursor();
						}
						s.RestoreCursor();
					}
				#endregion
			}
Esempio n. 6
0
			public ScriptFunction(ProjectState state, IO.XmlStream s) : base(state, s)
			{
				string return_type_name = null;
				s.ReadAttribute("returnType", ref return_type_name);
				s.ReadAttributeOpt("help", ref helpString);
				s.ReadAttributeOpt("helpArg", ref helpArgString);
				s.ReadAttributeOpt("internal", ref IsInternal);

				foreach (XmlNode n in s.Cursor.ChildNodes)
				{
					if (n.Name != "arg") continue;

					s.SaveCursor(n);
					args.Add(new ScriptFunctionArg(this, state, s));
					s.RestoreCursor();
				}

				if (!state.scriptingInterface.Types.Contains(return_type_name))
					throw new Debug.ExceptionLog("CheApe: value type '{0}' does not exist", return_type_name);

				returnType = state.scriptingInterface.GetValueType(return_type_name);
				help = state.Compiler.Strings.Add(helpString);
				helpArg = state.Compiler.Strings.Add(helpArgString);
			}
Esempio n. 7
0
		void ProcessScriptGlobals(ProjectState state, IO.XmlStream s)
		{
			foreach (XmlNode n in s.Cursor.ChildNodes)
			{
				if (n.Name != "global") continue;

				s.SaveCursor(n);
				var sg = new ScriptGlobal(state, s);
				s.RestoreCursor();
				string name_str = sg.ToString();

				if (state.scriptingInterface.Globals.Contains(name_str))
				{
					Debug.LogFile.WriteLine("Engine already contains a {0} named '{1}', ignoring...", "script global", name_str);
					continue;
				}

				try { ScriptGlobals.Add(name_str, sg); }
				catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "script global definition", name_str); }
			}
		}
Esempio n. 8
0
		void ProcessTagDatas(ProjectState state, IO.XmlStream s)
		{
			foreach (XmlNode n in s.Cursor.ChildNodes)
			{
				if (n.Name != "TagData") continue;

				s.SaveCursor(n);
				var tagdata = new TagData(state, s);
				s.RestoreCursor();
				string name_str = tagdata.ToString();

				try { Data.Add(name_str, tagdata); }
				catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, "tag data definition", name_str); }
			}
		}
Esempio n. 9
0
		static void ProcessStringList(ProjectState state, IO.XmlStream s, Dictionary<string, StringList> listDic,
			string elementName, string listTypeName)
		{
			foreach (XmlNode n in s.Cursor.ChildNodes)
			{
				if (n.Name != elementName) continue;

				s.SaveCursor(n);
				var list = new StringList(state, s);
				s.RestoreCursor();
				string name_str = list.ToString();

				try { listDic.Add(name_str, list); }
				catch (ArgumentException) { Debug.LogFile.WriteLine(kDuplicateErrorStr, listTypeName, name_str); }
			}
		}
Esempio n. 10
0
			public Fixup(ProjectState state, IO.XmlStream s) : base(state, s)
			{
				string temp = string.Empty;

				s.ReadAttribute("guerilla", 16, ref addressGuerilla);
				s.ReadAttribute("tool", 16, ref addressTool);
				s.ReadAttribute("sapien", 16, ref addressSapien);

				s.ReadAttribute("type", ref type);

				#region Definition
				if (type != FixupType.Field && s.ReadAttributeOpt("definition", ref temp))
				{
					if (type == FixupType.String || type == FixupType.StringPtr)
														definition = state.Compiler.RamAddString(temp, out definitionLength).ToString("X8");
					else if (type == FixupType.Memory)	definition = state.Compiler.RamAddMemory(temp, out definitionLength).ToString("X8");
					else if (type == FixupType.Pointer)	definition = temp;

					definitionGuerilla =
					definitionTool =
					definitionSapien =
						ToPointer();
				}
				else definition = null;
				#endregion

				if(definition == null) foreach (XmlNode node in s.Cursor.ChildNodes)
				{
					if (node.Name == "definition")
					{
						s.SaveCursor(node);

						if (type != FixupType.Field)
						{
							bool is_string = type == FixupType.String;

							// this will be set to false when not all platforms have a definition
							bool add_def_memory = true;
							if (add_def_memory)	add_def_memory = ReadSingleDefinition(state, s, "guerilla", ref definitionGuerilla);
							else				definitionGuerilla = uint.MaxValue;
							if (add_def_memory)	add_def_memory = ReadSingleDefinition(state, s, "tool", ref definitionTool);
							else				definitionTool = uint.MaxValue;
							if (add_def_memory)	add_def_memory = ReadSingleDefinition(state, s, "sapien", ref definitionSapien);
							else				definitionSapien = uint.MaxValue;

							// Houston, we forgot a platform...
							if (!add_def_memory && definitionGuerilla != uint.MaxValue)
							{
								// TODO: error here
							}
						}
						else
						{
							foreach (XmlNode fnode in s.Cursor.ChildNodes)
								if (fnode.Name == "field")
								{
									s.SaveCursor(fnode);
									field = new Field(state, s);
									s.RestoreCursor();
									break;
								}
						}

						s.RestoreCursor();
						break;
					}
				}
			}
Esempio n. 11
0
			public override void Read(BlamLib.CheApe.ProjectState state, IO.XmlStream s)
			{
				base.Read(state, s);

				foreach (XmlNode n in s.Cursor.ChildNodes)
				{
					if (n.Name != "FieldSet") continue;

					s.SaveCursor(n);
					fieldSets.Add(new FieldSet(state, s));
					s.RestoreCursor();
				}
			}
Esempio n. 12
0
		void ProcessTagGroups(BlamLib.CheApe.ProjectState state, IO.XmlStream s)
		{
			foreach (XmlNode n in s.Cursor.ChildNodes)
			{
				if (n.Name != "TagGroup") continue;

				s.SaveCursor(n);
				var group = new TagGroup(state, s);
				s.RestoreCursor();
				string name_str = group.ToString();

				try { Groups.Add(name_str, group); }
				catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag group definition", name_str); }
			}
		}
Esempio n. 13
0
		void ProcessTagStructs(BlamLib.CheApe.ProjectState state, IO.XmlStream s)
		{
			foreach (XmlNode n in s.Cursor.ChildNodes)
			{
				if (n.Name != "Struct") continue;

				s.SaveCursor(n);
				var block = new TagStruct(state, s);
				s.RestoreCursor();
				string name_str = block.ToString();

				try { Structs.Add(name_str, block); }
				catch (ArgumentException) { Debug.LogFile.WriteLine(CheApe.Import.kDuplicateErrorStr, "tag struct definition", name_str); }
			}
		}