SWFProcessing.SWFModeller.ABC.AbcCode.CreateClass C# (CSharp) Method

CreateClass() private method

private CreateClass ( ) : AS3ClassDef
return AS3ClassDef
        internal AS3ClassDef CreateClass()
        {
            AS3ClassDef c = new AS3ClassDef(this);
            this.classes.Add(c);
            return c;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Factory method for a new timeline class.
        /// </summary>
        /// <param name="abc">The abc code to create the class within.</param>
        /// <param name="packageName">Name of the fla. You can make this up, since you probably don't have
        /// a fla.</param>
        /// <param name="className">Name of the class.</param>
        /// <returns>A bew timeline class.</returns>
        private static AS3ClassDef GenerateTimelineClass(AbcCode abc, string qClassName, SWFContext ctx)
        {
            int splitPos = qClassName.LastIndexOf('.');

            if (splitPos < 0)
            {
                throw new SWFModellerException(SWFModellerError.CodeMerge,
                                               "A generated timeline class must have a package name.",
                                               ctx.Sentinel("TimelineDefaultPackage"));
            }

            string packageName = qClassName.Substring(0, splitPos);
            string className   = qClassName.Substring(splitPos + 1);

            /* Class name: */
            Namespace flaNS = abc.CreateNamespace(Namespace.NamespaceKind.Package, packageName);
            Multiname classMultinameName = abc.CreateMultiname(Multiname.MultinameKind.QName, className, flaNS, null);

            /* Superclass: */
            Namespace nsFlashDisplay = abc.CreateNamespace(Namespace.NamespaceKind.Package, "flash.display");
            Multiname mnMovieClip    = abc.CreateMultiname(Multiname.MultinameKind.QName, "MovieClip", nsFlashDisplay, null);

            AS3ClassDef newClass = abc.CreateClass();

            newClass.Name      = classMultinameName;
            newClass.Supername = mnMovieClip;

            Namespace protectedNS = abc.CreateNamespace(Namespace.NamespaceKind.Protected, packageName + ":" + className);

            newClass.ProtectedNS = protectedNS;

            newClass.Cinit = abc.CreateMethod(className + "Constructor.abc", 1, 1, 9, 10,

                                              /* The above magic numbers come from the numbers generated by IDE versions of this function.
                                               * I have no real ideal about how I'd work them out for myself, which would obviously be
                                               * more ideal. */

                                              /* AFAICT, this is always generated by the IDE because the abc file format
                                               * doesn't allow for classes with no static initialiser. It doesn't seem
                                               * to actually do anything. */

                                              abc.Op(Opcode.Mnemonics.GetLocal0),
                                              abc.Op(Opcode.Mnemonics.PushScope),
                                              abc.Op(Opcode.Mnemonics.ReturnVoid));

            newClass.Iinit = abc.CreateMethod(className + "ClassInit.abc", 1, 1, 10, 11,

                                              /* The above magic numbers come from the numbers generated by IDE versions of this function.
                                               * I have no real ideal about how I'd work them out for myself, which would obviously be
                                               * more ideal. */

                                              abc.Op(Opcode.Mnemonics.GetLocal0),
                                              abc.Op(Opcode.Mnemonics.PushScope),
                                              abc.Op(Opcode.Mnemonics.GetLocal0),
                                              abc.Op(Opcode.Mnemonics.ConstructSuper, 0U),

                                              abc.Op(Opcode.Mnemonics.ReturnVoid));

            return(newClass);
        }
All Usage Examples Of SWFProcessing.SWFModeller.ABC.AbcCode::CreateClass