Commit Graph

1588 Commits

Author SHA1 Message Date
Chun-wei Fan
a7a6449f4d meson: Install items according to their relevance
The m4 and bash completion items are usable and relevant
depending on the host system's configuration.  So, we check for the
presence of the programs that these items depend on, and only install
them when those programs are found.

For the Valgrind suppression files, we don't install them on Windows as
Valgrind is currently not supported on Windows.

Als fix the path where the GDB helpers are installed, as the path is
incorrectly constructed.

This will fix the "install" stage when building on Visual Studio at
least as there are some post-install steps that are related to them,
which will make use of these programs.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
2017-09-14 16:02:03 +08:00
Nicolas Dufresne
0d9c5122bc valuearray: Skip g_value_array_free() in bindings
Calling this function can easily lead to an interpreter crash.

https://bugzilla.gnome.org/show_bug.cgi?id=780202
2017-09-11 21:11:55 +01:00
Mikhail Zabaluev
0ea004c6f9 gobject: Skip more non-introspectable data/qdata methods
https://bugzilla.gnome.org/show_bug.cgi?id=756588
2017-09-11 20:34:46 +01:00
Mikhail Zabaluev
1e45c0a0e1 gobject: Add missing (nullable) and (out) annotations on the data/qdata API
https://bugzilla.gnome.org/show_bug.cgi?id=756588
2017-09-11 20:34:45 +01:00
Federico Mena Quintero
51e852e5d0 validate_pspec_to_install(): Factor out function to validate a GParamSpec
This was duplicated also in g_object_interface_install_property().

Now, validations specific to classes happen in
validate_and_install_class_property() - specifically, the checks for
the presence of the get_property() and set_property() methods.

https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 12:44:45 -05:00
Federico Mena Quintero
20720eaf1e validate_and_install_property(): Check pspec-specific fields in the same order as g_object_interface_install_property()
https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 12:44:45 -05:00
Federico Mena Quintero
95f44b280f validate_and_install_property(): Validate presence of get/set_property methods last
https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 12:44:45 -05:00
Federico Mena Quintero
1b08414f06 g_object_interface_install_property(): Do interface-specific validations first
https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 12:44:45 -05:00
Federico Mena Quintero
e667d0d4c0 install_property_internal(): Propagate failure when installing duplicated properties
https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 12:44:41 -05:00
Federico Mena Quintero
9dd9fe4feb validate_and_install_class_property(): Factor out function to add a new property to a class
This was duplicated between g_object_class_install_property() and
g_object_class_install_properties().

https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 11:26:01 -05:00
Federico Mena Quintero
85ef144334 GObjectClass: extract class type and parent type at the beginning
https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 11:26:01 -05:00
Federico Mena Quintero
7d9a6c8687 GObjectClass: Validate installing property/properties in the same way
Then we'll be able to factor out duplicated code.

https://bugzilla.gnome.org/show_bug.cgi?id=787551
2017-09-11 11:26:01 -05:00
Emmanuele Bassi
100b83a7fa genmarshal Only wrap body prototypes in C++ guards
Commit 31ae2c5598 added the C++ guards
around all prototypes, including inside the header file. The header
file, though, already has C++ guards, so while it's harmless to have
them there, it's also unnecessary.

We should only emit C++ guards around the prototypes we include in the
generated source.
2017-08-25 09:53:56 +01:00
Ernestas Kulik
00f5d2ffa2 gobject: add autoptr support for GClosure
This commit defines a g_autoptr() cleanup function for use with
GClosure.

https://bugzilla.gnome.org/show_bug.cgi?id=786360
2017-08-16 16:19:28 +03:00
Mihai Moldovan
31ae2c5598 glib-genmarshal: wrap prototypes in G_{BEGIN,END}_DECLS.
Since --header --body has been deprecated and replaced with --body
--prototypes, the generated body is not wrapped with G_{BEGIN,END}_DECLS
any longer. Projects using C++ break due to that. Automatically wrap
prototypes individually in G_{BEGIN,END}_DECLS instead.

https://bugzilla.gnome.org/show_bug.cgi?id=785554
2017-08-07 17:07:06 +01:00
Alberts Muktupāvels
8cc9950202 glib-mkenums: fix parsing of flags annotation
https://bugzilla.gnome.org/show_bug.cgi?id=779332
2017-08-01 10:24:44 +01:00
Emmanuele Bassi
ca69df0f16 Revert "glib-mkenums: fix parsing of /*< flags >*/ annotation"
This reverts commit 1672678bc4.

A more comprehensive fix will follow.
2017-08-01 10:11:09 +01:00
Christoph Reiter
867b5e6f90 glib-mkenums: Python2: use locale encoding when redirecting stdout
In case of Python 2 and stdout being redirected to a file, sys.stdout.encoding
is None and it defaults ASCII for encoding text.

To match the behaviour of Python 3, which uses the locale encoding also when
redirecting to a file, wrap sys.stdout with a StreamWriter using the
locale encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=785113
2017-07-26 22:27:48 +02:00
Christoph Reiter
b92e15c75d glib-mkenums: fix encoding error when writing files
Instead of using NamedTemporaryFile, which doesn't take an encoding in Python 2
use mkstemp() to create a file and open it with io.open(), with a proper
encoding set.

https://bugzilla.gnome.org/show_bug.cgi?id=785113
2017-07-22 20:47:43 +02:00
Christoph Reiter
d88d1ba7e8 glib-mkenums: Don't use FileNotFoundError, it's Python 3 only.
https://bugzilla.gnome.org/show_bug.cgi?id=785113
2017-07-19 14:21:24 +02:00
Christoph Reiter
c2dace6b8b glib-mkenums: Use utf-8 for reading files
On Windows open() defaults to ANSI and on Python 2 it doesn't take
an encoding. Use io.open() instead which provides the same interface
on both Python versions.

https://bugzilla.gnome.org/show_bug.cgi?id=785113
2017-07-19 14:21:20 +02:00
Emmanuele Bassi
2219cfb92d mkenums: Keep compatibility with Python 2.x
Since every other tool in GLib is allowed to be used with Python 2.x,
glib-mkenums should follow suit.
2017-07-17 16:29:40 +01:00
Emmanuele Bassi
f18556749c mkenums: Skip unparsed lines
The old glib-mkenums just skipped lines it could not understand.
2017-07-17 16:11:19 +01:00
Emmanuele Bassi
4f17d1049f mkenums: Add missing --fprod handler
We are not generating the template for the --fprod command line
argument.
2017-07-17 11:15:06 +01:00
Emmanuele Bassi
3c03cc8f68 meson: Simplify the use of built tools
The Meson build has fallen a bit behind the Autotools one, when it comes
to the internally built tools like glib-mkenums and glib-genmarshals.

We don't need to generate gmarshal.strings any more, and since the
glib-genmarshal tool is now written in Python it can also be used when
cross-compiling, and without indirection, just like we use glib-mkenums.

We can also coalesce various rules into a simple array iteration, with
minimal changes to glib-mkenums, thus making the build a bit more
resilient and without unnecessary duplication.
2017-07-17 11:05:07 +01:00
Emmanuele Bassi
7ee050dc4b mkenums: Use the same reporting functions from genmarshal
We can reuse the same code to make error reporting stand out a bit more,
with colors and potentially with the ability to make warnings fatal.
2017-07-17 10:32:33 +01:00
Emmanuele Bassi
69515e9f5c mkenums: Skip files not found
The old glib-mkenums was more forgiving, and simply ignored any files it
could not find.

We're going to print a warning, as in the future we may want to allow
more strictness.
2017-07-17 10:24:32 +01:00
Emmanuele Bassi
77a3a96218 mkenums: Change ordering for template file and arguments
This is a bit of a hack to maintain some semblance of backward
compatibility with the old, Perl-based glib-mkenums. The old tool had an
implicit ordering on the arguments and templates; each argument was
parsed in order, and all the strings appended. This allowed developers
to write:

  glib-mkenums \
    --fhead ... \
    --template a-template-file.c.in \
    --ftail ...

And have the fhead be prepended to the file-head stanza in the template,
as well as the ftail be appended to the file-tail stanza in the
template.  Short of throwing away ArgumentParser and going over
sys.argv[] element by element, we can simulate that behaviour by
ensuring some ordering in how we build the template strings:

  - the head stanzas are always prepended to the template
  - the prod stanzas are always appended to the template
  - the tail stanzas are always appended to the template

Within each instance of the command line argument, we append each value
to the array in the order in which it appears on the command line.

This change fixes the libqmi build.
2017-07-17 09:37:21 +01:00
Emmanuele Bassi
35db045729 mkenums: Fix typo
There's a stray '~' that needs to be removed.
2017-07-16 17:25:08 +01:00
Emmanuele Bassi
69389bdc34 mkenums: Do not check for None
The symprefix variable can only be a string.
2017-07-16 12:06:34 +01:00
Emmanuele Bassi
af4a6457eb mkenums: Some arguments can be used multiple times
Some of the arguments that affect the generated result in glib-mkenums
can be used multiple times, to avoid embedding unnecessary newlines in
their values.

This change fixes the NetworkManager build.
2017-07-16 11:56:52 +01:00
Emmanuele Bassi
d19f53a767 Add more compatibility mode hacks
When using the `--header --body` compatibility mode, we need to emit
things we generally define in the header, such as the aliases for
standard marshallers, and aliases for deprecated tokens.

This fixes dbus-binding-tool, which is using `--header --body` and
deprecated tokens.

See: https://bugs.freedesktop.org/show_bug.cgi?id=101799
2017-07-16 11:15:07 +01:00
Christoph Reiter
fbf3511309 meson: fix typo in install path for gobject_gdb.py 2017-07-16 00:23:16 +02:00
Tim-Philipp Müller
8451f0b817 glib-mkenums: unescape \n etc. in command line arguments
Fixes generation of GStreamer enumtype files with autotools build.

https://bugzilla.gnome.org/show_bug.cgi?id=779332
2017-07-15 13:02:40 -04:00
Igor Gnatenko
a882c974d3 mkenums: pass string for re.sub() for real
Signed-off-by: Igor Gnatenko <ignatenko@src.gnome.org>
2017-07-15 15:33:17 +02:00
Igor Gnatenko
1a182df5d1 mkenums: don't try to call undefined function
argparse will take care about everything

Signed-off-by: Igor Gnatenko <ignatenko@src.gnome.org>
2017-07-15 15:33:17 +02:00
Igor Gnatenko
615238d0a4 mkenums: make string raw for real regex
Signed-off-by: Igor Gnatenko <ignatenko@src.gnome.org>
2017-07-15 15:33:17 +02:00
Igor Gnatenko
d753a411c0 mkenums: trivial style fixes
Signed-off-by: Igor Gnatenko <ignatenko@src.gnome.org>
2017-07-15 15:33:17 +02:00
Igor Gnatenko
112908d9e4 mkenums: fix main incompatibility with python2
Signed-off-by: Igor Gnatenko <ignatenko@src.gnome.org>
2017-07-15 15:27:31 +02:00
Emmanuele Bassi
4395a89777 Use env to run the Python-based tools
Otherwise overriding the Python interpreter with `--with-python` won't
work correctly.
2017-07-14 21:21:33 +01:00
Emmanuele Bassi
0f18a2ebda meson: Substitute the Python shebang
Just like we do with Autotools. This allows building glib-mkenums and
glib-genmarshal on older platforms that only have Python 2.
2017-07-14 20:43:19 +01:00
Emmanuele Bassi
065a8a488a meson: Use the appropriate interface and binary ages
We need to build them out of the project version, and then propagate
them.
2017-07-14 14:21:57 +01:00
Matthias Clasen
b8c8bb73b0 Fix glib-genmarshal build with meson
This is no longer built from a C source, but a python file.
2017-07-13 19:35:09 -04:00
Tim-Philipp Müller
dbf0a56670 glib-mkenums: pick up /*< nick=xyz >*/ annotation again
... in glib-mkenums python port.

Was parsed correctly but then skipped due to inverted condition.

https://bugzilla.gnome.org/show_bug.cgi?id=779332
2017-07-13 19:03:39 -04:00
Matej Knopp
dc9b01fd64 glib-mkenums: add back missing --fprod option
... in glib-mkenums python port.

https://bugzilla.gnome.org/show_bug.cgi?id=779332
https://bugzilla.gnome.org/show_bug.cgi?id=783198
2017-07-13 19:03:39 -04:00
Matej Knopp
29f9fe041b glib-mkenums: Fix parsing of multiline comments
... in glib-mkenums python port.

https://bugzilla.gnome.org/show_bug.cgi?id=779332
https://bugzilla.gnome.org/show_bug.cgi?id=783198
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
1672678bc4 glib-mkenums: fix parsing of /*< flags >*/ annotation
Fixes get_type function generation for:

 - GMountMountFlags
 - GDriveStartFlags
 - GResourceLookupFlags
 - GSocketMsgFlags
 - GTlsDatabaseVerifyFlags
 - GTestDBusFlags

which were registered as enum types before, which broke
some unit tests.

Problem is that the flags annotation has no value, so
options.get('flags') would always return None even if
it was present.

https://bugzilla.gnome.org/show_bug.cgi?id=779332
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
2d72a9e1d1 glib-mkenums: misc fixes to python port 2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
dd8ff54736 meson: Use Python port of glib-mkenums
This reduces the build-time dependencies of glib to only Python 3,
Meson, and git. Git is also optional if you provide a tarball in
which the subproject directories already exist.

The Python port was done by Jussi Pakkanen on bugzilla:
https://bugzilla.gnome.org/show_bug.cgi?id=779332

This version contains some fixes from that and also changes all
instances of `@` to `\u0040` because Meson does not yet provide a
configure_file() mode that ignores unknown @MACRO@ values.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
ee94ad776e meson: Use proxy-libintl if gettext is not found
This is a stub-only library that can be used while building against
MSVC and contains no i18n machinery at all.

The dependencies added indirectly use the libintl.h header, and when
built as a subproject, the header won't be in a path known the
pre-processor.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
2f29ee1735 meson: add -fvisibility=hidden explicitly to selected targets
Don't use it project-wide for building everything. Otherwise
symbols for shared modules won't be exposed, e.g. in the
resourceplugin used by the gio resource unit test.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
34e4e25d53 meson: gio/tests: add more missing tests 2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
33fb1bbb61 meson: gio, gobject: use files() for headers list
Since these variables are referenced from other directories
such as the tests/ subdir as well.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
d29f022b0b meson: add support for dtrace/systemtap
Still at least one FIXME. And untested so far. It builds.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
e2da3cb599 meson: Port to latest master (2.51.0)
Also remove headers from some gio sources. Headers do not need to be
added to the list of sources.

+ various smaller self-explanatory fixes.
2017-07-13 19:03:39 -04:00
Patrick Griffis
d10be6102f meson: Minor modernizations 2017-07-13 19:03:39 -04:00
Patrick Griffis
a690e2a375 meson: More build fixes
- Fix installing various data files
- Build translations
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
fe2a9887a8 meson: Improve MSVC and MinGW support and fix dependencies everywhere
Disable gio tests on Windows, fix .gitignore to not ignore
config.h.meson, and add more things to it.

Rename the library file naming and versioning to match what Autotools
outputs, e.g., libglib-2.0.so.0.5000.2 on Linux, libglib-2.0-0.dll  and
glib-2.0-0.dll on Windows with MSVC.

Several more tiny fixes, more executables built and installed, install
pkg-config and m4 files, fix building of gobject tests.

Changes to gdbus-codegen to support out-of-tree builds without
environment variables set (which you can't in Meson). We now add the
build directory to the Python module search path.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
213957970e meson: Fix glib, add gobject, gio, gthread, gmodule, etc
Several small fixes to the build files.

Lots of tests have also been added, and glib tests pass now.
2017-07-13 19:03:39 -04:00
Matthias Clasen
41385745e7 Revert "mkenums: Support public/private trigraph"
This reverts commit 9ba17d511e.

This conflicts with the python port in the meson branch.
2017-07-13 19:03:00 -04:00
Emmanuele Bassi
c6793d1cfb Allow whitespace between marshallers list tokens
Some (older) list files use whitespace, and we need to take that into
account when splitting off the various tokens.
2017-07-11 18:25:26 +01:00
Emmanuele Bassi
30b961607a Avoid a leak for arguments in va_list marshallers
We need to revers a check on whether the list of arguments needs
unboxing.
2017-07-11 12:24:10 +01:00
Emmanuele Bassi
ea365530d2 Do not mix declarations and statements
Projects using glib-genmarshal may still wish to support C89.
2017-07-11 12:15:44 +01:00
Emmanuele Bassi
9c66e65b29 Remove unused marshallers-related files
We don't use gmarshal.list any more, and the generated gmarshal.strings
file is not used after the Python port of glib-genmarshal.

https://bugzilla.gnome.org/show_bug.cgi?id=784528
2017-07-10 16:47:48 +01:00
Emmanuele Bassi
f7643a7df7 Re-enable signal tests when cross-compiling
The glib-genmarshal tool has been rewritten in Python, which means we
can run it when cross-compiling.

https://bugzilla.gnome.org/show_bug.cgi?id=784528
2017-07-10 16:47:48 +01:00
Emmanuele Bassi
93f16a45ab Rewrite glib-genmarshal in Python
We're in the process or rewriting other tools in Python to reduce the
number of dependencies of GLib.

Additionally, making glib-genmarshal a Python script reduces the
complexity when cross-compiling, as we don't need a native build to
generate the marshallers.

https://bugzilla.gnome.org/show_bug.cgi?id=784528
2017-07-10 16:47:47 +01:00
Philip Withnall
a131134918 build: Drop nmake/MSC build system for GLib
It hasn’t been seriously maintained for the best part of 10 years and is
very outdated. The recommended way to build GLib on Windows is now
Visual Studio:

https://wiki.gnome.org/Projects/GTK%2B/Win32/MSVCCompilationOfGTKStack#GLib

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=722047
2017-07-10 11:22:40 +01:00
Colin Walters
017f78d77f gtype: Add private DEFINE_TYPE with prelude to workaround gtype deadlocks
And use it in GSocket, as it had a real-world case reported.

https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-06-14 14:45:45 -04:00
Sébastien Wilmet
6b948d9613 gobject/: LGPLv2+ -> LGPLv2.1+
All gobject/*.{c,h} files have been processed.

gmarshal.c and gmarshal.h don't have a license header.

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-24 11:58:19 +02:00
Sébastien Wilmet
308bc41fb9 gobject/tests/: LGPLv2+ -> LGPLv2.1+
A lot of tests in gobject/tests/ don't have a license header. And some
tests are licensed under a BSD-style license.

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-24 11:58:19 +02:00
Emmanuele Bassi
9ba17d511e mkenums: Support public/private trigraph
It is possible, when using GTK-Doc, to mark sections of an enumeration
type as "private": the values are there, but they are not documented,
and GTK-Doc won't complain about missing symbols:

    typedef enum {
      /*< private >*/
      MY_FOO_PRIVATE,

      /*< public >*/
      MY_FOO_VALUE_A,
      MY_FOO_VALUE_B,

      /*< private >*/
      MY_FOO_VALUE_C,
      MY_FOO_VALUE_D
    } MyFooValue;

The glib-mkenums parser also allows skipping enumeration values, using a
slightly different syntax:

    typedef enum P
      MY_BAR_PRIVATE, /*< skip >*/
      MY_BAR_VALUE_A,
      MY_BAR_VALUE_B
    } MyBarValue;

The annotation must sit on the same line as the enumeration value.

Both GTK-Doc and glib-mkenum use the same trigraph syntax, but slightly
different keys. This makes combining them slightly redundant, but
feasible.

All would be well and good, except that glib-mkenum will generate a
warning for lines it does not understand — and that includes the GTK-Doc
annotation trigraph, which, when confronted with the MyFooValue
enumeration above, will result in a warning like:

    glib-mkenums: myfoo.h:2: Failed to parse `  /*< private >*/ '
    glib-mkenums: myfoo.h:5: Failed to parse `  /*< public >*/ '
    glib-mkenums: myfoo.h:9: Failed to parse `  /*< private >*/ '

Of course, we could make glib-mkenum ignore any trigraph comment on a
stand alone line, but it would probably be better to ensure that both
glib-mkenums and gtk-doc behave consistently with each other, and
especially with the maintainer's intent of hiding some values from the
user, and reserving them for internal use.

So we should ensure that glib-mkenums automatically skips all the
enumeration values after a "private" flag has been set, until it reaches
a "public" stanza.

https://bugzilla.gnome.org/show_bug.cgi?id=782162
2017-05-16 11:23:50 +01:00
Mohammed Sadiq
274f336f6a docs: Trivial typo fixes
The presence of space was resulting in wrongly rendered documentation
in devhelp (and probably in other documentations).

https://bugzilla.gnome.org/show_bug.cgi?id=782068
2017-05-16 11:22:54 +01:00
Emmanuele Bassi
17a3c782db genmarshal: Always generate the prototypes in the body
This way code that does not manually include the generated marshallers
header and wishes to build with `-Wmissing-prototypes` will not generate
a compiler warning.

https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
Emmanuele Bassi
616cff7c87 genmarshal: Use fewer magic numbers
https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
Emmanuele Bassi
a8b5192d16 genmarshal: Constify global variables
https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
Emmanuele Bassi
1ffad8fed9 genmarshal: Conform --help output to conventions
The convention for arguments taking a value is:

  --argument=VALUE

with the `VALUE` in caps.

https://bugzilla.gnome.org/show_bug.cgi?id=781755
2017-04-28 17:39:14 +01:00
Emmanuele Bassi
f952fdf3fc Drop trailing semi-colon from G_DEFINE_ macro
It's unnecessary, and only adds visual noise; we have been fairly
inconsistent in the past, but the semi-colon-less version clearly
dominates in the code base.

https://bugzilla.gnome.org/show_bug.cgi?id=669355
2017-04-10 10:38:31 +01:00
Tim-Philipp Müller
a83ccc535f gobject: remove duplicate GType sanity check
This is going to be checked again by g_object_new_with_properties()
and g_object_new_valist() anyway, so might just as well leave it
to those functions to do the check and only do it once. It doesn't
matter which function emits the critical warning in the end either,
as one has to look at a stack trace to find out what code triggered
it in any case.

https://bugzilla.gnome.org/show_bug.cgi?id=780908
2017-04-08 01:20:29 -04:00
Philip Withnall
2f2c2b6362 gobject: Fix Since/Deprecated versions for GParameter replacement API
This slipped through the review cracks.

https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 11:09:53 +01:00
Fabian Orccon
e2c3b7f634 gobject: Deprecate g_object_newv
g_object_newv uses a GParameter as argument. Since GParameter
is deprecated due to this type is not introspectible,
g_object_newv is deprecated now.

https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 11:00:23 +01:00
Fabian Orccon
2646c21735 gobject: Deprecate GParameter
GParameter is a rarely used type and not introspectible.

https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 11:00:23 +01:00
Fabian Orccon
942edbc700 tests: Add test for gobject properties for g_object_newv/setv/getv
https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 11:00:23 +01:00
Fabian Orccon
c6d373bfe7 gobject: Add g_object_setv and g_object_getv functions
https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 10:38:30 +01:00
Fabian Orccon
26b211ef89 gobject: Add g_object_new_with_properties
g_object_new_with_properties is an alternative to g_object_newv.
The last one, takes an array of GParameter. However, GParameter
is a rarely used type and this type is not introspectible, so
it will not work properly in bindings.

https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 10:38:30 +01:00
Fabian Orccon
19e81dedc9 gobject: Add helper functions to handle warnings in g_object_new/set/get
g_object_new_is_valid_property
g_object_get_is_valid_property
g_object_set_is_valid_property

https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 10:38:30 +01:00
Garrett Regier
6c95cd22e9 gobject: Add to_string() functions for Enum and Flags types
These are useful for debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=447907
2017-03-30 09:52:28 +01:00
Simon McVittie
8686e43058 glib-mkenums: Sort input files for more deterministic output
This should be helpful for reproducible builds
<https://reproducible-builds.org/>.

Perl's sorting is not locale-sensitive unless the lexical scope has
'use locale', which this one does not, so we do not need to force
locale-agnostic sorting.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=769983
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=809152
2017-03-04 22:05:44 +00:00
Simon McVittie
e3f59e482b Install gdb Python helpers as data, not as executable scripts
They do not start with the #!/usr/bin/python that would be necessary
to make them run with Python rather than a shell, and they would
not be useful to run anyway: they are libraries to be imported,
not scripts to be run.

Signed-off-by: Simon McVittie <smcv@debian.org>
2017-03-03 20:08:42 +00:00
Chun-wei Fan
6dfc6fee7b Visual Studio builds: Move project files to win32/
It was suggested that the project files be moved here as we don't actually
need to go two directory layers from $(srcroot), and would help us to
standardize on things in the future across the board.
2017-01-09 14:00:46 +08:00
Philip Withnall
953c182d25 gobject: Document behaviour of GType checking macros on NULL
The macros differ in their handling of NULL values — some macros ignore
them and pass through (e.g. G_TYPE_CHECK_INSTANCE_CAST) while others
will explicitly emit a warning if passed NULL (e.g.
G_TYPE_CHECK_INSTANCE).

Document their behaviour, so people don’t end up putting unnecessary
NULL checks in their code when doing checked type casts.

https://bugzilla.gnome.org/show_bug.cgi?id=735731
2017-01-07 23:43:06 +00:00
Simon McVittie
e5ed410c8c Avoid calling Standard C string/array functions with NULL arguments
glibc string.h declares memcpy() with attribute(nonnull(1,2)), causing
calls with NULL arguments to be treated as undefined behaviour.
This is consistent with ISO C99 and C11, which state that passing 0
to string functions as an array length does not remove the requirement
that the pointer to the array is a valid pointer.
gcc -fsanitize=undefined catches this while running OSTree's test suite.

Similarly, running the GLib test suite reports similar issues for
qsort(), memmove(), memcmp().

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
2016-12-02 19:10:39 +00:00
Simon McVittie
5e7eaaaaee GParam: make G_PARAM_USER_MASK unsigned
UBSan considers left-shifting a negative number to be undefined
behaviour (per
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_081.html> it is
implementation-defined in C89, but according to
<https://llvm.org/bugs/show_bug.cgi?id=17490> it is undefined in C99).

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
2016-12-02 19:10:26 +00:00
Philip Withnall
3e7b5cbef8 glib: Namespace global tapset variables by soname
global variables in SystemTap are shared between all SystemTap scripts;
so if scripts are loaded for two versions of GLib (for example, a stable
and a development version), those global variables will conflict.

Avoid that by including the soname’s version in the global variable
names.

https://bugzilla.gnome.org/show_bug.cgi?id=770646
2016-11-23 10:50:39 +00:00
Christian Hergert
18a33f72db introspection: use (nullable) or (optional) instead of (allow-none)
If we have an input parameter (or return value) we need to use (nullable).
However, if it is an (inout) or (out) parameter, (optional) is sufficient.

It looks like (nullable) could be used for everything according to the
Annotation documentation, but (optional) is more specific.
2016-11-22 14:14:37 -08:00
Philip Withnall
9f4d5e8b91 gsignal: Mention handler ID type in signal connection macro docs
gtk-doc doesn’t make the return type clear, because these are macros
rather than inline functions, so people often have to guess at the
return type (or look it up from g_signal_connect_closure(), but that’s
hard work).

Make it clear that the return type for handler IDs is gulong. While
there, fix the capitalisation of ‘id’ to ‘ID’ in a few places.
2016-11-10 16:12:41 +00:00
Tim-Philipp Müller
932eb87083 glib-mkenums: fix variable declaration
Inconsequential, just sync up declaration with actual
name of variable to avoid confusion.

https://bugzilla.gnome.org/show_bug.cgi?id=770175
2016-11-08 15:21:03 +00:00
Hannes Müller
7470cc902b Avoid warning for G_PARAM_DEPRECATED with GCC 6 [-Wpedantic]
Refer to https://bugzilla.gnome.org/show_bug.cgi?id=767882
Related to GCC https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71803
2016-10-24 06:10:14 -04:00
Tim-Philipp Müller
ac54db2ee2 glib-mkenums: add --output option to write output to a file
https://bugzilla.gnome.org/show_bug.cgi?id=770175
2016-10-12 17:05:07 -04:00
Tim-Philipp Müller
0fbc98097f glib-genmarshal: add --output option to write output to a file
https://bugzilla.gnome.org/show_bug.cgi?id=770175
2016-10-12 15:56:49 -04:00
Matthias Clasen
53d5a9f6fb Fix the signals test
The test setup here is not really independent, so the addition
of the custom-marshaller test was breaking some of the other
tests. Fix things up.
2016-08-27 22:54:39 -04:00
Benjamin Otte
edfbfc1827 tests: Add test showing default marshaller override
https://bugzilla.gnome.org/show_bug.cgi?id=769076
2016-08-25 13:26:58 -04:00
Matthias Clasen
ef16cbee5b Don't set a va marshaller if a marshaller was set
Otherwise we get warnings when the caller later tries to set a
va marshaller with g_signal_set_va_marshaller.

https://bugzilla.gnome.org/show_bug.cgi?id=769076
2016-08-25 13:26:58 -04:00
Philip Withnall
a5044a8e78 build: Fix SystemTap build to disable semaphores as before
At some point, upstream SystemTap changed from using a
STAP_HAS_SEMAPHORES preprocessor variable for this, to using
_SDT_HAS_SEMAPHORES instead. We need to update our build system to
disable that as well.

The original discussion about use of semaphores is here:

https://bugzilla.gnome.org/show_bug.cgi?id=606044

This was breaking the build with -flto enabled, either because -flto
doesn’t work with semaphores.

https://bugzilla.gnome.org/show_bug.cgi?id=768198
2016-08-13 09:32:12 +02:00
Emmanuele Bassi
5ff8579527 Fix debug builds under MSVC
The C spec leaves conditional evaluation inside a macro expansion as
undefined behaviour. This means we cannot use constructs like:

  GOBJECT_IF_DEBUG(OBJECTS, {
    ...
  #ifdef BLAH
    ...
  #endif
    ...});

Because compilers are entirely justified to ignore the conditional, or,
like in the case of MSVC, error out.

https://bugzilla.gnome.org/show_bug.cgi?id=769504
2016-08-04 10:18:46 +01:00
Alberts Muktupāvels
ad669500a6 gobject: add g_autoptr support for GTypeModule
https://bugzilla.gnome.org/show_bug.cgi?id=769033
2016-07-21 17:03:06 +03:00
Kang Hu
42dad59cc1 gobject: add GOBJECT_IF_DEBUG macro for debugging gobjects and gsignals.
historically, DEBUG_CODE(gtype.c) and IF_DEBUG(gobject.c, gsignal.c)
macros are used to support debugging messages about object bookkeeping
and signal emission.
DEBUG_CODE has never been used in gtype.c. IF_DEBUG, when used, must be
accompanied by an extra #ifdef G_ENABLE_DEBUG. this is cumbersome.

this patch add a new macro GOBJECT_IF_DEBUG based on DEBUG_CODE as
a replacement for both DEBUG_CODE and IF_DEBUG.

https://bugzilla.gnome.org/show_bug.cgi?id=729914
2016-07-16 20:54:44 -04:00
Philip Withnall
c4695f192c build: Rename SystemTap scripts to include the LT version
In a vague attempt at ensuring the .stp scripts can be closely
associated with the .so files which they hard-code references to, rename
the scripts so they include the LT version — so that they are the .so
file name plus .stp.

This does not fix the fact that our .stp scripts will not work on
multiarch systems, as they are installed in an architecture-independent
directory (/usr/share/systemtap/tapset). At the moment, it is
recommended that any distribution who package the .stp files should
install them in the architecture-specific subdirectories of this (for
example, /usr/share/systemtap/tapset/x86-64).

A better long-term solution for this is under discussion upstream:
https://sourceware.org/bugzilla/show_bug.cgi?id=20264

https://bugzilla.gnome.org/show_bug.cgi?id=662802
2016-06-29 14:43:52 +01:00
Ryan Lortie
7563ab4734 build: simplify dtrace configuration
The ability to pass libtool via $(CC) to dtrace and have it respect this
appears to be a feature that is only present in the systemtap version of
the tool.  In particular, FreeBSD (which seems to be using a copy of the
tool from Solaris) doesn't support this.

The result is that, with $(CC) ignored, and a .lo file specified in -o,
we get an ELF written to the .lo.

Instead of trying to have dtrace run libtool we can have libtool run
dtrace.  dtrace is really just a compiler that produces an object file
here, and it even understands -o, so libtool can make the appropriate
adjustments.

There appears to be some prior art for this approach.  A quick search
shows that at least QEMU is using this approach.  It also appears to
work on Linux with systemtap's dtrace and on FreeBSD.

This may regress cross-compilation because the dtrace command will have
no way of knowing which compiler we intend for it to use to produce the
object file.  I say "may" because I don't know if dtrace ever worked in
the first place under cross-compilation.

https://bugzilla.gnome.org/show_bug.cgi?id=725902
2016-06-20 12:35:47 -04:00
Gerald Combs
05d429af9d gsignal: Remove a UTF-8 ellipsis from docs
Some compilers have trouble with such sequences. Visual C++ may or may
not generate a warning in this particular case depending on if the
local code page supports an ellipsis.

https://bugzilla.gnome.org/show_bug.cgi?id=767218
2016-06-03 16:09:43 -04:00
Tom Tromey
b7145a1d72 Rename gdb macros with _gdb suffix to avoid ns clashes
glib installs a gdb helper file named `glib.py`.
Then the "hook" file updates `sys.path` and does `import glib`.

This will fail if glib has already been imported into gdb, say
using `from gi.repository import GLib`.  This is due to a namespace clash.

One fix would be to rename the gdb helper files to not clash with
other Python modules.  This should be done for all such helper files.

https://bugzilla.gnome.org/show_bug.cgi?id=760186
2016-05-23 10:52:10 -04:00
Kjell Ahlstedt
05e5da9a83 gvalue: Fix description of g_value_type_transformable()
Types are transformable if they are compatible *or* a transformation function
is registered.

https://bugzilla.gnome.org/show_bug.cgi?id=742898
2016-04-28 12:05:50 +02:00
Sebastian Dröge
4e3cd88c2b gparamspecs: GTypes are stored in v_pointer, not v_long
v_long is 32 bits on Win64, v_pointer is 64 bits. On most other platforms the
size of long and pointer is the same, so it's usually not a problem.

https://bugzilla.gnome.org/show_bug.cgi?id=758738
2016-04-27 10:28:09 +03:00
Phillip Wood
38c4e31c8a Fix documentation typos
Character entities are not supposed to be supported by gtk-doc¹ and
fix the spelling of ‘optional’

¹https://bugzilla.gnome.org/show_bug.cgi?id=758137

https://bugzilla.gnome.org/show_bug.cgi?id=758174
2016-04-11 23:31:38 -04:00
Colin Walters
14885a5b19 build: Also dist Systemtap files always for gobject/
Mirrors
https://git.gnome.org/browse/glib/commit/?id=ad2092bc680e434c3d17600988ec9b20f52eebef
except I didn't also change gobject/.

https://bugzilla.gnome.org/show_bug.cgi?id=763821
2016-03-23 09:02:35 -04:00
Rico Tzschichholz
e3189527dc gio/gobject: Various introspection fixes 2016-02-03 18:13:49 +01:00
Philip Withnall
8c263008bb build: Calculate ABS_GLIB_RUNTIME_LIBDIR at build time
Rather than calculating it at configure time. This means it can expand
$libdir properly, and use the Make $(realpath) function rather than
invoking the non-portable `readlink -f`.

This fixes problems where `readlink` would be called on an invalid path
(due to a variable not being expanded) and would evaluate to "", which
would then cause things to be installed in the wrong place.

https://bugzilla.gnome.org/show_bug.cgi?id=744772
2016-01-24 14:44:44 +00:00
Emmanuele Bassi
85a23529ab Revert "make *_get_instance_private const-compliant"
This reverts commit a3a9664ed2.

Constifying the autogenerated get_instance_private functio makes C++
compilers and GCC with -Wcast-qual warn during compilation of GLib and
projects depending on GLib.

Since using const with GObject instances is not a common coding
practice, it's better to revert than trying to make every sigle GType
function const-safe (and possibly add more compiler warnings in the
process).

https://bugzilla.gnome.org/show_bug.cgi?id=745068
2016-01-18 18:48:42 +00:00
Emmanuele Bassi
617189f28c Revert "G_DECLARE_*: be const-compliant"
This reverts commit 52f23db74a.

Constifying these macros make C++ compilers and GCC with -Wcast-qual
warn during compilation of GLib and projects depending on GLib.

Since using const with GObject instances is not a common coding
practice, it's better to revert than trying to make every sigle GType
function const-safe (and possibly add more compiler warnings in the
process).

https://bugzilla.gnome.org/show_bug.cgi?id=745068
2016-01-18 18:46:12 +00:00
Simon Feltman
1513efc904 Add GParamSpec object ref management annotations
Add ref-func, unref-func, set-value-func, and get-value-func annotations to
GParamSpec so that it can be managed generically as a fundamental type with
introspection.

https://bugzilla.gnome.org/show_bug.cgi?id=710243
2015-12-16 07:47:54 -05:00
Philip Withnall
25a7c817d3 glib: Add missing (nullable) and (optional) annotations
Add various (nullable) and (optional) annotations which were missing
from a variety of functions. Also port a couple of existing (allow-none)
annotations in the same files to use (nullable) and (optional) as
appropriate instead.

Secondly, add various (not nullable) annotations as needed by the new
default in gobject-introspection of marking gpointers as (nullable). See
https://bugzilla.gnome.org/show_bug.cgi?id=729660.

This includes adding some stub documentation comments for the
assertion macro error functions, which weren’t previously documented.
The new comments are purely to allow for annotations, and hence are
marked as (skip) to prevent the symbols appearing in the GIR file.

https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-11-07 10:48:32 +01:00
Xavier Claessens
2331437df3 Doc: fix some gtk-doc warnings
https://bugzilla.gnome.org/show_bug.cgi?id=755364
2015-10-30 10:30:55 -04:00
Murray Cumming
adfd184776 Fix tiny typo. 2015-10-28 10:50:40 +01:00
Dan Winship
263aac125e .gitignore updates 2015-10-23 11:28:03 -04:00
Matthias Clasen
2ac7c5a6fb Use -Wl,-znodelete for all our libraries
Now that we initialize the quark tables from a constructor,
reloading libglib is just as bad as reloading libgobject,
so add the linker option to the LDFLAGS for all our libraries.

https://bugzilla.gnome.org/show_bug.cgi?id=755609
2015-10-20 08:18:22 -04:00
Ignacio Casal Quinteiro
7a29771a74 gobject: use a DllMain to initialize gobject on windows
It seems that VS 2015 optimizes out the constructor on windows,
so it is better to use a DllMain to initialize the library
and keep using a normal constructor on the other platforms.
This research was done by  Arnav Singh.

https://bugzilla.gnome.org/show_bug.cgi?id=752837
2015-10-11 10:29:10 +02:00
Philip Withnall
144d38fb9d gparamspecs: Mark g_param_spec_string()’s default value as (nullable) 2015-10-08 12:57:33 +01:00
Matthias Clasen
8d83aace10 Call glib_init from the gobject constructor
We are using quarks in the gobject constructor, among other things,
so we need to ensure that glib is being initialized first.

https://bugzilla.gnome.org/show_bug.cgi?id=756139
2015-10-07 23:39:29 -04:00
Philip Withnall
4f6dc30232 glib-genmarshal: Fix memory leak with --prefix
If --prefix is specified, marshaller_prefix is allocated and never
freed. It does not actually have to be allocated — just use the static
string from argv.

Coverity CID: 1325370
2015-10-03 11:33:00 +01:00
Dan Winship
4b2d92a864 Allow passing unset GValues to g_value_unset()
This makes it more useful as an autocleanup func.

Also, add a minimal test of g_value_init/g_value_reset/g_value_unset.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-10-02 10:07:53 -04:00
Dan Winship
b4a3c1bb11 Revert "gvalue: Add g_value_clear method"
This reverts commit 1233962b54.
2015-10-02 10:07:53 -04:00
Dan Winship
4c870904cd Revert "gvalue: Use g_value_clear as clear function"
This reverts commit 3bb2e8dfc9.
2015-10-02 10:07:53 -04:00
Dan Winship
8ed9e8c79f Revert "gvalue: Improve _unset() documentation"
This reverts commit 3c0d38d68b.
2015-10-02 10:07:53 -04:00
Emmanuele Bassi
037991211d Revert "Apply the previous change to gmarshal.c"
This reverts commit 43e8bfca0c.

https://bugzilla.gnome.org/show_bug.cgi?id=755922
2015-10-01 11:58:37 +01:00
Emmanuele Bassi
cc818f5fe4 Revert "glib-genmarshal: Treat all parameters the same"
This reverts commit 8e362161d9.

There is a fundamental difference between g_value_peek_pointer() and
g_value_get_pointer(), and it's not just complexity: the latter checks
if the GValue holds a pointer type, whereas the former doesn't.

https://bugzilla.gnome.org/show_bug.cgi?id=755922
2015-10-01 11:54:11 +01:00
Nicolas Dufresne
3c0d38d68b gvalue: Improve _unset() documentation
g_value_unset() only works with initialized value and will assert
if the GValue is zero-filled (or initialized with G_VALUE_INIT). Document
this behaviour and refer to g_value_clear() for a method that work on
both initialized and zero-filled GValue.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-09-29 08:30:21 -04:00
Nicolas Dufresne
3bb2e8dfc9 gvalue: Use g_value_clear as clear function
This change allow leaving a scope before g_value_init() has been
called. This would happen if you do:

  {
    g_auto(GValue) value = G_VALUE_INIT;
  }

Or have a return statement (due to failure) before the part of
your code where you set this GValue.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-09-29 08:26:14 -04:00
Nicolas Dufresne
1233962b54 gvalue: Add g_value_clear method
This method is similar to g_value_unset() but will accept
an uninitialized (zero-filled) GValue structure.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
2015-09-29 08:26:14 -04:00
Matthias Clasen
43e8bfca0c Apply the previous change to gmarshal.c
Since gmarshal.c is no longer generated, we have to manually
apply this change to the builtin marshallers.
2015-09-29 07:04:36 -04:00
Matthias Clasen
8e362161d9 glib-genmarshal: Treat all parameters the same
There's no need to use a more expensive getter when swapping,
so just use the g_marshal_ getters there too.
2015-09-29 07:04:35 -04:00
Xavier Claessens
b81f3ced71 Move GStrv typedef to glib.h instead of gobject.h
GStrv was historically only needed for the boxed G_TYPE_STRV,
but it is now useful for g_auto(GStrv) as well. This is not
an ABI change.

https://bugzilla.gnome.org/show_bug.cgi?id=755355
2015-09-22 11:18:30 -04:00
Xavier Claessens
32811598f3 doc: clarify that _get_instance_private() is NULL-safe
https://bugzilla.gnome.org/show_bug.cgi?id=755083
2015-09-22 11:15:19 -04:00
Benjamin Otte
58eae7782a tests: Do last commit's fix for enums, too
We don't want to treat enums as ints but as ints.
2015-09-16 18:45:48 +02:00
Benjamin Otte
605ff1efe7 tests: Make testcase not pass 0 as a flags value
This will not catch the case where we fail in libffi and always use 0.
In fact, be a real annoying person and use (1 << 31) as a flags value to
test signedness, too.

Also update the testcase to actually use flags everywhere and ot uint.

https://bugzilla.gnome.org/show_bug.cgi?id=754882
2015-09-16 18:45:48 +02:00
Ray Strode
7b685eab88 ffi: Marshal flags like enums
Flags are enums.
Fixes broken marshalling on BE 64bit architectures.

https://bugzilla.gnome.org/show_bug.cgi?id=754882
2015-09-16 18:45:48 +02:00
Matthias Clasen
3bd1618ea9 Disable deprecation warnings for the stable release again
Keeping these enabled causes too many people to file
bugs against gobject, and not enough people to send
patches to port away from deprecated properties.
2015-09-14 18:42:12 -04:00
Alexander Larsson
69002f726d signal: return TRUE from g_signal_has_handler_pending for custom class closure
This is almost always what you want, because if you're using this you
want to know if any "custom code" (i.e. not the default class closure)
is going to be run if you emit this signal.

I looked at all the existing uses of this and they were all broken in the
presence of g_signal_override_class_closure().

https://bugzilla.gnome.org/show_bug.cgi?id=754986
2015-09-14 13:19:51 +02:00
Nicola Fontana
a51a877d27 GParamSpec: do not use static GParamSpecTypeInfo
g_param_type_register_static() has read-only access the pspec_info
argument: no need to keep the original struct around.

https://bugzilla.gnome.org/show_bug.cgi?id=696426
2015-09-13 02:15:04 -04:00
Michael Catanzaro
ee6740aa78 Fix a typo 2015-09-10 20:46:37 -05:00
Rico Tzschichholz
5a84f84325 gparam: Fix Since tag of g_param_spec_get_name_quark 2015-09-08 14:15:44 +02:00
Matthias Clasen
00933dfc9c Speed up property change notification a bit
Avoid the quark lock and hash table lookup for every
emission of ::notify.
2015-09-07 20:56:10 -04:00