protected override void OutputDocumentation(CodeDocumentationNodeCollection docs) { if (docs.Count > 0) { var output = base.Output; output.WriteLine("/** "); bool firstParam = true; bool prevWasSummary = false; // Probably need to have this sorted at some point. foreach (CodeDocumentationNode node in docs) { if (prevWasSummary) { output.WriteLine(" * "); prevWasSummary = false; } if (node is CodeDocumentationSummaryNode) { var n = (CodeDocumentationSummaryNode)node; foreach (string s in n.Lines) { output.Write(" * "); output.WriteLine(s); } prevWasSummary = true; } else if (node is CodeDocumentationParameterNode) { var n = (CodeDocumentationParameterNode)node; if (firstParam) { output.WriteLine(" * Params:"); firstParam = false; } output.Write(" * "); output.Write(n.ParamName); output.Write(" = "); output.WriteLine(n.Summary); } else if (node is CodeDocumentationReturnNode) { output.Write(" * Returns: "); output.WriteLine(((CodeDocumentationReturnNode)node).Summary); } else { throw new Exception("Unknown documentation node type!"); } } output.WriteLine(" */"); } }
public void AddRange(CodeDocumentationNodeCollection value) { if (value == null) { throw new ArgumentNullException("value"); } int count = value.Count; for (int i = 0; i < count; i++) { Add(value[i]); } }
protected override void OutputDocumentation(CodeDocumentationNodeCollection docs) { foreach (CodeDocumentationNode node in docs) { if (node is CodeDocumentationSummaryNode) OutputDocumentationSummaryNode((CodeDocumentationSummaryNode)node); else if (node is CodeDocumentationParameterNode) OutputDocumentationParameterNode((CodeDocumentationParameterNode)node); else if (node is CodeDocumentationReturnNode) OutputDocumentationReturnNode((CodeDocumentationReturnNode)node); else throw new Exception("Unknown documentation node type!"); } }
public CodeDocumentationNodeCollection(CodeDocumentationNodeCollection value) { AddRange(value); }
public void WriteConstructors(CodeTypeDeclaration tdecl, string className) { if (ParentInstruction.LinesOfDocumentation.Count == 0) { ParentInstruction.LinesOfDocumentation.Add("Creates a new instance of the <see cref=\"" + ParentInstruction.FileName + "\" /> class."); } if (Arg1.ArgType == InstructionArgType.None) { CodeConstructor c = new CodeConstructor(); c.Attributes = MemberAttributes.Public; c.Documentation.AddRange( new CodeDocumentationSummaryNode(ParentInstruction.LinesOfDocumentation), new CodeDocumentationParameterNode("parentAssembler", "The assembler to add this instruction to.") ); c.Parameters.Add(new CodeParameterDeclarationExpression(StaticTypeReferences.Assembler, "parentAssembler")); c.BaseConstructorArgs.Add(new CodeArgumentReferenceExpression("parentAssembler")); tdecl.Members.Add(c); } else { List<byte> sizesNeeded = new List<byte>(4); List<string> formsNeeded = new List<string>(4); bool constructorNeeded; bool needsSizeArg = ParentInstruction.NeedsSizeArgument(Arg1.ArgType, Arg2.ArgType, Arg3.ArgType, ref sizesNeeded, out constructorNeeded, ref formsNeeded); if (constructorNeeded) { int segArgIdx; bool needsSegArg = NeedsSegment(out segArgIdx); CodeConstructor c = new CodeConstructor(); c.Attributes = MemberAttributes.Public; c.Parameters.Add(new CodeParameterDeclarationExpression(StaticTypeReferences.Assembler, "parentAssembler")); c.BaseConstructorArgs.Add(new CodeArgumentReferenceExpression("parentAssembler")); Arg1.ArgType.RequestParameters(Arg1, needsSizeArg, c.Parameters); Arg2.ArgType.RequestParameters(Arg2, needsSizeArg, c.Parameters); Arg3.ArgType.RequestParameters(Arg3, needsSizeArg, c.Parameters); if (needsSizeArg) c.Parameters.Add(new CodeParameterDeclarationExpression(StaticTypeReferences.Byte, "size")); if (needsSegArg) { CodeParameterDeclarationExpression cpd = new CodeParameterDeclarationExpression(StaticTypeReferences.Segment, "segment"); cpd.DefaultValueExpression = new CodeFieldReferenceExpression(StaticTypeReferences.SegmentExpression, DefaultSegment.ToString()); c.Parameters.Add(cpd); } CodeDocumentationNodeCollection docs = new CodeDocumentationNodeCollection(); docs.Add(new CodeDocumentationParameterNode("parentAssembler", "The assembler to add this instruction to.")); Arg1.ArgType.AddDocumentationLines(Arg1.Name, docs); Arg2.ArgType.AddDocumentationLines(Arg2.Name, docs); Arg3.ArgType.AddDocumentationLines(Arg3.Name, docs); if (needsSizeArg) docs.Add(new CodeDocumentationParameterNode("size", "The size of the operands for this instruction.")); if (needsSegArg) docs.Add(new CodeDocumentationParameterNode("segment", "The segment to use for memory access within this instruction.")); c.Documentation.Add(new CodeDocumentationSummaryNode(ParentInstruction.LinesOfDocumentation)); c.Documentation.AddRange(docs); WriteConstructorBodyInstructionFormDetermination(c, sizesNeeded, formsNeeded); Arg1.ArgType.WriteConstructorBodyArgProcessing(this, c, 0); Arg2.ArgType.WriteConstructorBodyArgProcessing(this, c, 1); Arg3.ArgType.WriteConstructorBodyArgProcessing(this, c, 2); if (needsSegArg) { c.Statements.Add( new CodeAssignStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), GetArgName(FieldTypeRegistry.Segment.ID, 1, segArgIdx)), new CodeArgumentReferenceExpression("segment") ) ); } tdecl.Members.Add(c); } } }
public void AddDocumentationLines(string argBaseName, CodeDocumentationNodeCollection LinesOfDocumentation) { foreach (CustomInstructionArgParameter param in mParameters.Values) { LinesOfDocumentation.Add(new CodeDocumentationParameterNode(argBaseName + param.ArgNameSuffix, DocAliasRegistry.ExpandDocAliasValue(param.Documentation, argBaseName))); } }