From 461c6d9864f1981fa764784fea268abf4697a911 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Sun, 29 Dec 2024 21:47:55 -0800 Subject: [PATCH] typegen bootstrap --- examples/random/random.go | 4 ++-- examples/random/typegen.go | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/random/random.go b/examples/random/random.go index 42d1d9e..d43e7cd 100644 --- a/examples/random/random.go +++ b/examples/random/random.go @@ -5,7 +5,7 @@ // Package random plots histograms of random distributions. package main -//go:generate core generate -add-types +//go:generate core generate import ( "cogentcore.org/core/base/metadata" @@ -25,7 +25,7 @@ import ( ) // Random is the random distribution plotter widget. -type Random struct { //types:add +type Random struct { core.Frame Data } diff --git a/examples/random/typegen.go b/examples/random/typegen.go index 9394647..8f4576e 100644 --- a/examples/random/typegen.go +++ b/examples/random/typegen.go @@ -1,11 +1,16 @@ -// Code generated by "core generate -add-types"; DO NOT EDIT. +// Code generated by "core generate"; DO NOT EDIT. package main import ( + "cogentcore.org/core/tree" "cogentcore.org/core/types" ) -var _ = types.AddType(&types.Type{Name: "main.Random", IDName: "random", Doc: "Random is the random distribution plotter widget.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Methods: []types.Method{{Name: "Plot", Doc: "Plot generates the data and plots a histogram of results.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "Frame"}, {Name: "Data"}}}) +var _ = types.AddType(&types.Type{Name: "main.Random", IDName: "random", Doc: "Random is the random distribution plotter widget.", Methods: []types.Method{{Name: "Plot", Doc: "Plot generates the data and plots a histogram of results.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}}}, Embeds: []types.Field{{Name: "Frame"}, {Name: "Data"}}}) + +// NewRandom returns a new [Random] with the given optional parent: +// Random is the random distribution plotter widget. +func NewRandom(parent ...tree.Node) *Random { return tree.New[Random](parent...) } var _ = types.AddType(&types.Type{Name: "main.Data", IDName: "data", Doc: "Data contains the random distribution plotter data and options.", Directives: []types.Directive{{Tool: "types", Directive: "add"}}, Fields: []types.Field{{Name: "Dist", Doc: "random params"}, {Name: "NumSamples", Doc: "number of samples"}, {Name: "NumBins", Doc: "number of bins in the histogram"}, {Name: "Range", Doc: "range for histogram"}, {Name: "Table", Doc: "table for raw data"}, {Name: "Histogram", Doc: "histogram of data"}, {Name: "plot", Doc: "the plot"}}})