Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        public AbcNamespaceSet DefineNamespaceSet(params AbcNamespace[] list)
        {
            string key = AbcNamespaceSet.KeyOf(list);
            var    nss = NamespaceSets[key];

            if (nss != null)
            {
                return(nss);
            }
            nss = new AbcNamespaceSet(list, key);
            NamespaceSets.Add(nss);
            return(nss);
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Imports <see cref="AbcNamespaceSet"/> constant.
 /// </summary>
 /// <param name="set">constant to import.</param>
 /// <returns></returns>
 public AbcNamespaceSet ImportConst(AbcNamespaceSet set)
 {
     return(NamespaceSets.Import(set));
 }