Basically various trivial instances of the following MSVC compiler
warning:
```
../gio/gio-tool-set.c(50): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
```
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
There is a meson option (gir_dir_prefix), but without being passed in here
the files would always get installed into the default location (datadir).
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
All of the indications in the surrounding code are that `node` should
never be `NULL`, but the error handling for it did actually allow it to
be `NULL` iff its `parent` was also `NULL`.
That made scan-build (kind of legitimately) warn about `NULL` pointer
dereferences of `node`.
Avoid that by unambiguously using an assertion to prevent `NULL` nodes.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #1767
scan-build thinks that the `atypes` array is leaked, but it’s not.
Ownership is transferred into the `ffi_cif` structure, and it’s
eventually freed in `gi_callable_info_destroy_closure()`.
Try and help the static analysis by adding an explicit ownership
transfer annotation. It probably won’t help.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #1767
We don't actually need to use the Meson-detected size macros here,
because the result of `sizeof()` is an integer constant expression.
No functional change.
Signed-off-by: Simon McVittie <smcv@collabora.com>
g-ir-scanner currently maps these to lower-level types at scan time by
assuming that time_t is an alias for long, off_t is an alias for size_t
and so on. This is not always accurate: some ILP32 architectures have
64-bit time_t (for Y2038 compatibility) and 64-bit off_t (for large file
support), and that mismatch is tracked as GNOME/gobject-introspection#494.
One option for resolving this g-ir-scanner bug is to have it pass these
types through to the GIR XML, and teach g-ir-compiler and its replacement
gi-compile-repository to convert them to the corresponding concrete
type tag, as they already do for abstract types such as `long long` and
`size_t`.
Loosely based on GNOME/gobject-introspection!451 by Shuyu Liu.
Co-authored-by: Shuyu Liu <liushuyu011@gmail.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
We don't actually need to use the results of configure-time checks here:
sizeof is a perfectly reasonable integer constant expression, so we can
use that directly.
Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
Signed-off-by: Simon McVittie <smcv@collabora.com>
Otherwise, correct invocation isn't clear from the --help output.
This does not introduce new translated strings: FILE was already
translated.
Signed-off-by: Simon McVittie <smcv@collabora.com>
If we don't do this, the --help text is formatted as though the option
did not expect an argument.
This does not introduce new translated strings: DIRECTORY was already
translated.
Signed-off-by: Simon McVittie <smcv@collabora.com>
The code and strings are the same, so let’s simplify things and reduce
LoC for no functional change.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This fixes a few formatting and newline issues in the strings at the
same time, but nothing major.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: #3263
This is a behaviour change from g-ir-generate, which treats it as
least-important-first (the last directory on the command-line is
searched first).
gi-compile-repository --includedir and gcc -I are most-important-first
(the first directory on the command-line is searched first) so it seems
like it makes most sense to be consistent with that.
Signed-off-by: Simon McVittie <smcv@collabora.com>
This should make the code a bit more usable in situations where people
aren’t potentially using MSVC.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3255
`GITypeInfo` isn’t defined in `libgirepository-internals`, and that was
forcing us to do some header includes which violated the layering
between `libigrepository-internals` and `libgirepository`. Fix that by
moving the helper function to the header/source where `GITypeInfo` is
defined.
This fixes commit 54f156bd63.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
We certainly won't find the requested namespace in a newly-created
repository with no typelibs loaded.
Fixes: 9ab84bc1 "girwriter: Stop using the singleton GIRepository"
Signed-off-by: Simon McVittie <smcv@collabora.com>
The positional parameters are declared as G_OPTION_ARG_FILENAME_ARRAY,
but only the first one is used.
Signed-off-by: Simon McVittie <smcv@collabora.com>
This seems to have been a remnant of support for embedding the typelib
in the shared library, which was removed from this tool in commit 4bf5ef6b
"[girepository] Actually verify header of loaded typelibs in
g_irepository_require" (originally gobject-introspection@05ffd857).
The feature of embedding the typelib in a shared library was itself
removed in commit b2df59c3 "compiler: Remove --code argument",
originally gobject-introspection@ac81f3e8, with a note that because
we rely on being able to load the shared library into g-ir-scanner,
anything that links g-ir-scanner output into the shared library would be
a circular dependency.
Signed-off-by: Simon McVittie <smcv@collabora.com>
It seems cleaner to store this in the parser, rather than having the
compiler export a global variable that the parser must read.
Signed-off-by: Simon McVittie <smcv@collabora.com>
This hasn't actually done anything since commit 45a04358
"[gircompiler] Clean up parsing" (originally
gobject-introspection@8942500c).
Signed-off-by: Simon McVittie <smcv@collabora.com>
On i386 Linux, the minimal ABI alignment of a double is only 4, and
therefore the alignment of GDoubleIEEE754 is also 4.
Signed-off-by: Simon McVittie <smcv@collabora.com>
To avoid a big introspection API break.
These APIs are now listed in the new `{GLib,Gio}{Unix,Win32}-2.0.gir`
files, but for backwards compatibility they need to continue to be
listed in `Gio-2.0.gir` and `GLib-2.0.gir` as well, until the next major
introspection API break (and none is planned).
No new platform specific APIs should be added to these GIR files, but
these existing ones must remain.
See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3892#note_2001361
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
So now introspection users will have to call `GLibUnix.open_pipe()`
rather than `GLibUnix.unix_open_pipe()` — or
`GLibWin32.check_windows_version()` rather than
`GLibWin32.win32_check_windows_version()`.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3037
For both GLib and GIO. (GObject, GIRepository and GModule don’t have any
platform specific APIs.)
This is needed for two reasons:
* If the same GIR file is shipped on multiple platforms, it has no way
to conditionally define/not-define an API based on the platform (like
an `#ifdef` in a C header). So we either end up shipping differing
GIR APIs on different platforms, or shipping a GIR file which
declares APIs which aren’t resolvable by `dlopen()` on certain
platforms, and will cause a language runtime error.
* The API reference documentation is now generated from the GIR, and
similar problems are present there: if the GIR contains different
symbols depending on the platform, there is no way to generate API
documentation for the union of all of them.
The fix is to ensure that there are no conditional symbols in a GIR, by
splitting out the platform specific symbols into platform specific GIR
files. Platform specific documentation can then be generated from these,
in addition to the main, platform agnostic, documentation.
The documentation changes will following in a subsequent commit.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3037
There was no obvious logical need to list the `GAppInfo` subclass
sources separately in the build. It makes more sense to add them to the
platform-specific source lists, since they are platform specific.
This will be used in an upcoming commit which generates
platform-specific GIR files, so needs the full platform-specific lists
of sources.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3037
It was causing a build failure on some platforms:
```
In file included from ../girepository/gthash.c:29:
In file included from ../girepository/gitypelib-internal.h:30:
../girepository/girepository-private.h:26:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^~~~~~~
```
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Instead, add a method on `GIRegisteredTypeInfo` which indicates whether
the registered type is a boxed type. This will return true for
`GIStructInfo` and `GIUnionInfo` instances which are boxed (not all
structs and unions are).
This makes `GIBoxedInfo` redundant, and it’ll be dropped in a following
commit.
---
There are several different things which typelibs need to be able to
represent:
1. Plain old datatype (POD) structs
2. POD unions
3. Structs with a copy func and/or free func
4. Unions with a copy func and/or free func
5. Structs which are the ‘GType struct’ for an object or interface (i.e.
the class or instance or interface struct)
6. Structs with a copy func and free func *and* boxed GType
7. Unions with a copy func and free func *and* boxed GType
8. Boxed GTypes which represent something other than a struct or union
So there’s a lot going on here. In commit
e28078c70cbf4a57c7dbd39626f43f9bd2674145, a lot of this was reworked,
and support was added for boxed unions and boxed ‘others’ (the last item
on the list above).
Since then, support for boxed types other than structs seems to have
atrophied a bit, and the whole lot has got a bit confusing.
It was perhaps less confusing when all the `GIBaseInfo` subclasses were
actually aliases of each other, but now they have subtype relationships,
the position of `GIBoxedInfo` in that type hierarchy has become unclear.
How is it related to `GIStructInfo`, `GIUnionInfo` and
`GIRegisteredTypeInfo`?
Since a boxed type is necessarily a `GIRegisteredTypeInfo`, and the
methods of `GIRegisteredTypeInfo` are all written to allow a `GType` to
be optional, so that `GIStructInfo` and `GIUnionInfo` can safely derive
from it and still be used to represent plain old datatypes without
`GType`s, it makes sense to add a method to `GIRegisteredTypeInfo` to
indicate that the registered type is derived from `G_TYPE_BOXED`.
Accordingly, the things above are now represented in libgirepository’s
type system as:
1. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return no
`GType` info
2. `GIUnionInfo` instance similarly
3. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return no
`GType` info, `gi_struct_info_get_{copy,free}_function_name()` return
non-`NULL` values
4. `GIUnionInfo` instance similarly
5. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return no
`GType` info, `gi_struct_info_is_gtype_struct()` returns true
6. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return valid
`GType` information, `gi_registered_type_info_is_boxed()` returns
true, `gi_struct_info_get_{copy,free}_function_name()` return
`NULL` values (because the copy/free functions are hidden inside the
boxed type registration at runtime)
7. `GIUnionInfo` instance similarly
8. Not representable, but could be represented in future by re-adding a
`GIBoxedInfo` type which derives from `GIRegisteredTypeInfo` and is
used solely for boxed ‘other’ types, *not* boxed structs or unions
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Fixes: #3245
When creating `GIBaseInfo` instances from binary blobs, so far the code
has used an undocumented implicit conversion from one enum type to the
other. That’s a bit nasty, as it means the two enum types need to be
kept in sync (without that need being documented).
Introduce an explicit conversion function to make things more explicit.
Currently it does nothing, but in an upcoming commit it will be used to
deprecate a blob type.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: #3245