libs

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuiltinH = `cxgo_builtin.h`

	RuntimeOrg         = "github.com/gotranspile"
	RuntimePackage     = RuntimeOrg + "/cxgo"
	RuntimePackageVers = "main"
	RuntimePrefix      = RuntimePackage + "/runtime/"
	RuntimeLibc        = RuntimePrefix + "libc"
)
View Source
const IncludePath = "/_cxgo_overrides"
View Source
const (
	StdargH = "stdarg.h"
)
View Source
const (
	StdioH = "stdio.h"
)
View Source
const StdlibH = "stdlib.h"

Variables

This section is empty.

Functions

func RegisterLibrary

func RegisterLibrary(name string, fnc LibraryFunc)

RegisterLibrary registers an override for a C library.

Types

type Env

type Env struct {
	*types.Env
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv(conf types.Config) *Env

NewEnv creates a new environment. It uses GOARCH env to set sensible defaults.

func (*Env) Clone

func (c *Env) Clone() *Env

func (*Env) ForceMacro added in v0.3.0

func (c *Env) ForceMacro(name string) bool

func (*Env) GetLibrary

func (c *Env) GetLibrary(name string) (*Library, bool)

GetLibrary finds or initializes the library, given a C include filename.

func (*Env) GetLibraryType

func (c *Env) GetLibraryType(lib, typ string) types.Type

GetLibraryType is a helper for GetLibrary followed by GetType.

func (*Env) IdentByName

func (c *Env) IdentByName(name string) (*types.Ident, bool)

func (*Env) LibIdentByName

func (c *Env) LibIdentByName(name string) (*Library, *types.Ident, bool)

func (*Env) LookupLibrary added in v0.3.1

func (c *Env) LookupLibrary(name string) *Library

LookupLibrary finds an already loaded Library. It is useful to prevent import loops.

Typically, the GetLibrary function should be used instead, because it will load the library automatically, if needed.

func (*Env) NewIdent

func (c *Env) NewIdent(cname, goname string, v interface{}, typ types.Type) *types.Ident

func (*Env) NewLibrary

func (c *Env) NewLibrary(path string) (*Library, bool)

func (*Env) ResolveImport

func (c *Env) ResolveImport(name string) string

func (*Env) TypeByName

func (c *Env) TypeByName(name string) (types.Type, bool)

type Library

type Library struct {
	Name string
	// Header is a content of a C header file for the library.
	// It will be protected by a ifndef guard automatically.
	Header string
	// Types overrides type definitions parsed from the library's header with a custom ones.
	Types map[string]types.Type

	Idents map[string]*types.Ident

	Imports map[string]string

	ForceMacros map[string]bool
	// contains filtered or unexported fields
}

func (*Library) Declare

func (l *Library) Declare(ids ...*types.Ident)

Declare adds a new ident to the library. It also writes a corresponding C definition to the header.

func (*Library) GetType

func (l *Library) GetType(name string) types.Type

type LibraryFunc

type LibraryFunc func(c *Env) *Library

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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