Documentation
¶
Index ¶
Constants ¶
const ( DbgFlagSettings = 1 << iota DbgFlagAll = DbgFlagSettings )
Variables ¶
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") )
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
DisposeSources disposes the given translation units.
func ParseFlags ¶ added in v0.9.2
ParseFlags constructs the command-line flags for parsing C/C++ source files with clang.
Types ¶
type Config ¶
type Config struct {
// Package Name (required). Sub-package name should start with '/'.
Name string `json:"Name"`
// Language (required). c, c++, etc.
Language string `json:"Language"`
// dir or dir/... (recursive), required
Dir string `json:"Dir"`
// selected header files relative to Dir; overrides auto-discovery, optional.
Files []string `json:"Files"`
// C stdlib include dir, optional
Stdlib string `json:"Stdlib"`
// LLGoPackage specifies the value of the LLGoPackage constant in the generated
// Go package (optional).
LLGoPackage string `json:"LLGoPackage"`
// CFlags specifies the compiler flags to be used when compiling the wrapper file.
// If not specified, llcppg will skip wrapping inline functions/methods.
CFlags string `json:"CFlags"`
// dependencies (module paths), optional
Deps []string `json:"Deps"`
// Class specifies a list of C/C++ typedef names to be treated as classes (optional).
Class []string `json:"Class"`
// 1) for typedef: NonClass specifies a list of C/C++ typedef names to be treated
// as non-classes.
// 2) for global function to method: NonClass specifies a list of Go type names to
// be treated as non-classes.
NonClass []string `json:"NonClass"`
// NSPrefix specifies the prefix to remove from C/C++ namespace names when generating
// Go package names (optional).
NSPrefix []string `json:"NSPrefix"` // C/C++ namespace prefix to remove
// Type Creator Detection (optional). See https://github.com/xgo-dev/llcppg/issues/960.
NewCheck []string `json:"NewCheck"`
// Type Method Detection (optional). See https://github.com/xgo-dev/llcppg/issues/955.
MethodCheck []string `json:"MethodCheck"`
// FuncPrefix specifies the prefix to remove from C/C++ global function names when
// generating Go function names (optional).
FuncPrefix []string `json:"FuncPrefix"`
// VarPrefix specifies the prefix to remove from C/C++ global variable names when
// generating Go variable names (optional).
VarPrefix []string `json:"VarPrefix"`
// EnumPrefix specifies the prefix to remove from C/C++ enum value names when generating
// Go const names (optional).
EnumPrefix []string `json:"EnumPrefix"`
// MacroPrefix specifies the prefix to remove from C/C++ macro names when generating
// Go const names (optional).
MacroPrefix []string `json:"MacroPrefix"`
// TypePrefix/TypeSuffix specifies the prefix/suffix to remove from C/C++ type names
// when generating Go type names (optional).
TypePrefix []string `json:"TypePrefix"`
TypeSuffix []string `json:"TypeSuffix"`
// TypeAbbr specifies abbreviated name for Go type names and will be used in function
// names (optional). See https://github.com/xgo-dev/llcppg/issues/958.
TypeAbbr []string `json:"TypeAbbr"`
// Rename specifies a mapping of C/C++ names to Go names (optional). If a name is present
// in the map, it will be renamed to the corresponding Go name.
Rename map[string]string `json:"Rename"`
// TypeAlias specifies a mapping of C/C++ type names to a Go type name in pkgPath.Name
// format (pkgPath can be empty if Name is in current package), optional.
TypeAlias map[string]string `json:"TypeAlias"`
// TypeIgnore specifies a list of C/C++ type names to be ignored (optional).
TypeIgnore []string `json:"TypeIgnore"`
// FuncIgnore specifies a list of C/C++ function names to be ignored (optional).
FuncIgnore []string `json:"FuncIgnore"`
// MacroIgnore specifies a list of C/C++ macro names to be ignored (optional).
MacroIgnore []string `json:"MacroIgnore"`
// NSIgnore specifies a list of C/C++ namespaces to be ignored (optional).
NSIgnore []string `json:"NSIgnore"`
// Sub-packages to generate, optional
Pkgs []string `json:"Pkgs"`
// exit on first N errors, optional
FailFast int `json:"FailFast"`
// convert capitalized, underscore-joined names to camel case, except names whose final
// segment is all-uppercase (acronyms/macros), which are kept as-is.
ForceCamelCase bool `json:"ForceCamelCase"`
// quietly ignore inline functions
IgnoreInline bool `json:"IgnoreInline"`
// quietly ignore functions with no mangled symbol
NoManglingIgnore bool `json:"NoManglingIgnore"`
// treats sub-directory files as a single file.
// Deprecated: use GroupSubdirBy instead.
GroupSubdir bool `json:"GroupSubdir"`
// criterion to group sub-directory files by, e.g., "dir" or "fname". `GroupSubdir = true`
// is equivalent to `GroupSubdirBy = "dir"`.
GroupSubdirBy string `json:"GroupSubdirBy"`
// IncludeDir specifies a function to determine the include directory for a given
// package path (optional).
IncludeDir func(pkgPath string) (includeDir string, err error) `json:"-"`
}
Config represents the configuration for the llcppg tool.
func (*Config) Apply ¶ added in v0.9.2
Apply applies the parent configuration to the current 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
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
LoadModuleFrom loads a llcppg module from the specified directory.
func (Module) IncludeDir ¶ added in v0.9.2
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.