cl

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 (
	DbgFlagCompileDecl = 1 << iota
	DbgFlagImport
	DbgFlagAll = DbgFlagCompileDecl | DbgFlagImport
)

Variables

This section is empty.

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)

	// Ignore specifies a list of C/C++ names to be ignored (optional).
	Ignore []string

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

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

	// TypePrefix specifies the prefix to remove from C/C++ type names when generating Go
	// type names (optional).
	TypePrefix []string

	// EnumPrefix specifies the prefix to remove from C/C++ enum value names when generating
	// Go const names (optional).
	EnumPrefix []string

	// FuncPrefix specifies the prefix to remove from C/C++ global function names when
	// generating Go function names (optional).
	FuncPrefix []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

	// GenMultiGoFiles specifies whether to generate multiple Go files for each header file.
	GenMultiGoFiles 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 a translation unit 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