tool

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbgFlagSettings = 1 << iota
	DbgFlagAll      = DbgFlagSettings
)

Variables

View Source
var (
	// ErrDirRequired is returned when the Dir field in the configuration is empty.
	// It indicates that the directory containing the header files is required.
	ErrDirRequired = errors.New("Dir (contains the header files) 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 ParseFlags added in v0.9.2

func ParseFlags(includeDirs []string, lang string) []string

ParseFlags constructs the command-line flags for parsing C/C++ source files with clang.

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, sub package name should start with '/'
	Language       string            `json:"Language"`       // c, c++, etc. required
	Dir            string            `json:"Dir"`            // dir or dir/... (recursive), required
	Files          []string          `json:"Files"`          // selected header files relative to Dir; overrides auto-discovery, optional.
	Stdlib         string            `json:"Stdlib"`         // C stdlib include dir, optional
	LLGoPackage    string            `json:"LLGoPackage"`    // optional
	CFlags         string            `json:"CFlags"`         // optional
	Deps           []string          `json:"Deps"`           // dependencies (module 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
	NSPrefix       []string          `json:"NSPrefix"`       // namespace prefix to remove
	FuncPrefix     []string          `json:"FuncPrefix"`     // global function prefix to remove
	VarPrefix      []string          `json:"VarPrefix"`      // global variable prefix to remove
	EnumPrefix     []string          `json:"EnumPrefix"`     // enum value prefix to remove
	MacroPrefix    []string          `json:"MacroPrefix"`    // macro prefix to remove
	TypePrefix     []string          `json:"TypePrefix"`     // type prefix to remove
	TypeSuffix     []string          `json:"TypeSuffix"`     // type suffix to remove
	TypeAbbrSuffix []string          `json:"TypeAbbrSuffix"` // type abbr suffix to remove, only valid for types that are not present in TypeAbbr
	TypeAbbr       map[string]any    `json:"TypeAbbr"`       // Go type name to its abbr(s), used in function names
	Rename         map[string]string `json:"Rename"`         // renaming of C/C++ names to Go names
	TypeAlias      map[string]string `json:"TypeAlias"`      // C/C++ type name to another C/C++ type name
	TypeIgnore     []string          `json:"TypeIgnore"`     // C/C++ type names to ignore
	MacroIgnore    []string          `json:"MacroIgnore"`    // C/C++ macro names to ignore
	NSIgnore       []string          `json:"NSIgnore"`       // namespaces (Go style names) to ignore
	Pkgs           []string          `json:"Pkgs"`           // sub-packages to generate, optional
	FailFast       int               `json:"FailFast"`       // exit on first N errors, optional
	IgnoreInline   bool              `json:"IgnoreInline"`   // quietly ignore inline functions
	GroupSubdir    bool              `json:"GroupSubdir"`    // treats sub-directory files as a single file
}

func LoadConf added in v0.9.0

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

LoadConf loads the llcppg configuration.

func (*Config) Apply added in v0.9.2

func (cfg *Config) Apply(parent *Config)

Apply applies the parent configuration to the current 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, pkgName, 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.

func (*Config) StdlibDirs added in v0.9.2

func (cfg *Config) StdlibDirs(workDir string) []string

StdlibDirs returns the standard library include directories.

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) IncludeDir added in v0.9.2

func (p Module) IncludeDir(modPath string) (includeDir string, err error)

IncludeDir returns the include directory for the specified module path. It looks up the module version in the go.mod file and retrieves the include directory from the module cache.

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