Help us shape the future of Go! Take the 2026 Go Developer Survey

cl

package
v0.9.5 Latest Latest
Warning

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

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

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

func SetDebug

func SetDebug(flags int)

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

	// 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

	// 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

	// TypeAbbr specifies a mapping of Go type name to its abbreviated name(s). The abbreviated
	// name(s) can be a name or name list. They will be used in function names (optional).
	TypeAbbr map[string]any

	// TypeAbbrSuffix specifies the suffix to remove from Go type name when generating function
	// names. It is only valid for types that are not present in TypeAbbr (optional).
	TypeAbbrSuffix []string

	// TypePrefix/TypeSuffix specifies the prefix/suffix to remove from C/C++ type names
	// when generating Go type names (optional).
	TypePrefix, TypeSuffix []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

	// 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

	// NonClass specifies a list of C/C++ typedef names to be treated as non-classes (optional).
	NonClass []string

	// DefaultGoFile specifies default file name (optional).
	DefaultGoFile string

	// 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

	// 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

	// DontKeepDoc specifies whether to keep the documentation comments in the generated
	// Go package. If true, the documentation comments will be removed (optional).
	DontKeepDoc bool
}

Config specifies the configuration for llcppg.

type Entry added in v0.9.0

type Entry struct {
	Name   string
	GoName string    // optional
	Tag    typeTag   // only valid for Kind == 'T'
	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.

const (
	LanguageC Language = iota
	LanguageCXX
)

type Package

type Package struct {
	*gogen.Package
	Wrap   *WrapFile
	Public []Entry // public entries
}

Package represents a generated Go package from a C/C++ library.

func NewPackage

func NewPackage(pkgPath, pkgName string, files []Source, conf *Config) (ret Package, err error)

NewPackage loads translation units and generates a Go package with the given package path, name and configuration.

type Source added in v0.9.0

type Source = clang.TranslationUnit

Source represents a source file to be processed by llcppg.

type WrapFile added in v0.9.0

type WrapFile struct {
	Filename string
	Content  bytes.Buffer
}

Jump to

Keyboard shortcuts

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