Documentation
¶
Index ¶
Constants ¶
View Source
const ( DbgFlagCompileDecl = 1 << iota DbgFlagMajorProc DbgFlagQuietIgnore DbgFlagAll = DbgFlagCompileDecl | DbgFlagMajorProc | DbgFlagQuietIgnore )
View Source
const (
QuietIgnore = featQuietIgnore
)
Variables ¶
View Source
var ( InlineFuncIgnore = featExplicitIgnore NoManglingIgnore = featExplicitIgnore )
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Fset provides source position information for syntax trees and types (optional).
// If Fset is nil, Load will use a new fileset, but preserve Fset's value.
Fset *token.FileSet
// An Importer resolves import paths to Packages (optional).
Importer types.Importer
// LLGoPackage specifies the value of the LLGoPackage constant in the generated
// Go package (optional).
LLGoPackage string
// Language specifies the programming language of the header file (default LanguageC).
Language Language
// 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
// WrapFileHeader specifies the header content to be included at the top of the generated
// wrapper file (optional).
WrapFileHeader string
// PackageOf returns the package path for a given header file. If ok is false, it means
// we don't know the package path for the header file. If not specified, llcppg will
// assume all header files belong to the same package.
PackageOf func(headerFile string) (pkgPath string, ok bool)
// PubFileLookup looks up the public file for a given package path. A public file is
// a text file that contains a list of public C/C++ names and their corresponding Go
// names (required).
PubFileLookup func(pkgPath string) (pubFile string, ok bool)
// NameLookup looks up the archive path for a given mangling name. It returns the
// archive path and a boolean indicating whether the lookup was successful. If not
// specified, llcppg uses a default lookup function that returns an empty archivePath
// and true (it means any mangling name is considered found).
NameLookup func(manglingName string) (archivePath string, ok bool)
// 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
// NSIgnore specifies a list of C/C++ namespaces to be ignored (optional).
NSIgnore []string
// MacroIgnore specifies a list of C/C++ macro names to be ignored (optional).
MacroIgnore []string
// MacroFunc maps a function-like C macro name to the name of a reference
// function declared in the processed headers (optional). Each listed macro is
// wrapped as a function the same way static inline functions are: llcppg emits
// a C wrapper whose body invokes the macro, and a Go declaration linking to it.
// The reference function supplies the wrapper's return type and the parameter
// types (matched to the macro's parameters by name, then by position).
// See https://github.com/goplus/llcppg/issues/1051.
MacroFunc map[string]string
// MacroGroup declares groups of related constant macros that are emitted
// together as a single Go `const ( ... )` block (optional). It maps the
// first macro of a group to its last macro; every macro definition between
// them in source order (inclusive) belongs to the group, regardless of blank
// lines or comments. Names are the original C macro names, before MacroPrefix
// stripping or renaming. The first and last macro must live in the same
// header file: a range that crosses a header boundary is a configuration
// error. Configured groups take priority over automatic detection, which
// groups runs of adjacent constant macros of the same type.
// See https://github.com/goplus/llcppg/issues/1064.
MacroGroup map[string]string
// TypeIgnore specifies a list of C/C++ type names to be ignored (optional).
TypeIgnore []string
// FuncIgnore specifies a list of C/C++ function names to be ignored (optional).
FuncIgnore []string
// FieldAlias overrides the Go name and type of C/C++ fields (optional).
// See https://github.com/xgo-dev/llcppg/issues/1019.
FieldAlias map[string]string
// TypeAlias specifies a mapping of C/C++ type names to a Go type name (alias) in
// pkgPath.Name format (pkgPath can be empty if Name is in current package), optional.
//
// alias = "void (ignore this type, as an empty class)"
// alias = ".StdBasicString[byte, c.Void, c.Void]"
// alias = ".Iterator"
// alias = "[_Derived, _Category, _Tp, _Distance, _Pointer, _Reference] = .Iterator[_Category, _Tp, _Distance, _Pointer, _Reference]"
//
// See https://github.com/xgo-dev/llcppg/issues/929.
TypeAlias map[string]string
// 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
// TypePrefix/TypeSuffix specifies the prefix/suffix to remove from C/C++ type names
// when generating Go type names (optional).
TypePrefix, TypeSuffix []string
// MethodPrefix specifies a literal prefix to remove from the names of methods associated
// with a Go type (optional). The key is the Go type name and the value is the prefix in
// the original C/C++ function name. See https://github.com/goplus/llcppg/issues/1061.
MethodPrefix map[string]string
// EnumPrefix specifies the prefix to remove from C/C++ enum value names when generating
// Go const names (optional).
EnumPrefix []string
// MacroPrefix specifies the prefix to remove from C/C++ macro names when generating
// Go const names (optional).
MacroPrefix []string
// Type Creator Detection (optional). See https://github.com/xgo-dev/llcppg/issues/960.
NewCheck []string
// Type Method Detection (optional). See https://github.com/xgo-dev/llcppg/issues/955.
MethodCheck []string
// FuncPrefix specifies the prefix to remove from C/C++ global function names when
// generating Go function names (optional).
FuncPrefix []string
// VarPrefix specifies the prefix to remove from C/C++ global variable names when
// generating Go variable names (optional).
VarPrefix []string
// NSPrefix specifies the prefix to remove from C/C++ namespace names when generating
// Go package names (optional).
NSPrefix []string
// Class specifies a list of C/C++ typedef names to be treated as classes (optional).
Class []string
// 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
// DefaultGoFile specifies default file name (optional).
DefaultGoFile string
// Define specifies user constants to inject into the generated package (optional).
Define []Define
// GoFileOf returns the Go file name for a given header file (optional). If ok is false,
// it means we don't know the Go file name for the header file and this header file will
// be skipped. If not specified, llcppg will use the default Go file name (DefaultGoFile)
// for all header files.
GoFileOf func(headerFile string) (string, bool)
// FailFast specifies whether to fail fast on errors (optional). If FailFast is non-zero,
// llcppg will stop after printing errors `FailFast` times.
FailFast int
// ForceCamelCase converts capitalized, underscore-joined names to camel case (optional),
// except names whose final segment is all-uppercase (acronyms/macros), which are kept
// as-is.
ForceCamelCase bool
// LoadLibcPubFile specifies whether to load the pubFile for libc package (optional).
LoadLibcPubFile bool
// UseStdRecvName specifies whether to use a standard receiver name (self) for C functions
// converted to Go methods (optional). If false, the receiver name is taken from the first
// parameter name. This option does not affect C++ instance methods, whose receiver is
// always named this.
UseStdRecvName bool
}
Config specifies the configuration for llcppg.
type Define ¶ added in v0.12.1
Define represents a user constant to be injected into the generated package.
type Entry ¶ added in v0.9.0
type Entry struct {
Name string
GoName string // optional; omitted names use externName, independent of llcppg.cfg
Kind entryKind // 'T' (type), 'f' (func), 'v' (var), 'D' (dependency)
}
Entry represents a C/C++ name and its corresponding Go name.
type Language ¶ added in v0.9.0
type Language int
Language specifies the programming language of the header file.
type Source ¶ added in v0.9.0
type Source = clang.TranslationUnit
Source represents a source file to be processed by llcppg.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.