tool

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbgFlagLoadSource = 1 << iota
	DbgFlagImport
	DbgFlagAll = DbgFlagLoadSource | DbgFlagImport
)

Variables

View Source
var (
	// ErrStdlibRequired is returned when the stdlib field is not specified in the
	// configuration.
	ErrStdlibRequired = errors.New("stdlib is required")
)
View Source
var (
	// GeneratedHeader is the header comment for llcppg generated Go files.
	GeneratedHeader = "// Code generated by llcppg; DO NOT EDIT.\n\n"
)

Functions

func DisposeSources added in v0.9.0

func DisposeSources(sources []cl.Source)

DisposeSources disposes the given translation units.

func Dump added in v0.9.0

func Dump(node clang.Cursor, ns, dir string)

func Gen added in v0.9.0

func Gen(destDir, srcDir string, index clang.Index) (err error)

Gen generates Go files from the C/C++ header files and llcppg.cfg in the specified source directory and writes them to the destination directory. It uses the provided clang index for parsing.

func ParseSources added in v0.9.0

func ParseSources(index clang.Index, headerFiles, includeDirs []string, lang string) ([]cl.Source, error)

ParseSources parses the given source files and returns the translation units corresponding to those files.

func SetDebug added in v0.9.0

func SetDebug(flags int)

Types

type Config

type Config struct {
	Name        string            `json:"Name"`        // required
	Language    string            `json:"Language"`    // c, c++, etc. required
	Dir         string            `json:"Dir"`         // dir or dir/... (recursive), required
	Stdlib      string            `json:"Stdlib"`      // C stdlib include dir, required
	LLGoPackage string            `json:"LLGoPackage"` // optional
	CFlags      string            `json:"CFlags"`      // optional
	Deps        []string          `json:"Deps"`        // dependencies (package paths), optional
	Class       []string          `json:"Class"`       // typedef names to be treated as classes
	NonClass    []string          `json:"NonClass"`    // typedef names to be treated as non-classes
	FuncPrefix  []string          `json:"FuncPrefix"`  // global function prefix to remove
	EnumPrefix  []string          `json:"EnumPrefix"`  // enum value prefix to remove
	TypePrefix  []string          `json:"TypePrefix"`  // type prefix to remove
	TypeAbbr    map[string]string `json:"TypeAbbr"`    // Go type name to its abbr, used in function names
	Rename      map[string]string `json:"Rename"`      // renaming of C/C++ names to Go names
	Ignore      []string          `json:"Ignore"`      // C/C++ names to ignore
}

func LoadConf added in v0.9.0

func LoadConf(filename string) (cfg Config, err error)

LoadConf loads the llcppg configuration.

func (*Config) Lang added in v0.9.0

func (cfg *Config) Lang() (lang cl.Language, ok bool)

Lang returns the language of the configuration.

func (*Config) NewPackage added in v0.9.0

func (cfg *Config) NewPackage(pkgPath, workDir string, index clang.Index) (ret cl.Package, lang cl.Language, err error)

NewPackage loads the source files and converts them into a Go package according to the configuration.

type Module added in v0.9.0

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

Module represents a llcppg module.

func LoadModuleFrom added in v0.9.0

func LoadModuleFrom(dir string) (ret Module, err error)

LoadModuleFrom loads a llcppg module from the specified directory.

func (Module) PubFileLookup added in v0.9.0

func (p Module) PubFileLookup(pkgPath string) (pubFile string, ok bool)

PubFileLookup looks up the public file for the given package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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