예제 #1
0
 protected internal void ProcOpty(string s, OutPort opt)
 {
     if (opt.arrayPort)
     {
         OutArray oa = new OutArray();
         _outputPorts.Add(s, oa);
         oa._fixedSize = opt.fixedSize;
         oa._optional  = opt.optional;
     }
     else
     {
         OutputPort op = new NullOutputPort();
         op._optional = opt.optional;
         op.SetSender(this);
         _outputPorts.Add(s, op);
         op._name = s;
     }
 }
예제 #2
0
        protected internal OutputPort[] OpenOutputArray(string name, int arraySize)
        {
            if (name.StartsWith("*"))
            {
                FlowError.Complain("Attempt to open * port: " + this + "." + name);
            }

            OutArray oa = null;

            if (!_outputPorts.ContainsKey(name))
            {
                FlowError.Complain("Port not defined as output array in metadata: " + this._name + "." + name);
            }
            Object o = _outputPorts[name];

            if (!(o is OutArray))
            {
                FlowError.Complain("Port not defined as output array in metadata: " + this._name + "." + name);
            }
            oa = (OutArray)o;

            if (!(oa._fixedSize ^ arraySize == 0))
            {
                FlowError.Complain("Array port fixedSize option in metadata doesn't match specified size: " + this._name
                                   + "." + name);
            }
            OutputPort[] array = GetPortArray(_outputPorts, name);

            if (array == null && !oa._optional)
            {
                FlowError.Complain("No elements defined in mandatory output array port: " + this._name + "." + name);
            }

            if (array != null)
            {
                if (arraySize > 0 && array.Length > arraySize)
                {
                    FlowError.Complain("Number of elements specified for array port less than actual number used: "
                                       + this._name + "." + name);
                }

                if (arraySize > 0 && array.Length < arraySize)
                {
                    Array.Resize(ref array, arraySize);
                }

                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] == null)
                    {
                        if (!oa._optional && arraySize > 0)
                        {
                            FlowError.Complain("Mandatory output array port has missing elements: " + this._name + "." + name);
                        }
                        array[i]         = new NullOutputPort();
                        array[i]._sender = this;
                        array[i].Name    = Name + "." + name + "[" + i + "]";
                    }
                }
            }
            _outputPorts.Remove(name);
            return(array);
        }