dotc

package
v0.0.0-...-917641f Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dotc implements code-generation tools for dot.changes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	Name, Key, Type                                           string
	Atomic                                                    bool
	ToValueFmt, FromValueFmt, ToStreamFmt, FromStreamValueFmt string
}

Field holds info for a struct field

func (Field) FromStreamValue

func (f Field) FromStreamValue(recv, field string) string

FromStreamValue returns the name of the associated stream type

func (Field) FromValue

func (f Field) FromValue(recv, field string) string

FromValue converts a changes.Value to the type of the field

func (Field) Getter

func (f Field) Getter() string

Getter returns the method name of the field getter

func (Field) Setter

func (f Field) Setter() string

Setter returns the method name of the field setter

func (Field) ToStreamType

func (f Field) ToStreamType() string

ToStreamType returns the name of the associated stream type

func (Field) ToValue

func (f Field) ToValue(recv, field string) string

ToValue converts a strongly typed field to changes.Value

type Info

type Info struct {
	Package       string
	Imports       [][2]string
	Structs       []Struct
	Unions        []Union
	Slices        []Slice
	StructStreams []Struct
	UnionStreams  []Union
	SliceStreams  []Slice
}

Info tracks all information used for code generation

func (Info) Generate

func (info Info) Generate() (result string, err error)

Generate implements the helper methods for the provided types

func (Info) GenerateTests

func (info Info) GenerateTests() (result string, err error)

GenerateTests generates the tests

type Slice

type Slice struct {
	Recv, Type, ElemType string
	Atomic               bool
}

Slice has the type information of a slice for code generation of the Apply(), ApplyCollection() and Splice() methods

func (Slice) Elem

func (s Slice) Elem() Field

Elem returns a field version of the element

func (Slice) GenerateApply

func (s Slice) GenerateApply(w io.Writer) error

GenerateApply generates the code for the changes.Value Apply() method and the ApplyCollection() method

func (Slice) GenerateSetters

func (s Slice) GenerateSetters(w io.Writer) error

GenerateSetters generates the code for the field setters

func (Slice) Item

func (s Slice) Item(index string) string

Item returns s.Recv[index]

func (Slice) Pointer

func (s Slice) Pointer() bool

Pointer checks if the slice type is a pointer

func (Slice) RawType

func (s Slice) RawType() string

RawType returns the non-pointer inner type if Type is a pointer

type SliceStream

type SliceStream Slice

SliceStream implements code generation for streams of slices

func (SliceStream) Elem

func (s SliceStream) Elem() Field

Elem simply proxies to Slice, needed because of template limitation

func (SliceStream) GenerateStream

func (s SliceStream) GenerateStream(w io.Writer) error

GenerateStream generates the stream implementation

func (SliceStream) GenerateStreamTests

func (s SliceStream) GenerateStreamTests(w io.Writer) error

GenerateStreamTests generates the stream tests

func (SliceStream) Pointer

func (s SliceStream) Pointer() bool

Pointer simply proxies to Slice, needed because of template limitation

func (SliceStream) RawType

func (s SliceStream) RawType() string

RawType simply proxies to Slice, needed because of template limitation

func (SliceStream) StreamType

func (s SliceStream) StreamType() string

StreamType provides the stream type of the struct

type Struct

type Struct struct {
	Recv, Type string
	Fields     []Field
}

Struct has the type information of a struct for code generation of the Apply() and SetField(..) methods

func (Struct) GenerateApply

func (s Struct) GenerateApply(w io.Writer) error

GenerateApply generates the code for the changes.Value Apply() method

func (Struct) GenerateSetters

func (s Struct) GenerateSetters(w io.Writer) error

GenerateSetters generates the code for the field setters

func (Struct) Pointer

func (s Struct) Pointer() bool

Pointer specifies if the struct type is itself a pointer

type StructStream

type StructStream Struct

StructStream implements code generation for streams of structs

func (StructStream) GenerateStream

func (s StructStream) GenerateStream(w io.Writer) error

GenerateStream generates the stream implementation

func (StructStream) GenerateStreamTests

func (s StructStream) GenerateStreamTests(w io.Writer) error

GenerateStreamTests generates the stream tests

func (StructStream) StreamType

func (s StructStream) StreamType() string

StreamType provides the stream type of the struct

type Union

type Union struct {
	Recv, Type string
	Fields     []Field
}

Union has the type information of a union for code generation of the Apply() and SetField(..) methods

func (Union) Ctor

func (s Union) Ctor() string

Ctor returns the type used to create this

func (Union) GenerateApply

func (s Union) GenerateApply(w io.Writer) error

GenerateApply generates the code for the changes.Value Apply() method

func (Union) GenerateSetters

func (s Union) GenerateSetters(w io.Writer) error

GenerateSetters generates the code for the field setters

func (Union) Pointer

func (s Union) Pointer() bool

Pointer specifies if the union type is itself a pointer

type UnionStream

type UnionStream Union

UnionStream implements stream functionality for unions

func (UnionStream) GenerateStream

func (s UnionStream) GenerateStream(w io.Writer) error

GenerateStream generates the stream implementation

func (UnionStream) GenerateStreamTests

func (s UnionStream) GenerateStreamTests(w io.Writer) error

GenerateStreamTests generates the stream tests

func (UnionStream) Pointer

func (s UnionStream) Pointer() bool

Pointer specifies if the struct type is itself a pointer

func (UnionStream) StreamType

func (s UnionStream) StreamType() string

StreamType provides the stream type of the struct

Jump to

Keyboard shortcuts

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