Exemplo n.º 1
0
			protected void InitializeForExport(ProjectState state, IO.XmlStream s)
			{
				s.ReadAttributeOpt("export", ref mIsExported);

//				if (IsExported)
//					state.Compiler.AddExport(this);
			}
Exemplo n.º 2
0
				public Element(VertexBuffers owner, Definition parent, IO.XmlStream s) : base(parent, s)
				{
					UsageIndex = 0;

					string TypeStr = null;
					s.ReadAttribute("type", ref TypeStr);
					s.ReadAttributeOpt("usageIndex", 10, ref UsageIndex);

					Type t = owner.TypeFind(TypeStr) as Type;

					if (t != null) this.Type = t;
					else throw new Debug.ExceptionLog("'{0}' isn't a defined type (Owner: {1}/{2})", TypeStr, parent.Opcode.ToString("X2"), parent.Name);
				}
Exemplo n.º 3
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);
			}
Exemplo n.º 4
0
			public ScriptGlobal(ProjectState state, IO.XmlStream s) : base(state, s)
			{
				string type_name = null;
				s.ReadAttribute("type", ref type_name);
				s.ReadAttributeOpt("internal", ref IsInternal);

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

				type = state.scriptingInterface.GetValueType(type_name);
			}
Exemplo n.º 5
0
			/// <summary>
			/// Constructs a tag group definition from an xml definition node
			/// </summary>
			/// <param name="state"></param>
			/// <param name="s"></param>
			/// <remarks>Construct <see cref="TagGroup.Block"/> in the inheriting class's ctor</remarks>
			protected TagGroup(ProjectState state, IO.XmlStream s) : base(state, s)
			{
				s.ReadAttribute("groupTag", ref groupTag);
				s.ReadAttributeOpt("parentTag", ref parentTag);
				s.ReadAttribute("version", 10, ref version);
			}
Exemplo n.º 6
0
			/// <summary>
			/// Constructs a block definition from an xml definition node
			/// </summary>
			/// <param name="state"></param>
			/// <param name="s"></param>
			protected Block(ProjectState state, IO.XmlStream s) : base(state, s)
			{
				try { state.ImportedBlocks.Add(this.nameString, this); }
				catch (Exception) { }

				#region DisplayName
				if (s.ReadAttributeOpt("displayName", ref displayString)) displayName = state.Compiler.Strings.Add(displayString);
				else { displayName = name; displayString = nameString; }
				#endregion
			}
Exemplo n.º 7
0
		/// <summary>
		/// Constructs a tag field description from an xml stream
		/// </summary>
		/// <param name="type"></param>
		/// <param name="s"></param>
		internal protected FieldAttribute(FieldType type, IO.XmlStream s)
		{
			Type = type;
			//s.ReadAttribute("type", ref Type);
			s.ReadAttributeOpt("name", ref Name);
			s.ReadAttributeOpt("help", ref Help);
			s.ReadAttributeOpt("units", ref Units);

			s.ReadAttributeOpt("blockname", ref IsBlockName);
			s.ReadAttributeOpt("readonly", ref IsReadonly);
			s.ReadAttributeOpt("hidden", ref IsHidden);
		}
Exemplo n.º 8
0
				protected ElementBase(DefinitionBase parent, IO.XmlStream s)
				{
					Name = string.Empty;

					s.ReadAttributeOpt("name", ref Name);
					s.ReadAttribute("declType", ref DeclarationType);
				}
Exemplo n.º 9
0
				public Type(IO.XmlStream s) : base(s)
				{
					s.ReadAttributeOpt("declMethod", ref DeclarationMethod);
					s.ReadAttribute("declUsage", ref DeclarationUsage);
					s.ReadAttributeOpt("usageIndex", 10, ref UsageIndex);
				}
Exemplo n.º 10
0
			/// <summary>
			/// Constructs a tag group definition from an xml definition node
			/// </summary>
			/// <param name="state"></param>
			/// <param name="s"></param>
			public TagGroup(BlamLib.CheApe.ProjectState state, IO.XmlStream s) : base(state, s)
			{
				s.ReadAttributeOpt("isIncludedInTagGroupsChecksum", ref IsIncludedInTagGroupsChecksum);

				block = new TagBlock();
				block.DisplayName = name;
				string tempName = nameString + "_block";
				block.Name = blockName = state.Compiler.Strings.Add(tempName);
				block.Read(state, s);
			}
Exemplo n.º 11
0
			public TagBlock(BlamLib.CheApe.ProjectState state, IO.XmlStream s) : base(state, s)
			{
				s.ReadAttribute("maxElements", 10, ref maxElements);
				s.ReadAttributeOpt("dontReadChildren", ref DontReadChildren);

				mFields.Read(state, s);
			}
Exemplo n.º 12
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;
					}
				}
			}
Exemplo n.º 13
0
			bool ReadSingleDefinition(ProjectState state, IO.XmlStream s, string attr_name, ref uint value)
			{
				string temp = null;
				bool add_def_memory = s.ReadAttributeOpt(attr_name, ref temp);
				if(add_def_memory)
				{
					if (type == FixupType.String || type == FixupType.StringPtr)
														value = state.Compiler.RamAddString(temp, out definitionLength);
					else if (type == FixupType.Memory)	value = state.Compiler.RamAddMemory(temp, out definitionLength);
					else if (type == FixupType.Pointer)	value = Convert.ToUInt32(definition, 16);
				}

				return add_def_memory;
			}
Exemplo n.º 14
0
		internal static string BuildEditorNameString(IO.XmlStream s)
		{
			StringBuilder value = new StringBuilder();
			string temp = string.Empty;

			// HACK: Begins the string with a null terminator, leading the tools to think the field is nameless
			// Nameless fields are always hidden
			if (s.ReadAttributeOpt("hiddenAlways", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append('\0');

			if (s.ReadAttributeOpt("name", ref temp)) value.Append(temp);

			if (s.ReadAttributeOpt("locked", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupLocked);

			if (s.ReadAttributeOpt("hidden", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupHidden);

			if (s.ReadAttributeOpt("blockname", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupBlockname);

			if (s.ReadAttributeOpt("deprecated", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupDepricated);

			if (s.ReadAttributeOpt("units", ref temp))
				value.AppendFormat("{0}{1}", MarkupUnits, temp);

			if (s.ReadAttributeOpt("tooltip", ref temp))
				value.AppendFormat("{0}{1}", MarkupTooltip, temp);

			return value.ToString();
		}
Exemplo n.º 15
0
		internal static string BuildEditorNameString(IO.XmlStream s)
		{
			StringBuilder value = new StringBuilder();
			string temp = string.Empty;

			if (s.ReadAttributeOpt("name", ref temp)) value.Append(temp);

			if (s.ReadAttributeOpt("locked", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupLocked);

			if (s.ReadAttributeOpt("hidden", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupHidden);

			if (s.ReadAttributeOpt("blockname", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupBlockname);

			if (s.ReadAttributeOpt("deprecated", ref temp) && Util.ParseBooleanLazy(temp))
				value.Append(MarkupDepricated);

			if (s.ReadAttributeOpt("units", ref temp))
				value.AppendFormat("{0}{1}", MarkupUnits, temp);

			if (s.ReadAttributeOpt("tooltip", ref temp))
				value.AppendFormat("{0}{1}", MarkupTooltip, temp);

			return value.ToString();
		}
Exemplo n.º 16
0
			/// <summary>
			/// Constructs a field from an xml definition node
			/// </summary>
			/// <param name="state"></param>
			/// <param name="s"></param>
			public Field(ProjectState state, IO.XmlStream s)
			{
				string temp = string.Empty;

				#region Type
				s.ReadAttribute("type", ref temp);

				typeIndex = state.Definition.GetTypeIndex(temp);
				Debug.Assert.If(typeIndex != -1, "Not a usable field type: {0}", temp);
				#endregion

				#region Name
				nameString = temp = XmlInterface.BuildEditorNameString(s);

				name = state.Compiler.Strings.Add(temp);
				#endregion

				#region Definition
				if (s.ReadAttributeOpt("definition", ref definition) || TypeIndexIsExplanation(state))
				{
					SyncDefinitionWithState(state);
				}
				else if(state.Definition.FieldTypes[typeIndex].RequiresDefinition)
					throw new Debug.ExceptionLog("\"{0}\" of type {1} has no definition", nameString, state.Definition.FieldTypes[typeIndex].Name);
				#endregion
			}
Exemplo n.º 17
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
			}
Exemplo n.º 18
0
			/// <summary>
			/// Constructs a tag reference definition from an xml definition node
			/// </summary>
			/// <param name="state"></param>
			/// <param name="s"></param>
			public TagReference(ProjectState state, IO.XmlStream s) : base(state, s)
			{
				s.ReadAttributeOpt("isNonResolving", ref IsNonResolving);

				foreach (XmlNode node in s.Cursor.ChildNodes)
					if (node.Name == "field")
						this.elements.Add(node.InnerText);
			}
Exemplo n.º 19
0
				protected TypeBase(IO.XmlStream s)
				{
					if (!s.ReadAttributeOpt("name", ref Name)) Name = string.Empty;
					s.ReadAttribute("opcode", 16, ref Opcode);
				}
Exemplo n.º 20
0
			/// <summary>
			/// Constructs a data definition from an xml definition node
			/// </summary>
			/// <param name="state"></param>
			/// <param name="s"></param>
			public TagData(ProjectState state, IO.XmlStream s) : base(state, s)
			{
				s.ReadAttributeOpt("maxSize", 16, ref maxSize);
				s.ReadAttributeOpt("isNeverStreamed", ref IsNeverStreamed);
				s.ReadAttributeOpt("isTextData", ref IsTextData);
				s.ReadAttributeOpt("isDebugData", ref IsDebugData);
			}
Exemplo n.º 21
0
				protected DefinitionBase(VertexBuffers owner, IO.XmlStream s)
				{
					if (!s.ReadAttributeOpt("name", ref Name)) Name = string.Empty;
					s.ReadAttribute("opcode", 16, ref Opcode);
					if (Name == "") Name = Opcode.ToString();
				}
Exemplo n.º 22
0
		/// <summary>
		/// Constructs a bounded floating point tag field description from an xml stream
		/// </summary>
		/// <param name="type"></param>
		/// <param name="s"></param>
		internal protected BoundedRealFieldAttribute(FieldType type, IO.XmlStream s) : base(type, s)
		{
			if (!s.ReadAttributeOpt("min", ref Min)) Min = 0;
			if (!s.ReadAttributeOpt("max", ref Max)) Max = 0;

			if (Units == string.Empty && Min != 0 && Max != 0)
				Units = string.Format("[{0},{1}]", Min.ToString(), Max.ToString());
		}