code_file_build

package
v0.0.0-...-baa1c12 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ErrRepeatParse TODO maybe no use.
	ErrRepeatParse = "ErrRepeatParse"
)

Variables

This section is empty.

Functions

func CppImp

func CppImp(pkg string) string

CppImp import cpp pakcage.

func CppPkg

func CppPkg(cf *CodeFile, pkg string)

func GoImp

func GoImp(pkg string) string

GoImp import go pkg.

func GoPkg

func GoPkg(cf *CodeFile, pkg string)

func JavaImp

func JavaImp(pkg string) string

JavaImp import java pkg.

func LocalImportable

func LocalImportable(goPath string) map[string]string

func LocalImptTarget

func LocalImptTarget(goPath string, targetPaths ...string) map[string]string

Types

type BlockContainer

type BlockContainer interface {
	AddBlock(format string, a ...interface{}) *CodeBlock
}

BlockContainer who can create/add block.

type CFBImpFunc

type CFBImpFunc func(pkg string) string

CFBImpFunc write import. pkg is package name. for C/C++ is include file name. result is all include(import) line e.g. In C++: pkg = "cstdio" , out is "#include<cstdio>"

type CFBPkgFunc

type CFBPkgFunc func(cf *CodeFile, pkg string)

CFBPkgFunc about pkg's declear, for cpp is namespace.

type CodeBlock

type CodeBlock struct {
	smn_muti_write_cache.FileMutiWriteCacheItf

	BlockStart string // start of Block such as for cpp/go/java code is "{"
	BlockEnd   string //end of block, for cpp class is "};"
	BlockDef   string // block def such as in "for(){}" "for()"is def
	// contains filtered or unexported fields
}

CodeBlock {}.

func (*CodeBlock) AddBlock

func (cb *CodeBlock) AddBlock(format string, a ...interface{}) *CodeBlock

AddBlock add block.

func (*CodeBlock) Imports

func (cb *CodeBlock) Imports(imports ...string)

Imports import muti package.

func (*CodeBlock) IndentationAdd

func (cb *CodeBlock) IndentationAdd(n int)

IndentationAdd for code format.

func (*CodeBlock) Output

func (cb *CodeBlock) Output(oup io.Writer) (int, error)

Output let user can decide block head & tail.

func (*CodeBlock) Write

func (cb *CodeBlock) Write(format string, a ...interface{})

Write writef maybe better.

func (*CodeBlock) WriteLine

func (cb *CodeBlock) WriteLine(format string, a ...interface{})

WriteLine .

func (*CodeBlock) WriteToNewLine

func (cb *CodeBlock) WriteToNewLine(format string, a ...interface{})

WriteToNewLine .

type CodeFile

type CodeFile struct {
	smn_muti_write_cache.FileMutiWriteCacheItf
	// contains filtered or unexported fields
}

CodeFile create a lang's code file.

func NewCodeFile

func NewCodeFile(pkg string, w io.Writer, impFunc CFBImpFunc, pkgFunc CFBPkgFunc, comments ...string) *CodeFile

NewCodeFile create a new CodeFile.

func NewGoFile

func NewGoFile(pkg string, w io.Writer, comments ...string) *CodeFile

In order to be compatible with the previous code.

func (*CodeFile) AddBlock

func (cf *CodeFile) AddBlock(format string, a ...interface{}) *CodeBlock

AddBlock add a block like for{}.

func (*CodeFile) AddImports

func (cf *CodeFile) AddImports(imp map[string]string)

AddImports sometimes maybe can't give package's full-path.

func (*CodeFile) Import

func (cf *CodeFile) Import(str string) bool

Import import package.

func (*CodeFile) Imports

func (cf *CodeFile) Imports(imps ...string)

Imports do import.

func (*CodeFile) Output

func (cf *CodeFile) Output() (int, error)

Output write to file.

func (*CodeFile) Write

func (cf *CodeFile) Write(str string)

Write add a str cache.

func (*CodeFile) WriteLine

func (cf *CodeFile) WriteLine(str string)

WriteLine add on string line.

Jump to

Keyboard shortcuts

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