コード例 #1
0
ファイル: AbcFileLoader.cs プロジェクト: liwq-net/SwfLib
        private AbcTrait GetTrait(AsTraitsInfo traitInfo)
        {
            AbcTrait trait;
            switch (traitInfo.Kind) {
                case AsTraitKind.Const:
                    trait = new AbcConstTrait {
                        SlotId = traitInfo.Slot.SlotId,
                        TypeName = GetMultiname(traitInfo.Slot.TypeName, AbcMultiname.Any),
                        Value = GetConstantValue(traitInfo.Slot.ValueKind, traitInfo.Slot.ValueIndex)
                    };
                    break;
                case AsTraitKind.Slot:
                    trait = new AbcSlotTrait {
                        SlotId = traitInfo.Slot.SlotId,
                        TypeName = GetMultiname(traitInfo.Slot.TypeName, AbcMultiname.Any),
                        Value = GetConstantValue(traitInfo.Slot.ValueKind, traitInfo.Slot.ValueIndex)
                    };
                    break;
                case AsTraitKind.Class:
                    trait = new AbcClassTrait {
                        SlotId = traitInfo.Class.SlotId,
                        Class = GetClass(traitInfo.Class.Class)
                    };
                    break;
                case AsTraitKind.Function:
                    trait = new AbcFunctionTrait {
                        SlotId = traitInfo.Function.SlotId,
                        Method = GetMethod(traitInfo.Function.Function)
                    };
                    break;
                case AsTraitKind.Method:
                    trait = new AbcMethodTrait {
                        DispId = traitInfo.Method.DispId,
                        Method = GetMethod(traitInfo.Method.Method)
                    };
                    break;
                case AsTraitKind.Getter:
                    trait = new AbcGetterTrait {
                        DispId = traitInfo.Method.DispId,
                        Method = GetMethod(traitInfo.Method.Method)
                    };
                    break;
                case AsTraitKind.Setter:
                    trait = new AbcSetterTrait {
                        DispId = traitInfo.Method.DispId,
                        Method = GetMethod(traitInfo.Method.Method)
                    };
                    break;
                default:
                    throw new Exception("unsupported trait kind " + traitInfo.Kind);
            }

            trait.Name = GetMultiname(traitInfo.Name, null);
            trait.Final = traitInfo.Final;
            trait.Override = traitInfo.Override;

            if (traitInfo.Metadata != null) {
                foreach (var metaIndex in traitInfo.Metadata) {
                    var meta = GetMetadata(metaIndex);
                    trait.Metadata.Add(meta);
                }
            }
            return trait;
        }
コード例 #2
0
        private AbcTrait GetTrait(AsTraitsInfo traitInfo)
        {
            AbcTrait trait;

            switch (traitInfo.Kind)
            {
            case AsTraitKind.Const:
                trait = new AbcConstTrait {
                    SlotId   = traitInfo.Slot.SlotId,
                    TypeName = GetMultiname(traitInfo.Slot.TypeName, AbcMultiname.Any),
                    Value    = GetConstantValue(traitInfo.Slot.ValueKind, traitInfo.Slot.ValueIndex)
                };
                break;

            case AsTraitKind.Slot:
                trait = new AbcSlotTrait {
                    SlotId   = traitInfo.Slot.SlotId,
                    TypeName = GetMultiname(traitInfo.Slot.TypeName, AbcMultiname.Any),
                    Value    = GetConstantValue(traitInfo.Slot.ValueKind, traitInfo.Slot.ValueIndex)
                };
                break;

            case AsTraitKind.Class:
                trait = new AbcClassTrait {
                    SlotId = traitInfo.Class.SlotId,
                    Class  = GetClass(traitInfo.Class.Class)
                };
                break;

            case AsTraitKind.Function:
                trait = new AbcFunctionTrait {
                    SlotId = traitInfo.Function.SlotId,
                    Method = GetMethod(traitInfo.Function.Function)
                };
                break;

            case AsTraitKind.Method:
                trait = new AbcMethodTrait {
                    DispId = traitInfo.Method.DispId,
                    Method = GetMethod(traitInfo.Method.Method)
                };
                break;

            case AsTraitKind.Getter:
                trait = new AbcGetterTrait {
                    DispId = traitInfo.Method.DispId,
                    Method = GetMethod(traitInfo.Method.Method)
                };
                break;

            case AsTraitKind.Setter:
                trait = new AbcSetterTrait {
                    DispId = traitInfo.Method.DispId,
                    Method = GetMethod(traitInfo.Method.Method)
                };
                break;

            default:
                throw new Exception("unsupported trait kind " + traitInfo.Kind);
            }

            trait.Name     = GetMultiname(traitInfo.Name, null);
            trait.Final    = traitInfo.Final;
            trait.Override = traitInfo.Override;

            if (traitInfo.Metadata != null)
            {
                foreach (var metaIndex in traitInfo.Metadata)
                {
                    var meta = GetMetadata(metaIndex);
                    trait.Metadata.Add(meta);
                }
            }
            return(trait);
        }