From 256761bd91aa9341edc6b679cbf4ed7d1c6edd3a Mon Sep 17 00:00:00 2001 From: Mike D Pilsbury Date: Sun, 30 Dec 2018 15:30:26 +0000 Subject: [PATCH] Conditionally include gio network header for 2.36 or later. --- gobbi | 2 +- internal/generate/cincludes.go | 9 ++++++--- internal/generate/namespace-file-generate.go | 8 ++++---- internal/gir-files/Gio-2.0-addenda.gir | 3 +++ internal/test/gio/gio_test.go | 6 ++++++ lib/gio/bitfield-2.38.go | 1 + lib/gio/bitfield-2.40.go | 1 + lib/gio/class-2.36.go | 1 + lib/gio/class-2.38.go | 1 + lib/gio/class-2.40.go | 1 + lib/gio/class-2.42.go | 1 + lib/gio/class-2.44.go | 1 + lib/gio/class-2.46.go | 1 + lib/gio/class-2.48.go | 1 + lib/gio/class-2.50.go | 1 + lib/gio/class-2.56.go | 1 + lib/gio/constant-2.36.go | 1 + lib/gio/constant-2.38.go | 1 + lib/gio/constant-2.40.go | 1 + lib/gio/constant-2.46.go | 1 + lib/gio/constant-2.52.go | 1 + lib/gio/enum-2.40.go | 1 + lib/gio/enum-2.42.go | 1 + lib/gio/enum-2.44.go | 1 + lib/gio/enum-2.46.go | 1 + lib/gio/function-2.36.go | 1 + lib/gio/function-2.38.go | 1 + lib/gio/function-2.48.go | 1 + lib/gio/function-2.50.go | 1 + lib/gio/function-2.52.go | 1 + lib/gio/function-2.54.go | 1 + lib/gio/function-2.56.go | 1 + lib/gio/interface-2.38.go | 1 + lib/gio/interface-2.40.go | 1 + lib/gio/interface-2.44.go | 1 + lib/gio/interface-2.46.go | 1 + lib/gio/interface-2.48.go | 1 + lib/gio/interface-2.50.go | 1 + lib/gio/interface-2.56.go | 1 + lib/gio/record-2.40.go | 1 + lib/gio/record-2.44.go | 1 + lib/gio/record-2.46.go | 1 + lib/gio/record-2.48.go | 1 + lib/gio/record-2.54.go | 1 + 44 files changed, 59 insertions(+), 8 deletions(-) diff --git a/gobbi b/gobbi index 0fea50c3..202bbe30 100755 --- a/gobbi +++ b/gobbi @@ -3,7 +3,7 @@ set -e set -u exampleDir=example -tags="gobject_2.10 glib_2.48 gdk_3.4 gdkpixbuf_2.32 gio_2.32 gtk_3.18" +tags="gobject_2.10 glib_2.48 gdk_3.4 gdkpixbuf_2.32 gio_2.36 gtk_3.18" usage () { echo "Usage:" diff --git a/internal/generate/cincludes.go b/internal/generate/cincludes.go index af221d4c..a7346c65 100644 --- a/internal/generate/cincludes.go +++ b/internal/generate/cincludes.go @@ -7,13 +7,16 @@ import ( ) type CInclude struct { - Name string `xml:"name,attr"` + Name string `xml:"name,attr"` + Version string `xml:"version,attr"` } type CIncludes []*CInclude -func (cc CIncludes) generate(f *jen.File) { +func (cc CIncludes) generate(f *jen.File, version Version) { for _, cInclude := range cc { - f.CgoPreamble(fmt.Sprintf("#include <%s>", cInclude.Name)) + if cInclude.Version == "" || version.GTE(VersionNew(cInclude.Version)) { + f.CgoPreamble(fmt.Sprintf("#include <%s>", cInclude.Name)) + } } } diff --git a/internal/generate/namespace-file-generate.go b/internal/generate/namespace-file-generate.go index 6e6b9fdc..f7f2dbb5 100644 --- a/internal/generate/namespace-file-generate.go +++ b/internal/generate/namespace-file-generate.go @@ -45,7 +45,7 @@ func (ns *Namespace) generatePackageFile() { func (ns *Namespace) generateBooleanFile() { ns.generateFile("boolean", func(f *jen.File) { - ns.cgoPreambleHeaders(f) + ns.cgoPreambleHeaders(f, Version{}) f. Func(). @@ -62,7 +62,7 @@ func (ns *Namespace) generateBooleanFile() { }) } -func (ns *Namespace) cgoPreambleHeaders(file *jen.File) { +func (ns *Namespace) cgoPreambleHeaders(file *jen.File, version Version) { /* * Suppress C compiler warnings about deprecated functions. * @@ -77,7 +77,7 @@ func (ns *Namespace) cgoPreambleHeaders(file *jen.File) { file.CgoPreamble("#cgo CFLAGS: -Wno-format-security") file.CgoPreamble("#cgo CFLAGS: -Wno-incompatible-pointer-types") - ns.repo.CIncludes.generate(file) + ns.repo.CIncludes.generate(file, version) file.CgoPreamble("#include ") } @@ -98,7 +98,7 @@ func (ns *Namespace) generateGeneratables(typeName string, generatables Generata func (ns *Namespace) generateEntityVersionedFile(filename string, version Version, generatables Generatables) { ns.generateFile(filename, func(f *jen.File) { ns.buildConstraintsForVersion(f, version) - ns.cgoPreambleHeaders(f) + ns.cgoPreambleHeaders(f, version) ns.generateVersionDebugFunction(f, version.value) for _, entity := range generatables.entities() { diff --git a/internal/gir-files/Gio-2.0-addenda.gir b/internal/gir-files/Gio-2.0-addenda.gir index 115194f0..a782b33a 100644 --- a/internal/gir-files/Gio-2.0-addenda.gir +++ b/internal/gir-files/Gio-2.0-addenda.gir @@ -4,6 +4,9 @@ xmlns:c="http://www.gtk.org/introspection/c/1.0" xmlns:glib="http://www.gtk.org/introspection/glib/1.0" > + + + diff --git a/internal/test/gio/gio_test.go b/internal/test/gio/gio_test.go index 8646084c..948a1fd0 100644 --- a/internal/test/gio/gio_test.go +++ b/internal/test/gio/gio_test.go @@ -11,3 +11,9 @@ func TestCleanBuild(t *testing.T) { gio.APPLICATION_FLAGS_NONE) assert.NotNil(t, app) } + +// g_networking_init is defined in a header file that is not included +// in the gio gir repo file. +func TestAddendaCInclude(t *testing.T) { + gio.NetworkingInit() +} diff --git a/lib/gio/bitfield-2.38.go b/lib/gio/bitfield-2.38.go index f73e7930..d1d8d7e9 100644 --- a/lib/gio/bitfield-2.38.go +++ b/lib/gio/bitfield-2.38.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/bitfield-2.40.go b/lib/gio/bitfield-2.40.go index 0904b365..2b1b64e8 100644 --- a/lib/gio/bitfield-2.40.go +++ b/lib/gio/bitfield-2.40.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/class-2.36.go b/lib/gio/class-2.36.go index 87570acc..40ea1b56 100644 --- a/lib/gio/class-2.36.go +++ b/lib/gio/class-2.36.go @@ -24,6 +24,7 @@ import ( // #include // #include // #include +// #include // #include /* diff --git a/lib/gio/class-2.38.go b/lib/gio/class-2.38.go index 4e023148..6476fc00 100644 --- a/lib/gio/class-2.38.go +++ b/lib/gio/class-2.38.go @@ -24,6 +24,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/class-2.40.go b/lib/gio/class-2.40.go index 7b607bf1..f3c50000 100644 --- a/lib/gio/class-2.40.go +++ b/lib/gio/class-2.40.go @@ -26,6 +26,7 @@ import ( // #include // #include // #include +// #include // #include /* diff --git a/lib/gio/class-2.42.go b/lib/gio/class-2.42.go index fdf0cb4b..a9feffdb 100644 --- a/lib/gio/class-2.42.go +++ b/lib/gio/class-2.42.go @@ -22,6 +22,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/class-2.44.go b/lib/gio/class-2.44.go index c887e696..85b097de 100644 --- a/lib/gio/class-2.44.go +++ b/lib/gio/class-2.44.go @@ -24,6 +24,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/class-2.46.go b/lib/gio/class-2.46.go index 1efb5607..f634e516 100644 --- a/lib/gio/class-2.46.go +++ b/lib/gio/class-2.46.go @@ -23,6 +23,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/class-2.48.go b/lib/gio/class-2.48.go index 024d2902..26b1cbc3 100644 --- a/lib/gio/class-2.48.go +++ b/lib/gio/class-2.48.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/class-2.50.go b/lib/gio/class-2.50.go index 0272bf67..3c2c05a5 100644 --- a/lib/gio/class-2.50.go +++ b/lib/gio/class-2.50.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/class-2.56.go b/lib/gio/class-2.56.go index 0afc7af3..06b5e686 100644 --- a/lib/gio/class-2.56.go +++ b/lib/gio/class-2.56.go @@ -22,6 +22,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/constant-2.36.go b/lib/gio/constant-2.36.go index 90c23184..6f9c3ed5 100644 --- a/lib/gio/constant-2.36.go +++ b/lib/gio/constant-2.36.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/constant-2.38.go b/lib/gio/constant-2.38.go index 3eb8b745..e4ce05b2 100644 --- a/lib/gio/constant-2.38.go +++ b/lib/gio/constant-2.38.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/constant-2.40.go b/lib/gio/constant-2.40.go index 35155da4..47651f81 100644 --- a/lib/gio/constant-2.40.go +++ b/lib/gio/constant-2.40.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/constant-2.46.go b/lib/gio/constant-2.46.go index a7bd57d6..6fe664a9 100644 --- a/lib/gio/constant-2.46.go +++ b/lib/gio/constant-2.46.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/constant-2.52.go b/lib/gio/constant-2.52.go index 268f0ebd..c2ce9fc7 100644 --- a/lib/gio/constant-2.52.go +++ b/lib/gio/constant-2.52.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/enum-2.40.go b/lib/gio/enum-2.40.go index 80a8f612..2bad1cb6 100644 --- a/lib/gio/enum-2.40.go +++ b/lib/gio/enum-2.40.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/enum-2.42.go b/lib/gio/enum-2.42.go index 2725e0b3..9f9ee264 100644 --- a/lib/gio/enum-2.42.go +++ b/lib/gio/enum-2.42.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/enum-2.44.go b/lib/gio/enum-2.44.go index b44b655f..fea94235 100644 --- a/lib/gio/enum-2.44.go +++ b/lib/gio/enum-2.44.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/enum-2.46.go b/lib/gio/enum-2.46.go index 8cf13644..7ab82214 100644 --- a/lib/gio/enum-2.46.go +++ b/lib/gio/enum-2.46.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/function-2.36.go b/lib/gio/function-2.36.go index 82b83099..acdd3f1b 100644 --- a/lib/gio/function-2.36.go +++ b/lib/gio/function-2.36.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/function-2.38.go b/lib/gio/function-2.38.go index 9000ba9e..d95050e6 100644 --- a/lib/gio/function-2.38.go +++ b/lib/gio/function-2.38.go @@ -17,5 +17,6 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/function-2.48.go b/lib/gio/function-2.48.go index a6462781..53f132d0 100644 --- a/lib/gio/function-2.48.go +++ b/lib/gio/function-2.48.go @@ -17,5 +17,6 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/function-2.50.go b/lib/gio/function-2.50.go index 4a413f8d..1976cd7b 100644 --- a/lib/gio/function-2.50.go +++ b/lib/gio/function-2.50.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/function-2.52.go b/lib/gio/function-2.52.go index 3730b7a6..b3115d9b 100644 --- a/lib/gio/function-2.52.go +++ b/lib/gio/function-2.52.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/function-2.54.go b/lib/gio/function-2.54.go index d9668be1..7cd6f52c 100644 --- a/lib/gio/function-2.54.go +++ b/lib/gio/function-2.54.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/function-2.56.go b/lib/gio/function-2.56.go index 6c56243d..ff09131a 100644 --- a/lib/gio/function-2.56.go +++ b/lib/gio/function-2.56.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/interface-2.38.go b/lib/gio/interface-2.38.go index 72e46afa..f75abb01 100644 --- a/lib/gio/interface-2.38.go +++ b/lib/gio/interface-2.38.go @@ -22,6 +22,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/interface-2.40.go b/lib/gio/interface-2.40.go index e97785a5..6b679093 100644 --- a/lib/gio/interface-2.40.go +++ b/lib/gio/interface-2.40.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/interface-2.44.go b/lib/gio/interface-2.44.go index d2e5752a..4bd16793 100644 --- a/lib/gio/interface-2.44.go +++ b/lib/gio/interface-2.44.go @@ -23,6 +23,7 @@ import ( // #include // #include // #include +// #include // #include /* diff --git a/lib/gio/interface-2.46.go b/lib/gio/interface-2.46.go index 919b6508..454c676a 100644 --- a/lib/gio/interface-2.46.go +++ b/lib/gio/interface-2.46.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/interface-2.48.go b/lib/gio/interface-2.48.go index f28f2b87..3a477753 100644 --- a/lib/gio/interface-2.48.go +++ b/lib/gio/interface-2.48.go @@ -23,6 +23,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/interface-2.50.go b/lib/gio/interface-2.50.go index c2dce235..e6e65265 100644 --- a/lib/gio/interface-2.50.go +++ b/lib/gio/interface-2.50.go @@ -22,6 +22,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/interface-2.56.go b/lib/gio/interface-2.56.go index 30601a36..97341860 100644 --- a/lib/gio/interface-2.56.go +++ b/lib/gio/interface-2.56.go @@ -22,6 +22,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/record-2.40.go b/lib/gio/record-2.40.go index bf3baeb9..546791b3 100644 --- a/lib/gio/record-2.40.go +++ b/lib/gio/record-2.40.go @@ -22,6 +22,7 @@ import ( // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/record-2.44.go b/lib/gio/record-2.44.go index 26b423b7..1128657b 100644 --- a/lib/gio/record-2.44.go +++ b/lib/gio/record-2.44.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/record-2.46.go b/lib/gio/record-2.46.go index 2d1f560c..557fe251 100644 --- a/lib/gio/record-2.46.go +++ b/lib/gio/record-2.46.go @@ -17,6 +17,7 @@ package gio // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/record-2.48.go b/lib/gio/record-2.48.go index 52322a4b..da09e357 100644 --- a/lib/gio/record-2.48.go +++ b/lib/gio/record-2.48.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C" diff --git a/lib/gio/record-2.54.go b/lib/gio/record-2.54.go index 760369df..ac322a3d 100644 --- a/lib/gio/record-2.54.go +++ b/lib/gio/record-2.54.go @@ -19,6 +19,7 @@ import "unsafe" // #include // #include // #include +// #include // #include import "C"