bam

package
v0.0.0-...-7050ccd Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const NotEmbedded = false
View Source
const NotList = false
View Source
const YesEmbedded = true
View Source
const YesIsList = true

Variables

View Source
var Verbose bool

for debug output

Functions

func CanonCapType

func CanonCapType(capTypeSeq []string) string

func CanonGoType

func CanonGoType(goTypeSeq []string) string

func CapnpCompilePath

func CapnpCompilePath(fname string) (generatedGoFile []byte, comboOut []byte, err error)

func Cp

func Cp(originPath, destinationPath string) (err error)

Cp implements a portable version of /bin/cp for use in golang code that wants to work on many platforms. If the destinationPath directory hierarchy does not exist, we will attempt to make it, like mkdir -p would.

func DirExists

func DirExists(name string) bool

func ExtraSpaces

func ExtraSpaces(fieldNum int) string

func ExtractCapnToGoCode

func ExtractCapnToGoCode(src string, goName string) string

func ExtractFromString

func ExtractFromString(src string) ([]byte, error)

func ExtractGoToCapnCode

func ExtractGoToCapnCode(src string, goName string) string

func ExtractString2String

func ExtractString2String(src string) string

func ExtractStructs

func ExtractStructs(fname string, src interface{}, x *Extractor) ([]byte, error)

ExtractStructs pulls out the struct definitions from a golang source file.

src has to be string, []byte, or io.Reader, as in parser.ParseFile(). src can be nil if fname is provided. See http://golang.org/pkg/go/parser/#ParseFile

func FileExists

func FileExists(name string) bool

func GetTypeAsString

func GetTypeAsString(ty ast.Expr, sofar string, goTypeSeq []string) (string, string, []string)

recursively extract the go type as a string

func GoType2CapnType

func GoType2CapnType(gotypeName string) string

func IsDirPath

func IsDirPath(dir string) bool

func IsDoubleList

func IsDoubleList(f *Field) bool

func IsIntrinsicGoType

func IsIntrinsicGoType(goFieldTypeName string) bool

func IsSlice

func IsSlice(tnas string) bool

func LowercaseCapnpFieldName

func LowercaseCapnpFieldName(name string) string

func SetSpaces

func SetSpaces(spaces *string, Max int, Len int)

func TSPrintf

func TSPrintf(format string, a ...interface{})

time-stamped printf

func UppercaseFirstLetter

func UppercaseFirstLetter(name string) string

func VPrintf

func VPrintf(format string, a ...interface{})

print debug/status conditionally on having Verbose on

Types

type AlphaHelper

type AlphaHelper struct {
	Name string
	Code []byte
}

type AlphaHelperSlice

type AlphaHelperSlice []AlphaHelper

func (AlphaHelperSlice) Len

func (s AlphaHelperSlice) Len() int

func (AlphaHelperSlice) Less

func (s AlphaHelperSlice) Less(i, j int) bool

func (AlphaHelperSlice) Swap

func (s AlphaHelperSlice) Swap(i, j int)

type ByFinalOrder

type ByFinalOrder []*Field

func (ByFinalOrder) Len

func (s ByFinalOrder) Len() int

func (ByFinalOrder) Less

func (s ByFinalOrder) Less(i, j int) bool

func (ByFinalOrder) Swap

func (s ByFinalOrder) Swap(i, j int)

type ByGoName

type ByGoName []*Struct

func (ByGoName) Len

func (s ByGoName) Len() int

func (ByGoName) Less

func (s ByGoName) Less(i, j int) bool

func (ByGoName) Swap

func (s ByGoName) Swap(i, j int)

type ByOrderOfAppearance

type ByOrderOfAppearance []*Field

func (ByOrderOfAppearance) Len

func (s ByOrderOfAppearance) Len() int

func (ByOrderOfAppearance) Less

func (s ByOrderOfAppearance) Less(i, j int) bool

func (ByOrderOfAppearance) Swap

func (s ByOrderOfAppearance) Swap(i, j int)

type Extractor

type Extractor struct {
	PkgName string

	FieldPrefix string
	FieldSuffix string

	ExtractPrivate bool

	ToGoCode   map[string][]byte
	ToCapnCode map[string][]byte
	SaveCode   map[string][]byte
	LoadCode   map[string][]byte
	CapnUnion  map[string][]byte

	// key is CanonGoType(goTypeSeq)
	SliceToListCode map[string][]byte
	ListToSliceCode map[string][]byte

	CompileDir *TempDir
	OutDir     string

	Overwrite bool

	// fields for testing capid tagging
	PubABC int `capid:"1"`
	PubYXZ int `capid:"0"`
	PubDEF int
	// contains filtered or unexported fields
}

func CapnpCompileFragment

func CapnpCompileFragment(in []byte) ([]byte, error, *Extractor)

func NewExtractor

func NewExtractor() *Extractor

func (*Extractor) AssembleCapnpFile

func (x *Extractor) AssembleCapnpFile(in []byte) *bytes.Buffer

func (*Extractor) CapnTypeToGoType

func (x *Extractor) CapnTypeToGoType(capTypeSeq []string) (goTypeSeq []string, displayGoCapGoType string)

func (*Extractor) CapnpCompileFragment

func (x *Extractor) CapnpCompileFragment(in []byte) ([]byte, error)

func (*Extractor) Cleanup

func (x *Extractor) Cleanup()

func (*Extractor) CopySourceFilesAddCapidTag

func (x *Extractor) CopySourceFilesAddCapidTag() error

func (*Extractor) ElemStarCapToGo

func (x *Extractor) ElemStarCapToGo(addStar string, f *Field) string

func (*Extractor) EndStruct

func (x *Extractor) EndStruct()

func (*Extractor) ExtractStructsFromOneFile

func (x *Extractor) ExtractStructsFromOneFile(src interface{}, fname string) ([]byte, error)

func (*Extractor) GenCapidTag

func (x *Extractor) GenCapidTag(f *Field) string

func (*Extractor) GenCapnpHeader

func (x *Extractor) GenCapnpHeader() *bytes.Buffer

func (*Extractor) GenerateComment

func (x *Extractor) GenerateComment(c string)

func (*Extractor) GenerateEmbedded

func (x *Extractor) GenerateEmbedded(typeName string)

func (*Extractor) GenerateListHelpers

func (x *Extractor) GenerateListHelpers(f *Field, capListTypeSeq []string, goTypeSeq []string)

func (*Extractor) GenerateStructField

func (x *Extractor) GenerateStructField(goFieldName string, goFieldTypePrefix string, goFieldTypeName string, astfld *ast.Field, isList bool, tag *ast.BasicLit, IsEmbedded bool, goTypeSeq []string) error

func (*Extractor) GenerateTranslators

func (x *Extractor) GenerateTranslators()

func (*Extractor) GoTypeToCapnpType

func (x *Extractor) GoTypeToCapnpType(curField *Field, goTypeSeq []string) (capTypeSeq []string, capnTypeDisplayed string)

func (*Extractor) ListToSliceSetLHS_RHS

func (x *Extractor) ListToSliceSetLHS_RHS(baseIsIntrinsic bool, capName string, goBaseType string) string

func (*Extractor) NewEnum

func (x *Extractor) NewEnum(typeName string)

func (*Extractor) NoteTypedef

func (x *Extractor) NoteTypedef(goNewTypeName string, goTargetTypeName string)

func (*Extractor) PrettyPrint

func (x *Extractor) PrettyPrint(fileSet *token.FileSet, astfile *ast.File, fn string) error

PrettyPrint out the go source file we read in.

func (*Extractor) SetUnionStruct

func (x *Extractor) SetUnionStruct()

func (*Extractor) SettersToCapn

func (x *Extractor) SettersToCapn(goName string) string

func (*Extractor) SettersToGo

func (x *Extractor) SettersToGo(goName string) string

func (*Extractor) SettersToGoListHelper

func (x *Extractor) SettersToGoListHelper(buf io.Writer, myStruct *Struct, f *Field)

func (*Extractor) SliceToListSetRHS

func (x *Extractor) SliceToListSetRHS(baseIsIntrinsic bool, goName string, c2g string) string

func (*Extractor) StartStruct

func (x *Extractor) StartStruct(goName string) error

func (*Extractor) ToCapnCodeFor

func (x *Extractor) ToCapnCodeFor(goStructName string) []byte

func (*Extractor) ToGoCodeFor

func (x *Extractor) ToGoCodeFor(goName string) []byte

func (*Extractor) WriteToSchema

func (x *Extractor) WriteToSchema(w io.Writer) (n int64, err error)

func (*Extractor) WriteToTranslators

func (x *Extractor) WriteToTranslators(w io.Writer) (n int64, err error)

type Field

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

type SrcFile

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

type Struct

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

func NewStruct

func NewStruct(capName, goName string) *Struct

type TempDir

type TempDir struct {
	OrigDir string
	DirPath string
	Files   map[string]*os.File
}

func NewTempDir

func NewTempDir() *TempDir

func (*TempDir) Cleanup

func (d *TempDir) Cleanup()

func (*TempDir) Close

func (d *TempDir) Close()

func (*TempDir) MoveTo

func (d *TempDir) MoveTo()

func (*TempDir) TempFile

func (d *TempDir) TempFile() *os.File

Jump to

Keyboard shortcuts

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