file

package
v0.0.0-...-aefa52a Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package file provides per-file state helpers, such as for tracking imports.

Index

Constants

View Source
const CoreImportPath = "github.com/brotholo/gotk4/pkg/core"

CoreImportPath is the path to the core import path.

Variables

View Source
var NoopHeader = &Header{stop: true}

NoopHeader is a header instance where its methods do nothing. This instance is useful for functions that both validate and generate, but generation is not wanted.

Functions

func ApplyHeader

func ApplyHeader(dst Headerer, srcs ...Headerer)

ApplyHeader applies the given src headers to dst.

func CallableExportedName

func CallableExportedName(source *gir.NamespaceFindResult, callable *gir.CallableAttrs) string

CallableExportedName creates the exported C name of the given callback from the given namespace.

func ExportedName

func ExportedName(source *gir.NamespaceFindResult, suffixes ...string) string

ExportedName generates the full name for any exported function or variable generated by gotk4. It prepends the right strings to make the exported identifier unique in the C namespace.

func ImportCore

func ImportCore(core string) string

ImportCore returns the path to import a core package.

Types

type Header struct {
	Marshalers     []Marshaler
	Imports        map[string]string
	CIncludes      map[string]struct{}
	Packages       map[string]struct{} // for pkg-config
	Callbacks      map[string]struct{} // used for C blocks in general
	CallbackDelete bool
	// contains filtered or unexported fields
}

Header describes the side effects of the conversion, such as importing new things or modifying the CGo preamble. A zero-value instance is a valid instance.

func CopyHeader

func CopyHeader(src *Header) Header

CopyHeader copies the given header.

func (*Header) AddCBlock

func (h *Header) AddCBlock(block string)

AddCBlock adds a block of C code into the Cgo preamble.

func (*Header) AddCallbackHeader

func (h *Header) AddCallbackHeader(header string)

AddCallbackHeader adds a callback header raw.

func (*Header) AddMarshaler

func (h *Header) AddMarshaler(glibGetType, goName string)

AddMarshaler adds the type marshaler into the init header. It also adds imports.

func (*Header) AddPackage

func (h *Header) AddPackage(pkg string)

AddPackage adds a pkg-config package.

func (*Header) ApplyFrom

func (h *Header) ApplyFrom(src *Header)

ApplyFrom is ApplyTo but reversed.

func (*Header) ApplyTo

func (h *Header) ApplyTo(dst *Header)

ApplyTo applies the headers into the given one. The caller is responsible for calling this.

func (*Header) Copy

func (h *Header) Copy() *Header

func (*Header) DashImport

func (h *Header) DashImport(path string)

DashImport imports the given path if it's not already imported.

func (*Header) HasImport

func (h *Header) HasImport(path string) bool

HasImport returns true if the header imports the given path.

func (*Header) Import

func (h *Header) Import(path string)

func (*Header) ImportAlias

func (h *Header) ImportAlias(path, alias string)

func (*Header) ImportCore

func (h *Header) ImportCore(core string)

ImportCore adds a core import.

func (*Header) ImportResolvedType

func (h *Header) ImportResolvedType(imports Import)

func (*Header) IncludeC

func (h *Header) IncludeC(include string)

IncludeC adds a C header file into the cgo preamble.

func (*Header) NeedsExternGLib

func (h *Header) NeedsExternGLib()

needsExternGLib adds the external gotk3/glib import.

func (*Header) NeedsGLibObject

func (h *Header) NeedsGLibObject()

NeedsGLibObject adds the glib-object.h include and the glib-2.0 package.

func (*Header) Reset

func (h *Header) Reset()

Reset resets the file header to a zero state.

func (*Header) SortedCIncludes

func (h *Header) SortedCIncludes() []string

SortedCIncludes returns the list of C includes sorted.

func (*Header) SortedCallbackHeaders

func (h *Header) SortedCallbackHeaders() []string

SortedCallbackHeaders returns the sorted C callback headers.

type Headerer

type Headerer interface {
	Header() *Header
}

Headerer is an interface of something that returns its internal header.

type Import

type Import struct {
	Path    string // full path
	Package string // package name, import alias
}

Import is a single import for a package.

type Marshaler

type Marshaler struct {
	GLibGetType string
	GoTypeName  string
}

Marshaler describes a marshaler.

func (Marshaler) GLibType

func (m Marshaler) GLibType() string

GLibType returns a type-casted get_type function call.

Jump to

Keyboard shortcuts

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