mutant

package
v0.0.0-...-56ca850 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Trace bool = true

Functions

func ContainerName

func ContainerName(blockType string) string

func DescribeQuark

func DescribeQuark(q Quark) block.Dict

make blockly compatible description of the quark's mui block

func MutatorName

func MutatorName(blockType string) string

func PaletteQuarks

func PaletteQuarks(quarks Quarks) (ret []string)

return a list of blocks used in a palette; exludes the fixed block if any.

func RegisterQuarks

func RegisterQuarks(p block.Project, qs Quarks) (err error)

func RemoveAtoms

func RemoveAtoms(b block.Inputs)

Types

type AtomizedInput

type AtomizedInput struct {
	Name string // mui block guid
	Type string // type that was created
}

func (*AtomizedInput) String

func (a *AtomizedInput) String() string

type Atomizer

type Atomizer interface {
	// return choices for the passed (pre-registered) enum.
	GetPairs(string) []enum.Pair
	// lookup the limits of the passed block type
	GetTerms(string) (block.Limits, error)
	// lookup the limits of the passed block type
	GetStatements(string) (block.Limits, error)

	// a work in progress: interfaces arent registered to blockly
	// so they cant be found by type name; we need typename tho for loading from xml.
	GetTermsByType(r.Type) block.Limits
	GetStatementsByType(r.Type) block.Limits
}

interface for creating, listening to atom expansion

type BlockMutations

type BlockMutations struct {
	Inputs    []string            // ordered input names (b/c golang maps are unordered)
	Mutations map[string]Mutation // input name to mutation info interface
}

descriptions of the mutable inputs for a given type of block.

func (*BlockMutations) AddMutation

func (m *BlockMutations) AddMutation(inputName string, arch Mutation)

func (*BlockMutations) DescribeContainer

func (m *BlockMutations) DescribeContainer(containerName string) (ret block.Dict)

produce a description of the mui container. each input in the container represents a mutable input in the workspace block.

func (*BlockMutations) GetMutation

func (m *BlockMutations) GetMutation(n string) (ret Mutation, okay bool)

return the mutation description for the passed input name.

func (*BlockMutations) Mutates

func (m *BlockMutations) Mutates() bool

does this block type have any mutations?

func (*BlockMutations) Preregister

func (m *BlockMutations) Preregister(blockType string, p block.Project) (err error)

register the mui container and all of its mui blocks with blockly

func (*BlockMutations) Quarks

func (m *BlockMutations) Quarks(paletteOnly bool) (ret Quark, okay bool)

visit all quarks defined by all input mutations

type MutatedBlock

type MutatedBlock struct {
	// contains filtered or unexported fields
}

each mutable workspace block contains one or more mutable inputs containing a list of atoms and connections to existing workspace blocks.

func (*MutatedBlock) ContainerName

func (mb *MutatedBlock) ContainerName() string

func (*MutatedBlock) CreateFromMui

func (mb *MutatedBlock) CreateFromMui(muiContainer block.Shape) (err error)

aka. compose -- turn the mui into new workspace inputs adds new inputs to target, returns the atoms for those inputs

func (*MutatedBlock) CreateMui

func (mb *MutatedBlock) CreateMui(mui block.Workspace) (ret block.Shape, err error)

CreateMui from existing workspace blocks. ( aka decompose )

func (*MutatedBlock) GetMutatedInput

func (mb *MutatedBlock) GetMutatedInput(inputName string) (ret *MutatedInput, okay bool)

returns a MutatedInput if the named input was mutable.

func (*MutatedBlock) LoadMutation

func (mb *MutatedBlock) LoadMutation(els *dom.BlockMutation) (err error)

LoadMutation, creating workspace inputs based on the recorded mutation

func (*MutatedBlock) SaveConnections

func (mb *MutatedBlock) SaveConnections(muiContainer block.Shape) Storage

SaveConnections happens before any mui transformation

func (*MutatedBlock) SaveMutation

func (mb *MutatedBlock) SaveMutation() (ret dom.BlockMutation)

serialize the mutation to xml friendly data

type MutatedBlocks

type MutatedBlocks struct {
	// contains filtered or unexported fields
}

maps workspace blocks to user edited mutation data. shared across every Mutator.

func NewMutatedBlocks

func NewMutatedBlocks() *MutatedBlocks

create a new of mutable blocks. these blocks are editable by the user using the mutation ui.

func (*MutatedBlocks) CreateMutatedBlock

func (mbs *MutatedBlocks) CreateMutatedBlock(main block.Shape, arch *BlockMutations, atomizer Atomizer) (ret *MutatedBlock)

func (*MutatedBlocks) GetMutatedBlock

func (mbs *MutatedBlocks) GetMutatedBlock(main block.Shape) (*MutatedBlock, bool)

func (*MutatedBlocks) OnDelete

func (mbs *MutatedBlocks) OnDelete(wsId, blockId string)

type MutatedInput

type MutatedInput struct {
	InputName string
	// mutation that created us.
	Arch Mutation
	// list atoms created by the user
	Atoms []*AtomizedInput
}

type Mutation

type Mutation interface {
	// name of the original mutation type ( in blockly friendly format )
	Name() string
	// quarks which can directly attach to the mutation's input
	Limits() block.Limits
	// returns an optional fixed-in-place first quark
	FirstBlock() (Quark, bool)
	// all quarks (mui bock types) available for this mutation
	Quarks(paletteOnly bool) (Quark, bool)
}

the description of a single input's mutation

type Mutator

type Mutator struct {
	// contains filtered or unexported fields
}

instance data for mutations implements block.Mutator

func NewMutator

func NewMutator(arch *BlockMutations, db Atomizer, mbs *MutatedBlocks) *Mutator

func (*Mutator) Compose

func (a *Mutator) Compose(main, mui block.Shape) (err error)

create workspace inputs from the atoms the user selected and arranged in the mui popup

func (*Mutator) Decompose

func (a *Mutator) Decompose(main block.Shape, popup block.Workspace) (block.Shape, error)

create the mui container from workspace data.

func (*Mutator) DomToMutation

func (a *Mutator) DomToMutation(main block.Shape, str string) (err error)

func (*Mutator) MutationToDom

func (a *Mutator) MutationToDom(main block.Shape) (ret string, err error)

func (*Mutator) PostMixin

func (a *Mutator) PostMixin(b block.Shape) (err error)

func (*Mutator) Quarks

func (a *Mutator) Quarks() (ret []string)

func (*Mutator) SaveConnections

func (a *Mutator) SaveConnections(main, mui block.Shape) (err error)

type Quark

type Quark interface {
	// type name without including owner mutation
	Name() string
	// type name scoped to the owner mutation
	BlockType() string
	// mui block display name
	Label() string
	// the quark (names) this can connect to
	LimitsOfNext() block.Limits
	// expand this quark into a bundle of workspace items (fields and inputs)
	// item names are prefixed with "scope" to make them unique.
	Atomize(scope string, atomizer Atomizer) (block.Args, error)
	// next quark in the mutation
	NextQuark() (Quark, bool)
}

Quark - a block in a mutation ui palette. supports iteration to the next quark in the palette.

func FindQuark

func FindQuark(quarks Quarks, name string) (ret Quark, okay bool)

find a quark with the passed full or short name

type Quarks

type Quarks interface {
	Quarks(paletteOnly bool) (Quark, bool)
}

type Storage

type Storage map[string]Store

type Store

type Store struct {
	// contains filtered or unexported fields
}

FIX: storing fields

func (*Store) Connections

func (s *Store) Connections() []block.Connection

func (*Store) Restore

func (s *Store) Restore(b block.Shape, start, numInputs int)

FIX: this isnt going to be right for fields, etc.

func (*Store) SaveConnection

func (s *Store) SaveConnection(in block.Input)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL