Exemple #1
0
        private bool ImportResourceBundle(AbcFile abc, AbcMetaEntry e)
        {
            if (e.NameString != MetadataTags.ResourceBundle)
            {
                return(false);
            }

            string name = e.GetResourceBundleName();

            if (string.IsNullOrEmpty(name))
            {
                throw Errors.RBC.BadMetaEntry.CreateException();
            }

            var swc = abc.Swc;

            if (swc != null)
            {
                swc.LoadResourceBundles();
            }

            var context = new ResourceBundleContext {
                Swc = swc
            };

            ImportResourceBundle(name, context);
            return(true);
        }
Exemple #2
0
        private AbcMetaEntry ImportMetaEntry(AbcFile abc, AbcMetaEntry from)
        {
            if (IgnoreMetadata)
            {
                return(null);
            }

            if (from == null)
            {
                return(null);
            }

            if (Metadata.IsDefined(from))
            {
                return(from);
            }

            //NOTE: Ignore some unecessary metadata
            if (FilterMetadata)
            {
                string name = from.Name.Value;
                if (FilterMetaEntry(name))
                {
                    return(null);
                }
            }

            var e = new AbcMetaEntry {
                Name = ImportConst(from.Name)
            };

            foreach (var item in from.Items)
            {
                var key = ImportConst(item.Key);
                var val = ImportConst(item.Value);
                e.Items.Add(key, val);
            }

            Metadata.Add(e);

            return(e);
        }
Exemple #3
0
        private bool ProcessMetaEntry(AbcFile abc, AbcTrait trait, AbcMetaEntry e)
        {
            if (ImportResourceBundle(abc, e))
            {
                return(true);
            }

            string name = e.NameString;

            if (name == MetadataTags.Mixin)
            {
                var klass = trait.Class;
                if (klass != null)
                {
                    var instance = klass.Instance;
                    instance.IsMixin = true;

                    var sfc = SwfCompiler;
                    if (sfc != null)
                    {
                        sfc.Mixins.RegisterMixinClass(instance);
                    }
                }
                return(true);
            }

            if (name == MetadataTags.RemoteClass)
            {
                var sfc = SwfCompiler;
                if (sfc != null)
                {
                    var klass = trait.Class;
                    if (klass != null)
                    {
                        string alias = e["alias"];
                        sfc.FlexInit.RegisterRemoteClass(alias, klass.Instance);
                    }
                }
                return(true);
            }

            if (name == MetadataTags.Effect)
            {
                var sfc = SwfCompiler;
                if (sfc != null)
                {
                    string effectName  = e["name"];
                    string effectEvent = e["event"];
                    sfc.FlexInit.RegisterEffectTrigger(effectName, effectEvent);
                }
                return(true);
            }

            if (name == MetadataTags.Style)
            {
                //TODO: Can be also used to collect inheriting styles
                var klass = trait.Class;
                if (klass != null)
                {
                    klass.Instance.HasStyles = true;

                    var sfc = SwfCompiler;
                    if (sfc != null)
                    {
                        sfc.Mixins.AddStyleClient(klass.Instance);
                    }
                }
            }

            return(false);
        }