Exemplo n.º 1
0
        public void AddParameters(AbcParameterList list, params object[] args)
        {
            if (args == null)
            {
                return;
            }
            int n = args.Length;

            for (int i = 0; i < n; ++i)
            {
                var arg = args[i];

                var p = arg as AbcParameter;
                if (p != null)
                {
                    list.Add(ImportParam(p));
                    continue;
                }

                var typeName = DefineTypeName(arg);
                if (typeName != null)
                {
                    var name = GetParamName(args, ref i);
                    list.Add(new AbcParameter(typeName, name));
                    continue;
                }

                var m = arg as AbcMethod;
                if (m != null)
                {
                    list.CopyFrom(m);
                    continue;
                }

                var pl = arg as AbcParameterList;
                if (pl != null)
                {
                    list.CopyFrom(pl);
                    continue;
                }

                throw new NotImplementedException();
            }
        }
Exemplo n.º 2
0
        public void Read(SwfReader reader)
        {
            int paramCount = (int)reader.ReadUIntEncoded();

            ReturnType = reader.ReadMultiname(); //ret_type

            //U30 param_types[param_count]
            for (int i = 0; i < paramCount; ++i)
            {
                var type = reader.ReadMultiname();
                _params.Add(new AbcParameter {
                    Type = type
                });
            }

            _name = reader.ReadAbcString(); //name_index
            Flags = (AbcMethodFlags)reader.ReadUInt8();

            if ((Flags & AbcMethodFlags.HasOptional) != 0)
            {
                int optionalCount      = (int)reader.ReadUIntEncoded();
                int firstOptionalParam = paramCount - optionalCount;
                for (int i = 0; i < optionalCount; ++i)
                {
                    int valueIndex = (int)reader.ReadUIntEncoded();
                    var valueKind  = (AbcConstKind)reader.ReadUInt8();
                    var p          = _params[firstOptionalParam + i];
                    p.Value      = reader.ABC.GetConstant(valueKind, valueIndex);
                    p.IsOptional = true;
                }
            }

            if ((Flags & AbcMethodFlags.HasParamNames) != 0)
            {
                for (int i = 0; i < paramCount; ++i)
                {
                    _params[i].Name = reader.ReadAbcString();
                }
            }
        }