Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of a SWF writer with the given options.
        /// </summary>
        /// <param name="swf">The SWF to write.</param>
        /// <param name="options">The options that control the output, or
        /// null for the defaults.</param>
        public SWFWriter(SWF swf, SWFWriterOptions options, StringBuilder writeLog, StringBuilder abcWriteLog)
        {
            if (options == null)
            {
                /* Create a default object */
                this.options = new SWFWriterOptions()
                {
                    Compressed     = true,
                    EnableDebugger = false
                };
            }
            else
            {
                this.options = options;
            }

            this.swf              = swf;
            this.writeLog         = writeLog;
            this.abcWriteLog      = abcWriteLog;
            this.characterMarshal = new IDMarshaller <ICharacter>(1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of a SWF writer with the given options.
        /// </summary>
        /// <param name="swf">The SWF to write.</param>
        /// <param name="options">The options that control the output, or
        /// null for the defaults.</param>
        public SWFWriter(SWF swf, SWFWriterOptions options, StringBuilder writeLog, StringBuilder abcWriteLog)
        {
            if (options == null)
            {
                /* Create a default object */
                this.options = new SWFWriterOptions()
                {
                    Compressed = true,
                    EnableDebugger = false
                };
            }
            else
            {
                this.options = options;
            }

            this.swf = swf;
            this.writeLog = writeLog;
            this.abcWriteLog = abcWriteLog;
            this.characterMarshal = new IDMarshaller<ICharacter>(1);
        }
Ejemplo n.º 3
0
        private void ReBuildTables(AbcCode code, string mainClassName)
        {
            /* These objects will keep track of the new IDs generated for all sorts of things... */

            this.intMarshal       = new IDMarshaller <int>(0, 0);
            this.uintMarshal      = new IDMarshaller <uint>(0, 0);
            this.stringMarshal    = new IDMarshaller <string>(0, ABCValues.AnyName);
            this.doubleMarshal    = new IDMarshaller <ulong>(0, 0L);
            this.nsMarshal        = new IDMarshaller <Namespace>(0, Namespace.GlobalNS);
            this.nsSetMarshal     = new IDMarshaller <NamespaceSet>(0, NamespaceSet.EmptySet);
            this.multinameMarshal = new IDMarshaller <Multiname>(0, Multiname.GlobalMultiname);
            this.classMarshal     = new IDMarshaller <AS3ClassDef>(0);
            this.methodMarshal    = new IDMarshaller <Method>(0);

            AS3ClassDef mainClass = null;

            foreach (AS3ClassDef clazz in code.Classes)
            {
                if (clazz.Name.QualifiedName == mainClassName && mainClassName != null)
                {
                    /* To make sure the main class is last.
                     *
                     * Note that we do this out of paranoia and observation, not out of
                     * any kind of understanding that it's necessary. As far as I know, it
                     * probably doesn't matter.
                     *
                     * Note that even without the check for the main class, we'd still need to take
                     * all the classes and register them in the marshal.
                     */
                    mainClass = clazz;
                }
                else
                {
                    this.classMarshal.Register(clazz);
                }
            }

            if (mainClass != null)
            {
                this.classMarshal.Register(mainClass);
            }

            code.SetClasses(this.classMarshal.ToArray());

            foreach (AS3ClassDef clazz in code.Classes)
            {
                this.ProcessClass(clazz);
            }

            foreach (Script s in code.Scripts)
            {
                this.AssembleMethod(s.Method);
                using (IEnumerator <Trait> i = s.Traits)
                {
                    while (i.MoveNext())
                    {
                        this.ProcessTrait(i.Current);
                    }
                }
            }

            code.SetMethods(this.methodMarshal.ToArray());
        }
Ejemplo n.º 4
0
        private void ReBuildTables(AbcCode code, string mainClassName)
        {
            /* These objects will keep track of the new IDs generated for all sorts of things... */

            this.intMarshal = new IDMarshaller<int>(0, 0);
            this.uintMarshal = new IDMarshaller<uint>(0, 0);
            this.stringMarshal = new IDMarshaller<string>(0, ABCValues.AnyName);
            this.doubleMarshal = new IDMarshaller<ulong>(0, 0L);
            this.nsMarshal = new IDMarshaller<Namespace>(0, Namespace.GlobalNS);
            this.nsSetMarshal = new IDMarshaller<NamespaceSet>(0, NamespaceSet.EmptySet);
            this.multinameMarshal = new IDMarshaller<Multiname>(0, Multiname.GlobalMultiname);
            this.classMarshal = new IDMarshaller<AS3ClassDef>(0);
            this.methodMarshal = new IDMarshaller<Method>(0);

            AS3ClassDef mainClass = null;
            foreach (AS3ClassDef clazz in code.Classes)
            {
                if (clazz.Name.QualifiedName == mainClassName && mainClassName != null)
                {
                    /* To make sure the main class is last.
                     *
                     * Note that we do this out of paranoia and observation, not out of
                     * any kind of understanding that it's necessary. As far as I know, it
                     * probably doesn't matter.
                     *
                     * Note that even without the check for the main class, we'd still need to take
                     * all the classes and register them in the marshal.
                     */
                    mainClass = clazz;
                }
                else
                {
                    this.classMarshal.Register(clazz);
                }
            }

            if (mainClass != null)
            {
                this.classMarshal.Register(mainClass);
            }

            code.SetClasses(this.classMarshal.ToArray());

            foreach (AS3ClassDef clazz in code.Classes)
            {
                this.ProcessClass(clazz);
            }

            foreach (Script s in code.Scripts)
            {
                this.AssembleMethod(s.Method);
                using (IEnumerator<Trait> i = s.Traits)
                {
                    while (i.MoveNext())
                    {
                        this.ProcessTrait(i.Current);
                    }
                }
            }

            code.SetMethods(this.methodMarshal.ToArray());
        }