protected void InitializeForExport(ProjectState state, IO.XmlStream s) { s.ReadAttributeOpt("export", ref mIsExported); // if (IsExported) // state.Compiler.AddExport(this); }
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); }
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); }
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); }
/// <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); }
/// <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 }
/// <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); }
protected ElementBase(DefinitionBase parent, IO.XmlStream s) { Name = string.Empty; s.ReadAttributeOpt("name", ref Name); s.ReadAttribute("declType", ref DeclarationType); }
public Type(IO.XmlStream s) : base(s) { s.ReadAttributeOpt("declMethod", ref DeclarationMethod); s.ReadAttribute("declUsage", ref DeclarationUsage); s.ReadAttributeOpt("usageIndex", 10, ref UsageIndex); }
/// <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); }
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); }
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; } } }
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; }
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(); }
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(); }
/// <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 }
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 }
/// <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); }
protected TypeBase(IO.XmlStream s) { if (!s.ReadAttributeOpt("name", ref Name)) Name = string.Empty; s.ReadAttribute("opcode", 16, ref Opcode); }
/// <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); }
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(); }
/// <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()); }