public ChartViewModel() { ViewportManager = new DefaultViewportManager(); var dataSeries = new XyDataSeries <float, float>(); var x = new float[] { 1, 2, 4, 5, 6, 7 }; var y = new float[] { 4, 2, 3, 1, 2, 3 }; dataSeries.SeriesName = "Series 1"; dataSeries.Append(x, y); var viewModel = new LineRenderableSeriesViewModel { DataSeries = dataSeries, StyleKey = "LineStyle" }; RenderableSeriesViewModels.Add(viewModel); var annotation = new ExHorizontalLineAnnotation { Caption = "Annotation", Y1 = 2 }; Annotations.Add(annotation); ViewportManager.ZoomExtents(); }
public void RetrieveAnnotations() { string query = @" <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='annotation'> <attribute name='subject' /> <attribute name='notetext' /> <attribute name='annotationid' /> <attribute name='createdon' /> <filter type='and'> <condition attribute='subject' operator='eq' value='DW-Narrative' /> </filter> <link-entity name='eims_dw_samplingplan' from='eims_dw_samplingplanid' to='objectid' alias='ah'> <filter type='and'> <condition attribute='eims_dw_samplingplanid' operator='eq' uitype='eims_dw_samplingplan' value='" + Id + @"' /> </filter> </link-entity> </entity> </fetch>"; EntityCollection annotations = Service.RetrieveMultiple(new FetchExpression(query)); foreach (Entity annotation in annotations.Entities) { Annotations.Add(new Annotation(annotation)); } }
private void OnLoaded(object sender, RoutedEventArgs e) { //BoxAnnotation Annotations.Add(new BoxAnnotation { CoordinateMode = AnnotationCoordinateMode.Relative, IsEditable = false, ResizeDirections = SciChart.Charting.XyDirection.XDirection, Background = grayBrushLight, BorderBrush = grayBrushRegular, X1 = 0, X2 = 1, Y1 = 0, Y2 = 1 }); //Center dashed line Annotations.Add(new LineAnnotation { CoordinateMode = AnnotationCoordinateMode.Relative, Stroke = grayBrushRegular, StrokeThickness = 1, IsEditable = true, ResizeDirections = SciChart.Charting.XyDirection.XDirection, StrokeDashArray = new DoubleCollection(new double[] { 2, 4 }), X1 = 0, X2 = 1, Y1 = 0.5, Y2 = 0.5 }); Loaded -= OnLoaded; }
public MacdPaneModel(Context context, PriceSeries prices) : base(context, MACD, "0.0", false) { var macdPoints = prices.CloseData.Macd(12, 25, 9); var histogramSeries = new XyDataSeries <DateTime, double> { SeriesName = "Histogram" }; histogramSeries.Append(prices.TimeData, macdPoints.Select(x => x.Divergence)); AddRenderableSeries(new FastColumnRenderableSeries { DataSeries = histogramSeries, YAxisId = MACD }); var macdSeries = new XyyDataSeries <DateTime, double> { SeriesName = "MACD" }; macdSeries.Append(prices.TimeData, macdPoints.Select(x => x.Macd), macdPoints.Select(x => x.Signal)); AddRenderableSeries(new FastBandRenderableSeries { DataSeries = macdSeries, YAxisId = MACD }); Annotations.Add(new AxisMarkerAnnotation(context) { Y1 = (Java.Lang.IComparable)histogramSeries.YValues.Get(histogramSeries.Count - 1), YAxisId = MACD }); Annotations.Add(new AxisMarkerAnnotation(context) { Y1 = (Java.Lang.IComparable)macdSeries.YValues.Get(macdSeries.Count - 1), YAxisId = MACD }); }
public VolumePaneModel(PriceSeries prices) : base(VOLUME, "", false) { YAxis.NumberFormatter = new NSNumberFormatter { MaximumIntegerDigits = 3, NumberStyle = NSNumberFormatterStyle.Scientific, ExponentSymbol = @"E+" }; var volumePrices = new XyDataSeries <DateTime, double> { SeriesName = "Volume" }; volumePrices.Append(prices.TimeData, prices.VolumeData.Select(x => (double)x)); AddRenderableSeries(new SCIFastColumnRenderableSeries { DataSeries = volumePrices, YAxisId = VOLUME, FillBrushStyle = new SCISolidBrushStyle(UIColor.White), StrokeStyle = new SCISolidPenStyle(UIColor.White, 1f) }); Annotations.Add(new SCIAxisMarkerAnnotation { Position = volumePrices.YValues.ValueAt(volumePrices.Count - 1).ToComparable(), YAxisId = VOLUME, }); }
protected override MKAnnotation CreateAnnotation(object item) { var annotation = new PlaceAnnotation <T>((T)item); Annotations.Add(annotation); return(annotation); }
public MainViewModel() { CreateChartData(); CreateChartSeries(); CreateChartAxis(); // Subscribe to future updates int i = 0; _dummyDataProvider.SubscribeUpdates((newValues) => { // Append when new values arrive _lineData.Append(newValues.XValues, newValues.YValues); // Zoom the chart to fit _lineData.InvalidateParentSurface(RangeMode.ZoomToFit); // Every 100th datapoint, add an annotation if (i % 100 == 0) { Annotations.Add(new InfoAnnotationViewModel() { X1 = _lineData.XValues.Last(), Y1 = 0.0 }); } i++; }); }
/// <summary> /// Load annotations for a photo. /// </summary> private async Task ShowAnnotations() { try { var photoWithAnnotations = _photo; // Avoid making the service call again if it's already been made. if (!_isPhotoLoadedFromService) { photoWithAnnotations = await _petCareService.GetPhotoDetails(Photo.Id); // Update photo gold count. Photo.GoldCount = photoWithAnnotations.GoldCount; } // Some views will pass the photo without a corresponding // category instance, so we need to update it here. if (Category == null) { Category = photoWithAnnotations.ExtractCategoryPreview(); } var annotations = photoWithAnnotations.Annotations.OrderByDescending(p => p.CreatedTime); Annotations.Clear(); foreach (var annotation in annotations) { Annotations.Add(annotation); } } catch (ServiceException) { await _dialogService.ShowGenericServiceErrorNotification(); } }
public ChartViewModel(IDataProvider dataProvider, string chartTitle, string mouseEventGroupId) { _dataProvider = dataProvider; _chartTitle = chartTitle; MouseEventGroup = mouseEventGroupId; CreateChartData(); CreateChartSeries(); CreateChartAxis(); // Subscribe to future updates int i = 0; _dataProvider.SubscribeUpdates((newValues) => { // Append when new values arrive _lineData.Append(newValues.XValues, newValues.YValues); // Zoom the chart to fit _lineData.InvalidateParentSurface(RangeMode.ZoomToFit); // Every 100th datapoint, add an annotation if (i % 100 == 0) { Annotations.Add(new InfoAnnotationViewModel() { X1 = _lineData.XValues.Last(), Y1 = 0.0 }); } i++; }); }
private void AddAnnotation(Annotation annot) { if (!_hidden && Annotations != null && !Annotations.Contains(annot)) { Annotations.Add(annot); } }
public PricePaneModel(PriceSeries prices) : base(PRICES, "$%.4f", true) { var stockPrices = new OhlcDataSeries <DateTime, double> { SeriesName = "EUR/USD" }; stockPrices.Append(prices.TimeData, prices.OpenData, prices.HighData, prices.LowData, prices.CloseData); AddRenderableSeries(new SCIFastCandlestickRenderableSeries { DataSeries = stockPrices, YAxisId = PRICES, StrokeUpStyle = new SCISolidPenStyle(0xff52cc54, 1f), FillUpBrushStyle = new SCISolidBrushStyle(0xa052cc54), StrokeDownStyle = new SCISolidPenStyle(0xffe26565, 1f), FillDownBrushStyle = new SCISolidBrushStyle(0xd0e26565) }); var maLow = new XyDataSeries <DateTime, double> { SeriesName = "Low Line" }; maLow.Append(prices.TimeData, prices.CloseData.MovingAverage(50)); AddRenderableSeries(new SCIFastLineRenderableSeries { DataSeries = maLow, StrokeStyle = new SCISolidPenStyle(0xFFFF3333, 1f), YAxisId = PRICES }); var maHigh = new XyDataSeries <DateTime, double> { SeriesName = "High Line" }; maHigh.Append(prices.TimeData, prices.CloseData.MovingAverage(200)); AddRenderableSeries(new SCIFastLineRenderableSeries { DataSeries = maHigh, StrokeStyle = new SCISolidPenStyle(0xFF33DD33, 1f), YAxisId = PRICES }); var priceMarker = new SCIAxisMarkerAnnotation { Position = stockPrices.YValues.ValueAt(stockPrices.Count - 1).ToComparable(), Style = { BackgroundColor = 0xFFFF3333.ToColor() }, YAxisId = PRICES }; var maLowMarker = new SCIAxisMarkerAnnotation { Position = maLow.YValues.ValueAt(maLow.Count - 1).ToComparable(), Style = { BackgroundColor = 0xFFFF3333.ToColor() }, YAxisId = PRICES }; var maHighMarker = new SCIAxisMarkerAnnotation { Position = maHigh.YValues.ValueAt(maHigh.Count - 1).ToComparable(), Style = { BackgroundColor = 0xFF33DD33.ToColor() }, YAxisId = PRICES }; Annotations.Add(priceMarker); Annotations.Add(maLowMarker); Annotations.Add(maHighMarker); }
public void AddValidationAttrib(string attrib, string exception = null) { if (attrib == null) { return; } Owner.Using.Add("System.ComponentModel.DataAnnotations"); Annotations.Add(attrib); var constructor = attrib; var start = attrib.IndexOf('('); if (start < 0) { constructor += "Attribute()"; } else { constructor = attrib.Substring(0, start) + "Attribute" + attrib.Substring(start); } Validations.Add(new ValidationInfo("!new " + constructor + ".IsValid(value)", exception ?? "new ArgumentException(" + FormatCodeToString(attrib) + ", property)")); }
private void AddAnnotationIfNotPresent(string annotation) { if (!Annotations.Contains(annotation)) { Annotations.Add(annotation); } }
void AddDrawing(IDrawing drawing) { _drawings.Add(drawing); if (drawing.Annotation != null) { Annotations.Add(drawing.Annotation); } }
public void AddAnnotation(AnnotationBase annotation) { annotation.SetBinding(AnnotationBase.IsInEditModeProperty, new Binding(IsInEditModeProperty.Name) { Source = this }); Annotations.Add(annotation); }
private void FinishCurrentAnnotation() { if (currentAnnotation != null && currentAnnotation.IsCreating) { currentAnnotation.IsCreating = false; currentAnnotation.Selected = true; Annotations.Add(currentAnnotation); currentAnnotation.Render(); } }
private void UpdateAnnotations() { Annotations.Clear(); foreach (ReferenceLine refLine in ReferenceLines) { Annotations.Add(CreateReferenceLine(refLine)); } Annotations.Add(CreateStatsText()); }
public PricePaneModel(Context context, PriceSeries prices) : base(context, PRICES, "$0.0000", true) { var stockPrices = new OhlcDataSeries <DateTime, double> { SeriesName = "EUR/USD" }; stockPrices.Append(prices.TimeData, prices.OpenData, prices.HighData, prices.LowData, prices.CloseData); AddRenderableSeries(new FastCandlestickRenderableSeries { DataSeries = stockPrices, YAxisId = PRICES }); var maLow = new XyDataSeries <DateTime, double> { SeriesName = "Low Line" }; maLow.Append(prices.TimeData, prices.CloseData.MovingAverage(50)); AddRenderableSeries(new FastLineRenderableSeries { DataSeries = maLow, StrokeStyle = new SolidPenStyle(0xFFFF3333, 1f.ToDip(context)), YAxisId = PRICES }); var maHigh = new XyDataSeries <DateTime, double> { SeriesName = "High Line" }; maHigh.Append(prices.TimeData, prices.CloseData.MovingAverage(200)); AddRenderableSeries(new FastLineRenderableSeries { DataSeries = maHigh, StrokeStyle = new SolidPenStyle(0xFF33DD33, 1f.ToDip(context)), YAxisId = PRICES }); var priceMarker = new AxisMarkerAnnotation(context) { Y1 = (Java.Lang.IComparable)stockPrices.YValues.Get(stockPrices.Count - 1), YAxisId = PRICES }; priceMarker.SetBackgroundColor(0xFFFF3333.ToColor()); var maLowMarker = new AxisMarkerAnnotation(context) { Y1 = (Java.Lang.IComparable)maLow.YValues.Get(maLow.Count - 1), YAxisId = PRICES }; maLowMarker.SetBackgroundColor(0xFFFF3333.ToColor()); var maHighMarker = new AxisMarkerAnnotation(context) { Y1 = (Java.Lang.IComparable)maHigh.YValues.Get(maHigh.Count - 1), YAxisId = PRICES }; maHighMarker.SetBackgroundColor(0xFF33DD33.ToColor()); Annotations.Add(priceMarker); Annotations.Add(maLowMarker); Annotations.Add(maHighMarker); }
public TypeInfo(string Name, string KindName, string Base, bool Include) { this.Name = Name; this.KindName = KindName; this.Base = new TypeReference(Base); this.Include = Include; if (Include) { Annotations.Add(new Annotation("IncludeInKinds")); } }
public virtual AnnotationGroupElement AddAnnotationGroup(double?x, double?y) { var annotationGroup = new AnnotationGroupElement { X = x, Y = y, }; Annotations.Add(annotationGroup); return(annotationGroup); }
public FibonacciRetracementViewModel(params RatioModel[] ratios) : this() { Annotations.Add(CreateFibonacciRatioLine(ratios[0].Value, ratios[0].Brush)); for (int i = 1; i < ratios.Length; i++) { Annotations.Add(CreateFibonacciRatioBox(ratios[i - 1].Value, ratios[i].Value, ratios[i].Brush)); Annotations.Add(CreateFibonacciRatioLine(ratios[i].Value, ratios[i].Brush)); } Annotations.Add(CreateTrendLine(new DoubleCollection {2d, 4d}, 2d, new SolidColorBrush(Color.FromArgb(0xFF, 0xBA, 0xBA, 0xBA)))); }
void CreateAnnotation(string annotationBody) { var annot = new SmaliAnnotation(); annot.Parse(annotationBody); if (annot.AnnotationType == "Lcom/xquadplaystatic/Hook;") { Program.RegisterMethodToHook(new MethodToHook(annot, this)); } Annotations.Add(annot); }
public override string VisitAnnotationMember(ShaderInputsParser.AnnotationMemberContext context) { string name = context.NAME().ToString(); AnnotationValueVisitor valueVisitor = new AnnotationValueVisitor(); valueVisitor.Visit(context); Annotation annotation; annotation.Name = name; annotation.Value = valueVisitor.Value; Annotations.Add(annotation); return(base.VisitAnnotationMember(context)); }
public ParameterAnnotation(ConstantPool constantPool, Stream stream, int index) { ConstantPool = constantPool; ParameterIndex = index; var ann_count = stream.ReadNetworkUInt16(); for (var i = 0; i < ann_count; ++i) { var a = new Annotation(constantPool, stream); Annotations.Add(a); } }
public CompositeLineSquareAnnotation() { var firstLine = new LineAnnotation(); var secondLine = new LineAnnotation(); var thirdLine = new LineAnnotation(); var forthLine = new LineAnnotation(); Annotations.Add(firstLine); Annotations.Add(secondLine); Annotations.Add(thirdLine); Annotations.Add(forthLine); BorderThickness = new Thickness(0); }
public EntityClass(EntityConstraintsClass eConsts, string module) { EntityConstraints = eConsts; Name = eConsts.TableName.ToPascalCase() + "Entity"; Package = $@"havelsan.kovan.{module}.service.entity"; BaseClass = PredefinedClasses.HvlEntity; Annotations.Add(Entity()); Annotations.Add(Table() .SetParameter("name", eConsts.TableNameRef) .SetParameter("schema", eConsts.TableSchema) .SetParameter("indexes", eConsts.UniqueConstraintsRef.Select(u => Index() .SetParameter("name", u.Name) .SetParameter("unique", true) .SetParameter("columnList", u.ColumnList)).ToList() )); IfPresent(eConsts.TableSequenceRef, ts => Annotations.Add(HvlEntitySequence().SetParameter("name", ts))); ClassMembers.AddRange(eConsts.Table.Columns.Select(col => { var cm = new ClassMember(col.Name.ToCamelCase(), col.Type.ToJavaType(), null, AccessModifier.Private); cm.Annotations.Add(Column().SetParameter("name", eConsts.GetColumnName(col))); cm.Annotations.AddIfTrue(!col.Nullable, NotNull()); IfPresent(col.Size, size => { if (cm.Type.BaseClass == PredefinedClasses.JavaNumber) { var da = Digits(); size.Max.IfPresent(max => da.SetParameter("integer", eConsts.GetColumnSizeMax(col))); size.Min.IfPresent(min => da.SetParameter("fraction", eConsts.GetColumnSizeMin(col))); cm.Annotations.Add(da); } else { var sa = Size(); size.Min.IfPresent(min => sa.SetParameter("min", eConsts.GetColumnSizeMin(col))); size.Max.IfPresent(max => sa.SetParameter("max", eConsts.GetColumnSizeMax(col))); cm.Annotations.Add(sa); } }); return(cm); })); }
private void AddAnnotation(Func <FeatureCurve[], Annotation> factory) { var selectedElements = sessionData.SelectedFeatureCurves.ToArray(); if (selectedElements.Length > 0) { var annotation = factory(selectedElements); if (annotation != null) // null means that a valid annotation could not be created { undoHistory.Push(); Annotations.Add(annotation); SelectedAnnotationIndex = Annotations.Count - 1; Work.Execute(eventAggregator, () => snapper.RecalculateAsync()); } } }
public VolumePaneModel(Context context, PriceSeries prices) : base(context, VOLUME, "###E+0", false) { var volumePrices = new XyDataSeries <DateTime, double> { SeriesName = "Volume" }; volumePrices.Append(prices.TimeData, prices.VolumeData.Select(x => (double)x)); AddRenderableSeries(new FastColumnRenderableSeries { DataSeries = volumePrices, YAxisId = VOLUME }); Annotations.Add(new AxisMarkerAnnotation(context) { Y1 = (Java.Lang.IComparable)volumePrices.YValues.Get(volumePrices.Count - 1), YAxisId = VOLUME }); }
void ResolveImport(MSBuildImportElement element, MSBuildParserContext parseContext, MSBuildImportResolver importResolver) { var importAtt = element.ProjectAttribute; var sdkAtt = element.SdkAttribute; ExpressionNode import = null; string importTxt = null; if (importAtt?.Value != null) { import = importAtt.Value; importTxt = importAtt.XAttribute.Value; } if (sdkAtt?.Value is ExpressionText sdkTxt) { var loc = sdkAtt.XAttribute.ValueSpan; string sdkPath = parseContext.GetSdkPath(this, sdkTxt.Value, loc); import = import == null ? null : new ExpressionText(0, Path.Combine(sdkPath, importTxt), true); if (IsToplevel && sdkPath != null) { Annotations.Add(sdkAtt.XAttribute, new NavigationAnnotation(sdkPath, loc)); } } if (import != null) { bool wasResolved = false; var loc = importAtt.XAttribute.ValueSpan; foreach (var resolvedImport in importResolver.Resolve(import, importTxt, null)) { this.AddImport(resolvedImport); wasResolved |= resolvedImport.IsResolved; if (IsToplevel && wasResolved) { Annotations.Add(importAtt.XAttribute, new NavigationAnnotation(resolvedImport.Filename, loc)); } } if (!wasResolved && IsToplevel) { DiagnosticSeverity type = element.ConditionAttribute == null ? DiagnosticSeverity.Error : DiagnosticSeverity.Warning; Diagnostics.Add(CoreDiagnostics.UnresolvedImport, loc, importTxt); } } }
public void AddAnnotationEveryDay() { var points = GetFirst().Points; if (points.Count == 0) { points = GetLast().Points; if (points.Count == 0) { return; } } var lastPoint = points.Where(x => !x.Equals(DataPoint.Undefined)).Max(x => x.X); var firstPoint = points.Where(x => !x.Equals(DataPoint.Undefined)).Min(x => x.X); var beginingDate = DateTimeAxis.ToDateTime(firstPoint); var lastDate = DateTimeAxis.ToDateTime(lastPoint); double Y = 70; var date = new DateTime(beginingDate.Date.Year, beginingDate.Date.Month, beginingDate.Date.Day); var date2 = new DateTime(lastDate.Date.Year, lastDate.Date.Month, lastDate.Date.Day); var days = (int)(date2 - date).TotalDays; double X = DateTimeAxis.ToDouble(date); for (int i = 0; i <= days + 1; i++) { LineAnnotation Line = new LineAnnotation() { Tag = "period", StrokeThickness = 2, Color = OxyColors.Green, Type = LineAnnotationType.Vertical, Text = Y.ToString(), TextColor = OxyColors.White, X = X, LineStyle = LineStyle.Dash, }; Annotations.Add(Line); date = date.AddDays(1); X = DateTimeAxis.ToDouble(date); } }
static bool ParseMembers (MemberInfo parent, Tokenizer tokenizer) { Annotations properties = new Annotations (); TypeInfo parent_type = parent as TypeInfo; string accessibility; TypeReference returntype; bool is_dtor; bool is_ctor; bool is_virtual; bool is_static; bool is_const; bool is_extern; string name; //Console.WriteLine ("ParseMembers ({0})", type.Name); do { returntype = null; is_dtor = is_ctor = is_virtual = is_static = false; is_extern = is_const = false; name = null; properties = new Annotations (); if (parent_type != null) accessibility = parent_type.IsStruct ? "public" : "private"; else accessibility = "public"; try { if (tokenizer.Accept (Token2Type.Punctuation, ";")) continue; } catch { return false; } if (tokenizer.CurrentToken.value == "}") return true; while (tokenizer.CurrentToken.type == Token2Type.CommentProperty) { properties.Add (tokenizer.CurrentToken.value); tokenizer.Advance (true); } //Console.WriteLine ("ParseMembers: Current token: {0}", tokenizer.CurrentToken); if (tokenizer.CurrentToken.type == Token2Type.Identifier) { string v = tokenizer.CurrentToken.value; switch (v) { case "public": case "protected": case "private": accessibility = v; tokenizer.Advance (true); tokenizer.Accept (Token2Type.Punctuation, ":"); continue; case "enum": ParseEnum (properties, parent, tokenizer); continue; case "friend": while (!tokenizer.Accept (Token2Type.Punctuation, ";")) { tokenizer.Advance (true); } continue; case "struct": case "class": case "union": if (!ParseClassOrStruct (properties, parent, tokenizer)) return false; continue; case "typedef": StringBuilder requisite = new StringBuilder (); requisite.Append (tokenizer.CurrentToken.value); requisite.Append (' '); tokenizer.Advance (true); while (!tokenizer.Accept (Token2Type.Punctuation, ";")) { requisite.Append (tokenizer.CurrentToken.value); requisite.Append (' '); if (tokenizer.CurrentToken.value == "{") { tokenizer.Advance (true); while (!tokenizer.Accept (Token2Type.Punctuation, "}")) { requisite.Append (tokenizer.CurrentToken.value); requisite.Append (' '); tokenizer.Advance (true); } requisite.Append (tokenizer.CurrentToken.value); requisite.Append (' '); } tokenizer.Advance (true); } requisite.Append (";"); if (properties.ContainsKey ("CBindingRequisite")) cbinding_requisites.AppendLine (requisite.ToString ()); continue; case "EVENTHANDLER": while (!tokenizer.Accept (Token2Type.Punctuation, ";")) tokenizer.Advance (true); continue; case "template": tokenizer.Advance (true); tokenizer.AcceptOrThrow (Token2Type.Punctuation, "<"); tokenizer.AcceptOrThrow (Token2Type.Identifier, "typename"); tokenizer.GetIdentifier (); tokenizer.AcceptOrThrow (Token2Type.Punctuation, ">"); continue; case "using": tokenizer.Advance (true); continue; case "namespace": tokenizer.Advance (true); tokenizer.GetIdentifier (); tokenizer.Accept (Token2Type.Punctuation, "{"); continue; case "mutable": tokenizer.Advance (true); continue; } } do { if (tokenizer.Accept (Token2Type.Identifier, "virtual")) { is_virtual = true; continue; } if (tokenizer.Accept (Token2Type.Identifier, "static")) { is_static = true; continue; } if (tokenizer.Accept (Token2Type.Identifier, "const")) { is_const = true; continue; } if (tokenizer.Accept (Token2Type.Identifier, "extern")) { is_extern = true; continue; } if (tokenizer.Accept (Token2Type.Identifier, "volatile")) { continue; } if (tokenizer.Accept (Token2Type.Identifier, "G_GNUC_INTERNAL")) { continue; } break; } while (true); if (is_extern && tokenizer.Accept (Token2Type.Literal, "C")) { tokenizer.SyncWithEndBrace (); continue; } if (tokenizer.Accept (Token2Type.Punctuation, "~")) { is_dtor = true; if (!is_virtual) { TypeInfo ti = parent as TypeInfo; if (ti != null && ti.Base != null) Console.WriteLine ("The class {0} has a non-virtual destructor, and it's base class is {2} ({1}).", parent.Name, parent.Header, ti != null && ti.Base != null ? ti.Base.Value : "<none>"); } } if (is_dtor) { name = "~" + tokenizer.GetIdentifier (); returntype = new TypeReference ("void"); } else { returntype = ParseTypeReference (tokenizer); if (tokenizer.CurrentToken.value == "<") { tokenizer.Advance (true); while (!tokenizer.Accept (Token2Type.Punctuation, ">")) tokenizer.Advance (true); } if (returntype.Value == parent.Name && tokenizer.CurrentToken.value == "(") { is_ctor = true; name = returntype.Value; returntype.Value += "*"; } else { name = tokenizer.GetIdentifier (); } } returntype.IsConst = is_const; returntype.IsReturnType = true; //Console.WriteLine ("ParseMembers: found member '{0}' is_ctor: {1}", name, is_ctor); if (tokenizer.Accept (Token2Type.Punctuation, "(")) { // Method MethodInfo method = new MethodInfo (); method.Header = tokenizer.CurrentFile; method.Parent = parent; method.Annotations = properties; method.Name = name; method.IsConstructor = is_ctor; method.IsDestructor = is_dtor; method.IsVirtual = is_virtual; method.IsStatic = is_static; method.IsPublic = accessibility == "public"; method.IsPrivate = accessibility == "private"; method.IsProtected = accessibility == "protected"; method.ReturnType = returntype; //Console.WriteLine ("ParseMembers: found method '{0}' is_ctor: {1}", name, is_ctor); if (!tokenizer.Accept (Token2Type.Punctuation, ")")) { string param_value = null; do { ParameterInfo parameter = new ParameterInfo (method); while (tokenizer.CurrentToken.type == Token2Type.CommentProperty) { parameter.Annotations.Add (tokenizer.CurrentToken.value); tokenizer.Advance (true); } if (tokenizer.Accept (Token2Type.Punctuation, ".") && tokenizer.Accept (Token2Type.Punctuation, ".") && tokenizer.Accept (Token2Type.Punctuation, ".")) { // ... variable argument declaration parameter.ParameterType = new TypeReference ("..."); } else { if (tokenizer.CurrentToken.type == Token2Type.Identifier) { if (tokenizer.Accept (Token2Type.Identifier, "Moonlight")) { tokenizer.Accept (Token2Type.Punctuation, ":"); tokenizer.Accept (Token2Type.Punctuation, ":"); } } parameter.ParameterType = ParseTypeReference (tokenizer); } if (tokenizer.CurrentToken.value != "," && tokenizer.CurrentToken.value != ")") { parameter.Name = tokenizer.GetIdentifier (); if (tokenizer.Accept (Token2Type.Punctuation, "[")) { if (tokenizer.CurrentToken.type == Token2Type.Identifier) tokenizer.Advance (true); tokenizer.AcceptOrThrow (Token2Type.Punctuation, "]"); } if (tokenizer.Accept (Token2Type.Punctuation, "=")) { param_value = string.Empty; if (tokenizer.Accept (Token2Type.Punctuation, "-")) param_value = "-"; param_value += tokenizer.GetIdentifier (); if (tokenizer.Accept (Token2Type.Punctuation, ":")) { tokenizer.AcceptOrThrow (Token2Type.Punctuation, ":"); param_value += "::" + tokenizer.GetIdentifier (); } } } method.Parameters.Add (parameter); //Console.WriteLine ("ParseMember: got parameter, type: '{0}' name: '{1}' value: '{2}'", parameter.ParameterType.Value, parameter.Name, param_value); } while (tokenizer.Accept (Token2Type.Punctuation, ",")); tokenizer.AcceptOrThrow (Token2Type.Punctuation, ")"); } parent.Children.Add (method); //Allow const member functions, ignore the const keyword tokenizer.Accept (Token2Type.Identifier, "const"); if (tokenizer.CurrentToken.value == "{") { //Console.WriteLine ("ParseMember: member has body, skipping it"); tokenizer.SyncWithEndBrace (); } else if (is_ctor && tokenizer.Accept (Token2Type.Punctuation, ":")) { // ctor method implemented in header with field initializers and/or base class ctor call tokenizer.FindStartBrace (); tokenizer.SyncWithEndBrace (); //Console.WriteLine ("ParseMember: skipped ctor method implementation"); } else if (tokenizer.Accept (Token2Type.Punctuation, "=")) { // pure virtual method tokenizer.AcceptOrThrow (Token2Type.Identifier, "0"); tokenizer.AcceptOrThrow (Token2Type.Punctuation, ";"); method.IsAbstract = true; } else { if (tokenizer.Accept (Token2Type.Identifier, "__attribute__")) { tokenizer.AcceptOrThrow (Token2Type.Punctuation, "("); tokenizer.AcceptOrThrow (Token2Type.Punctuation, "("); if (tokenizer.CurrentToken.type == Token2Type.Identifier) tokenizer.Advance (true); tokenizer.AcceptOrThrow (Token2Type.Punctuation, ")"); tokenizer.AcceptOrThrow (Token2Type.Punctuation, ")"); } tokenizer.AcceptOrThrow (Token2Type.Punctuation, ";"); } } else { if (is_ctor || is_dtor) throw new Exception (string.Format ("Expected '(', not '{0}'", tokenizer.CurrentToken.value)); if (name == "operator") { while (true) { if (tokenizer.CurrentToken.value == ";") { // End of operator break; } else if (tokenizer.CurrentToken.value == "{") { // In-line implementation tokenizer.SyncWithEndBrace (); break; } tokenizer.Advance (true); } //Console.WriteLine ("ParseMembers: skipped operator"); } else { FieldInfo field = new FieldInfo (); field.IsConst = is_const; field.IsStatic = is_static; field.IsExtern = is_extern; field.Name = name; field.FieldType = returntype; field.IsPublic = accessibility == "public"; field.IsPrivate = accessibility == "private"; field.IsProtected = accessibility == "protected"; field.Annotations = properties; // Field do { //Console.WriteLine ("ParseMembers: found field '{0}'", name); field.Parent = parent; parent.Children.Add (field); if (tokenizer.Accept (Token2Type.Punctuation, "[")) { while (!tokenizer.Accept (Token2Type.Punctuation, "]")) { tokenizer.Advance (true); } } if (tokenizer.Accept (Token2Type.Punctuation, ":")) { field.BitField = tokenizer.GetIdentifier (); } if (tokenizer.Accept (Token2Type.Punctuation, ",")) { field = new FieldInfo (); if (tokenizer.Accept (Token2Type.Punctuation, "*")) { // ok } field.Name = tokenizer.GetIdentifier (); field.FieldType = returntype; continue; } if (tokenizer.Accept (Token2Type.Punctuation, "=")) { tokenizer.Advance (true); /* this can be an arbitrary long expression, sync with the ';'? */ } break; } while (true); tokenizer.Accept (Token2Type.Punctuation, ";"); } } } while (true); }