Documentation ¶
Index ¶
- Constants
- Variables
- func AddCallableHeader(gen FileGenerator, h *file.Header, name string, callable *gir.CallableAttrs)
- func AddCallbackHeader(gen FileGenerator, h *file.Header, callback *gir.Callback)
- func AnyTypeC(any gir.AnyType) string
- func AnyTypeCGo(any gir.AnyType) string
- func AnyTypeCGoPrimitive(gen FileGenerator, any gir.AnyType) string
- func AnyTypeCPrimitive(gen FileGenerator, any gir.AnyType) string
- func AnyTypeIsPtr(any gir.AnyType) bool
- func AnyTypeIsVoid(any gir.AnyType) bool
- func ApplyPreprocessors(repos gir.Repositories, preprocs []Preprocessor)
- func CGoTypeFromC(cType string) string
- func CTypeFallback(c, gir string) string
- func CTypeToPrimitive(cType string) string
- func CallableCHeader(gen FileGenerator, name string, callable *gir.CallableAttrs) string
- func CgoFuncBridge(gen FileGenerator, name string, callable *gir.CallableAttrs) string
- func CleanCType(cType string, stripPtr bool) string
- func CountPtr(typ string) int
- func DecPtr(t string) string
- func DetectLengthParameters(params []gir.Parameter)
- func EnsureNamespace(nsp *gir.NamespaceFindResult, girType string) string
- func EqNamespace(nsp, girType string) (typ string, ok bool)
- func Filter(gen FileGenerator, gir, c string) (omit bool)
- func FilterCType(gen FileGenerator, c string) (omit bool)
- func FilterField(gen FileGenerator, parent string, field *gir.Field) (omit bool)
- func FilterMethod(gen FileGenerator, parent string, method *gir.Method) (omit bool)
- func FilterSub(gen FileGenerator, parent, sub, cType string) (omit bool)
- func Find(gen FileGenerator, girType string) *gir.TypeFindResult
- func FindMethodName(methods []gir.Method, name string) *gir.Method
- func FindParameter(c *gir.CallableAttrs, paramName string) *gir.ParameterAttrs
- func FindParameterFromSlice(params []gir.Parameter, paramName string) *gir.ParameterAttrs
- func GIRBuiltinGo(typ string) string
- func GIRIsPrimitive(typ string) bool
- func GIRPrimitiveGo(typ string) string
- func GoAnyType(gen FileGenerator, any gir.AnyType, pub bool) (string, bool)
- func GoImplType(gen FileGenerator, resolved *Resolved) string
- func GoPublicType(gen FileGenerator, resolved *Resolved) string
- func GoType(gen FileGenerator, typ gir.Type, pub bool) (string, bool)
- func GuessParameterOutput(param *gir.Parameter) string
- func IsGpointer(ctype string) bool
- func IsObjectorMethod(goName string) bool
- func MakePathMatcher(inputs []string) func(string) bool
- func MoveCPtr(orig, into string) string
- func MovePtr(orig, into string) string
- func MoveTypePtr(src, dst gir.Type) *gir.Type
- func RecordHasFree(record *gir.Record) *gir.Method
- func RecordHasRef(record *gir.Record) *gir.Method
- func RecordHasUnref(record *gir.Record) *gir.Method
- func RecordIsOpaque(rec gir.Record) bool
- func RecordPrintFree(gen FileGenerator, parent *gir.TypeFindResult, value string) string
- func RecordPrintFreeMethod(gen FileGenerator, parent *gir.TypeFindResult, value string) stringdeprecated
- func ResolveAnyType(gen FileGenerator, any gir.AnyType) gir.AnyType
- func ResolveAnyTypeC(gen FileGenerator, any gir.AnyType) string
- func ResolveAnyTypeCGo(gen FileGenerator, any gir.AnyType) string
- func ResolveParameters(gen FileGenerator, params []gir.Parameter) []gir.Parameter
- func ReturnIsVoid(ret *gir.ReturnValue) bool
- func StripPtr(t string) string
- func TypeCGo(typ *gir.Type) string
- func TypeFile(typ any) string
- func TypeIsInFile(typ interface{}, file string) bool
- type FileGenerator
- type FilterMatcher
- type LinkMode
- type ModulePathFunc
- type Preprocessor
- func ModifyCallable(girType string, f func(c *gir.CallableAttrs)) Preprocessor
- func ModifyParamDirections(girType string, dirOverrides map[string]string) Preprocessor
- func ModifySignal(girType string, f func(c *gir.Signal)) Preprocessor
- func MustIntrospect(girType string) Preprocessor
- func PreserveGetName(girType string) Preprocessor
- func RemoveCIncludes(girFile string, cincls ...string) Preprocessor
- func RemovePkgconfig(girFile string, pkgs ...string) Preprocessor
- func RemoveRecordFields(girType string, fields ...string) Preprocessor
- func RenameCallable(girType, newName string) Preprocessor
- func RenameEnumMembers(enum, regex, replace string) Preprocessor
- func TypeRenamer(girType, newName string) Preprocessor
- type PreprocessorFunc
- type Resolved
- func (typ *Resolved) AsDynamicLinkedCType(gen FileGenerator) string
- func (typ *Resolved) AsPrimitiveCType(gen FileGenerator) string
- func (typ *Resolved) CGoType() string
- func (typ *Resolved) CanCast(gen FileGenerator) bool
- func (typ *Resolved) CanNil() bool
- func (typ *Resolved) DynamicLinked(gen FileGenerator) bool
- func (typ *Resolved) FullGType() stringdeprecated
- func (typ *Resolved) HasImport() bool
- func (typ *Resolved) HasPointer(gen FileGenerator) bool
- func (typ *Resolved) ImplName() string
- func (typ *Resolved) ImplType(needsNamespace bool) string
- func (typ *Resolved) ImportImpl(gen FileGenerator, h *file.Header)
- func (typ *Resolved) ImportPubl(gen FileGenerator, h *file.Header)
- func (typ *Resolved) IsAbstract() bool
- func (typ *Resolved) IsAbstractClass() bool
- func (typ *Resolved) IsBuiltin(builtins ...string) bool
- func (typ *Resolved) IsCallback() bool
- func (typ *Resolved) IsClass() bool
- func (typ *Resolved) IsContainerBuiltin() bool
- func (typ *Resolved) IsEnumOrBitfield() bool
- func (typ *Resolved) IsExternGLib(glibType string) bool
- func (typ *Resolved) IsForeignRecord() bool
- func (typ *Resolved) IsGpointer() bool
- func (typ *Resolved) IsInterface() bool
- func (typ *Resolved) IsPrimitive() bool
- func (typ *Resolved) IsRecord() bool
- func (typ *Resolved) IsUnion() bool
- func (typ *Resolved) Name() string
- func (typ *Resolved) NeedsNamespace(current *gir.NamespaceFindResult) bool
- func (typ *Resolved) PublicIsInterface() bool
- func (typ *Resolved) PublicName() string
- func (typ *Resolved) PublicType(needsNamespace bool) string
- func (typ *Resolved) Underlying() *Resolved
- func (typ *Resolved) UnderlyingExtern() *gir.TypeFindResult
- func (typ *Resolved) WrapName(needsNamespace bool) string
- type Tree
- func (tree *Tree) AmbiguousSelectorTypes() []*Resolved
- func (tree *Tree) FirstGObjectSelector(v string) string
- func (tree *Tree) ImplInterfaces() []*Resolved
- func (tree *Tree) ImplTypes() []string
- func (tree *Tree) Reset()
- func (tree *Tree) Resolve(toplevel string) bool
- func (tree *Tree) ResolveFromType(toplevel *Resolved) bool
- func (tree *Tree) Walk(f func(t *Tree, root bool) (traversed []Tree))
- func (tree *Tree) WithoutGObject() []Tree
- func (tree *Tree) Wrap(obj string, h *file.Header) string
- func (tree *Tree) WrapInNamespace(obj string, h *file.Header, n *gir.NamespaceFindResult) string
Constants ¶
const InternalImportPath = "github.com/diamondburned/gotk4/pkg/core"
InternalImportPath is the path to the core import path.
Variables ¶
var BuiltinHandledTypes = []FilterMatcher{ AbsoluteFilter("GLib.Error"), RegexFilter("GObject..*"), AbsoluteFilter("*.long double"), AbsoluteFilter("C.intern"), RegexFilter(`C.g_byte_array_.*`), AbsoluteFilter("GLib.Type"), }
BuiltinHandledTypes contains types manually handled by Resolve and typeconv.Converter, as well as types that are never supposed to be handled.
var UnsupportedCTypes = []string{
"tm",
"va_list",
}
UnsupportedCTypes is the list of unsupported C types, either because it is not yet supported or will never be supported due to redundancy or else.
Functions ¶
func AddCallableHeader ¶ added in v0.0.4
func AddCallableHeader(gen FileGenerator, h *file.Header, name string, callable *gir.CallableAttrs)
AddCallableHeader adds an extern C function header from the callable. The extern function will have the given name.
func AddCallbackHeader ¶ added in v0.0.4
func AddCallbackHeader(gen FileGenerator, h *file.Header, callback *gir.Callback)
AddCallbackHeader is a convenient function around AddCallableHeader that takes in a Callback.
func AnyTypeC ¶
AnyTypeC returns the C type for a GIR AnyType. An empty string is returned if none is made.
func AnyTypeCGo ¶
AnyTypeCGo returns the CGo type for a GIR AnyType. An empty string is returned if none is made.
func AnyTypeCGoPrimitive ¶ added in v0.0.4
func AnyTypeCGoPrimitive(gen FileGenerator, any gir.AnyType) string
AnyTypeCGoPrimitive converts AnyType to a CGo primitive type.
func AnyTypeCPrimitive ¶ added in v0.0.4
func AnyTypeCPrimitive(gen FileGenerator, any gir.AnyType) string
AnyTypeCPrimitive converts AnyType to a C primitive type.
func AnyTypeIsPtr ¶
AnyTypeIsPtr returns true if the AnyType contains a pointer.
func AnyTypeIsVoid ¶
AnyTypeIsVoid returns true if AnyType is a void type.
func ApplyPreprocessors ¶
func ApplyPreprocessors(repos gir.Repositories, preprocs []Preprocessor)
ApplyPreprocessors applies the given list of preprocessors onto the given list of GIR repositories.
func CGoTypeFromC ¶
CGoTypeFromC converts a C type to a CGo type.
func CTypeFallback ¶
CTypeFallback returns the C type OR the GIR type if it's empty.
func CTypeToPrimitive ¶ added in v0.0.4
CTypeToPrimitive converts a C type to the primitive type.
func CallableCHeader ¶ added in v0.0.4
func CallableCHeader(gen FileGenerator, name string, callable *gir.CallableAttrs) string
CallableCHeader renders the C function signature.
TODO: wherever this is called, we may need to heavily refactor this to also resolve all arguments of the callback. The function signature may look something like
func CallableCHeader(gen FileGenerator, name string, callable *gir.CallableAttrs) string
func CgoFuncBridge ¶ added in v0.0.5
func CgoFuncBridge(gen FileGenerator, name string, callable *gir.CallableAttrs) string
CgoFuncBridge generates a C function that calls a C function pointer.
func CleanCType ¶
CleanCType cleans the underlying C type of and special keywords for comparison.
func CountPtr ¶
CountPtr counts the number of pointers in the given type string. If the string contains "[]", then the pointer is counted up to that.
func DetectLengthParameters ¶ added in v0.3.0
Convert char* to array with an associated length parameter Based on detect_length https://github.com/gtk-rs/gir/blob/master/src/analysis/function_parameters.rs
func EnsureNamespace ¶
func EnsureNamespace(nsp *gir.NamespaceFindResult, girType string) string
EnsureNamespace ensures that exported, non-primitive types have the namespace prepended. This is useful for matching hard-coded types.
func EqNamespace ¶
EqNamespace is used for FilterMatchers to compare types and namespaces.
func Filter ¶
func Filter(gen FileGenerator, gir, c string) (omit bool)
Filter returns true if the given GIR and/or C type should be omitted from the given generator.
func FilterCType ¶
func FilterCType(gen FileGenerator, c string) (omit bool)
FilterCType filters only the C type or identifier. It is useful for filtering C functions and such.
func FilterField ¶
func FilterField(gen FileGenerator, parent string, field *gir.Field) (omit bool)
FilterField filters a field similarly to Filter.
func FilterMethod ¶
func FilterMethod(gen FileGenerator, parent string, method *gir.Method) (omit bool)
FilterMethod filters a method similarly to Filter.
func FilterSub ¶
func FilterSub(gen FileGenerator, parent, sub, cType string) (omit bool)
FilterSub filters a field or method inside a parent.
func Find ¶
func Find(gen FileGenerator, girType string) *gir.TypeFindResult
Find finds the given GIR type from the given generator.
func FindMethodName ¶ added in v0.0.3
FindMethodName finds from the method the given name.
func FindParameter ¶
func FindParameter(c *gir.CallableAttrs, paramName string) *gir.ParameterAttrs
FindParameter finds a parameter.
func FindParameterFromSlice ¶ added in v0.0.3
func FindParameterFromSlice(params []gir.Parameter, paramName string) *gir.ParameterAttrs
FindParameter finds a parameter from a slice of gir.Parameters.
func GIRBuiltinGo ¶
GIRPrimitiveGo returns Go built-in types (primitive types and string). It returns an empty string if there's none.
func GIRIsPrimitive ¶ added in v0.0.4
GIRIsPrimitive returns true if the Go primitive type of the GIR type is valid and is not a string.
func GIRPrimitiveGo ¶
GIRPrimitiveGo returns Go primitive types that can be copied by-value without doing any pointer work. It returns an empty string if there's none.
func GoAnyType ¶
GoAnyType generates the Go type signature for the AnyType union. An empty string returned is an invalid type. If pub is true, then the returned string will use public interface types for classes instead of implementation types.
func GoImplType ¶
func GoImplType(gen FileGenerator, resolved *Resolved) string
GoImplType is a convenient function around ResolvedType.ImplType.
func GoPublicType ¶
func GoPublicType(gen FileGenerator, resolved *Resolved) string
GoPublicType is a convenient function around ResolvedType.ImplType.
func GoType ¶
GoType is a convenient function that wraps around ResolveType and returns the Go type.
func GuessParameterOutput ¶
GuessParameterOutput guesses the parameter output using various clues to make up for GIR's painful shortcomings.
func IsGpointer ¶
IsGpointer returns true if the given type is a gpointer or a pointer to it.
func IsObjectorMethod ¶
func MakePathMatcher ¶ added in v0.0.3
MakePathMatcher makes a matcher from the given file name inputs.
func MoveCPtr ¶
MoveCPtr moves the same number of pointers from the given orig string into another string as prefix, for C types.
func MovePtr ¶
MovePtr moves the same number of pointers from the given orig string into another string.
func MoveTypePtr ¶
MoveTypePtr moves the pointer from src to dst. It overrides dst's pointer. A copy of dst is returned.
func RecordHasFree ¶
RecordHasFree returns the free/unref method if it has one.
func RecordHasRef ¶
RecordHasRef returns the ref method if it has one.
func RecordHasUnref ¶
RecordHasUnref returns the unref method if it has one.
func RecordIsOpaque ¶
RecordIsOpaque returns true if the record has no fields in the GIR schema. These records must always be referenced using a pointer.
func RecordPrintFree ¶ added in v0.0.3
func RecordPrintFree(gen FileGenerator, parent *gir.TypeFindResult, value string) string
RecordPrintFree prints the call to the record's free function OR an empty string.
func RecordPrintFreeMethod
deprecated
added in
v0.0.3
func RecordPrintFreeMethod(gen FileGenerator, parent *gir.TypeFindResult, value string) string
RecordPrintFreeMethod generates a call with 1 argument for either free or unref. If method is nil, then a C.free call is generated. Value is assumed to be an unsafe.Pointer.
The caller must import girepository.Argument manually.
Deprecated: Use RecordPrintFree.
func ResolveAnyType ¶ added in v0.0.3
func ResolveAnyType(gen FileGenerator, any gir.AnyType) gir.AnyType
ResolveAnyType returns a copy of gir.AnyType containg the C type fields filled.
func ResolveAnyTypeC ¶ added in v0.0.4
func ResolveAnyTypeC(gen FileGenerator, any gir.AnyType) string
ResolveAnyTypeC resolves any type to its C type. If link mode is runtime, then a primitive is returned.
func ResolveAnyTypeCGo ¶ added in v0.0.4
func ResolveAnyTypeCGo(gen FileGenerator, any gir.AnyType) string
ResolveAnyTypeCGo resolves any type to its Cgo type. If link mode is runtime, then a primitive is returned.
func ResolveParameters ¶ added in v0.0.3
func ResolveParameters(gen FileGenerator, params []gir.Parameter) []gir.Parameter
ResolveParameters puts each parameter through the type resolver and fill up any missing CType using ResolveAnyType. The returned slice is a copy.
func ReturnIsVoid ¶
func ReturnIsVoid(ret *gir.ReturnValue) bool
ReturnIsVoid returns true if the return type is void.
func TypeFile ¶ added in v0.0.5
TypeFile returns the filename of the given type. The filename shouldn't contain the file extension.
func TypeIsInFile ¶
TypeIsInFile returns true if the given type was declared in the given filename. The filename shouldn't contain the file extension.
Types ¶
type FileGenerator ¶
type FileGenerator interface { logger.LineLogger // CanGenerate checks if a type is going to be generated or not. It is used // primarily during type resolving. CanGenerate(*Resolved) bool // Filters returns the list of matchers that the current generator has. Filters() []FilterMatcher // ModPath crafts an import path from the given GIR namespace. The import // path is assumed to have the same package name as the base file, but major // versions are exempted as an edge case. ModPath(*gir.Namespace) string // Repositories returns the list of known repositories inside the generator. Repositories() gir.Repositories // Namespace returns the generator's current namespace. Namespace() *gir.NamespaceFindResult // NamespaceLinkMode returns the link mode for the given namespace. NamespaceLinkMode(*gir.Namespace) LinkMode // LinkMode gets the current link mode of the file generator. LinkMode() LinkMode }
FileGenerator defines a generator instance.
func OverrideNamespace ¶
func OverrideNamespace(gen FileGenerator, nsp *gir.NamespaceFindResult) FileGenerator
OverrideNamespace returns a new generator that overrides a generator's current namespace.
type FilterMatcher ¶
type FilterMatcher interface { // Filter matches for the girType within the given namespace from the // namespace generator. The GIR type will never have a namespace prefix. Filter(gen FileGenerator, gir, c string) (omit bool) }
FilterMatcher describes a filter for a GIR type.
func AbsoluteFilter ¶
func AbsoluteFilter(abs string) FilterMatcher
AbsoluteFilter matches the names absolutely.
func FileFilter ¶
func FileFilter(contains string) FilterMatcher
FileFilter filters based on the source position. It filters out types that have a source position that contains the given string.
func FileFilterNamespace ¶ added in v0.0.5
func FileFilterNamespace(namespace, contains string) FilterMatcher
FileFilterNamespace filters based on the source position and namespace. It filters out types that have a source position that contains the given string and are in the given namespace.
func RegexFilter ¶
func RegexFilter(matcher string) FilterMatcher
RegexFilter returns a regex filter for FilterMatcher. A regex filter's format is a string consisting of two parts joined by a period: a namespace and a matcher. The only regex part is the matcher.
type LinkMode ¶ added in v0.0.4
type LinkMode uint8
LinkMode describes the mode that determines how the generator generates code to be linked. See the possible constants for more information.
const ( // RuntimeLinkMode is the new generation mode. It generates Go code that // uses the girepository library to link the library at runtime instead of // compile-time. // // Since all generated calls are actually Go function calls and not C // function calls, compile times are far better than when using // DynamicLinkMode, but runtime performance may be slightly lower and more // memory-intensive. // // Use RuntimeLinkMode for large packages, such as GTK; use DynamicLinkMode // for small and important packages, such as the core glib/v2 package. RuntimeLinkMode LinkMode = iota // DynamicLinkMode is the old generation mode. It generates Cgo code that // contains compile-time link flags to dynamically link libraries to the // output binary. // // This mode forces the use of cmd/cgo on every call during compilation, // making it very slow. Only use this on core packages such as glib. DynamicLinkMode )
type ModulePathFunc ¶
ModulePathFunc returns the Go module import path from the given namespace. See Generator.ModPath for mroe information.
type Preprocessor ¶
type Preprocessor interface { // Preprocess goes over the given list of repos, changing what's necessary. Preprocess(repos gir.Repositories) }
Preprocessor describes something that can preprocess anything in the given list of repositories. This is useful for renaming functions, classes or anything else.
func ModifyCallable ¶
func ModifyCallable(girType string, f func(c *gir.CallableAttrs)) Preprocessor
ModifyCallable is a preprocessor that modifies an existing callable. It only does Function or Callback.
func ModifyParamDirections ¶
func ModifyParamDirections(girType string, dirOverrides map[string]string) Preprocessor
ModifyParamDirections wraps ModifyCallable to conveniently override the parameters' directions.
func ModifySignal ¶ added in v0.0.3
func ModifySignal(girType string, f func(c *gir.Signal)) Preprocessor
ModifySignal is like ModifyCallable, except it only works on signals from classes and interfaces. The GIR type must be "package.class::signal-name".
func MustIntrospect ¶ added in v0.0.3
func MustIntrospect(girType string) Preprocessor
MustIntrospect forces the given type to be introspectable.
func PreserveGetName ¶
func PreserveGetName(girType string) Preprocessor
PreserveGetName matches a type and prepends "get_" or "Get" into it to preserve the getter name in case of collision.
func RemoveCIncludes ¶
func RemoveCIncludes(girFile string, cincls ...string) Preprocessor
RemoveCIncludes removes the given C includes from the given repository.
func RemovePkgconfig ¶ added in v0.0.3
func RemovePkgconfig(girFile string, pkgs ...string) Preprocessor
RemovePkgconfig removes the given pkgconfig packages from the given repository.
func RemoveRecordFields ¶
func RemoveRecordFields(girType string, fields ...string) Preprocessor
RemoveRecordFields removes the given fields from the record with the given full GIR type. The fields must be cased as they appear in the GIR file.
func RenameCallable ¶
func RenameCallable(girType, newName string) Preprocessor
RenameCallable renames a callable using ModifyCallable.
func RenameEnumMembers ¶
func RenameEnumMembers(enum, regex, replace string) Preprocessor
RenameEnumMembers renames all members of the matched enums. It is primarily used to avoid collisions.
func TypeRenamer ¶
func TypeRenamer(girType, newName string) Preprocessor
TypeRenamer creates a new filter matcher that renames a type. The given GIR type must contain the versioned namespace, like "Gtk3.Widget" but the given name must not. The GIR type is absolutely matched, similarly to AbsoluteFilter.
type PreprocessorFunc ¶
type PreprocessorFunc func(gir.Repositories)
PreprocessorFunc is a helper function to satisfy the Preprocessor interface.
func (PreprocessorFunc) Preprocess ¶
func (f PreprocessorFunc) Preprocess(repos gir.Repositories)
Preprocess calls f.
type Resolved ¶
type Resolved struct { // either or Extern *gir.TypeFindResult // optional Builtin *string // optional Aliased *Resolved // optional PublImport file.Import ImplImport file.Import CType string GType string Ptr uint8 // used ONLY for the Go type. }
Resolved is a resolved type from a given gir.Type.
func BuiltinType ¶
BuiltinType is a convenient function to make a new built-in *Resolved.
func Resolve ¶
func Resolve(gen FileGenerator, typ gir.Type) *Resolved
Resolve resolves the given type from the GIR type field. It returns nil if the type is not known. It does not recursively traverse the type.
func ResolveName ¶
func ResolveName(gen FileGenerator, girType string) *Resolved
ResolveName resolves the given GIR type name. The resolved type will always have no pointer.
func TypeFromResult ¶
func TypeFromResult(gen FileGenerator, v interface{}) *Resolved
TypeFromResult is meant to be used by an external package to generate a Resolved from existing type information.
func (*Resolved) AsDynamicLinkedCType ¶ added in v0.0.4
func (typ *Resolved) AsDynamicLinkedCType(gen FileGenerator) string
AsDynamicLinkedCType is a variant of AsPrimitiveCType that returns the original C type if it's from a dynamically linked package.
func (*Resolved) AsPrimitiveCType ¶ added in v0.0.4
func (typ *Resolved) AsPrimitiveCType(gen FileGenerator) string
AsPrimitiveCType resolves Resolved's CType to a primitive type if possible. This is different to IsPrimitive in that all types are coerced into primitive types such as gpointer, and types that cannot be coerced will return an empty string.
func (*Resolved) CanCast ¶
func (typ *Resolved) CanCast(gen FileGenerator) bool
CanCast returns true if the resolved type is a builtin type that can be directly casted to an equivalent C type OR a record..
func (*Resolved) DynamicLinked ¶ added in v0.0.4
func (typ *Resolved) DynamicLinked(gen FileGenerator) bool
func (*Resolved) HasPointer ¶
func (typ *Resolved) HasPointer(gen FileGenerator) bool
HasPointer returns true if the type being resolved has a pointer. This is useful for array passing from Go memory to C memory.
func (*Resolved) ImplType ¶
ImplType returns the implementation type. This is only different to PublicType as far as classes go: the returned type is the unexported implementation type.
func (*Resolved) ImportImpl ¶ added in v0.0.4
func (typ *Resolved) ImportImpl(gen FileGenerator, h *file.Header)
ImportImpl adds the import for the implementing type of the Resolved type into the file header.
func (*Resolved) ImportPubl ¶ added in v0.0.4
func (typ *Resolved) ImportPubl(gen FileGenerator, h *file.Header)
ImportPubl adds the import for the public type of the Resolved type into the file header.
func (*Resolved) IsAbstract ¶
IsAbstract returns true if the resolved type is an interface or an abstract class.
func (*Resolved) IsAbstractClass ¶ added in v0.0.3
IsAbstractClass returns true if the resolved type is an abstract class.
func (*Resolved) IsCallback ¶
IsCallback returns true if the current ResolvedType is a callback.
func (*Resolved) IsContainerBuiltin ¶
IsContainerBuiltin returns true if the resolved type is a built-in Go container type (like string, error or interface{}).
func (*Resolved) IsEnumOrBitfield ¶ added in v0.0.3
IsEnumOrBitfield returns true if the resolved type is an external enum or bitfield type.
func (*Resolved) IsExternGLib ¶
IsExternGLib checks that the ResolvedType is exactly the gotk3/glib type with the given name. Pointers are not compared.
func (*Resolved) IsForeignRecord ¶ added in v0.0.3
IsForeignRecord returns true if the current ResolvedType is a foreign record.
func (*Resolved) IsGpointer ¶
IsGpointer returns true if the given type is a gpointer type.
func (*Resolved) IsInterface ¶
IsInterface returns true if the current ResolvedType is an interface.
func (*Resolved) IsPrimitive ¶
IsPrimitive returns true if the resolved type is a builtin type that can be directly casted to an equivalent C type OR a record.
func (*Resolved) IsUnion ¶ added in v0.0.3
IsUnion returns true if the current ResolvedType is a union.
func (*Resolved) NeedsNamespace ¶
func (typ *Resolved) NeedsNamespace(current *gir.NamespaceFindResult) bool
NeedsNamespace returns true if the returned Go type needs a namespace to be referenced properly.
func (*Resolved) PublicIsInterface ¶
func (*Resolved) PublicName ¶
PublicName returns the public type name.
func (*Resolved) PublicType ¶
PublicType returns the public type. If the resolved type is a class, then the interface type is returned.
func (*Resolved) Underlying ¶ added in v0.0.3
Underlying returns itself OR the alias' resolved type if there's one. It runs until the final type is resolved.
func (*Resolved) UnderlyingExtern ¶ added in v0.0.3
func (typ *Resolved) UnderlyingExtern() *gir.TypeFindResult
UnderlyingExtern returns the extern type OR the alias' extern type iff there's one. Nil is returned if neither.
type Tree ¶
type Tree struct { *Resolved // Requires contains the direct dependencies of the current type. It may // contain interfaces that are also in other interfaces, which will not // build. Requires []Tree // contains filtered or unexported fields }
Tree is a structure for a type that is resolved to the lowest level of inheritance.
func NewTree ¶
func NewTree(gen FileGenerator) Tree
NewTree creates a new empty type tree for resolving.
func (*Tree) AmbiguousSelectorTypes ¶ added in v0.0.3
AmbiguousSelectorTypes scans the whole tree and finds all types whose selectors are ambiguous if directly referenced from the top-level type.
func (*Tree) FirstGObjectSelector ¶
FirstGObjectSelector returns the selector path to the firts GObject field. The returning selector should have the *Object type. The selectors will all use the implementation type for the name.
If the object does not contain the Object field somewhere, then "nil" is returned.
func (*Tree) ImplInterfaces ¶ added in v0.0.3
ImplInterfaces returns the sorted list of all Go interfaces that this type implements. The namespaces are appropriately prepended if needed.
At the moment, the method will only care about abstract classes.
func (*Tree) ImplTypes ¶
ImplTypes returns the sorted list of the toplevel type's children as Go implementation type names. The namespaces are appropriately prepended if needed.
func (*Tree) Resolve ¶
Resolve resolves the given toplevel type into the Tree, overriding the Resolved and Requires fields. True is returned if the tree is successfully resolved.
func (*Tree) ResolveFromType ¶
ResolveFromType is like Resolve, but the caller directly supplies the resolved top-level type.
func (*Tree) Walk ¶
Walk walks the tree recursively on what the callback returns. The callback will be called on the root (receiver) tree; it should then return the list of parents of that tree. This process is then repeated for each tree returned.
Example:
tree.Walk(func(t *Tree, root bool) []Tree { log.Println("currently at", t.Resolved.PublName()) return t.Requires })
func (*Tree) WithoutGObject ¶
WithoutGObject returns the Requires list without the GObject item.
func (*Tree) WrapInNamespace ¶
WrapInNamespace wraps with the given current namespace.