public EnumContext EnumFromLean(IntegerEnum integerEnum) { var name = MangleJavaTypeName(integerEnum.Name); var javaType = typeRegistry.FindType(defaultNamespace, name); return(new EnumContext(integerEnum.DocStringLines, javaType.Package, javaType.SimpleName)); }
public EnumContext EnumFromTrip(IntegerEnum integerEnum) { var name = MangleCSharpTypeName(integerEnum.Name); var csharpType = typeRegistry.FindType(defaultNamespace, name); return(new EnumContext(integerEnum.DocStringLines, csharpType.TypeNamespace, csharpType.TypeName)); }
public override void Visit(IntegerEnum integerEnum) { var enumContext = GetEnumContext(integerEnum); Render(enumContext, "enumHeader", HeaderFileExtension); Render(enumContext, "intEnum", null); }
public virtual EnumContext EnumFromIdl(IntegerEnum integerEnum) { var name = _typeMangler.MangleTypeName(integerEnum.Name); var type = _typeRegistry.FindType(_defaultNamespace, name); return(new EnumContext(integerEnum.DocStringLines, type.CodeNamespace, type.Name)); }
protected EnumContext GetEnumContext(IntegerEnum integerEnum) { var enumContext = _contextGenerator.EnumFromIdl(integerEnum); foreach (var field in integerEnum.Fields) { enumContext.AddField(_contextGenerator.FieldFromIdl(field)); } return(enumContext); }
public void Visit(IntegerEnum integerEnum) { var enumContext = _contextGenerator.EnumFromIdl(integerEnum); foreach (var field in integerEnum.Fields) { enumContext.AddField(_contextGenerator.FieldFromIdl(field)); } Render(enumContext, "intEnum"); }
public void Visit(IntegerEnum integerEnum) { sb.Append("Enum ").Append(integerEnum.Name); sb.AppendLine(" {"); foreach (var enumField in integerEnum.Fields) { Visit(enumField); sb.AppendLine(); } sb.AppendLine("}"); }
public void Visit(IntegerEnum integer, byte data) { Content.Add(integer.Value); if (model.GetNextRun(integer.Source) is not ITableRun containingTable) { return; } var offset = containingTable.ConvertByteOffsetToArrayOffset(integer.Source); var enumValue = model.ReadMultiByteValue(offset.SegmentStart, containingTable.ElementContent[offset.SegmentIndex].Length); var segment = containingTable.ElementContent[offset.SegmentIndex]; if (segment is ArrayRunRecordSegment recordSegment) { segment = recordSegment.CreateConcrete(model, integer.Source); } if (segment is not ArrayRunEnumSegment enumSeg) { return; } var parentAddress = model.GetAddressFromAnchor(new(), -1, enumSeg.EnumName); if (model.GetNextRun(parentAddress) is not ArrayRun parentArray) { return; } foreach (var array in model.GetRelatedArrays(parentArray)) { int segOffset = 0; foreach (var seg in array.ElementContent) { var itemIndex = enumValue + array.ParentOffset.BeginningMargin; var destination = model.ReadPointer(array.Start + array.ElementLength * itemIndex + segOffset); segOffset += seg.Length; if (seg.Type != ElementContentType.Pointer) { continue; } if (model.GetNextRun(destination) is not ISpriteRun spriteRun) { continue; } var paletteRuns = spriteRun.FindRelatedPalettes(model, array.Start + array.ElementLength * itemIndex); Content.Add(ReadonlyPixelViewModel.Create(model, spriteRun, paletteRuns.FirstOrDefault(), true)); return; } } }
public void Visit(IntegerEnum integer, byte data) { // must end in whitespace or must have matching quotation marks (ex. "Mr. Mime") var quoteCount = CurrentText.Count(c => c == '"'); if (quoteCount == 0 && char.IsWhiteSpace(CurrentText.Last())) { CompleteIntegerEnumEdit(integer); Result = true; } else if (quoteCount == 2) { CompleteIntegerEnumEdit(integer); Result = true; } }
public virtual void Visit(IntegerEnum integerEnum) { var enumContext = GetEnumContext(integerEnum); Render(enumContext, "intEnum", null); }
public void Visit(IntegerEnum integerEnum, byte data) => buffer.WriteMultiByteValue(index, integerEnum.Length, currentChange, 0);
protected void PruneModel(IntegerEnum enumModel) { _retainedModels.Add(enumModel); }
public void IntegerEnumsAreReadCorrectly(IntegerEnum enumValue, ByteOrder byteOrder) { var constructStream = new ConstructReaderStream(DataStream.Create((int)enumValue, byteOrder)); var result = constructStream.ReadEnum(typeof (IntegerEnum), byteOrder); Assert.AreEqual(enumValue, result); }
public static List <Definition> BuildDefinitions(ParseTreeNodeList definitionNodes) { var definitions = new List <Definition>(); foreach (var definitionNode in definitionNodes) { var definitionChildNode = definitionNode.ChildNodes[0]; if (definitionChildNode.Term.Name == IdlGrammar.CNAME_DOC_STRING) { continue; } string[] docStringLines = null; IList <Annotation> annotations = null; var docStringNode = definitionChildNode.ChildNodes[0]; if (docStringNode.ChildNodes.Count != 0) { docStringLines = ParseDocStringLines(docStringNode.ChildNodes[0].Token.Text); } var annotationsNode = definitionChildNode.ChildNodes[1]; if (annotationsNode.ChildNodes.Count != 0) { annotations = BuildAnnotations(annotationsNode.ChildNodes); } if (definitionChildNode.Term.Name == IdlGrammar.NTNAME_TENUM) { var enumId = definitionChildNode.ChildNodes[2].Token.Text; var enumFields = new List <IntegerEnumField>(); int nextDefaultEnumValue = 0; // enumerations start at zero by default foreach (var enumFieldNode in definitionChildNode.ChildNodes[3].ChildNodes) { string[] fieldDocStringLines = null; var fieldDocStringNode = enumFieldNode.ChildNodes[0]; if (fieldDocStringNode.ChildNodes.Count != 0) { fieldDocStringLines = ParseDocStringLines(fieldDocStringNode.ChildNodes[0].Token.Text); } var enumFieldId = enumFieldNode.ChildNodes[1].Token.Text; IntegerEnumField enumField; if (enumFieldNode.ChildNodes.Count > 1 && enumFieldNode.ChildNodes[2].ChildNodes != null && enumFieldNode.ChildNodes[2].ChildNodes.Count > 0) // has enum value { var valueText = enumFieldNode.ChildNodes[2].ChildNodes[0].Token.Text; int enumValue = int.Parse(valueText); enumField = new IntegerEnumField(fieldDocStringLines, enumFieldId, enumValue, nextDefaultEnumValue); nextDefaultEnumValue = ++enumValue; } else { enumField = new IntegerEnumField(fieldDocStringLines, enumFieldId, null, nextDefaultEnumValue); ++nextDefaultEnumValue; } enumFields.Add(enumField); } var integerEnum = new IntegerEnum(docStringLines, enumId, enumFields, annotations); definitions.Add(integerEnum); } else if (definitionChildNode.Term.Name == IdlGrammar.NTNAME_TSTRUCT) { var name = definitionChildNode.ChildNodes[2].Token.Text; var fFields = BuildFields(definitionChildNode.ChildNodes[3], name); var @struct = new Struct(docStringLines, name, fFields, annotations); definitions.Add(@struct); } else if (definitionChildNode.Term.Name == IdlGrammar.NTNAME_TSERVICE) { var name = definitionChildNode.ChildNodes[2].Token.Text; IList <BaijiMethod> methods = new List <BaijiMethod>(); var functionsChild = definitionChildNode.ChildNodes[3]; if (functionsChild.Term.Name == IdlGrammar.NTNAME_FUNCTIONS) { methods = BuildMethods(functionsChild); } var service = new Service(docStringLines, name, methods, annotations); definitions.Add(service); } } // Mark all locally referenced response struct types. var structs = definitions.OfType <Struct>().ToList(); foreach (var service in definitions.OfType <Service>()) { foreach (var method in service.Methods) { var responseStruct = structs.FirstOrDefault(s => s.Name == method.ReturnType.Name); if (responseStruct != null) { responseStruct.IsServiceResponse = true; } } } return(definitions); }
public ClassWithIntBasedEnum(IntegerEnum value) { Enum = value; }
public void Visit(IntegerEnum integerEnum) { throw new NotImplementedException(); }
public void Visit(IntegerEnum integerEnum, byte data) => Result = integerEnum.Value;
public void Visit(IntegerEnum integer, byte data) => Content.Add(integer.DisplayValue);
public string TestFunc(IntegerEnum e) { return("integer-enum"); }