public void DumpXml(XmlWriter writer) { writer.WriteStartElement("abc"); writer.WriteAttributeString("version", Version.ToString()); if (!string.IsNullOrEmpty(Name)) { writer.WriteAttributeString("name", Name); } //constant pool if (AbcDumpService.DumpConstPool) { writer.WriteStartElement("constants"); IntPool.DumpXml(writer); UIntPool.DumpXml(writer); DoublePool.DumpXml(writer); StringPool.DumpXml(writer); Namespaces.DumpXml(writer); NamespaceSets.DumpXml(writer); Multinames.DumpXml(writer); writer.WriteEndElement(); } Methods.DumpXml(writer); //NOTE: metadata will be dumped with traits. //_metadata.DumpXml(writer); Instances.DumpXml(writer); //NOTE: classes are dumped with instances //_classes.DumpXml(writer); Scripts.DumpXml(writer); //NOTE: bodies are dumped with methods //_methodBodies.Dump(writer); writer.WriteEndElement(); }
public void Write(SwfWriter writer) { writer.ABC = this; var ver = Version; writer.WriteUInt16((ushort)ver.Minor); writer.WriteUInt16((ushort)ver.Major); if (ver.Major == CurrentMajor && ver.Minor == CurrentMinor) { IntPool.Write(writer); UIntPool.Write(writer); DoublePool.Write(writer); StringPool.Write(writer); Namespaces.Write(writer); NamespaceSets.Write(writer); Multinames.Write(writer); Methods.Write(writer); Metadata.Write(writer); int n = Instances.Count; writer.WriteUIntEncoded((uint)n); Instances.Write(writer); Classes.Write(writer); Scripts.Write(writer); MethodBodies.Write(writer); } else { throw new NotImplementedException(); } }
public void Get() { IntPool pool = new IntPool(); pool.Push(10); Assert.AreEqual(10, pool.Get()); Assert.AreEqual(0, pool.Get()); }
public void Read(SwfReader reader) { reader.ABC = this; int minor = reader.ReadUInt16(); int major = reader.ReadUInt16(); _version = new Version(major, minor); if (minor == CurrentMinor && major == CurrentMajor) { //NOTE: The "0" entry of each constant pool is not used. If the count for a given pool says there are //NOTE: "n" entries in the pool, there are "n-1" entries in the file, corresponding to indices 1..(n-1). IntPool.Read(reader); UIntPool.Read(reader); SwfReader.CheckU30 = true; DoublePool.Read(reader); StringPool.Read(reader); Namespaces.Read(reader); NamespaceSets.Read(reader); Multinames.Read(reader); Methods.Read(reader); Metadata.Read(reader); int n = (int)reader.ReadUIntEncoded(); Instances.Read(n, reader); Classes.Read(n, reader); for (int i = 0; i < n; ++i) { var klass = Classes[i]; var instance = Instances[i]; instance.Class = klass; klass.Instance = instance; klass.Initializer.Instance = instance; } Scripts.Read(reader); MethodBodies.Read(reader); SwfReader.CheckU30 = false; } else { throw new NotImplementedException(); } }
/// <summary> /// Defines 32-bit signed integer constant. /// </summary> /// <param name="value">value of constant to define.</param> /// <returns></returns> public AbcConst <int> DefineInt(int value) { return(IntPool.Define(value)); }