Documentation ¶
Overview ¶
Package gendata contains data used to generate GTK4 bindings for Go. It exists primarily to be used externally.
Index ¶
- Constants
- Variables
- func GLibAliases(nsgen *girgen.NamespaceGenerator) error
- func GLibDateTime(nsgen *girgen.NamespaceGenerator) error
- func GLibLogs(nsgen *girgen.NamespaceGenerator) error
- func GLibObjectComparer(nsgen *girgen.NamespaceGenerator) error
- func GLibVariantIter(nsgen *girgen.NamespaceGenerator) error
- func GdkPixbufFromImage(nsgen *girgen.NamespaceGenerator) error
- func GioArrayUseBytes(nsgen *girgen.NamespaceGenerator) error
- func GtkInvalidListItem(nsgen *girgen.NamespaceGenerator) error
- func GtkLockOSThread(nsgen *girgen.NamespaceGenerator) error
- func GtkNewDialog(nsgen *girgen.NamespaceGenerator) error
- func GtkNewMessageDialog(nsgen *girgen.NamespaceGenerator) error
- func ImportGError(nsgen *girgen.NamespaceGenerator) error
Constants ¶
const Module = "github.com/jgillich/gotk4-split/pkg"
Variables ¶
var ConversionProcessors = []ConversionProcessor{ ProcessCallback("Gio-2.AsyncReadyCallback", func(conv *Converter) { conv.Results[0].Skip = true }), }
var DynamicLinkNamespaces = []string{
"GLib-2",
"GObject-2",
"Graphene-1",
"GdkPixbuf-2",
}
DynamicLinkNamespaces lists namespaces that should be generated directly using Cgo. It includes important core packages as well as packages that are small but performance-sensitive.
var ExtraGoContents = map[string]string{
"gtk/v3/gtk.go": `
// Init binds to the gtk_init() function. Argument parsing is not
// supported.
func Init() {
C.gtk_init(nil, nil)
}
`,
}
ExtraGoContents contains the contents of files that are appended into generated outputs. It is used to add custom implementations of missing functions.
var Filters = []FilterMatcher{
AbsoluteFilter("C.cairo_image_surface_create"),
AbsoluteFilter("C.gsk_path_builder_add_cairo_path"),
AbsoluteFilter("GLib.VA_COPY_AS_ARRAY"),
AbsoluteFilter("cairo.ScaledFont"),
AbsoluteFilter("cairo.FontType"),
FileFilter("gsk/broadway/gskbroadwayrenderer.h"),
AbsoluteFilter("GLib.unichar_to_utf8"),
AbsoluteFilter("GLib.nullify_pointer"),
AbsoluteFilter("GLib.idle_add_full"),
AbsoluteFilter("GLib.timeout_add_full"),
AbsoluteFilter("GLib.timeout_add_seconds_full"),
AbsoluteFilter("GLib.log_set_writer_func"),
AbsoluteFilter("GLib.log_set_handler_full"),
AbsoluteFilter("GLib.unix_error_quark"),
AbsoluteFilter("Gio.networking_init"),
AbsoluteFilter("Gio.SimpleProxyResolver.set_ignore_hosts"),
AbsoluteFilter("C.GdkPixbufModule"),
AbsoluteFilter("GdkPixbuf.PixbufNonAnim"),
AbsoluteFilter("GdkPixbuf.PixbufModulePattern"),
AbsoluteFilter("GdkPixbuf.PixbufFormat.domain"),
AbsoluteFilter("GdkPixbuf.PixbufFormat.flags"),
AbsoluteFilter("GdkPixbuf.PixbufFormat.disabled"),
AbsoluteFilter("Atk.Document.get_text_selections"),
AbsoluteFilter("Atk.Document.set_text_selections"),
AbsoluteFilter("GLib.IOChannel.read"),
AbsoluteFilter("GLib.Bytes.new_take"),
AbsoluteFilter("GLib.Bytes.new_static"),
AbsoluteFilter("GLib.Bytes.unref_to_data"),
AbsoluteFilter("GLib.Bytes.unref_to_array"),
RegexFilter(`GLib.Source\..*unix.*`),
RegexFilter(`Gio.Subprocess`),
RegexFilter(`Gio.SubprocessLauncher`),
RegexFilter(`Gio..*[Uu]nix.*`),
AbsoluteFilter("GLib.Pid"),
AbsoluteFilter("GLib.PollFD"),
FileFilter("gfiledescriptorbased."),
FileFilter("gunix"),
FileFilterNamespace("GLib", "gasyncqueue."),
FileFilterNamespace("GLib", "gatomic."),
FileFilterNamespace("GLib", "gbacktrace."),
FileFilterNamespace("GLib", "gbase64."),
FileFilterNamespace("GLib", "gbitlock."),
FileFilterNamespace("GLib", "gdataset."),
FileFilterNamespace("GLib", "gdate."),
FileFilterNamespace("GLib", "gerror."),
FileFilterNamespace("GLib", "ghook."),
FileFilterNamespace("GLib", "glib-unix."),
FileFilterNamespace("GLib", "glist."),
FileFilterNamespace("GLib", "gmacros."),
FileFilterNamespace("GLib", "gmem."),
FileFilterNamespace("GLib", "gnetworking."),
FileFilterNamespace("GLib", "gprintf."),
FileFilterNamespace("GLib", "grcbox."),
FileFilterNamespace("GLib", "grefcount."),
FileFilterNamespace("GLib", "grefstring."),
FileFilterNamespace("GLib", "gslice."),
FileFilterNamespace("GLib", "gslist."),
FileFilterNamespace("GLib", "gstdio."),
FileFilterNamespace("GLib", "gstrfuncs."),
FileFilterNamespace("GLib", "gstringchunk."),
FileFilterNamespace("GLib", "gstring."),
FileFilterNamespace("GLib", "gstrvbuilder."),
FileFilterNamespace("GLib", "gtestutils."),
FileFilterNamespace("GLib", "gthread."),
FileFilterNamespace("GLib", "gthreadpool."),
FileFilterNamespace("GLib", "gtrashstack."),
FileFilterNamespace("Gio", "gsettingsbackend."),
FileFilter("gskglrenderer."),
FileFilter("gsknglrenderer."),
FileFilter("gskvulkanrenderer."),
FileFilter("gdesktopappinfo."),
FileFilter("gtkpagesetupunixdialog"),
FileFilter("gtkprintunixdialog"),
FileFilter("gtkprinter"),
FileFilter("gtkprintjob"),
FileFilter("gdkprivate"),
AbsoluteFilter("C.g_array_get_type"),
AbsoluteFilter("C.g_byte_array_get_type"),
AbsoluteFilter("C.g_bytes_get_type"),
AbsoluteFilter("C.g_ptr_array_get_type"),
AbsoluteFilter("C.gtk_header_bar_accessible_get_type"),
AbsoluteFilter("C.gdk_pixbuf_non_anim_get_type"),
AbsoluteFilter("C.gdk_window_destroy_notify"),
AbsoluteFilter("C.gtk_print_capabilities_get_type"),
AbsoluteFilter("C.GdkPixbufAnimationClass"),
AbsoluteFilter("C.GdkPixbufAnimationIterClass"),
AbsoluteFilter("C.GThreadedResolverClass"),
AbsoluteFilter("C.g_threaded_resolver_get_type"),
AbsoluteFilter("C.GtkFileChooserWidgetAccessibleClass"),
AbsoluteFilter("C.gtk_file_chooser_widget_accessible_get_type"),
AbsoluteFilter("Gtk-3.HeaderBarAccessibleClass"),
AbsoluteFilter("C.g_source_remove"),
}
Filters defines a list of GIR types to be filtered. The map key is the namespace, and the values are list of names.
var GenerateExceptions = []string{
"cairo-1",
"Atspi-2",
}
GenerateExceptions contains the keys of the underneath ImportOverrides map.
var ImportOverrides = map[string]string{}
ImportOverrides is the list of imports to defer to another library, usually because it's tedious or impossible to generate.
Not included: coreglib (gotk3/gotk3/glib).
var Main = genmain.Data{ Module: Module, Packages: Packages, ImportOverrides: ImportOverrides, PkgExceptions: PkgExceptions, GenerateExceptions: GenerateExceptions, PkgGenerated: PkgGenerated, Preprocessors: Preprocessors, Postprocessors: Postprocessors, ExtraGoContents: ExtraGoContents, Filters: Filters, ProcessConverters: ConversionProcessors, DynamicLinkNamespaces: DynamicLinkNamespaces, SingleFile: true, }
Main contains all of gendata's variables as one big genmain.Data value.
This stays ugly just because it's the main gotk4 package with exposed gendata. Don't actually do this; just make a global genmain.Data instead.
var Packages = []genmain.Package{ {Name: "glib-2.0", Namespaces: []string{ "GLib-2", "GObject-2", "Gio-2", }}, {Name: "gobject-introspection-1.0", Namespaces: []string{ "cairo-1", }}, {Name: "gdk-pixbuf-2.0"}, {Name: "graphene-1.0"}, {Name: "atk"}, {Name: "pango", Namespaces: []string{ "Pango-1", "PangoCairo-1", }}, {Name: "gtk4"}, {Name: "gtk+-3.0"}, }
Packages lists pkg-config packages and optionally the namespaces to be generated. If the list of namespaces is nil, then everything is generated.
var PkgExceptions = []string{
"core",
"cairo",
"LICENSE",
}
PkgExceptions contains a list of file names that won't be deleted off of pkg/.
var PkgGenerated = []string{
"atk",
"gdk",
"gdkpixbuf",
"gdkpixdata",
"gdkwayland",
"gdkx11",
"gio",
"glib",
"gobject",
"graphene",
"gsk",
"gtk",
"pango",
"pangocairo",
}
PkgGenerated contains a list of file names that are packages generated using the given Packages list. It is manually updated.
var Postprocessors = map[string][]girgen.Postprocessor{ "GLib-2": {ImportGError, GioArrayUseBytes, GLibVariantIter, GLibAliases, GLibLogs, GLibDateTime, GLibObjectComparer}, "GdkPixbuf-2": {GdkPixbufFromImage}, "Gio-2": {ImportGError}, "Gtk-3": {ImportGError, GtkNewDialog, GtkNewMessageDialog, GtkLockOSThread}, "Gtk-4": {ImportGError, GtkNewDialog, GtkNewMessageDialog, GtkLockOSThread, GtkInvalidListItem}, }
Postprocessors is similar to Append, except the caller can mutate the package in a more flexible manner.
var Preprocessors = []Preprocessor{ TypeRenamer("GLib-2.file_test", "test_file"), TypeRenamer("Gtk-4.Native", "NativeSurface"), TypeRenamer("Gtk-4.Editable", "EditableTextWidget"), RenameEnumMembers("Pango-1.AttrType", "ATTR_(.*)", "ATTR_TYPE_$1"), RenameEnumMembers("Gsk-4.RenderNodeType", ".*", "${0}_TYPE"), RenameEnumMembers("Gdk-3.EventType", ".*", "${0}_TYPE"), RenameEnumMembers("Gtk-4.GraphicsOffloadEnabled", ".*", "${0}_TYPE"), RemoveCIncludes("Gio-2.0.gir", "gio/gdesktopappinfo.h"), RemovePkgconfig("Gio-2.0.gir", "gio-unix-2.0"), RemoveCIncludes("Gio-2.0.gir", "gio/gfiledescriptorbased.h", `/gio/gunix.*\.h/`), RemoveRecordFields("GLib-2.LogField", "length", "value"), ModifyParamDirections("Gio-2.InputStream.read", map[string]string{ "buffer": "in", "count": "in", }), ModifyParamDirections("Gio-2.InputStream.read_async", map[string]string{ "buffer": "in", "count": "in", }), ModifyParamDirections("Gio-2.InputStream.read_all", map[string]string{ "buffer": "in", "count": "in", }), ModifyParamDirections("Gio-2.InputStream.read_all_async", map[string]string{ "buffer": "in", "count": "in", }), ModifyParamDirections("Gio-2.Socket.receive", map[string]string{ "buffer": "in", "size": "in", }), ModifyParamDirections("Gio-2.Socket.receive_from", map[string]string{ "buffer": "in", "size": "in", }), ModifyParamDirections("Gio-2.Socket.receive_with_blocking", map[string]string{ "buffer": "in", "size": "in", }), ModifyParamDirections("Gio-2.DBusInterfaceGetPropertyFunc", map[string]string{ "error": "out", }), ModifyCallable("Gdk-4.Clipboard.read_async", func(c *gir.CallableAttrs) { p := FindParameter(c, "mime_types") p.Array = &gir.Array{ CType: "const char**", Type: &gir.Type{Name: "utf8"}, } }), MustIntrospect("Gdk-4.Clipboard.set_text"), MustIntrospect("Gdk-4.Clipboard.set_texture"), ModifyCallable("GLib-2.Variant.get_string", func(c *gir.CallableAttrs) { c.ReturnValue.Array = &gir.Array{ CType: "const gchar*", Type: &gir.Type{Name: "gchar"}, Length: new(int), ZeroTerminated: new(bool), } }), ModifySignal("Gio-2.Application::open", func(sig *gir.Signal) { param := FindParameterFromSlice(sig.Parameters.Parameters, "files") param.Array.CType = "GFile**" }), PreprocessorFunc(func(repos gir.Repositories) { variant := repos.FindFullType("GLib-2.Variant").Type.(*gir.Record) for _, method := range variant.Methods { returnsGVariant := true && method.ReturnValue != nil && method.ReturnValue.Type != nil && method.ReturnValue.Type.CType == "GVariant*" if returnsGVariant && !method.ReturnValue.Nullable { method.ReturnValue.Nullable = true } } }), }
Preprocessors defines a list of preprocessors that the main generator will use. It's mostly used for renaming colliding types/identifiers.
Functions ¶
func GLibAliases ¶
func GLibAliases(nsgen *girgen.NamespaceGenerator) error
GLibAliases generates aliases in the glib/v2 package to the core/glib package. It is generated so that users don't have to import both glib packages.
func GLibDateTime ¶
func GLibDateTime(nsgen *girgen.NamespaceGenerator) error
GLibDateTime generates NewTimeZoneFromGo and NewDateTimeFromGo.
func GLibLogs ¶
func GLibLogs(nsgen *girgen.NamespaceGenerator) error
GLibLogs adds the following g_log_* functions:
- g_log_set_handler
- g_log_set_handler_full
func GLibObjectComparer ¶
func GLibObjectComparer(nsgen *girgen.NamespaceGenerator) error
func GLibVariantIter ¶
func GLibVariantIter(nsgen *girgen.NamespaceGenerator) error
func GdkPixbufFromImage ¶
func GdkPixbufFromImage(nsgen *girgen.NamespaceGenerator) error
func GioArrayUseBytes ¶
func GioArrayUseBytes(nsgen *girgen.NamespaceGenerator) error
GioArrayUseBytes is the postprocessor that adds gio/v2.UseBytes.
func GtkInvalidListItem ¶
func GtkInvalidListItem(nsgen *girgen.NamespaceGenerator) error
func GtkLockOSThread ¶
func GtkLockOSThread(nsgen *girgen.NamespaceGenerator) error
func GtkNewDialog ¶
func GtkNewDialog(nsgen *girgen.NamespaceGenerator) error
func GtkNewMessageDialog ¶
func GtkNewMessageDialog(nsgen *girgen.NamespaceGenerator) error
func ImportGError ¶
func ImportGError(nsgen *girgen.NamespaceGenerator) error
ImportGError ensures that gerror is imported.
Types ¶
This section is empty.