Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove InPortData and OutPortData #7301

Merged
merged 19 commits into from
Nov 5, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/DynamoCore/Core/CustomNodeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public CustomNodeDefinition(
// infinity output
? new[] {new {portIndex = 0, node = topNode, name = "∞"}}
// otherwise, grab all ports with connected outputs and package necessary info
: topNode.OutPortData
: topNode.OutPorts
.Select(
(port, i) =>
new {portIndex = i, node = topNode, name = port.NickName})
new {portIndex = i, node = topNode, name = port.PortName})
.Where(x => !topNode.HasOutput(x.portIndex)));

foreach (var rtnAndIndex in rtnPorts.Select((rtn, i) => new {rtn, idx = i}))
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCore/Core/CustomNodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,14 +1124,14 @@ from output in outputs
foreach (var hanging in
selectedNodeSet.SelectMany(
node =>
Enumerable.Range(0, node.OutPortData.Count)
Enumerable.Range(0, node.OutPorts.Count)
.Where(port => !node.HasOutput(port))
.Select(port => new { node, port })).Distinct())
{
//Create Symbol Node
var node = new Output
{
Symbol = hanging.node.OutPortData[hanging.port].NickName,
Symbol = hanging.node.OutPorts[hanging.port].PortName,
X = rightMost + 75 - leftShift
};
node.Y = i*(50 + node.Height);
Expand Down
6 changes: 3 additions & 3 deletions src/DynamoCore/Engine/CodeGeneration/AstBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private static void BfsTraverse(

nodeFlags[node] = MarkFlag.TempMark;

for (int i = 0; i < node.InPortData.Count; ++i)
for (int i = 0; i < node.InPorts.Count; ++i)
{
Tuple<int, NodeModel> t;
if (!node.TryGetInput(i, out t))
Expand Down Expand Up @@ -270,7 +270,7 @@ private void CompileToAstNodes(NodeModel node, List<AssociativeNode> resultList,

var inputAstNodes = new List<AssociativeNode>();
var inPortsCount = node.InPorts.Count;
var inPortDataCount = node.InPortData.Count;
var inPortDataCount = node.InPorts.Count;

//TODO: inputsCount should be removed in future.
// InPortData won't be used anymore, so we shouldn't take into account InPortData.Count.
Expand All @@ -297,7 +297,7 @@ private void CompileToAstNodes(NodeModel node, List<AssociativeNode> resultList,
if (node.InPorts.Count > index)
{
var port = node.InPorts[index];
if (port.UsingDefaultValue && port.DefaultValueEnabled)
if (port.UsingDefaultValue && port.DefaultValue != null)
{
inputAstNodes.Add(port.DefaultValue);
}
Expand Down
24 changes: 12 additions & 12 deletions src/DynamoCore/Graph/Nodes/CodeBlockNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ private void SetPreviewVariable(IEnumerable<Node> parsedNodes)
///
private void CreateInputOutputPorts()
{
InPortData.Clear();
OutPortData.Clear();
InPorts.Clear();
OutPorts.Clear();
if ((codeStatements == null || (codeStatements.Count == 0))
&& (inputIdentifiers == null || (inputIdentifiers.Count == 0)))
{
Expand All @@ -716,7 +716,7 @@ private void SetInputPorts()
// Generate input port data list from the unbound identifiers.
var inportData = CodeBlockUtils.GenerateInputPortData(inputPortNames);
foreach (var portData in inportData)
InPortData.Add(portData);
InPorts.Add(new PortModel(PortType.Input, this, portData));
}

private void SetOutputPorts()
Expand All @@ -732,11 +732,11 @@ private void SetOutputPorts()
if (tempVariables.Contains(def.Key))
tooltip = Formatting.TOOL_TIP_FOR_TEMP_VARIABLE;

OutPortData.Add(new PortData(string.Empty, tooltip)
OutPorts.Add(new PortModel(PortType.Output, this, new PortData(string.Empty, tooltip)
{
LineIndex = def.Value - 1, // Logical line index.
Height = Configurations.CodeBlockPortHeightInPixels
});
}));
}
}

Expand All @@ -751,7 +751,7 @@ private void SaveAndDeleteConnectors(IDictionary inportConnections, IDictionary
//----------------------------Inputs---------------------------------
foreach (var portModel in InPorts)
{
var portName = portModel.ToolTipContent;
var portName = portModel.ToolTip;
if (portModel.Connectors.Count != 0)
{
inportConnections.Add(portName, new List<PortModel>());
Expand All @@ -777,8 +777,8 @@ private void SaveAndDeleteConnectors(IDictionary inportConnections, IDictionary
for (int i = 0; i < OutPorts.Count; i++)
{
PortModel portModel = OutPorts[i];
string portName = portModel.ToolTipContent;
if (portModel.ToolTipContent.Equals(Formatting.TOOL_TIP_FOR_TEMP_VARIABLE))
string portName = portModel.ToolTip;
if (portModel.ToolTip.Equals(Formatting.TOOL_TIP_FOR_TEMP_VARIABLE))
portName += i.ToString(CultureInfo.InvariantCulture);
if (portModel.Connectors.Count != 0)
{
Expand Down Expand Up @@ -811,9 +811,9 @@ private void LoadAndCreateConnectors(OrderedDictionary inportConnections, Ordere
{
//----------------------------Inputs---------------------------------
/* Input Port connections are matched only if the name is the same */
for (int i = 0; i < InPortData.Count; i++)
for (int i = 0; i < InPorts.Count; i++)
{
string varName = InPortData[i].ToolTipString;
string varName = InPorts[i].ToolTip;
if (inportConnections.Contains(varName))
{
if (inportConnections[varName] != null)
Expand Down Expand Up @@ -842,9 +842,9 @@ private void LoadAndCreateConnectors(OrderedDictionary inportConnections, Ordere
* the new ports, it also finds the ports that didnt exist before
*/
List<int> undefinedIndices = new List<int>();
for (int i = 0; i < OutPortData.Count; i++)
for (int i = 0; i < OutPorts.Count; i++)
{
string varName = OutPortData[i].ToolTipString;
string varName = OutPorts[i].ToolTip;
if (outportConnections.Contains(varName))
{
if (outportConnections[varName] != null)
Expand Down
20 changes: 10 additions & 10 deletions src/DynamoCore/Graph/Nodes/CustomNodes/CustomNodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ public CustomNodeController(T def) : base(def) { }

protected override void InitializeInputs(NodeModel model)
{
model.InPortData.Clear();
model.InPorts.Clear();

if (Definition.DisplayParameters == null || Definition.Parameters == null)
return;

var inputs = Definition.DisplayParameters.Zip(Definition.Parameters, (dp, p) => Tuple.Create(dp, p.Description, p.DefaultValue));
foreach (var p in inputs)
model.InPortData.Add(new PortData(p.Item1, p.Item2, p.Item3));
model.InPorts.Add(new PortModel(PortType.Input, model, new PortData(p.Item1, p.Item2, p.Item3)));
}

protected override void InitializeOutputs(NodeModel model)
{
model.OutPortData.Clear();
model.OutPorts.Clear();
if (Definition.Returns.Any())
{
foreach (var pair in Definition.Returns)
Expand All @@ -41,12 +41,12 @@ protected override void InitializeOutputs(NodeModel model)
tooltip = Properties.Resources.ToolTipReturnValue;
}

model.OutPortData.Add(new PortData(key, tooltip));
model.OutPorts.Add(new PortModel(PortType.Output, model, new PortData(key, tooltip)));
}
}
else
{
model.OutPortData.Add(new PortData("", Properties.Resources.ToolTipReturnValue));
model.OutPorts.Add(new PortModel(PortType.Output, model, new PortData("", Properties.Resources.ToolTipReturnValue)));
}
}

Expand Down Expand Up @@ -88,7 +88,7 @@ protected override void BuildAstForPartialMultiOutput(
protected override void AssignIdentifiersForFunctionCall(
NodeModel model, AssociativeNode rhs, List<AssociativeNode> resultAst)
{
if (model.OutPortData.Count == 1)
if (model.OutPorts.Count == 1)
resultAst.Add(AstFactory.BuildAssignment(model.AstIdentifierForPreview, rhs));
else
base.AssignIdentifiersForFunctionCall(model, rhs, resultAst);
Expand Down Expand Up @@ -149,29 +149,29 @@ public bool IsInSyncWithNode(NodeModel model)

if (Definition.DisplayParameters != null)
{
var paramNames = model.InPortData.Select(p => p.NickName);
var paramNames = model.InPorts.Select(p => p.PortName);
if (!Definition.DisplayParameters.SequenceEqual(paramNames))
return false;
}

if (Definition.Parameters != null)
{
var defParamTypes = Definition.Parameters.Select(p => p.Type.ToShortString());
var paramTypes = model.InPortData.Select(p => p.ToolTipString);
var paramTypes = model.InPorts.Select(p => p.ToolTip);
if (!defParamTypes.SequenceEqual(paramTypes))
return false;
}

if (Definition.ReturnKeys != null)
{
var returnKeys = model.OutPortData.Select(p => p.NickName);
var returnKeys = model.OutPorts.Select(p => p.PortName);
if (!Definition.ReturnKeys.SequenceEqual(returnKeys))
return false;
}

if (Definition.Returns != null)
{
var tooltips = model.OutPortData.Select(p => p.ToolTipString);
var tooltips = model.OutPorts.Select(p => p.ToolTip);
if (!Definition.Returns.Select(r => string.IsNullOrEmpty(r.Item2) ? Properties.Resources.ToolTipReturnValue : r.Item2)
.SequenceEqual(tooltips))
return false;
Expand Down
38 changes: 19 additions & 19 deletions src/DynamoCore/Graph/Nodes/CustomNodes/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected override void SerializeCore(XmlElement element, SaveContext context)
element.AppendChild(outEl);

outEl = xmlDoc.CreateElement("Inputs");
foreach (string input in InPortData.Select(x => x.NickName))
foreach (string input in InPorts.Select(x => x.PortName))
{
XmlElement inputEl = xmlDoc.CreateElement("Input");
inputEl.SetAttribute("value", input);
Expand All @@ -109,7 +109,7 @@ protected override void SerializeCore(XmlElement element, SaveContext context)
element.AppendChild(outEl);

outEl = xmlDoc.CreateElement("Outputs");
foreach (string output in OutPortData.Select(x => x.NickName))
foreach (string output in OutPorts.Select(x => x.PortName))
{
XmlElement outputEl = xmlDoc.CreateElement("Output");
outputEl.SetAttribute("value", output);
Expand Down Expand Up @@ -145,10 +145,10 @@ internal void LoadNode(Guid nodeId, int inputs, int outputs)
for (int i = 0; i < outputs; i++)
{
data = new PortData("", "Output #" + (i + 1));
if (OutPortData.Count > i)
OutPortData[i] = data;
if (OutPorts.Count > i)
OutPorts[i] = new PortModel(PortType.Output, this, data);
else
OutPortData.Add(data);
OutPorts.Add(new PortModel(PortType.Output, this, data));
}
}

Expand All @@ -158,10 +158,10 @@ internal void LoadNode(Guid nodeId, int inputs, int outputs)
for (int i = 0; i < inputs; i++)
{
data = new PortData("", "Input #" + (i + 1));
if (InPortData.Count > i)
InPortData[i] = data;
if (InPorts.Count > i)
InPorts[i] = new PortModel(PortType.Input, this, data);
else
InPortData.Add(data);
InPorts.Add(new PortModel(PortType.Input, this, data));
}
}

Expand Down Expand Up @@ -201,10 +201,10 @@ protected override void DeserializeCore(XmlElement nodeElement, SaveContext cont

foreach (var dataAndIdx in data)
{
if (OutPortData.Count > dataAndIdx.idx)
OutPortData[dataAndIdx.idx] = dataAndIdx.data;
if (OutPorts.Count > dataAndIdx.idx)
OutPorts[dataAndIdx.idx] = new PortModel(PortType.Output, this, dataAndIdx.data);
else
OutPortData.Add(dataAndIdx.data);
OutPorts.Add(new PortModel(PortType.Output, this, dataAndIdx.data));
}
}
else if (subNode.Name.Equals("Inputs"))
Expand All @@ -221,10 +221,10 @@ protected override void DeserializeCore(XmlElement nodeElement, SaveContext cont

foreach (var dataAndIdx in data)
{
if (InPortData.Count > dataAndIdx.idx)
InPortData[dataAndIdx.idx] = dataAndIdx.data;
if (InPorts.Count > dataAndIdx.idx)
InPorts[dataAndIdx.idx] = new PortModel(PortType.Input, this, dataAndIdx.data);
else
InPortData.Add(dataAndIdx.data);
InPorts.Add(new PortModel(PortType.Input, this, dataAndIdx.data));
}
}

Expand All @@ -234,10 +234,10 @@ protected override void DeserializeCore(XmlElement nodeElement, SaveContext cont
{
var data = new PortData(subNode.Attributes[0].Value, Properties.Resources.ToolTipFunctionOutput);

if (OutPortData.Any())
OutPortData[0] = data;
if (OutPorts.Any())
OutPorts[0] = new PortModel(PortType.Output, this, data);
else
OutPortData.Add(data);
OutPorts.Add(new PortModel(PortType.Output, this, data));
}

#endregion
Expand Down Expand Up @@ -311,7 +311,7 @@ public class Symbol : NodeModel
/// </summary>
public Symbol()
{
OutPortData.Add(new PortData("", Properties.Resources.ToolTipSymbol));
OutPorts.Add(new PortModel(PortType.Output, this, new PortData("", Properties.Resources.ToolTipSymbol)));

RegisterAllPorts();

Expand Down Expand Up @@ -525,7 +525,7 @@ public class Output : NodeModel
/// </summary>
public Output()
{
InPortData.Add(new PortData("", ""));
InPorts.Add(new Nodes.PortModel(PortType.Input, this, new PortData("", "")));

RegisterAllPorts();

Expand Down
8 changes: 4 additions & 4 deletions src/DynamoCore/Graph/Nodes/DummyNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ private void LoadNode(XmlNode nodeElement)

private void UpdatePorts()
{
InPortData.Clear();
InPorts.Clear();
for (int input = 0; input < InputCount; input++)
{
var name = string.Format("Port {0}", input + 1);
InPortData.Add(new PortData(name, ""));
InPorts.Add(new PortModel(PortType.Output, this, new PortData(name, "")));
}

OutPortData.Clear();
OutPorts.Clear();
for (int output = 0; output < OutputCount; output++)
{
var name = string.Format("Port {0}", output + 1);
OutPortData.Add(new PortData(name, ""));
OutPorts.Add(new PortModel(PortType.Output, this, new PortData(name, "")));
}

RegisterAllPorts();
Expand Down
8 changes: 4 additions & 4 deletions src/DynamoCore/Graph/Nodes/FunctionCallNodeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected virtual void BuildAstForPartialMultiOutput(
NodeModel model, AssociativeNode rhs, List<AssociativeNode> resultAst)
{
var missingAmt =
Enumerable.Range(0, model.InPortData.Count).Count(x => !model.HasInput(x));
Enumerable.Range(0, model.InPorts.Count).Count(x => !model.HasInput(x));
var tmp =
AstFactory.BuildIdentifier("__partial_" + model.GUID.ToString().Replace('-', '_'));
resultAst.Add(AstFactory.BuildAssignment(tmp, rhs));
Expand Down Expand Up @@ -139,7 +139,7 @@ protected virtual void BuildOutputAst(
{
AssociativeNode rhs = GetFunctionApplication(model, inputAstNodes);

if (!model.IsPartiallyApplied || model.OutPortData.Count == 1)
if (!model.IsPartiallyApplied || model.OutPorts.Count == 1)
AssignIdentifiersForFunctionCall(model, rhs, resultAst);
else
BuildAstForPartialMultiOutput(model, rhs, resultAst);
Expand Down Expand Up @@ -186,8 +186,8 @@ public virtual void SyncNodeWithDefinition(NodeModel model)
if (Definition == null) return;

OnSyncWithDefinitionStart(model);
model.InPortData.Clear();
model.OutPortData.Clear();
model.InPorts.Clear();
model.OutPorts.Clear();

InitializeInputs(model);
InitializeOutputs(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public NodeModel CreateNodeFromXml(XmlElement nodeElement, SaveContext context,
foreach (var param in descriptor.Parameters)
{
if (i >= inputTypes.Length || param.Type.ToString() != inputTypes[i])
result.InPorts[j].UsingDefaultValue = result.InPortData[j].DefaultValue != null;
result.InPorts[j].UsingDefaultValue = result.InPorts[j].DefaultValue != null;
else
i++;
j++;
Expand Down
Loading