From d716945125543b999f892fbf6297ff6a37ee111f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Mar 2020 23:03:44 +0100 Subject: gimarshallingtests: Add marshalling tests for virtual functions with inout parameters Virtual functions may use input/output parameters but this is not currently well handled by gjs, so adding test cases to gobject-introspection to verify that virtual functions correctly receive valid input values and can return them. --- tests/gimarshallingtests.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ tests/gimarshallingtests.h | 38 ++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 92868016..44971506 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -4583,6 +4583,33 @@ gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObject *s g_assert_cmpint (local, ==, 0x12345678); } +/** + * gi_marshalling_tests_object_vfunc_one_inout_parameter: + * @a: (inout): + */ +void +gi_marshalling_tests_object_vfunc_one_inout_parameter (GIMarshallingTestsObject *self, gfloat *a) +{ + /* make sure that local variables don't get smashed */ + gulong local = 0x12345678; + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_one_inout_parameter (self, a); + g_assert_cmpint (local, ==, 0x12345678); +} + +/** + * gi_marshalling_tests_object_vfunc_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ +void +gi_marshalling_tests_object_vfunc_multiple_inout_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b) +{ + /* make sure that local variables don't get smashed */ + gulong local = 0x12345678; + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_multiple_inout_parameters (self, a, b); + g_assert_cmpint (local, ==, 0x12345678); +} + /** * gi_marshalling_tests_object_vfunc_multiple_out_parameters: * @a: (out): @@ -4651,6 +4678,37 @@ glong return return_value; } +/** + * gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter: + * @a: (inout): + */ +glong gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter (GIMarshallingTestsObject *self, glong *a) +{ + /* make sure that local variables don't get smashed */ + gulong return_value; + gulong local = 0x12345678; + return_value = GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_one_inout_parameter (self, a); + g_assert_cmpint (local, ==, 0x12345678); + return return_value; +} + +/** + * gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ +glong + gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters + (GIMarshallingTestsObject *self, glong *a, glong *b) +{ + gulong return_value; + gulong local = 0x12345678; + return_value = + GI_MARSHALLING_TESTS_OBJECT_GET_CLASS (self)->vfunc_return_value_and_multiple_inout_parameters (self, a, b); + g_assert_cmpint (local, ==, 0x12345678); + return return_value; +} + /** * gi_marshalling_tests_callback_owned_boxed: * @callback: (scope call) (closure callback_data): diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h index d5357ec9..747a075d 100644 --- a/tests/gimarshallingtests.h +++ b/tests/gimarshallingtests.h @@ -1409,6 +1409,19 @@ struct _GIMarshallingTestsObjectClass */ void (* vfunc_multiple_out_parameters) (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); + /** + * GIMarshallingTestsObjectClass::vfunc_one_inout_parameter: + * @a: (inout): + */ + void (* vfunc_one_inout_parameter) (GIMarshallingTestsObject *self, gfloat *a); + + /** + * GIMarshallingTestsObjectClass::vfunc_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ + void (* vfunc_multiple_inout_parameters) (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); + /** * GIMarshallingTestsObjectClass::vfunc_caller_allocated_out_parameter: * @a: (out): @@ -1434,6 +1447,19 @@ struct _GIMarshallingTestsObjectClass */ glong (* vfunc_return_value_and_multiple_out_parameters) (GIMarshallingTestsObject *self, glong *a, glong *b); + /** + * GIMarshallingTestsObjectClass::vfunc_return_value_and_one_inout_parameter: + * @a: (inout): + */ + glong (* vfunc_return_value_and_one_inout_parameter) (GIMarshallingTestsObject *self, glong *a); + + /** + * GIMarshallingTestsObjectClass::vfunc_return_value_and_multiple_inout_parameters: + * @a: (inout): + * @b: (inout): + */ + glong (* vfunc_return_value_and_multiple_inout_parameters) (GIMarshallingTestsObject *self, glong *a, glong *b); + /** * GIMarshallingTestsObjectClass::vfunc_meth_with_err: * @x: @@ -1560,6 +1586,12 @@ void gi_marshalling_tests_object_vfunc_one_out_parameter (GIMarshallingTestsObje _GI_TEST_EXTERN void gi_marshalling_tests_object_vfunc_multiple_out_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); +_GI_TEST_EXTERN +void gi_marshalling_tests_object_vfunc_one_inout_parameter (GIMarshallingTestsObject *self, gfloat *a); + +_GI_TEST_EXTERN +void gi_marshalling_tests_object_vfunc_multiple_inout_parameters (GIMarshallingTestsObject *self, gfloat *a, gfloat *b); + _GI_TEST_EXTERN void gi_marshalling_tests_object_vfunc_caller_allocated_out_parameter (GIMarshallingTestsObject *self, GValue *a); @@ -1572,6 +1604,12 @@ glong gi_marshalling_tests_object_vfunc_return_value_and_one_out_parameter (GIMa _GI_TEST_EXTERN glong gi_marshalling_tests_object_vfunc_return_value_and_multiple_out_parameters (GIMarshallingTestsObject *self, glong *a, glong *b); +_GI_TEST_EXTERN +glong gi_marshalling_tests_object_vfunc_return_value_and_one_inout_parameter (GIMarshallingTestsObject *self, glong *a); + +_GI_TEST_EXTERN +glong gi_marshalling_tests_object_vfunc_return_value_and_multiple_inout_parameters (GIMarshallingTestsObject *self, glong *a, glong *b); + _GI_TEST_EXTERN gboolean gi_marshalling_tests_object_vfunc_meth_with_error (GIMarshallingTestsObject *object, gint x, GError **error); -- cgit v1.2.1 From 49fa7c278a05228931b7b436b10b323c1ef6730e Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 12 Mar 2020 17:56:56 +0000 Subject: gimarshallingtests: Use g_assert_cmpfloat_with_epsilon Comparing floats directly doesn't always work on all architectures. --- tests/gimarshallingtests.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 44971506..53c17818 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -3167,13 +3167,13 @@ gi_marshalling_tests_ghashtable_double_in (GHashTable *hash_table) double *value; value = g_hash_table_lookup (hash_table, "-1"); - g_assert_cmpfloat (*value, ==, -0.1); + g_assert_cmpfloat_with_epsilon (*value, -0.1, 0.01); value = g_hash_table_lookup (hash_table, "0"); g_assert_cmpfloat (*value, ==, 0.0); value = g_hash_table_lookup (hash_table, "1"); - g_assert_cmpfloat (*value, ==, 0.1); + g_assert_cmpfloat_with_epsilon (*value, 0.1, 0.01); value = g_hash_table_lookup (hash_table, "2"); - g_assert_cmpfloat (*value, ==, 0.2); + g_assert_cmpfloat_with_epsilon (*value, 0.2, 0.01); } /** @@ -3188,13 +3188,13 @@ gi_marshalling_tests_ghashtable_float_in (GHashTable *hash_table) float *value; value = g_hash_table_lookup (hash_table, "-1"); - g_assert_cmpfloat (*value, ==, -0.1f); + g_assert_cmpfloat_with_epsilon (*value, -0.1f, 0.01f); value = g_hash_table_lookup (hash_table, "0"); g_assert_cmpfloat (*value, ==, 0.0f); value = g_hash_table_lookup (hash_table, "1"); - g_assert_cmpfloat (*value, ==, 0.1f); + g_assert_cmpfloat_with_epsilon (*value, 0.1f, 0.01f); value = g_hash_table_lookup (hash_table, "2"); - g_assert_cmpfloat (*value, ==, 0.2f); + g_assert_cmpfloat_with_epsilon (*value, 0.2f, 0.01f); } /** -- cgit v1.2.1 From 8ceb23621d7e59718c1d512155aae8e8eb17db56 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Thu, 26 Mar 2020 15:17:37 -0400 Subject: Replace calls to deprecated xml.etree.cElementTree cElementTree was removed in Python 3.9 in favor of ElementTree, which has used a fast, native implementation since Python 3.3. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1817649 Signed-off-by: Stephen Gallagher --- giscanner/gdumpparser.py | 2 +- giscanner/girparser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py index 1730fee5..e7ccf575 100644 --- a/giscanner/gdumpparser.py +++ b/giscanner/gdumpparser.py @@ -22,7 +22,7 @@ import os import sys import tempfile import subprocess -from xml.etree.cElementTree import parse +from xml.etree.ElementTree import parse from . import ast from . import message diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 0a6c687b..35206a41 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -21,7 +21,7 @@ import os from collections import OrderedDict -from xml.etree.cElementTree import parse +from xml.etree.ElementTree import parse from . import ast from .girwriter import COMPATIBLE_GIR_VERSION -- cgit v1.2.1 From 7e379314faa78b5a5670477a3d68dd28c1f8a267 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 5 Apr 2020 16:12:24 +0200 Subject: Update NEWS --- NEWS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NEWS b/NEWS index ddcece37..ffe77b8a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +1.64.1 - 2020-04-05 +------------------- + +* Replace calls to deprecated xml.etree.cElementTree removed in Python 3.9 :mr:`202` (:user:`Stephen Gallagher `) +* gimarshallingtests: Use g_assert_cmpfloat_with_epsilon. Fixes tests on some architectures :mr:`200` (:user:`Iain Lane `) + + 1.64.0 - 2020-03-07 ------------------- -- cgit v1.2.1 From ec00edd941953626ac027810f747847f68a71000 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 22 Apr 2020 21:15:45 -0400 Subject: Meson: Fix build when glib is built as subproject --- girepository/cmph/meson.build | 2 ++ girepository/meson.build | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/girepository/cmph/meson.build b/girepository/cmph/meson.build index 5bc41a33..2a0cef7e 100644 --- a/girepository/cmph/meson.build +++ b/girepository/cmph/meson.build @@ -26,6 +26,7 @@ cmph_sources = [ cmph_deps = [ glib_dep, + gobject_dep, cc.find_library('m', required: false), ] @@ -67,6 +68,7 @@ cmph_test = executable('cmph-bdz-test', '../cmph-bdz-test.c', dependencies: [ cmph_dep, glib_dep, + gobject_dep, ], c_args: custom_c_args, ) diff --git a/girepository/meson.build b/girepository/meson.build index 204659fe..6cd8fd30 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -17,12 +17,13 @@ girepo_gthash_lib = static_library('girepository-gthash', cmph_dep, glib_dep, gmodule_dep, + gobject_dep, ], ) girepo_gthash_dep = declare_dependency( link_with: girepo_gthash_lib, - dependencies: [glib_dep, gmodule_dep], + dependencies: [glib_dep, gmodule_dep, gobject_dep], include_directories: include_directories('.'), ) -- cgit v1.2.1 From d01a387475e2665275a6cd6b0059bf91121b8300 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 22 Apr 2020 21:16:08 -0400 Subject: Meson: Override gobject-introspection-1.0 dependency When gobject-introspection-1.0 pkg-config is not found on the system, Meson can fallback to configure g-i as subproject and needs a dependency object to replace the pc file. The dependency file needs to ensure that typelibs are created before compiling any other gir and provide the girdir for files within build directory. It also need to provide glib dependencies required to compile girs. Bump Meson version to 0.54.0 to use meson.override_dependency(). --- .gitlab-ci.yml | 4 ++-- .gitlab-ci/Dockerfile | 2 +- .gitlab-ci/minimal.Dockerfile | 2 +- .gitlab-ci/run-docker-minimal.sh | 2 +- .gitlab-ci/run-docker.sh | 2 +- .gitlab-ci/test-msvc.bat | 2 +- .gitlab-ci/test-msys2-meson.sh | 2 +- meson.build | 15 ++++++++++++++- 8 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16a8f3bb..2b1b9d4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: - build - deploy -image: registry.gitlab.gnome.org/gnome/gobject-introspection:v6 +image: registry.gitlab.gnome.org/gnome/gobject-introspection:v7 cache: paths: @@ -36,7 +36,7 @@ fedora-x86_64-meson: - public fedora-x86_64-subprojects: - image: registry.gitlab.gnome.org/gnome/gobject-introspection:min-v1 + image: registry.gitlab.gnome.org/gnome/gobject-introspection:min-v2 stage: build variables: CCACHE_BASEDIR: "${CI_PROJECT_DIR}" diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile index 0dec6700..61c5fe41 100644 --- a/.gitlab-ci/Dockerfile +++ b/.gitlab-ci/Dockerfile @@ -48,7 +48,7 @@ RUN dnf -y install \ zlib-devel \ && dnf clean all -RUN pip3 install meson==0.50.1 +RUN pip3 install meson==0.54.0 ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} diff --git a/.gitlab-ci/minimal.Dockerfile b/.gitlab-ci/minimal.Dockerfile index b33aa64b..e4d1f821 100644 --- a/.gitlab-ci/minimal.Dockerfile +++ b/.gitlab-ci/minimal.Dockerfile @@ -15,7 +15,7 @@ RUN dnf -y install \ libmount-devel \ && dnf clean all -RUN pip3 install meson==0.52.0 +RUN pip3 install meson==0.54.0 ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} diff --git a/.gitlab-ci/run-docker-minimal.sh b/.gitlab-ci/run-docker-minimal.sh index 36b2d376..9588f288 100755 --- a/.gitlab-ci/run-docker-minimal.sh +++ b/.gitlab-ci/run-docker-minimal.sh @@ -2,7 +2,7 @@ set -e -TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:min-v1" +TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:min-v2" sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \ --file "minimal.Dockerfile" . diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh index 5d29002c..8e6a04ab 100755 --- a/.gitlab-ci/run-docker.sh +++ b/.gitlab-ci/run-docker.sh @@ -2,7 +2,7 @@ set -e -TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:v6" +TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:v7" sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \ --file "Dockerfile" . diff --git a/.gitlab-ci/test-msvc.bat b/.gitlab-ci/test-msvc.bat index a2ee44b2..d8eaa776 100644 --- a/.gitlab-ci/test-msvc.bat +++ b/.gitlab-ci/test-msvc.bat @@ -9,7 +9,7 @@ py -3 -c "import urllib.request, sys; urllib.request.urlretrieve(*sys.argv[1:])" SET PATH=%CD%;%CD%\win_flex_bison;%PATH% -pip3 install --upgrade --user meson==0.50.1 || goto :error +pip3 install --upgrade --user meson==0.54.0 || goto :error meson _build || goto :error ninja -C _build || goto :error diff --git a/.gitlab-ci/test-msys2-meson.sh b/.gitlab-ci/test-msys2-meson.sh index 9f145e5b..9c607b29 100644 --- a/.gitlab-ci/test-msys2-meson.sh +++ b/.gitlab-ci/test-msys2-meson.sh @@ -31,7 +31,7 @@ pacman --noconfirm -S --needed \ export CCACHE_BASEDIR="${CI_PROJECT_DIR}" export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache" -pip3 install --upgrade --user meson==0.50.1 flake8 +pip3 install --upgrade --user meson==0.54.0 flake8 export PATH="$HOME/.local/bin:$PATH" export CFLAGS="-Werror" diff --git a/meson.build b/meson.build index 3d22dd55..f6f62444 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('gobject-introspection', 'c', version: '1.64.1', - meson_version: '>= 0.50.1', + meson_version: '>= 0.54.0', default_options: [ 'warning_level=1', 'buildtype=debugoptimized', @@ -264,3 +264,16 @@ configure_file( configuration: pkgconfig_conf, install_dir: join_paths(get_option('libdir'), 'pkgconfig'), ) + +# Dependency object used by Meson's GNOME module. This dependency variable must +# be named girepo_dep for backward compatibility with projects that where already +# using that name as fallback: dependency('gobject-introspection-1.0', +# fallback : ['gobject-introspection', 'girepo_dep']) +girepo_dep = declare_dependency( + sources: typelibs, + dependencies: girepo_dep, + variables: { + 'girdir': meson.current_build_dir() / 'gir', + }, +) +meson.override_dependency('gobject-introspection-1.0', girepo_dep) -- cgit v1.2.1 From 42b7d634a9a7500dcc71651f71844148fc200be3 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 24 Apr 2020 11:52:45 +0100 Subject: Revert "Meson: Fix build when glib is built as subproject" This reverts commit ec00edd941953626ac027810f747847f68a71000. The nightly run time does not have Meson 0.54. --- girepository/cmph/meson.build | 2 -- girepository/meson.build | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/girepository/cmph/meson.build b/girepository/cmph/meson.build index 2a0cef7e..5bc41a33 100644 --- a/girepository/cmph/meson.build +++ b/girepository/cmph/meson.build @@ -26,7 +26,6 @@ cmph_sources = [ cmph_deps = [ glib_dep, - gobject_dep, cc.find_library('m', required: false), ] @@ -68,7 +67,6 @@ cmph_test = executable('cmph-bdz-test', '../cmph-bdz-test.c', dependencies: [ cmph_dep, glib_dep, - gobject_dep, ], c_args: custom_c_args, ) diff --git a/girepository/meson.build b/girepository/meson.build index 6cd8fd30..204659fe 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -17,13 +17,12 @@ girepo_gthash_lib = static_library('girepository-gthash', cmph_dep, glib_dep, gmodule_dep, - gobject_dep, ], ) girepo_gthash_dep = declare_dependency( link_with: girepo_gthash_lib, - dependencies: [glib_dep, gmodule_dep, gobject_dep], + dependencies: [glib_dep, gmodule_dep], include_directories: include_directories('.'), ) -- cgit v1.2.1 From ec08670d80d12668e3e6be4b6eb395e5ad207034 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 24 Apr 2020 11:53:19 +0100 Subject: Revert "Meson: Override gobject-introspection-1.0 dependency" This reverts commit d01a387475e2665275a6cd6b0059bf91121b8300. The nightly run time does not have Meson 0.54 --- .gitlab-ci.yml | 4 ++-- .gitlab-ci/Dockerfile | 2 +- .gitlab-ci/minimal.Dockerfile | 2 +- .gitlab-ci/run-docker-minimal.sh | 2 +- .gitlab-ci/run-docker.sh | 2 +- .gitlab-ci/test-msvc.bat | 2 +- .gitlab-ci/test-msys2-meson.sh | 2 +- meson.build | 15 +-------------- 8 files changed, 9 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b1b9d4d..16a8f3bb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: - build - deploy -image: registry.gitlab.gnome.org/gnome/gobject-introspection:v7 +image: registry.gitlab.gnome.org/gnome/gobject-introspection:v6 cache: paths: @@ -36,7 +36,7 @@ fedora-x86_64-meson: - public fedora-x86_64-subprojects: - image: registry.gitlab.gnome.org/gnome/gobject-introspection:min-v2 + image: registry.gitlab.gnome.org/gnome/gobject-introspection:min-v1 stage: build variables: CCACHE_BASEDIR: "${CI_PROJECT_DIR}" diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile index 61c5fe41..0dec6700 100644 --- a/.gitlab-ci/Dockerfile +++ b/.gitlab-ci/Dockerfile @@ -48,7 +48,7 @@ RUN dnf -y install \ zlib-devel \ && dnf clean all -RUN pip3 install meson==0.54.0 +RUN pip3 install meson==0.50.1 ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} diff --git a/.gitlab-ci/minimal.Dockerfile b/.gitlab-ci/minimal.Dockerfile index e4d1f821..b33aa64b 100644 --- a/.gitlab-ci/minimal.Dockerfile +++ b/.gitlab-ci/minimal.Dockerfile @@ -15,7 +15,7 @@ RUN dnf -y install \ libmount-devel \ && dnf clean all -RUN pip3 install meson==0.54.0 +RUN pip3 install meson==0.52.0 ARG HOST_USER_ID=5555 ENV HOST_USER_ID ${HOST_USER_ID} diff --git a/.gitlab-ci/run-docker-minimal.sh b/.gitlab-ci/run-docker-minimal.sh index 9588f288..36b2d376 100755 --- a/.gitlab-ci/run-docker-minimal.sh +++ b/.gitlab-ci/run-docker-minimal.sh @@ -2,7 +2,7 @@ set -e -TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:min-v2" +TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:min-v1" sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \ --file "minimal.Dockerfile" . diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh index 8e6a04ab..5d29002c 100755 --- a/.gitlab-ci/run-docker.sh +++ b/.gitlab-ci/run-docker.sh @@ -2,7 +2,7 @@ set -e -TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:v7" +TAG="registry.gitlab.gnome.org/gnome/gobject-introspection:v6" sudo docker build --build-arg HOST_USER_ID="$UID" --tag "${TAG}" \ --file "Dockerfile" . diff --git a/.gitlab-ci/test-msvc.bat b/.gitlab-ci/test-msvc.bat index d8eaa776..a2ee44b2 100644 --- a/.gitlab-ci/test-msvc.bat +++ b/.gitlab-ci/test-msvc.bat @@ -9,7 +9,7 @@ py -3 -c "import urllib.request, sys; urllib.request.urlretrieve(*sys.argv[1:])" SET PATH=%CD%;%CD%\win_flex_bison;%PATH% -pip3 install --upgrade --user meson==0.54.0 || goto :error +pip3 install --upgrade --user meson==0.50.1 || goto :error meson _build || goto :error ninja -C _build || goto :error diff --git a/.gitlab-ci/test-msys2-meson.sh b/.gitlab-ci/test-msys2-meson.sh index 9c607b29..9f145e5b 100644 --- a/.gitlab-ci/test-msys2-meson.sh +++ b/.gitlab-ci/test-msys2-meson.sh @@ -31,7 +31,7 @@ pacman --noconfirm -S --needed \ export CCACHE_BASEDIR="${CI_PROJECT_DIR}" export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache" -pip3 install --upgrade --user meson==0.54.0 flake8 +pip3 install --upgrade --user meson==0.50.1 flake8 export PATH="$HOME/.local/bin:$PATH" export CFLAGS="-Werror" diff --git a/meson.build b/meson.build index f6f62444..3d22dd55 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('gobject-introspection', 'c', version: '1.64.1', - meson_version: '>= 0.54.0', + meson_version: '>= 0.50.1', default_options: [ 'warning_level=1', 'buildtype=debugoptimized', @@ -264,16 +264,3 @@ configure_file( configuration: pkgconfig_conf, install_dir: join_paths(get_option('libdir'), 'pkgconfig'), ) - -# Dependency object used by Meson's GNOME module. This dependency variable must -# be named girepo_dep for backward compatibility with projects that where already -# using that name as fallback: dependency('gobject-introspection-1.0', -# fallback : ['gobject-introspection', 'girepo_dep']) -girepo_dep = declare_dependency( - sources: typelibs, - dependencies: girepo_dep, - variables: { - 'girdir': meson.current_build_dir() / 'gir', - }, -) -meson.override_dependency('gobject-introspection-1.0', girepo_dep) -- cgit v1.2.1 From 9cb1ac54f5cda256230e76d4d78e960f98c9d2c3 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 8 Apr 2020 14:00:51 +0100 Subject: Support the gtk-doc action syntax GTK4 allows adding widget-related actions to the documentation with the newly defined syntax: '|' ':' This means g-ir-scanner needs to detect this new format, to avoid emitting unnecessary warnings. Currently, we don't do anything with the actions; in the future we might want to add them to the documentation in the GIR, but for that we'd need a new element. See also: GNOME/gtk-doc!30 --- giscanner/annotationparser.py | 42 ++++++- tests/scanner/annotationparser/test_patterns.py | 154 +++++++++++++++++++++++- 2 files changed, 189 insertions(+), 7 deletions(-) diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 9ab629b3..16a66f33 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -440,6 +440,27 @@ SIGNAL_RE = re.compile( ''', re.UNICODE | re.VERBOSE) +# Pattern matching action identifiers. +ACTION_RE = re.compile( + r''' + ^ # start + \s* # 0 or more whitespace characters + (?P[\w]+) # class name + \s* # 0 or more whitespace characters + \|{1} # 1 required vertical bar + \s* # 0 or more whitespace characters + (?P[\w-]+\.[\w-]+) # action name + \s* # 0 or more whitespace characters + (?P:?) # delimiter + \s* # 0 or more whitespace characters + (?P.*?) # annotations + description + \s* # 0 or more whitespace characters + :? # invalid delimiter + \s* # 0 or more whitespace characters + $ # end + ''', + re.UNICODE | re.VERBOSE) + # Pattern matching parameters. PARAMETER_RE = re.compile( r''' @@ -1338,13 +1359,22 @@ class GtkDocCommentBlockParser(object): identifier_fields = result.group('fields') identifier_fields_start = result.start('fields') else: - result = SYMBOL_RE.match(line) + result = ACTION_RE.match(line) if result: - identifier_name = '%s' % (result.group('symbol_name'), ) - identifier_delimiter = result.group('delimiter') - identifier_fields = result.group('fields') - identifier_fields_start = result.start('fields') + identifier_name = 'ACTION:%s:%s' % (result.group('class_name'), + result.group('action_name')) + identifier_delimiter = None + identifier_fields = None + identifier_fields_start = None + else: + result = SYMBOL_RE.match(line) + + if result: + identifier_name = '%s' % (result.group('symbol_name'), ) + identifier_delimiter = result.group('delimiter') + identifier_fields = result.group('fields') + identifier_fields_start = result.start('fields') if result: in_part = PART_IDENTIFIER @@ -2117,7 +2147,7 @@ class GtkDocCommentBlockWriter(object): lines = [] # Identifier part - if block.name.startswith('SECTION'): + if block.name.startswith('SECTION') or block.name.startswith('ACTION'): lines.append(block.name) else: if block.annotations: diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py index 131d6282..68db9870 100644 --- a/tests/scanner/annotationparser/test_patterns.py +++ b/tests/scanner/annotationparser/test_patterns.py @@ -33,7 +33,7 @@ import unittest from giscanner.annotationparser import (COMMENT_BLOCK_START_RE, COMMENT_BLOCK_END_RE, COMMENT_ASTERISK_RE, INDENTATION_RE, EMPTY_LINE_RE, - SECTION_RE, SYMBOL_RE, PROPERTY_RE, + SECTION_RE, SYMBOL_RE, PROPERTY_RE, ACTION_RE, SIGNAL_RE, PARAMETER_RE, TAG_RE, TAG_VALUE_VERSION_RE, TAG_VALUE_STABILITY_RE) @@ -663,6 +663,157 @@ identifier_signal_tests = [ 'delimiter': ':', 'fields': '(type GLib.List(GLib.List(utf8))) (transfer full)'})] +identifier_action_tests = [ + (ACTION_RE, 'GtkWidget|group.action (skip)', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': '', + 'fields': '(skip)'}), + (ACTION_RE, 'GtkWidget|group.action', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, ' GtkWidget |group.action', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, 'GtkWidget| group.action ', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, ' GtkWidget | group.action ', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, 'GtkWidget|group.action:', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'GtkWidget|group.action: ', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, ' GtkWidget|group.action:', + {'class_name': 'GtkWidget', + 'action_name': 'group.action', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'Something|group.action:', + {'class_name': 'Something', + 'action_name': 'group.action', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'Something|group.action: ', + {'class_name': 'Something', + 'action_name': 'group.action', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, ' Something|group.action:', + {'class_name': 'Something', + 'action_name': 'group.action', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'Weird-thing|name:', + None), + (ACTION_RE, 'really-weird_thing|name:', + None), + (ACTION_RE, 'GWin32InputStream|group.action:', + {'class_name': 'GWin32InputStream', + 'action_name': 'group.action', + 'delimiter': ':', + 'fields': ''}), + # properties: action name that contains a dash + (ACTION_RE, 'GtkWidget|group.double-buffered (skip)', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': '', + 'fields': '(skip)'}), + (ACTION_RE, 'GtkWidget|group.double-buffered', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, ' GtkWidget |group.double-buffered', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, 'GtkWidget| group.double-buffered ', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, ' GtkWidget | group.double-buffered ', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, 'GtkWidget|group.double-buffered:', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'GtkWidget|group.double-buffered: ', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, ' GtkWidget|group.double-buffered:', + {'class_name': 'GtkWidget', + 'action_name': 'group.double-buffered', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'Something|group.double-buffered:', + {'class_name': 'Something', + 'action_name': 'group.double-buffered', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'Something|group.double-buffered: ', + {'class_name': 'Something', + 'action_name': 'group.double-buffered', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, ' Something|group.double-buffered:', + {'class_name': 'Something', + 'action_name': 'group.double-buffered', + 'delimiter': ':', + 'fields': ''}), + (ACTION_RE, 'Weird-thing|double-buffered:', + None), + (ACTION_RE, 'really-weird_thing|double-buffered:', + None), + (ACTION_RE, ' GMemoryOutputStream|group.realloc-function: (skip)', + {'class_name': 'GMemoryOutputStream', + 'action_name': 'group.realloc-function', + 'delimiter': ':', + 'fields': '(skip)'}), + (ACTION_RE, 'Something|group-double.double-buffered', + {'class_name': 'Something', + 'action_name': 'group-double.double-buffered', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, 'Something| group-double.double-buffered', + {'class_name': 'Something', + 'action_name': 'group-double.double-buffered', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, 'Something |group-double.double-buffered', + {'class_name': 'Something', + 'action_name': 'group-double.double-buffered', + 'delimiter': '', + 'fields': ''}), + (ACTION_RE, 'Something | group-double.double-buffered', + {'class_name': 'Something', + 'action_name': 'group-double.double-buffered', + 'delimiter': '', + 'fields': ''})] + parameter_tests = [ (PARAMETER_RE, '@Short_description: Base class for all widgets ', {'parameter_name': 'Short_description', @@ -908,6 +1059,7 @@ def create_test_cases(): ('TestIdentifierSymbol', identifier_symbol_tests), ('TestIdentifierProperty', identifier_property_tests), ('TestIdentifierSignal', identifier_signal_tests), + ('TestIdentifierAction', identifier_action_tests), ('TestParameter', parameter_tests), ('TestTag', tag_tests), ('TestTagValueVersion', tag_value_version_tests), -- cgit v1.2.1 From b4c058bba4d95ae10e1e4238f9417fe954f97795 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 14 Feb 2020 14:53:09 +0000 Subject: Add element-type support to GListModel GListModel is an interface for creating typed, list-like containers. The data stored is GObject instances, but it's useful to be able to annotate the actual type, for both documentation and code generation purposes. Fixes: #328 --- giscanner/girparser.py | 2 +- giscanner/transformer.py | 3 ++ .../Regress.test_list_model_none.page | 30 ++++++++++++++++++++ .../Regress.test_list_model_object.page | 31 ++++++++++++++++++++ .../Regress.test_list_model_object.page | 33 ++++++++++++++++++++++ .../Regress.test_list_model_object.page | 32 +++++++++++++++++++++ tests/scanner/Regress-1.0-expected.gir | 32 +++++++++++++++++++++ tests/scanner/Regress-1.0-sections-expected.txt | 2 ++ tests/scanner/regress.c | 30 ++++++++++++++++++++ tests/scanner/regress.h | 6 ++++ 10 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page create mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page create mode 100644 tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page create mode 100644 tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 35206a41..d31b26cf 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -492,7 +492,7 @@ class GIRParser(object): if ctype is None: return ast.TypeUnknown() return ast.Type(ctype=ctype) - elif name in ['GLib.List', 'GLib.SList']: + elif name in ['GLib.List', 'GLib.SList', 'Gio.ListModel']: subchild = self._find_first_child(typenode, list(map(_corens, ('callback', 'array', ' varargs', 'type')))) diff --git a/giscanner/transformer.py b/giscanner/transformer.py index bcabdedc..7f230a20 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -698,6 +698,9 @@ raise ValueError.""" elif base in ('GHashTable', 'GLib.HashTable', 'GObject.HashTable'): return ast.Map(ast.TYPE_ANY, ast.TYPE_ANY, ctype=ctype, is_const=is_const, complete_ctype=complete_ctype) + elif base in ('GListModel', 'Gio.ListModel'): + return ast.List('Gio.ListModel', ast.TYPE_ANY, ctype=ctype, + is_const=is_const, complete_ctype=complete_ctype) return None def create_type_from_ctype_string(self, ctype, is_const=False, diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page new file mode 100644 index 00000000..b1458649 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page @@ -0,0 +1,30 @@ + + + + + + + GListModel* + + regress_test_list_model_none + + + regress_test_list_model_none + +GListModel* regress_test_list_model_none (void); + +

Test GListModel with no annotation.

+ + + +<code>Returns</code> +

a GListModel

+
+
+ +
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page new file mode 100644 index 00000000..620789cd --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page @@ -0,0 +1,31 @@ + + + + + + + GListModel* + + regress_test_list_model_object + + + regress_test_list_model_object + +GListModel* regress_test_list_model_object (void); + +

Test GListModel return value with an element type annotation.

+ + + +<code>Returns</code> +

a GListModel + containing RegressTestObj values

+
+
+ +
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page new file mode 100644 index 00000000..a9dd90d7 --- /dev/null +++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page @@ -0,0 +1,33 @@ + + + + + + + Array(Regress.TestObj) + + regress_test_list_model_object + + + Regress.test_list_model_object + +function test_list_model_object(): Array(Regress.TestObj) { + // Gjs wrapper for regress_test_list_model_object() +} + +

Test GListModel return value with an element type annotation.

+ + + +<code>Returns</code> +

a GListModel + containing RegressTestObj values

+
+
+ +
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page new file mode 100644 index 00000000..a4382c9d --- /dev/null +++ b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page @@ -0,0 +1,32 @@ + + + + + + + [Regress.TestObj] + + regress_test_list_model_object + + + Regress.test_list_model_object + +@returns([Regress.TestObj]) +def test_list_model_object(): + # Python wrapper for regress_test_list_model_object() + +

Test GListModel return value with an element type annotation.

+ + + +<code>Returns</code> +{formatter.format(node, node.retval.doc)} + + + +
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index cef3b124..af648273 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -8041,6 +8041,38 @@ element-type annotation. + + Test GListModel with no annotation. + + + a GListModel + + + + + + + Test GListModel return value with an element type annotation. + + + a GListModel + containing RegressTestObj values + + + + + diff --git a/tests/scanner/Regress-1.0-sections-expected.txt b/tests/scanner/Regress-1.0-sections-expected.txt index b35b3a9a..84f7ec67 100644 --- a/tests/scanner/Regress-1.0-sections-expected.txt +++ b/tests/scanner/Regress-1.0-sections-expected.txt @@ -159,6 +159,8 @@ regress_test_int64 regress_test_int8 regress_test_int_out_utf8 regress_test_int_value_arg +regress_test_list_model_none +regress_test_list_model_object regress_test_long regress_test_multi_callback regress_test_multi_double_args diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 3a63436b..e81d1989 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -4686,3 +4686,33 @@ regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len) g_assert_cmpint (arr[2].some_int, ==, 303); } +/** + * regress_test_list_model_none: + * + * Test GListModel with no annotation. + * + * Returns: (transfer full): a GListModel + */ +GListModel * +regress_test_list_model_none (void) +{ + GListStore *res = g_list_store_new (regress_test_obj_get_type ()); + + return G_LIST_MODEL (res); +} + +/** + * regress_test_list_model_object: + * + * Test GListModel return value with an element type annotation. + * + * Returns: (transfer full) (element-type RegressTestObj): a GListModel + * containing RegressTestObj values + */ +GListModel * +regress_test_list_model_object (void) +{ + GListStore *res = g_list_store_new (regress_test_obj_get_type ()); + + return G_LIST_MODEL (res); +} diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 0b239f14..9ff699fb 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -1534,4 +1534,10 @@ void regress_test_array_struct_in_full (RegressTestStructA *arr, gsize len); _GI_TEST_EXTERN void regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len); +_GI_TEST_EXTERN +GListModel *regress_test_list_model_none (void); + +_GI_TEST_EXTERN +GListModel *regress_test_list_model_object (void); + #endif /* __GITESTTYPES_H__ */ -- cgit v1.2.1 From ffe3e435e0b7943a0872034223b5f6ea02258ffa Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 21 Feb 2020 13:37:58 +0000 Subject: Generate appropriate docs for ListModel with element-type We need to special case the ListModel container type in the documentation writer so that we don't fall back into array/list automatic conversion in the code snippets. --- giscanner/docwriter.py | 18 +++++++++++++----- .../Regress.test_list_model_object.page | 4 ++-- .../Regress.test_list_model_object.page | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index 786da80d..e4a8f7c5 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -793,7 +793,11 @@ class DocFormatterPython(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, (ast.List, ast.Array)): + if isinstance(type_, ast.List): + if type_.name == 'Gio.ListModel': + return 'Gio.ListModel(item_type=' + self.format_type(type_.element_type) + ')' + return '[' + self.format_type(type_.element_type) + ']' + elif isinstance(type_, ast.Array): return '[' + self.format_type(type_.element_type) + ']' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type), @@ -930,10 +934,14 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, ast.Array) and \ - type_.element_type.target_fundamental in ('gint8', 'guint8'): - return 'ByteArray' - elif isinstance(type_, (ast.List, ast.Array)): + if isinstance(type_, ast.Array): + if type_.element_type.target_fundamental in ('gint8', 'guint8'): + return 'ByteArray' + else: + return 'Array(' + self.format_type(type_.element_type, link) + ')' + elif isinstance(type_, ast.List): + if type_.name == 'Gio.ListModel': + return 'Gio.ListModel({item_type: ' + self.format_type(type_.element_type) + '})' return 'Array(' + self.format_type(type_.element_type, link) + ')' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type, link), diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page index a9dd90d7..618ca7e3 100644 --- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page +++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page @@ -9,14 +9,14 @@ - Array(Regress.TestObj) + Gio.ListModel({item_type: Regress.TestObj}) regress_test_list_model_object Regress.test_list_model_object -function test_list_model_object(): Array(Regress.TestObj) { +function test_list_model_object(): Gio.ListModel({item_type: Regress.TestObj}) { // Gjs wrapper for regress_test_list_model_object() } diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page index a4382c9d..d9dca201 100644 --- a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page +++ b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page @@ -9,14 +9,14 @@ - [Regress.TestObj] + Gio.ListModel(item_type=Regress.TestObj) regress_test_list_model_object Regress.test_list_model_object -@returns([Regress.TestObj]) +@returns(Gio.ListModel(item_type=Regress.TestObj)) def test_list_model_object(): # Python wrapper for regress_test_list_model_object() -- cgit v1.2.1 From ad26ceaa536742060173257e661961bb26216e4e Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 24 Apr 2020 15:05:03 -0400 Subject: Revert "Revert "Meson: Fix build when glib is built as subproject"" This reverts commit 42b7d634a9a7500dcc71651f71844148fc200be3. --- girepository/cmph/meson.build | 2 ++ girepository/meson.build | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/girepository/cmph/meson.build b/girepository/cmph/meson.build index 5bc41a33..2a0cef7e 100644 --- a/girepository/cmph/meson.build +++ b/girepository/cmph/meson.build @@ -26,6 +26,7 @@ cmph_sources = [ cmph_deps = [ glib_dep, + gobject_dep, cc.find_library('m', required: false), ] @@ -67,6 +68,7 @@ cmph_test = executable('cmph-bdz-test', '../cmph-bdz-test.c', dependencies: [ cmph_dep, glib_dep, + gobject_dep, ], c_args: custom_c_args, ) diff --git a/girepository/meson.build b/girepository/meson.build index 204659fe..6cd8fd30 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -17,12 +17,13 @@ girepo_gthash_lib = static_library('girepository-gthash', cmph_dep, glib_dep, gmodule_dep, + gobject_dep, ], ) girepo_gthash_dep = declare_dependency( link_with: girepo_gthash_lib, - dependencies: [glib_dep, gmodule_dep], + dependencies: [glib_dep, gmodule_dep, gobject_dep], include_directories: include_directories('.'), ) -- cgit v1.2.1 From f9d53d9d0020d2a13ca246e19c5ce2e180e5b78a Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 24 Apr 2020 15:09:27 -0400 Subject: Meson: Override gobject-introspection-1.0 dependency When gobject-introspection-1.0 pkg-config is not found on the system, Meson can fallback to configure g-i as subproject and needs a dependency object to replace the pc file. The dependency file needs to ensure that typelibs are created before compiling any other gir and provide the girdir for files within build directory. It also need to provide glib dependencies required to compile girs. --- meson.build | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/meson.build b/meson.build index 3d22dd55..892f9c3c 100644 --- a/meson.build +++ b/meson.build @@ -264,3 +264,21 @@ configure_file( configuration: pkgconfig_conf, install_dir: join_paths(get_option('libdir'), 'pkgconfig'), ) + +# Dependency object used by Meson's GNOME module. This dependency variable must +# be named girepo_dep for backward compatibility with projects that where already +# using that name as fallback: dependency('gobject-introspection-1.0', +# fallback : ['gobject-introspection', 'girepo_dep']) +# FIXME: meson.override_dependency() and declare_dependency()'s variable arguments +# are new in Meson 0.54.0, older versions of Meson won't be able to use g-i as +# subproject anyway +if meson.version().version_compare('>=0.54.0') + girepo_dep = declare_dependency( + sources: typelibs, + dependencies: girepo_dep, + variables: { + 'girdir': meson.current_build_dir() / 'gir', + }, + ) + meson.override_dependency('gobject-introspection-1.0', girepo_dep) +endif -- cgit v1.2.1 From 6dc8402c267a5855219b77be2d649f3a9e84d817 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 26 Apr 2020 13:11:15 +0100 Subject: Revert "Generate appropriate docs for ListModel with element-type" This reverts commit ffe3e435e0b7943a0872034223b5f6ea02258ffa. See: #336 --- giscanner/docwriter.py | 18 +++++------------- .../Regress.test_list_model_object.page | 4 ++-- .../Regress.test_list_model_object.page | 4 ++-- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index e4a8f7c5..786da80d 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -793,11 +793,7 @@ class DocFormatterPython(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, ast.List): - if type_.name == 'Gio.ListModel': - return 'Gio.ListModel(item_type=' + self.format_type(type_.element_type) + ')' - return '[' + self.format_type(type_.element_type) + ']' - elif isinstance(type_, ast.Array): + if isinstance(type_, (ast.List, ast.Array)): return '[' + self.format_type(type_.element_type) + ']' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type), @@ -934,14 +930,10 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, ast.Array): - if type_.element_type.target_fundamental in ('gint8', 'guint8'): - return 'ByteArray' - else: - return 'Array(' + self.format_type(type_.element_type, link) + ')' - elif isinstance(type_, ast.List): - if type_.name == 'Gio.ListModel': - return 'Gio.ListModel({item_type: ' + self.format_type(type_.element_type) + '})' + if isinstance(type_, ast.Array) and \ + type_.element_type.target_fundamental in ('gint8', 'guint8'): + return 'ByteArray' + elif isinstance(type_, (ast.List, ast.Array)): return 'Array(' + self.format_type(type_.element_type, link) + ')' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type, link), diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page index 618ca7e3..a9dd90d7 100644 --- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page +++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page @@ -9,14 +9,14 @@ - Gio.ListModel({item_type: Regress.TestObj}) + Array(Regress.TestObj) regress_test_list_model_object Regress.test_list_model_object -function test_list_model_object(): Gio.ListModel({item_type: Regress.TestObj}) { +function test_list_model_object(): Array(Regress.TestObj) { // Gjs wrapper for regress_test_list_model_object() } diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page index d9dca201..a4382c9d 100644 --- a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page +++ b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page @@ -9,14 +9,14 @@ - Gio.ListModel(item_type=Regress.TestObj) + [Regress.TestObj] regress_test_list_model_object Regress.test_list_model_object -@returns(Gio.ListModel(item_type=Regress.TestObj)) +@returns([Regress.TestObj]) def test_list_model_object(): # Python wrapper for regress_test_list_model_object() -- cgit v1.2.1 From 07162e9064a0a64ee68826334d8ab2d5c25ff035 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 26 Apr 2020 13:16:17 +0100 Subject: Revert "Add element-type support to GListModel" This reverts commit b4c058bba4d95ae10e1e4238f9417fe954f97795. See: #336 --- giscanner/girparser.py | 2 +- giscanner/transformer.py | 3 -- .../Regress.test_list_model_none.page | 30 -------------------- .../Regress.test_list_model_object.page | 31 -------------------- .../Regress.test_list_model_object.page | 33 ---------------------- .../Regress.test_list_model_object.page | 32 --------------------- tests/scanner/Regress-1.0-expected.gir | 32 --------------------- tests/scanner/Regress-1.0-sections-expected.txt | 2 -- tests/scanner/regress.c | 30 -------------------- tests/scanner/regress.h | 6 ---- 10 files changed, 1 insertion(+), 200 deletions(-) delete mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page delete mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page delete mode 100644 tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page delete mode 100644 tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page diff --git a/giscanner/girparser.py b/giscanner/girparser.py index d31b26cf..35206a41 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -492,7 +492,7 @@ class GIRParser(object): if ctype is None: return ast.TypeUnknown() return ast.Type(ctype=ctype) - elif name in ['GLib.List', 'GLib.SList', 'Gio.ListModel']: + elif name in ['GLib.List', 'GLib.SList']: subchild = self._find_first_child(typenode, list(map(_corens, ('callback', 'array', ' varargs', 'type')))) diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 7f230a20..bcabdedc 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -698,9 +698,6 @@ raise ValueError.""" elif base in ('GHashTable', 'GLib.HashTable', 'GObject.HashTable'): return ast.Map(ast.TYPE_ANY, ast.TYPE_ANY, ctype=ctype, is_const=is_const, complete_ctype=complete_ctype) - elif base in ('GListModel', 'Gio.ListModel'): - return ast.List('Gio.ListModel', ast.TYPE_ANY, ctype=ctype, - is_const=is_const, complete_ctype=complete_ctype) return None def create_type_from_ctype_string(self, ctype, is_const=False, diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page deleted file mode 100644 index b1458649..00000000 --- a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - GListModel* - - regress_test_list_model_none - - - regress_test_list_model_none - -GListModel* regress_test_list_model_none (void); - -

Test GListModel with no annotation.

- - - -<code>Returns</code> -

a GListModel

-
-
- -
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page deleted file mode 100644 index 620789cd..00000000 --- a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - GListModel* - - regress_test_list_model_object - - - regress_test_list_model_object - -GListModel* regress_test_list_model_object (void); - -

Test GListModel return value with an element type annotation.

- - - -<code>Returns</code> -

a GListModel - containing RegressTestObj values

-
-
- -
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page deleted file mode 100644 index a9dd90d7..00000000 --- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - Array(Regress.TestObj) - - regress_test_list_model_object - - - Regress.test_list_model_object - -function test_list_model_object(): Array(Regress.TestObj) { - // Gjs wrapper for regress_test_list_model_object() -} - -

Test GListModel return value with an element type annotation.

- - - -<code>Returns</code> -

a GListModel - containing RegressTestObj values

-
-
- -
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page deleted file mode 100644 index a4382c9d..00000000 --- a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - [Regress.TestObj] - - regress_test_list_model_object - - - Regress.test_list_model_object - -@returns([Regress.TestObj]) -def test_list_model_object(): - # Python wrapper for regress_test_list_model_object() - -

Test GListModel return value with an element type annotation.

- - - -<code>Returns</code> -{formatter.format(node, node.retval.doc)} - - - -
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index af648273..cef3b124 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -8041,38 +8041,6 @@ element-type annotation.
- - Test GListModel with no annotation. - - - a GListModel - - - - - - - Test GListModel return value with an element type annotation. - - - a GListModel - containing RegressTestObj values - - - - - diff --git a/tests/scanner/Regress-1.0-sections-expected.txt b/tests/scanner/Regress-1.0-sections-expected.txt index 84f7ec67..b35b3a9a 100644 --- a/tests/scanner/Regress-1.0-sections-expected.txt +++ b/tests/scanner/Regress-1.0-sections-expected.txt @@ -159,8 +159,6 @@ regress_test_int64 regress_test_int8 regress_test_int_out_utf8 regress_test_int_value_arg -regress_test_list_model_none -regress_test_list_model_object regress_test_long regress_test_multi_callback regress_test_multi_double_args diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index e81d1989..3a63436b 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -4686,33 +4686,3 @@ regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len) g_assert_cmpint (arr[2].some_int, ==, 303); } -/** - * regress_test_list_model_none: - * - * Test GListModel with no annotation. - * - * Returns: (transfer full): a GListModel - */ -GListModel * -regress_test_list_model_none (void) -{ - GListStore *res = g_list_store_new (regress_test_obj_get_type ()); - - return G_LIST_MODEL (res); -} - -/** - * regress_test_list_model_object: - * - * Test GListModel return value with an element type annotation. - * - * Returns: (transfer full) (element-type RegressTestObj): a GListModel - * containing RegressTestObj values - */ -GListModel * -regress_test_list_model_object (void) -{ - GListStore *res = g_list_store_new (regress_test_obj_get_type ()); - - return G_LIST_MODEL (res); -} diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 9ff699fb..0b239f14 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -1534,10 +1534,4 @@ void regress_test_array_struct_in_full (RegressTestStructA *arr, gsize len); _GI_TEST_EXTERN void regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len); -_GI_TEST_EXTERN -GListModel *regress_test_list_model_none (void); - -_GI_TEST_EXTERN -GListModel *regress_test_list_model_object (void); - #endif /* __GITESTTYPES_H__ */ -- cgit v1.2.1 From a9f45431684e6be3623e272e54d481e4c5d9423d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 26 Apr 2020 13:17:15 +0100 Subject: Add support for element-type to GListModel GListModel is an interface for creating typed, list-like containers. The data stored is GObject instances, but it's useful to be able to annotate the actual type, for both documentation and code generation purposes. The annotation should be optional, to maintain backward compatibility. --- giscanner/docwriter.py | 18 ++++++++---- giscanner/girparser.py | 2 +- giscanner/introspectablepass.py | 3 +- giscanner/transformer.py | 3 ++ .../Regress.test_list_model_none.page | 30 ++++++++++++++++++++ .../Regress.test_list_model_object.page | 31 ++++++++++++++++++++ .../Regress.test_list_model_none.page | 32 +++++++++++++++++++++ .../Regress.test_list_model_object.page | 33 ++++++++++++++++++++++ .../Regress.test_list_model_none.page | 32 +++++++++++++++++++++ .../Regress.test_list_model_object.page | 32 +++++++++++++++++++++ tests/scanner/Regress-1.0-expected.gir | 31 ++++++++++++++++++++ tests/scanner/Regress-1.0-sections-expected.txt | 2 ++ tests/scanner/regress.c | 30 ++++++++++++++++++++ tests/scanner/regress.h | 6 ++++ 14 files changed, 278 insertions(+), 7 deletions(-) create mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page create mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page create mode 100644 tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page create mode 100644 tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page create mode 100644 tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page create mode 100644 tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index 786da80d..e4a8f7c5 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -793,7 +793,11 @@ class DocFormatterPython(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, (ast.List, ast.Array)): + if isinstance(type_, ast.List): + if type_.name == 'Gio.ListModel': + return 'Gio.ListModel(item_type=' + self.format_type(type_.element_type) + ')' + return '[' + self.format_type(type_.element_type) + ']' + elif isinstance(type_, ast.Array): return '[' + self.format_type(type_.element_type) + ']' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type), @@ -930,10 +934,14 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, ast.Array) and \ - type_.element_type.target_fundamental in ('gint8', 'guint8'): - return 'ByteArray' - elif isinstance(type_, (ast.List, ast.Array)): + if isinstance(type_, ast.Array): + if type_.element_type.target_fundamental in ('gint8', 'guint8'): + return 'ByteArray' + else: + return 'Array(' + self.format_type(type_.element_type, link) + ')' + elif isinstance(type_, ast.List): + if type_.name == 'Gio.ListModel': + return 'Gio.ListModel({item_type: ' + self.format_type(type_.element_type) + '})' return 'Array(' + self.format_type(type_.element_type, link) + ')' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type, link), diff --git a/giscanner/girparser.py b/giscanner/girparser.py index 35206a41..d31b26cf 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -492,7 +492,7 @@ class GIRParser(object): if ctype is None: return ast.TypeUnknown() return ast.Type(ctype=ctype) - elif name in ['GLib.List', 'GLib.SList']: + elif name in ['GLib.List', 'GLib.SList', 'Gio.ListModel']: subchild = self._find_first_child(typenode, list(map(_corens, ('callback', 'array', ' varargs', 'type')))) diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py index e2056b42..8ac50064 100644 --- a/giscanner/introspectablepass.py +++ b/giscanner/introspectablepass.py @@ -89,7 +89,8 @@ class IntrospectablePass(object): return if (isinstance(node.type, (ast.List, ast.Array)) - and node.type.element_type == ast.TYPE_ANY): + and node.type.element_type == ast.TYPE_ANY + and not (isinstance(node.type, ast.List) and node.type.name == 'Gio.ListModel')): self._parameter_warning(parent, node, "Missing (element-type) annotation") parent.introspectable = False return diff --git a/giscanner/transformer.py b/giscanner/transformer.py index bcabdedc..7f230a20 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -698,6 +698,9 @@ raise ValueError.""" elif base in ('GHashTable', 'GLib.HashTable', 'GObject.HashTable'): return ast.Map(ast.TYPE_ANY, ast.TYPE_ANY, ctype=ctype, is_const=is_const, complete_ctype=complete_ctype) + elif base in ('GListModel', 'Gio.ListModel'): + return ast.List('Gio.ListModel', ast.TYPE_ANY, ctype=ctype, + is_const=is_const, complete_ctype=complete_ctype) return None def create_type_from_ctype_string(self, ctype, is_const=False, diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page new file mode 100644 index 00000000..b1458649 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page @@ -0,0 +1,30 @@ + + + + + + + GListModel* + + regress_test_list_model_none + + + regress_test_list_model_none + +GListModel* regress_test_list_model_none (void); + +

Test GListModel with no annotation.

+ + + +<code>Returns</code> +

a GListModel

+
+
+ +
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page new file mode 100644 index 00000000..620789cd --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page @@ -0,0 +1,31 @@ + + + + + + + GListModel* + + regress_test_list_model_object + + + regress_test_list_model_object + +GListModel* regress_test_list_model_object (void); + +

Test GListModel return value with an element type annotation.

+ + + +<code>Returns</code> +

a GListModel + containing RegressTestObj values

+
+
+ +
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page new file mode 100644 index 00000000..099232e0 --- /dev/null +++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page @@ -0,0 +1,32 @@ + + + + + + + Gio.ListModel({item_type: void}) + + regress_test_list_model_none + + + Regress.test_list_model_none + +function test_list_model_none(): Gio.ListModel({item_type: void}) { + // Gjs wrapper for regress_test_list_model_none() +} + +

Test GListModel with no annotation.

+ + + +<code>Returns</code> +

a GListModel

+
+
+ +
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page new file mode 100644 index 00000000..618ca7e3 --- /dev/null +++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page @@ -0,0 +1,33 @@ + + + + + + + Gio.ListModel({item_type: Regress.TestObj}) + + regress_test_list_model_object + + + Regress.test_list_model_object + +function test_list_model_object(): Gio.ListModel({item_type: Regress.TestObj}) { + // Gjs wrapper for regress_test_list_model_object() +} + +

Test GListModel return value with an element type annotation.

+ + + +<code>Returns</code> +

a GListModel + containing RegressTestObj values

+
+
+ +
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page new file mode 100644 index 00000000..61cb3de1 --- /dev/null +++ b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page @@ -0,0 +1,32 @@ + + + + + + + Gio.ListModel(item_type=gpointer) + + regress_test_list_model_none + + + Regress.test_list_model_none + +@returns(Gio.ListModel(item_type=gpointer)) +def test_list_model_none(): + # Python wrapper for regress_test_list_model_none() + +

Test GListModel with no annotation.

+ + + +<code>Returns</code> +{formatter.format(node, node.retval.doc)} + + + +
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page new file mode 100644 index 00000000..d9dca201 --- /dev/null +++ b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page @@ -0,0 +1,32 @@ + + + + + + + Gio.ListModel(item_type=Regress.TestObj) + + regress_test_list_model_object + + + Regress.test_list_model_object + +@returns(Gio.ListModel(item_type=Regress.TestObj)) +def test_list_model_object(): + # Python wrapper for regress_test_list_model_object() + +

Test GListModel return value with an element type annotation.

+ + + +<code>Returns</code> +{formatter.format(node, node.retval.doc)} + + + +
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index cef3b124..bcba3fbe 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -8041,6 +8041,37 @@ element-type annotation.
+ + Test GListModel with no annotation. + + + a GListModel + + + + + + + Test GListModel return value with an element type annotation. + + + a GListModel + containing RegressTestObj values + + + + + diff --git a/tests/scanner/Regress-1.0-sections-expected.txt b/tests/scanner/Regress-1.0-sections-expected.txt index b35b3a9a..84f7ec67 100644 --- a/tests/scanner/Regress-1.0-sections-expected.txt +++ b/tests/scanner/Regress-1.0-sections-expected.txt @@ -159,6 +159,8 @@ regress_test_int64 regress_test_int8 regress_test_int_out_utf8 regress_test_int_value_arg +regress_test_list_model_none +regress_test_list_model_object regress_test_long regress_test_multi_callback regress_test_multi_double_args diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 3a63436b..e81d1989 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -4686,3 +4686,33 @@ regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len) g_assert_cmpint (arr[2].some_int, ==, 303); } +/** + * regress_test_list_model_none: + * + * Test GListModel with no annotation. + * + * Returns: (transfer full): a GListModel + */ +GListModel * +regress_test_list_model_none (void) +{ + GListStore *res = g_list_store_new (regress_test_obj_get_type ()); + + return G_LIST_MODEL (res); +} + +/** + * regress_test_list_model_object: + * + * Test GListModel return value with an element type annotation. + * + * Returns: (transfer full) (element-type RegressTestObj): a GListModel + * containing RegressTestObj values + */ +GListModel * +regress_test_list_model_object (void) +{ + GListStore *res = g_list_store_new (regress_test_obj_get_type ()); + + return G_LIST_MODEL (res); +} diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 0b239f14..9ff699fb 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -1534,4 +1534,10 @@ void regress_test_array_struct_in_full (RegressTestStructA *arr, gsize len); _GI_TEST_EXTERN void regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len); +_GI_TEST_EXTERN +GListModel *regress_test_list_model_none (void); + +_GI_TEST_EXTERN +GListModel *regress_test_list_model_object (void); + #endif /* __GITESTTYPES_H__ */ -- cgit v1.2.1 From 1647f69283eea8f762d3d27f19deac925a83d005 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sat, 11 Apr 2020 14:18:06 -0700 Subject: build: Check Python.h and fail early if not present Checking the Python dependency doesn't ensure the header is present. That needs to be checked separately. --- meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meson.build b/meson.build index 892f9c3c..f66d926e 100644 --- a/meson.build +++ b/meson.build @@ -152,6 +152,9 @@ endif libffi_dep = dependency('libffi', fallback : ['libffi', 'ffi_dep']) +# python headers +cc.check_header('Python.h', dependencies: [python.dependency()], required: true) + # cairo cairo_option = get_option('cairo') if cc.get_id() == 'msvc' -- cgit v1.2.1 From bcf8fa77d7946ce6285866b36b9c0d8134861109 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sat, 11 Apr 2020 14:19:06 -0700 Subject: girepository: Add 1.66 version macro Required for adding new API to the 1.66 series. --- girepository/giversionmacros.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/girepository/giversionmacros.h b/girepository/giversionmacros.h index c32e5bb8..a941ee2d 100644 --- a/girepository/giversionmacros.h +++ b/girepository/giversionmacros.h @@ -159,4 +159,10 @@ # define GI_AVAILABLE_IN_1_60 _GI_EXTERN #endif +#if defined(GLIB_VERSION_2_66) && GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 +# define GI_AVAILABLE_IN_1_66 GLIB_UNAVAILABLE(2, 66) +#else +# define GI_AVAILABLE_IN_1_66 _GI_EXTERN +#endif + #endif /* __GIVERSIONMACROS_H__ */ -- cgit v1.2.1 From 129c588fe3ec724a1537637d1c716e126b519b37 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sat, 11 Apr 2020 14:22:18 -0700 Subject: girepository: Add GITypeInfo utility functions for storing values in pointers This functionality is used in both PyGObject and GJS, and if not done correctly can lead to architecture-specific bugs. It seems best to add API in gobject-introspection for the correct way to do it. See also: GNOME/gjs#309 --- girepository/gitypeinfo.c | 170 ++++++++++++++++++++++++++++++++++++++++++++++ girepository/gitypeinfo.h | 12 ++++ 2 files changed, 182 insertions(+) diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index 1434b2f3..e90f9463 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -347,3 +347,173 @@ g_type_info_get_array_type (GITypeInfo *info) return -1; } + +/** + * g_type_info_get_storage_type: + * @info: a #GITypeInfo + * + * Obtain the type tag corresponding to the underlying storage type in C for + * the type. + * See #GITypeTag for a list of type tags. + * + * Returns: the type tag + * + * Since: 1.66 + */ +GITypeTag +g_type_info_get_storage_type (GITypeInfo *info) +{ + GITypeTag type_tag = g_type_info_get_tag (info); + + if (type_tag == GI_TYPE_TAG_INTERFACE) + { + GIBaseInfo *interface = g_type_info_get_interface (info); + GIInfoType info_type = g_base_info_get_type (interface); + if (info_type == GI_INFO_TYPE_ENUM || info_type == GI_INFO_TYPE_FLAGS) + type_tag = g_enum_info_get_storage_type (interface); + g_base_info_unref (interface); + } + + return type_tag; +} + +/** + * g_type_info_argument_from_hash_pointer: + * @info: a #GITypeInfo + * @hash_pointer: A pointer, such as a #GHashTable data pointer + * @arg: A #GIArgument to fill in + * + * GLib data structures, such as #GList, #GSList, and #GHashTable, all store + * data pointers. + * In the case where the list or hash table is storing single types rather than + * structs, these data pointers may have values stuffed into them via macros + * such as %GPOINTER_TO_INT. + * + * Use this function to ensure that all values are correctly extracted from + * stuffed pointers, regardless of the machine's architecture or endianness. + * + * This function fills in the appropriate field of @arg with the value extracted + * from @hash_pointer, depending on the storage type of @info. + * + * Since: 1.66 + */ +void +g_type_info_argument_from_hash_pointer (GITypeInfo *info, + gpointer hash_pointer, + GIArgument *arg) +{ + GITypeTag type_tag = g_type_info_get_storage_type (info); + + switch (type_tag) + { + case GI_TYPE_TAG_BOOLEAN: + arg->v_boolean = !!GPOINTER_TO_INT (hash_pointer); + break; + case GI_TYPE_TAG_INT8: + arg->v_int8 = (gint8)GPOINTER_TO_INT (hash_pointer); + break; + case GI_TYPE_TAG_UINT8: + arg->v_uint8 = (guint8)GPOINTER_TO_UINT (hash_pointer); + break; + case GI_TYPE_TAG_INT16: + arg->v_int16 = (gint16)GPOINTER_TO_INT (hash_pointer); + break; + case GI_TYPE_TAG_UINT16: + arg->v_uint16 = (guint16)GPOINTER_TO_UINT (hash_pointer); + break; + case GI_TYPE_TAG_INT32: + arg->v_int32 = (gint32)GPOINTER_TO_INT (hash_pointer); + break; + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_UNICHAR: + arg->v_uint32 = (guint32)GPOINTER_TO_UINT (hash_pointer); + break; + case GI_TYPE_TAG_GTYPE: + arg->v_size = GPOINTER_TO_SIZE (hash_pointer); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + case GI_TYPE_TAG_INTERFACE: + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + case GI_TYPE_TAG_ERROR: + arg->v_pointer = hash_pointer; + break; + case GI_TYPE_TAG_INT64: + case GI_TYPE_TAG_UINT64: + case GI_TYPE_TAG_FLOAT: + case GI_TYPE_TAG_DOUBLE: + default: + g_critical ("Unsupported type for pointer-stuffing: %s", + g_type_tag_to_string (type_tag)); + arg->v_pointer = hash_pointer; + } +} + +/** + * g_type_info_hash_pointer_from_argument: + * @info: a #GITypeInfo + * @arg: A #GIArgument with the value to stuff into a pointer + * + * GLib data structures, such as #GList, #GSList, and #GHashTable, all store + * data pointers. + * In the case where the list or hash table is storing single types rather than + * structs, these data pointers may have values stuffed into them via macros + * such as %GPOINTER_TO_INT. + * + * Use this function to ensure that all values are correctly stuffed into + * pointers, regardless of the machine's architecture or endianness. + * + * This function returns a pointer stuffed with the appropriate field of @arg, + * depending on the storage type of @info. + * + * Returns: A stuffed pointer, that can be stored in a #GHashTable, for example + * + * Since: 1.66 + */ +gpointer +g_type_info_hash_pointer_from_argument (GITypeInfo *info, + GIArgument *arg) +{ + GITypeTag type_tag = g_type_info_get_storage_type (info); + + switch (type_tag) + { + case GI_TYPE_TAG_BOOLEAN: + return GINT_TO_POINTER (arg->v_boolean); + case GI_TYPE_TAG_INT8: + return GINT_TO_POINTER (arg->v_int8); + case GI_TYPE_TAG_UINT8: + return GUINT_TO_POINTER (arg->v_uint8); + case GI_TYPE_TAG_INT16: + return GINT_TO_POINTER (arg->v_int16); + case GI_TYPE_TAG_UINT16: + return GUINT_TO_POINTER (arg->v_uint16); + case GI_TYPE_TAG_INT32: + return GINT_TO_POINTER (arg->v_int32); + case GI_TYPE_TAG_UINT32: + case GI_TYPE_TAG_UNICHAR: + return GUINT_TO_POINTER (arg->v_uint32); + case GI_TYPE_TAG_GTYPE: + return GSIZE_TO_POINTER (arg->v_size); + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + case GI_TYPE_TAG_INTERFACE: + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + case GI_TYPE_TAG_ERROR: + return arg->v_pointer; + case GI_TYPE_TAG_INT64: + case GI_TYPE_TAG_UINT64: + case GI_TYPE_TAG_FLOAT: + case GI_TYPE_TAG_DOUBLE: + default: + g_critical ("Unsupported type for pointer-stuffing: %s", + g_type_tag_to_string (type_tag)); + return arg->v_pointer; + } +} diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index 4d5679c9..fd7d5be6 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -80,6 +80,18 @@ gboolean g_type_info_is_zero_terminated (GITypeInfo *info); GI_AVAILABLE_IN_ALL GIArrayType g_type_info_get_array_type (GITypeInfo *info); +GI_AVAILABLE_IN_1_66 +GITypeTag g_type_info_get_storage_type (GITypeInfo *info); + +GI_AVAILABLE_IN_1_66 +void g_type_info_argument_from_hash_pointer (GITypeInfo *info, + gpointer hash_pointer, + GIArgument *arg); + +GI_AVAILABLE_IN_1_66 +gpointer g_type_info_hash_pointer_from_argument (GITypeInfo *info, + GIArgument *arg); + G_END_DECLS -- cgit v1.2.1 From 770d81f2a32a7bbaa64cd923a69838574e2f0454 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 26 Apr 2020 10:22:34 -0700 Subject: build: Bump version to 1.65 We are adding new API for 1.66, so bump the version number to the development series. --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index f66d926e..c730b2c6 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('gobject-introspection', 'c', - version: '1.64.1', + version: '1.65.1', meson_version: '>= 0.50.1', default_options: [ 'warning_level=1', -- cgit v1.2.1 From bb364bd25d50215b0c40d98ba5ecf2aa779e53a2 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 28 Apr 2020 11:18:18 +0200 Subject: Revert "Add support for element-type to GListModel" Breaks vapigen and changes GListModel definition in Gio-2.0.gir This reverts commit a9f45431684e6be3623e272e54d481e4c5d9423d. --- giscanner/docwriter.py | 18 ++++-------- giscanner/girparser.py | 2 +- giscanner/introspectablepass.py | 3 +- giscanner/transformer.py | 3 -- .../Regress.test_list_model_none.page | 30 -------------------- .../Regress.test_list_model_object.page | 31 -------------------- .../Regress.test_list_model_none.page | 32 --------------------- .../Regress.test_list_model_object.page | 33 ---------------------- .../Regress.test_list_model_none.page | 32 --------------------- .../Regress.test_list_model_object.page | 32 --------------------- tests/scanner/Regress-1.0-expected.gir | 31 -------------------- tests/scanner/Regress-1.0-sections-expected.txt | 2 -- tests/scanner/regress.c | 30 -------------------- tests/scanner/regress.h | 6 ---- 14 files changed, 7 insertions(+), 278 deletions(-) delete mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page delete mode 100644 tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page delete mode 100644 tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page delete mode 100644 tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page delete mode 100644 tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page delete mode 100644 tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index e4a8f7c5..786da80d 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -793,11 +793,7 @@ class DocFormatterPython(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, ast.List): - if type_.name == 'Gio.ListModel': - return 'Gio.ListModel(item_type=' + self.format_type(type_.element_type) + ')' - return '[' + self.format_type(type_.element_type) + ']' - elif isinstance(type_, ast.Array): + if isinstance(type_, (ast.List, ast.Array)): return '[' + self.format_type(type_.element_type) + ']' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type), @@ -934,14 +930,10 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): return fundamental_types.get(name, name) def format_type(self, type_, link=False): - if isinstance(type_, ast.Array): - if type_.element_type.target_fundamental in ('gint8', 'guint8'): - return 'ByteArray' - else: - return 'Array(' + self.format_type(type_.element_type, link) + ')' - elif isinstance(type_, ast.List): - if type_.name == 'Gio.ListModel': - return 'Gio.ListModel({item_type: ' + self.format_type(type_.element_type) + '})' + if isinstance(type_, ast.Array) and \ + type_.element_type.target_fundamental in ('gint8', 'guint8'): + return 'ByteArray' + elif isinstance(type_, (ast.List, ast.Array)): return 'Array(' + self.format_type(type_.element_type, link) + ')' elif isinstance(type_, ast.Map): return '{%s: %s}' % (self.format_type(type_.key_type, link), diff --git a/giscanner/girparser.py b/giscanner/girparser.py index d31b26cf..35206a41 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -492,7 +492,7 @@ class GIRParser(object): if ctype is None: return ast.TypeUnknown() return ast.Type(ctype=ctype) - elif name in ['GLib.List', 'GLib.SList', 'Gio.ListModel']: + elif name in ['GLib.List', 'GLib.SList']: subchild = self._find_first_child(typenode, list(map(_corens, ('callback', 'array', ' varargs', 'type')))) diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py index 8ac50064..e2056b42 100644 --- a/giscanner/introspectablepass.py +++ b/giscanner/introspectablepass.py @@ -89,8 +89,7 @@ class IntrospectablePass(object): return if (isinstance(node.type, (ast.List, ast.Array)) - and node.type.element_type == ast.TYPE_ANY - and not (isinstance(node.type, ast.List) and node.type.name == 'Gio.ListModel')): + and node.type.element_type == ast.TYPE_ANY): self._parameter_warning(parent, node, "Missing (element-type) annotation") parent.introspectable = False return diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 7f230a20..bcabdedc 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -698,9 +698,6 @@ raise ValueError.""" elif base in ('GHashTable', 'GLib.HashTable', 'GObject.HashTable'): return ast.Map(ast.TYPE_ANY, ast.TYPE_ANY, ctype=ctype, is_const=is_const, complete_ctype=complete_ctype) - elif base in ('GListModel', 'Gio.ListModel'): - return ast.List('Gio.ListModel', ast.TYPE_ANY, ctype=ctype, - is_const=is_const, complete_ctype=complete_ctype) return None def create_type_from_ctype_string(self, ctype, is_const=False, diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page deleted file mode 100644 index b1458649..00000000 --- a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_none.page +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - GListModel* - - regress_test_list_model_none - - - regress_test_list_model_none - -GListModel* regress_test_list_model_none (void); - -

Test GListModel with no annotation.

- - - -<code>Returns</code> -

a GListModel

-
-
- -
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page deleted file mode 100644 index 620789cd..00000000 --- a/tests/scanner/Regress-1.0-C-expected/Regress.test_list_model_object.page +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - GListModel* - - regress_test_list_model_object - - - regress_test_list_model_object - -GListModel* regress_test_list_model_object (void); - -

Test GListModel return value with an element type annotation.

- - - -<code>Returns</code> -

a GListModel - containing RegressTestObj values

-
-
- -
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page deleted file mode 100644 index 099232e0..00000000 --- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_none.page +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - Gio.ListModel({item_type: void}) - - regress_test_list_model_none - - - Regress.test_list_model_none - -function test_list_model_none(): Gio.ListModel({item_type: void}) { - // Gjs wrapper for regress_test_list_model_none() -} - -

Test GListModel with no annotation.

- - - -<code>Returns</code> -

a GListModel

-
-
- -
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page deleted file mode 100644 index 618ca7e3..00000000 --- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.test_list_model_object.page +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - Gio.ListModel({item_type: Regress.TestObj}) - - regress_test_list_model_object - - - Regress.test_list_model_object - -function test_list_model_object(): Gio.ListModel({item_type: Regress.TestObj}) { - // Gjs wrapper for regress_test_list_model_object() -} - -

Test GListModel return value with an element type annotation.

- - - -<code>Returns</code> -

a GListModel - containing RegressTestObj values

-
-
- -
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page deleted file mode 100644 index 61cb3de1..00000000 --- a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_none.page +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - Gio.ListModel(item_type=gpointer) - - regress_test_list_model_none - - - Regress.test_list_model_none - -@returns(Gio.ListModel(item_type=gpointer)) -def test_list_model_none(): - # Python wrapper for regress_test_list_model_none() - -

Test GListModel with no annotation.

- - - -<code>Returns</code> -{formatter.format(node, node.retval.doc)} - - - -
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page b/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page deleted file mode 100644 index d9dca201..00000000 --- a/tests/scanner/Regress-1.0-Python-expected/Regress.test_list_model_object.page +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - Gio.ListModel(item_type=Regress.TestObj) - - regress_test_list_model_object - - - Regress.test_list_model_object - -@returns(Gio.ListModel(item_type=Regress.TestObj)) -def test_list_model_object(): - # Python wrapper for regress_test_list_model_object() - -

Test GListModel return value with an element type annotation.

- - - -<code>Returns</code> -{formatter.format(node, node.retval.doc)} - - - -
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index bcba3fbe..cef3b124 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -8041,37 +8041,6 @@ element-type annotation.
- - Test GListModel with no annotation. - - - a GListModel - - - - - - - Test GListModel return value with an element type annotation. - - - a GListModel - containing RegressTestObj values - - - - - diff --git a/tests/scanner/Regress-1.0-sections-expected.txt b/tests/scanner/Regress-1.0-sections-expected.txt index 84f7ec67..b35b3a9a 100644 --- a/tests/scanner/Regress-1.0-sections-expected.txt +++ b/tests/scanner/Regress-1.0-sections-expected.txt @@ -159,8 +159,6 @@ regress_test_int64 regress_test_int8 regress_test_int_out_utf8 regress_test_int_value_arg -regress_test_list_model_none -regress_test_list_model_object regress_test_long regress_test_multi_callback regress_test_multi_double_args diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index e81d1989..3a63436b 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -4686,33 +4686,3 @@ regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len) g_assert_cmpint (arr[2].some_int, ==, 303); } -/** - * regress_test_list_model_none: - * - * Test GListModel with no annotation. - * - * Returns: (transfer full): a GListModel - */ -GListModel * -regress_test_list_model_none (void) -{ - GListStore *res = g_list_store_new (regress_test_obj_get_type ()); - - return G_LIST_MODEL (res); -} - -/** - * regress_test_list_model_object: - * - * Test GListModel return value with an element type annotation. - * - * Returns: (transfer full) (element-type RegressTestObj): a GListModel - * containing RegressTestObj values - */ -GListModel * -regress_test_list_model_object (void) -{ - GListStore *res = g_list_store_new (regress_test_obj_get_type ()); - - return G_LIST_MODEL (res); -} diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 9ff699fb..0b239f14 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -1534,10 +1534,4 @@ void regress_test_array_struct_in_full (RegressTestStructA *arr, gsize len); _GI_TEST_EXTERN void regress_test_array_struct_in_none (RegressTestStructA *arr, gsize len); -_GI_TEST_EXTERN -GListModel *regress_test_list_model_none (void); - -_GI_TEST_EXTERN -GListModel *regress_test_list_model_object (void); - #endif /* __GITESTTYPES_H__ */ -- cgit v1.2.1 From 7996257738a821af4538c32b5d334350813f67e0 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 28 Apr 2020 07:38:45 +0200 Subject: gir: Update annotations from glib git master --- gir/gio-2.0.c | 57 ++++++++++++++++++++++++++++++------------------------ gir/glib-2.0.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++--------- gir/gobject-2.0.c | 36 ++++++++++++++++++++++++++++++++-- 3 files changed, 115 insertions(+), 36 deletions(-) diff --git a/gir/gio-2.0.c b/gir/gio-2.0.c index 2d4e7bac..64812d38 100644 --- a/gir/gio-2.0.c +++ b/gir/gio-2.0.c @@ -1649,7 +1649,7 @@ /** - * GDtlsConnection:advertised-protocols: + * GDtlsConnection:advertised-protocols: (nullable) * * The list of application-layer protocols that the connection * advertises that it is willing to speak. See @@ -1680,7 +1680,7 @@ /** - * GDtlsConnection:database: + * GDtlsConnection:database: (nullable) * * The certificate database to use when verifying this TLS connection. * If no certificate database is set, then the default database will be @@ -1691,7 +1691,7 @@ /** - * GDtlsConnection:interaction: + * GDtlsConnection:interaction: (nullable) * * A #GTlsInteraction object to be used when the connection or certificate * database need to interact with the user. This will be used to prompt the @@ -1712,7 +1712,7 @@ /** - * GDtlsConnection:peer-certificate: + * GDtlsConnection:peer-certificate: (nullable) * * The connection's peer's certificate, after the TLS handshake has * completed and the certificate has been accepted. Note in @@ -3791,7 +3791,7 @@ /** - * GTlsConnection:advertised-protocols: + * GTlsConnection:advertised-protocols: (nullable) * * The list of application-layer protocols that the connection * advertises that it is willing to speak. See @@ -3825,7 +3825,7 @@ /** - * GTlsConnection:database: + * GTlsConnection:database: (nullable) * * The certificate database to use when verifying this TLS connection. * If no certificate database is set, then the default database will be @@ -3836,7 +3836,7 @@ /** - * GTlsConnection:interaction: + * GTlsConnection:interaction: (nullable) * * A #GTlsInteraction object to be used when the connection or certificate * database need to interact with the user. This will be used to prompt the @@ -3857,7 +3857,7 @@ /** - * GTlsConnection:peer-certificate: + * GTlsConnection:peer-certificate: (nullable) * * The connection's peer's certificate, after the TLS handshake has * completed and the certificate has been accepted. Note in @@ -4736,7 +4736,7 @@ * arguments are passed through platform communication to the already * running program. The already running instance of the program is * called the "primary instance"; for non-unique applications this is - * the always the current instance. On Linux, the D-Bus session bus + * always the current instance. On Linux, the D-Bus session bus * is used for communication. * * The use of #GApplication differs from some other commonly-used @@ -6919,6 +6919,13 @@ * - Run a garbage collection cycle * - Try and compress fragmented allocations * - Exit on idle if the process has no reason to stay around + * - Call [`malloc_trim(3)`](man:malloc_trim) to return cached heap pages to + * the kernel (if supported by your libc) + * + * Note that some actions may not always improve system performance, and so + * should be profiled for your application. `malloc_trim()`, for example, may + * make future heap allocations slower (due to releasing cached heap pages back + * to the kernel). * * See #GMemoryMonitorWarningLevel for details on the various warning levels. * @@ -20396,7 +20403,7 @@ * Gets @conn's certificate, as set by * g_dtls_connection_set_certificate(). * - * Returns: (transfer none): @conn's certificate, or %NULL + * Returns: (transfer none) (nullable): @conn's certificate, or %NULL * Since: 2.48 */ @@ -20408,7 +20415,7 @@ * Gets the certificate database that @conn uses to verify * peer certificates. See g_dtls_connection_set_database(). * - * Returns: (transfer none): the certificate database that @conn uses or %NULL + * Returns: (transfer none) (nullable): the certificate database that @conn uses or %NULL * Since: 2.48 */ @@ -20421,7 +20428,7 @@ * for things like prompting the user for passwords. If %NULL is returned, then * no user interaction will occur for this connection. * - * Returns: (transfer none): The interaction object. + * Returns: (transfer none) (nullable): The interaction object. * Since: 2.48 */ @@ -20451,7 +20458,7 @@ * (It is not set during the emission of * #GDtlsConnection::accept-certificate.) * - * Returns: (transfer none): @conn's peer's certificate, or %NULL + * Returns: (transfer none) (nullable): @conn's peer's certificate, or %NULL * Since: 2.48 */ @@ -20617,7 +20624,7 @@ /** * g_dtls_connection_set_database: * @conn: a #GDtlsConnection - * @database: a #GTlsDatabase + * @database: (nullable): a #GTlsDatabase * * Sets the certificate database that is used to verify peer certificates. * This is set to the default database by default. See @@ -25372,7 +25379,7 @@ /** * g_icon_deserialize: - * @value: a #GVariant created with g_icon_serialize() + * @value: (transfer none): a #GVariant created with g_icon_serialize() * * Deserializes a #GIcon previously serialized using g_icon_serialize(). * @@ -25431,7 +25438,7 @@ * makes sense to transfer the #GVariant between processes on the same machine, * (as opposed to over the network), and within the same file system namespace. * - * Returns: (transfer full): a #GVariant, or %NULL when serialization fails. + * Returns: (transfer full): a #GVariant, or %NULL when serialization fails. The #GVariant will not be floating. * Since: 2.38 */ @@ -25747,8 +25754,8 @@ * * Parses @string as an IP address and creates a new #GInetAddress. * - * Returns: a new #GInetAddress corresponding to @string, or %NULL if - * @string could not be parsed. + * Returns: (nullable) (transfer full): a new #GInetAddress corresponding + * to @string, or %NULL if @string could not be parsed. * Free the returned object with g_object_unref(). * Since: 2.22 */ @@ -25861,8 +25868,8 @@ * If @address is an IPv6 address, it can also contain a scope ID * (separated from the address by a `%`). * - * Returns: a new #GInetSocketAddress, or %NULL if @address cannot be - * parsed. + * Returns: (nullable) (transfer full): a new #GInetSocketAddress, + * or %NULL if @address cannot be parsed. * Since: 2.40 */ @@ -39321,7 +39328,7 @@ * Gets @conn's certificate, as set by * g_tls_connection_set_certificate(). * - * Returns: (transfer none): @conn's certificate, or %NULL + * Returns: (transfer none) (nullable): @conn's certificate, or %NULL * Since: 2.28 */ @@ -39333,7 +39340,7 @@ * Gets the certificate database that @conn uses to verify * peer certificates. See g_tls_connection_set_database(). * - * Returns: (transfer none): the certificate database that @conn uses or %NULL + * Returns: (transfer none) (nullable): the certificate database that @conn uses or %NULL * Since: 2.30 */ @@ -39346,7 +39353,7 @@ * for things like prompting the user for passwords. If %NULL is returned, then * no user interaction will occur for this connection. * - * Returns: (transfer none): The interaction object. + * Returns: (transfer none) (nullable): The interaction object. * Since: 2.30 */ @@ -39376,7 +39383,7 @@ * (It is not set during the emission of * #GTlsConnection::accept-certificate.) * - * Returns: (transfer none): @conn's peer's certificate, or %NULL + * Returns: (transfer none) (nullable): @conn's peer's certificate, or %NULL * Since: 2.28 */ @@ -39560,7 +39567,7 @@ /** * g_tls_connection_set_database: * @conn: a #GTlsConnection - * @database: a #GTlsDatabase + * @database: (nullable): a #GTlsDatabase * * Sets the certificate database that is used to verify peer certificates. * This is set to the default database by default. See diff --git a/gir/glib-2.0.c b/gir/glib-2.0.c index 76876983..931caca0 100644 --- a/gir/glib-2.0.c +++ b/gir/glib-2.0.c @@ -4889,14 +4889,15 @@ * To create a new array use g_array_new(). * * To add elements to an array, use g_array_append_val(), - * g_array_append_vals(), g_array_prepend_val(), and - * g_array_prepend_vals(). + * g_array_append_vals(), g_array_prepend_val(), g_array_prepend_vals(), + * g_array_insert_val() and g_array_insert_vals(). * - * To access an element of an array, use g_array_index(). + * To access an element of an array (to read it or write it), + * use g_array_index(). * * To set the size of an array, use g_array_set_size(). * - * To free an array, use g_array_free(). + * To free an array, use g_array_unref() or g_array_free(). * * Here is an example that stores integers in a #GArray: * |[ @@ -8633,9 +8634,23 @@ * The implementations of the Unicode functions in GLib are based * on the Unicode Character Data tables, which are available from * [www.unicode.org](http://www.unicode.org/). - * GLib 2.8 supports Unicode 4.0, GLib 2.10 supports Unicode 4.1, - * GLib 2.12 supports Unicode 5.0, GLib 2.16.3 supports Unicode 5.1, - * GLib 2.30 supports Unicode 6.0. + * + * * Unicode 4.0 was added in GLib 2.8 + * * Unicode 4.1 was added in GLib 2.10 + * * Unicode 5.0 was added in GLib 2.12 + * * Unicode 5.1 was added in GLib 2.16.3 + * * Unicode 6.0 was added in GLib 2.30 + * * Unicode 6.1 was added in GLib 2.32 + * * Unicode 6.2 was added in GLib 2.36 + * * Unicode 6.3 was added in GLib 2.40 + * * Unicode 7.0 was added in GLib 2.42 + * * Unicode 8.0 was added in GLib 2.48 + * * Unicode 9.0 was added in GLib 2.50.1 + * * Unicode 10.0 was added in GLib 2.54 + * * Unicode 11.10 was added in GLib 2.58 + * * Unicode 12.0 was added in GLib 2.62 + * * Unicode 12.1 was added in GLib 2.62 + * * Unicode 13.0 was added in GLib 2.66 */ @@ -8935,14 +8950,29 @@ * @i: the index of the element to return * * Returns the element of a #GArray at the given index. The return - * value is cast to the given type. + * value is cast to the given type. This is the main way to read or write an + * element in a #GArray. * - * This example gets a pointer to an element in a #GArray: + * Writing an element is typically done by reference, as in the following + * example. This example gets a pointer to an element in a #GArray, and then + * writes to a field in it: * |[ * EDayViewEvent *event; * // This gets a pointer to the 4th element in the array of * // EDayViewEvent structs. * event = &g_array_index (events, EDayViewEvent, 3); + * event->start_time = g_get_current_time (); + * ]| + * + * This example reads from and writes to an array of integers: + * |[ + * g_autoptr(GArray) int_array = g_array_new (FALSE, FALSE, sizeof (guint)); + * for (guint i = 0; i < 10; i++) + * g_array_append_val (int_array, i); + * + * guint *my_int = &g_array_index (int_array, guint, 1); + * g_print ("Int at index 1 is %u; decrementing it\n", *my_int); + * *my_int = *my_int - 1; * ]| * * Returns: the element of the #GArray at the index given by @i @@ -8979,6 +9009,10 @@ * will be initialised to zero if the array was configured to clear elements; * otherwise their values will be undefined. * + * If @index_ is less than the array’s current length, new entries will be + * inserted into the array, and the existing entries above @index_ will be moved + * upwards. + * * @data may be %NULL if (and only if) @len is zero. If @len is zero, this * function is a no-op. * @@ -36997,6 +37031,12 @@ * The returned value is never floating. You should free it with * g_variant_unref() when you're done with it. * + * Note that values borrowed from the returned child are not guaranteed to + * still be valid after the child is freed even if you still hold a reference + * to @value, if @value has not been serialised at the time this function is + * called. To avoid this, you can serialize @value by calling + * g_variant_get_data() and optionally ignoring the return value. + * * There may be implementation specific restrictions on deeply nested values, * which would result in the unit tuple being returned as the child value, * instead of further nested children. #GVariant is guaranteed to handle diff --git a/gir/gobject-2.0.c b/gir/gobject-2.0.c index 9ea50c91..f773584b 100644 --- a/gir/gobject-2.0.c +++ b/gir/gobject-2.0.c @@ -419,8 +419,8 @@ * * ## Parameter names # {#canonical-parameter-names} * - * A property name consists of segments consisting of ASCII letters and - * digits, separated by either the `-` or `_` character. The first + * A property name consists of one or more segments consisting of ASCII letters + * and digits, separated by either the `-` or `_` character. The first * character of a property name must be a letter. These are the same rules as * for signal naming (see g_signal_new()). * @@ -3795,6 +3795,22 @@ */ +/** + * g_param_spec_is_valid_name: + * @name: the canonical name of the property + * + * Validate a property name for a #GParamSpec. This can be useful for + * dynamically-generated properties which need to be validated at run-time + * before actually trying to create them. + * + * See [canonical parameter names][canonical-parameter-names] for details of + * the rules for valid names. + * + * Returns: %TRUE if @name is a valid property name, %FALSE otherwise. + * Since: 2.66 + */ + + /** * g_param_spec_long: * @name: canonical name of the property specified @@ -4718,6 +4734,22 @@ */ +/** + * g_signal_is_valid_name: + * @name: the canonical name of the signal + * + * Validate a signal name. This can be useful for dynamically-generated signals + * which need to be validated at run-time before actually trying to create them. + * + * See [canonical parameter names][canonical-parameter-names] for details of + * the rules for valid names. The rules for signal names are the same as those + * for property names. + * + * Returns: %TRUE if @name is a valid signal name, %FALSE otherwise. + * Since: 2.66 + */ + + /** * g_signal_list_ids: * @itype: Instance or interface type. -- cgit v1.2.1 From 769f886bfa3c7b21815def592eec7279bb123f23 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sun, 3 May 2020 20:50:08 +0200 Subject: CI: switch to new win32 runners powershell instead of cmd, win2016 instead of 2012r2 --- .gitlab-ci.yml | 8 ++++---- .gitlab-ci/test-msvc.bat | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16a8f3bb..0cb71530 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -79,7 +79,7 @@ fedora-x86_64-python3.5: msys2-mingw32-meson: stage: build tags: - - win32 + - win32-ps variables: MSYSTEM: "MINGW32" CHERE_INVOKING: "yes" @@ -88,19 +88,19 @@ msys2-mingw32-meson: - C:\msys64\usr\bin\bash -lc "bash -x ./.gitlab-ci/test-msys2-meson.sh" artifacts: when: on_failure - name: "gi-_%CI_COMMIT_REF_NAME%" + name: "gi-_${env:CI_COMMIT_REF_NAME}" paths: - _build/meson-logs vs2017-x64-meson: stage: build tags: - - win32 + - win32-ps script: - .gitlab-ci/test-msvc.bat artifacts: when: on_failure - name: "gi-_%CI_COMMIT_REF_NAME%" + name: "gi-_${env:CI_COMMIT_REF_NAME}" paths: - _build/meson-logs diff --git a/.gitlab-ci/test-msvc.bat b/.gitlab-ci/test-msvc.bat index a2ee44b2..549d4fd1 100644 --- a/.gitlab-ci/test-msvc.bat +++ b/.gitlab-ci/test-msvc.bat @@ -1,5 +1,5 @@ @echo on -call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 +call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 @echo on py -3 -c "import urllib.request, sys; urllib.request.urlretrieve(*sys.argv[1:])" "https://github.com/lexxmark/winflexbison/releases/download/v2.5.14/win_flex_bison-2.5.14.zip" win_flex_bison.zip -- cgit v1.2.1 From f8e080d03bb490e3539a2a7e0c4a5e7a20fcd863 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 6 May 2020 14:24:34 -0400 Subject: Meson: Fix build as subproject meson.build_root() is the root of the main project, better use meson.current_build_dir() instead. --- meson.build | 2 ++ tests/meson.build | 10 +++++----- tests/repository/meson.build | 10 +++++----- tests/scanner/meson.build | 40 ++++++++++++++++++++-------------------- tests/warn/meson.build | 8 ++++---- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/meson.build b/meson.build index c730b2c6..6f3ba8c8 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,8 @@ project('gobject-introspection', 'c', host_system = host_machine.system() gi_versions = meson.project_version().split('.') +build_root = meson.current_build_dir() +source_root = meson.current_source_dir() configinc = include_directories('.') diff --git a/tests/meson.build b/tests/meson.build index f4c57ed7..b240749e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -115,8 +115,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--warn-all', '--warn-error', '--namespace=Everything', @@ -141,8 +141,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--warn-all', '--warn-error', '--namespace=GIMarshallingTests', @@ -163,7 +163,7 @@ if glib_dep.type_name() == 'pkgconfig' output: '@BASENAME@.typelib', depends: [gobject_gir, ], command: [gircompiler, '-o', '@OUTPUT@', '@INPUT@', - '--includedir', join_paths(meson.build_root(), 'gir'), + '--includedir', join_paths(build_root, 'gir'), '--includedir', meson.current_build_dir() ], ) diff --git a/tests/repository/meson.build b/tests/repository/meson.build index 497ab106..17445381 100644 --- a/tests/repository/meson.build +++ b/tests/repository/meson.build @@ -10,17 +10,17 @@ if glib_dep.type_name() == 'pkgconfig' repository_test_env = environment() repository_test_env.prepend( 'GI_TYPELIB_PATH', - join_paths(meson.build_root(), 'gir'), - join_paths(meson.build_root(), 'tests'), - join_paths(meson.build_root(), 'tests', 'scanner'), + join_paths(build_root, 'gir'), + join_paths(build_root, 'tests'), + join_paths(build_root, 'tests', 'scanner'), ) repository_test_env.prepend( 'LD_LIBRARY_PATH', - join_paths(meson.build_root(), 'tests', 'scanner'), + join_paths(build_root, 'tests', 'scanner'), ) if host_system == 'windows' repository_test_env.prepend( - 'PATH', join_paths(meson.build_root(), 'tests', 'scanner')) + 'PATH', join_paths(build_root, 'tests', 'scanner')) endif custom_c_args = cc.get_supported_arguments([ diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build index 50ca5a2b..fa7f7eca 100644 --- a/tests/scanner/meson.build +++ b/tests/scanner/meson.build @@ -106,7 +106,7 @@ python_path = run_command(python, ['-c', 'import sys; sys.stdout.write(sys.execu gircompiler_command = [ gircompiler, '-o', '@OUTPUT@', '@INPUT@', - '--includedir', join_paths(meson.build_root(), 'gir'), + '--includedir', join_paths(build_root, 'gir'), '--includedir', meson.current_build_dir(), ] @@ -122,8 +122,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--warn-all', '--warn-error', '--namespace=Typedefs', @@ -162,8 +162,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--warn-all', '--warn-error', '--namespace=Bar', @@ -173,7 +173,7 @@ if glib_dep.type_name() == 'pkgconfig' '--library=barapp-1.0', '--accept-unprefixed', '-L', meson.current_build_dir(), - '-L', join_paths(meson.build_root(), 'girepository'), + '-L', join_paths(build_root, 'girepository'), '-I', meson.current_source_dir(), '-I', join_paths(meson.current_source_dir(), '..'), extra_giscanner_args, @@ -201,8 +201,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--warn-all', '--warn-error', '--namespace=SLetter', @@ -239,8 +239,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--namespace=WarnLib', '--nsversion=1.0', '--include=Gio-2.0', @@ -275,8 +275,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--warn-all', '--warn-error', '--namespace=Utility', @@ -313,8 +313,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--warn-all', '--warn-error', '--namespace=GtkFrob', @@ -352,8 +352,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--namespace=GetType', '--nsversion=1.0', '--identifier-prefix=GetType', @@ -483,8 +483,8 @@ if glib_dep.type_name() == 'pkgconfig' '--output=@OUTPUT@', '--no-libtool', '--reparse-validate', - '--add-include-path', join_paths(meson.source_root(), 'gir'), - '--add-include-path', join_paths(meson.build_root(), 'gir'), + '--add-include-path', join_paths(source_root, 'gir'), + '--add-include-path', join_paths(build_root, 'gir'), '--add-include-path', meson.current_build_dir(), '--namespace=Regress', '--nsversion=1.0', @@ -542,7 +542,7 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig' output: 'Regress-1.0-' + language, command: [ python, girdoctool, - '--add-include-path=' + join_paths(meson.build_root(), 'gir'), + '--add-include-path=' + join_paths(build_root, 'gir'), '--add-include-path=' + meson.current_build_dir(), '--language', language, '@INPUT@', '-o', '@OUTPUT@'], @@ -570,7 +570,7 @@ if has_girdoctool and glib_dep.type_name() == 'pkgconfig' output: 'Regress-1.0-sections.txt', command: [ python, girdoctool, - '--add-include-path=' + join_paths(meson.build_root(), 'gir'), + '--add-include-path=' + join_paths(build_root, 'gir'), '--add-include-path=' + meson.current_build_dir(), '--write-sections-file', '@INPUT@', '-o', '@OUTPUT@'], diff --git a/tests/warn/meson.build b/tests/warn/meson.build index 1f144e70..9641787f 100644 --- a/tests/warn/meson.build +++ b/tests/warn/meson.build @@ -21,12 +21,12 @@ warn_tests = [ ] warn_test_env = environment() -warn_test_env.set('UNINSTALLED_INTROSPECTION_SRCDIR', meson.source_root()) -warn_test_env.set('TOP_BUILDDIR', meson.build_root()) +warn_test_env.set('UNINSTALLED_INTROSPECTION_SRCDIR', source_root) +warn_test_env.set('TOP_BUILDDIR', build_root) warn_test_env.set( 'PYTHONPATH', - meson.build_root(), - join_paths(meson.build_root(), 'giscanner')) + build_root, + join_paths(build_root, 'giscanner')) # FIXME: Glib as a subproject (used on Windows mostly). if glib_dep.type_name() == 'pkgconfig' -- cgit v1.2.1 From 2ae776ad2ea1951d03ac661c13efa9518f73056a Mon Sep 17 00:00:00 2001 From: neok Date: Sun, 10 May 2020 22:06:29 +0000 Subject: Update utils.py --- giscanner/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/giscanner/utils.py b/giscanner/utils.py index e8c246dd..e3396c6e 100644 --- a/giscanner/utils.py +++ b/giscanner/utils.py @@ -255,7 +255,7 @@ def get_system_data_dirs(): If any changes are made to that function they'll need to be copied here. ''' xdg_data_dirs = [x for x in os.environ.get('XDG_DATA_DIRS', '').split(os.pathsep)] - if not xdg_data_dirs and os.name != 'nt': + if not any(xdg_data_dirs) and os.name != 'nt': xdg_data_dirs.append('/usr/local/share') xdg_data_dirs.append('/usr/share') -- cgit v1.2.1 From aaeb15ec1a841b7581d10db4f403a571d5d58e19 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Thu, 14 May 2020 09:48:55 +0200 Subject: flake8: fix invalid placeholder in GtkDocAnnotatable repr format string The newest flake8 has started to detect this. --- giscanner/annotationparser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 16a66f33..63212963 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -566,7 +566,7 @@ class GtkDocAnnotatable(object): self.annotations = GtkDocAnnotations() def __repr__(self): - return "" % (self.annotations, ) + return "" % (self.annotations, ) def validate(self): ''' -- cgit v1.2.1 From 487d3f01bcd4c2bc9adbe2d4aaa77b2c37c44795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Thu, 14 May 2020 15:20:25 +0000 Subject: Add missing nullable annotation to g_irepository_get_shared_library --- girepository/girepository.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/girepository/girepository.c b/girepository/girepository.c index b7948d61..7d034859 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -1144,7 +1144,7 @@ g_irepository_get_version (GIRepository *repository, * Note: The namespace must have already been loaded using a function * such as g_irepository_require() before calling this function. * - * Returns: Comma-separated list of paths to shared libraries, + * Returns: (nullable): Comma-separated list of paths to shared libraries, * or %NULL if none are associated */ const gchar * -- cgit v1.2.1 From f9a92fc3a4d380b4795eefda593082779763d792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Thu, 14 May 2020 17:26:21 +0200 Subject: Add missing nullable annotation to g_object_info_get_parent --- girepository/giobjectinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index efb9ad76..3f3423cc 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -89,7 +89,7 @@ g_object_info_get_field_offset (GIObjectInfo *info, * * Obtain the parent of the object type. * - * Returns: (transfer full): the #GIObjectInfo. Free the struct by calling + * Returns: (transfer full) (nullable): the #GIObjectInfo. Free the struct by calling * g_base_info_unref() when done. */ GIObjectInfo * -- cgit v1.2.1 From cea7ef1e4a5626de1332bc34e1962befb75c2976 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Thu, 14 May 2020 09:41:43 +0200 Subject: dumper: Fix missing symbols in LTO case or with overridden symbol visibility settings In case a user had a combination of -fvisibility=hidden, -Wl,--as-needed, -flto, -O2 in the CFLAGS the linker would sometimes detect that all the referenced gtype functions weren't actually used and throw them out with their providing libraries. Instead of hoping that the user's CFLAGS don't mess without our symbol visibility just use G_MODULE_EXPORT on the two symbols which reference all other gtype and gquark symbols. This fixes errors such as: Invalid GType function: 'gtk_accel_group_get_type' Failed to find symbol 'gtk_accel_group_get_type' during the g-ir-scanner execution. Fixes #280 --- giscanner/dumper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/giscanner/dumper.py b/giscanner/dumper.py index 0c10a780..e4b6ea03 100644 --- a/giscanner/dumper.py +++ b/giscanner/dumper.py @@ -126,7 +126,7 @@ class DumpCompiler(object): if len(self._get_type_functions) > 0: for func in self._get_type_functions: f.write("extern GType " + func + "(void);\n") - f.write("GType (*GI_GET_TYPE_FUNCS_[])(void) = {\n") + f.write("G_MODULE_EXPORT GType (*GI_GET_TYPE_FUNCS_[])(void) = {\n") first = True for func in self._get_type_functions: if first: @@ -138,7 +138,7 @@ class DumpCompiler(object): if len(self._error_quark_functions) > 0: for func in self._error_quark_functions: f.write("extern GQuark " + func + "(void);\n") - f.write("GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = {\n") + f.write("G_MODULE_EXPORT GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = {\n") first = True for func in self._error_quark_functions: if first: -- cgit v1.2.1 From 67a598010ee0431aa8ad0540cd5cf62aedb7773b Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 15 May 2020 21:19:54 +0200 Subject: docs: Update website link --- docs/g-ir-compiler.1 | 2 +- docs/g-ir-generate.1 | 2 +- docs/g-ir-scanner.1 | 2 +- docs/website/tools/g-ir-compiler.rst | 2 +- docs/website/tools/g-ir-generate.rst | 2 +- docs/website/tools/g-ir-scanner.rst | 2 +- docs/website/users.rst | 2 +- gobject-introspection.doap | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/g-ir-compiler.1 b/docs/g-ir-compiler.1 index 48dc5ceb..f3eda03c 100644 --- a/docs/g-ir-compiler.1 +++ b/docs/g-ir-compiler.1 @@ -72,7 +72,7 @@ Show program\(aqs version number and exit Report bugs at \fI\%https://gitlab.gnome.org/GNOME/gobject\-introspection/issues\fP .SH HOMEPAGE AND CONTACT .sp -\fI\%http://live.gnome.org/GObjectIntrospection\fP +\fI\%https://gi.readthedocs.io/\fP .SH AUTHORS .sp Mattias Clasen diff --git a/docs/g-ir-generate.1 b/docs/g-ir-generate.1 index 038d171f..f05a295a 100644 --- a/docs/g-ir-generate.1 +++ b/docs/g-ir-generate.1 @@ -58,7 +58,7 @@ Show program\(aqs version number and exit Report bugs at \fI\%https://gitlab.gnome.org/GNOME/gobject\-introspection/issues\fP .SH HOMEPAGE AND CONTACT .sp -\fI\%http://live.gnome.org/GObjectIntrospection\fP +\fI\%https://gi.readthedocs.io/\fP .SH AUTHORS .sp Mattias Clasen diff --git a/docs/g-ir-scanner.1 b/docs/g-ir-scanner.1 index 528bed5c..d25f321b 100644 --- a/docs/g-ir-scanner.1 +++ b/docs/g-ir-scanner.1 @@ -177,7 +177,7 @@ generating introspection data in a cross-compilation environment. Report bugs at \fI\%https://gitlab.gnome.org/GNOME/gobject\-introspection/issues\fP .SH HOMEPAGE AND CONTACT .sp -\fI\%http://live.gnome.org/GObjectIntrospection\fP +\fI\%https://gi.readthedocs.io/\fP .SH AUTHORS .sp Johan Dahlin diff --git a/docs/website/tools/g-ir-compiler.rst b/docs/website/tools/g-ir-compiler.rst index 5c17a7ce..28ca44aa 100644 --- a/docs/website/tools/g-ir-compiler.rst +++ b/docs/website/tools/g-ir-compiler.rst @@ -62,7 +62,7 @@ Report bugs at https://gitlab.gnome.org/GNOME/gobject-introspection/issues HOMEPAGE and CONTACT ==================== -http://live.gnome.org/GObjectIntrospection +https://gi.readthedocs.io/ AUTHORS diff --git a/docs/website/tools/g-ir-generate.rst b/docs/website/tools/g-ir-generate.rst index 931ee449..0b0c8fe0 100644 --- a/docs/website/tools/g-ir-generate.rst +++ b/docs/website/tools/g-ir-generate.rst @@ -48,7 +48,7 @@ Report bugs at https://gitlab.gnome.org/GNOME/gobject-introspection/issues HOMEPAGE and CONTACT ==================== -http://live.gnome.org/GObjectIntrospection +https://gi.readthedocs.io/ AUTHORS diff --git a/docs/website/tools/g-ir-scanner.rst b/docs/website/tools/g-ir-scanner.rst index fc6abe3e..e8df7457 100644 --- a/docs/website/tools/g-ir-scanner.rst +++ b/docs/website/tools/g-ir-scanner.rst @@ -166,7 +166,7 @@ Report bugs at https://gitlab.gnome.org/GNOME/gobject-introspection/issues HOMEPAGE and CONTACT ==================== -http://live.gnome.org/GObjectIntrospection +https://gi.readthedocs.io/ AUTHORS diff --git a/docs/website/users.rst b/docs/website/users.rst index 6d651092..c2faf51b 100644 --- a/docs/website/users.rst +++ b/docs/website/users.rst @@ -14,7 +14,7 @@ Bindings based on GObject-Introspection * `JGIR `__ - Java/JVM bindings (compile time, using typelib) * `GJS `__ - Javascript (spidermonkey) bindings (runtime) * `Seed `__ - Javascript (JSCore, WebKit JS engine) bindings (runtime) -* `sbank `__ - Scheme binding for gobject-introspection (runtime) +* `sbank `__ - Scheme binding for gobject-introspection (runtime) * `GObjectIntrospection/GObjectConsume `__ - Qt bindings (compile time) * `GirFFI `__ - Ruby bindings (runtime) * `Ruby-GNOME `__ - Ruby bindings (runtime) diff --git a/gobject-introspection.doap b/gobject-introspection.doap index 0da06245..6e59acc5 100644 --- a/gobject-introspection.doap +++ b/gobject-introspection.doap @@ -13,7 +13,7 @@ GObject introspection provides tools and libraries to help manage its common metadata format for representing GObject-based C APIs, designed for bindings, documentation tools and API verification. - + -- cgit v1.2.1 From c193a227ffbe3e14b2c6bda74889fcac004db9f0 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 15 May 2020 21:20:43 +0200 Subject: docs: Unify DocBook doctype There has been no backwards incompatible changes between DockBook 4.3 and 4.5 so there is no need to use both. Ideally, we would switch to DocBook 5 but that will require more changes. --- docs/reference/gi-struct-hierarchy.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/gi-struct-hierarchy.xml b/docs/reference/gi-struct-hierarchy.xml index 685f85aa..7d40e053 100644 --- a/docs/reference/gi-struct-hierarchy.xml +++ b/docs/reference/gi-struct-hierarchy.xml @@ -1,6 +1,6 @@ - ]> -- cgit v1.2.1 From 1c53902e2712633e042fb5601dc1f3eb396c709c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 17 May 2020 09:32:26 -0400 Subject: Remove old autoconf fallback code for the python tools. --- tools/g-ir-tool-template.in | 9 ++------- tools/meson.build | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/tools/g-ir-tool-template.in b/tools/g-ir-tool-template.in index c4a10a28..75bf759c 100755 --- a/tools/g-ir-tool-template.in +++ b/tools/g-ir-tool-template.in @@ -53,14 +53,9 @@ if not os.path.isdir(os.path.join(datadir, 'gir-1.0')): builtins.__dict__['DATADIR'] = datadir -# Respect gir_dir_prefix for meson and autotools +# Respect gir_dir_prefix girdir = '' -# for meson -if '@gir_dir_prefix@' and not '@gir_dir_prefix@'.startswith('@'): - girdir = os.path.abspath(os.path.join(filedir, '..', '@gir_dir_prefix@')) -# for autotools -elif '@GIR_DIR@' and not '@GIR_DIR@'.startswith('@'): - girdir = os.path.dirname(os.path.abspath('@GIR_DIR@')) +girdir = os.path.abspath(os.path.join(filedir, '..', '@gir_dir_prefix@')) builtins.__dict__['GIRDIR'] = [girdir] # Again, relative paths first so that the installation prefix is relocatable diff --git a/tools/meson.build b/tools/meson.build index 103480c4..2d67d6ef 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -22,7 +22,6 @@ foreach tool : tools tools_conf.set('datarootdir', datadir_abs) tools_conf.set('gir_dir_prefix', gir_dir_prefix) tools_conf.set('PYTHON_CMD', python_cmd) - tools_conf.set('GIR_DIR', girdir) tools_conf.set('TOOL_MODULE', tool[1]) tools_conf.set('TOOL_FUNCTION', tool[2]) @@ -75,4 +74,4 @@ girinspect = executable('g-ir-inspect', 'g-ir-inspect.c', install: true, c_args: custom_c_args, ) -meson.override_find_program('g-ir-inspect', girinspect) \ No newline at end of file +meson.override_find_program('g-ir-inspect', girinspect) -- cgit v1.2.1 From db136cbaf88a86081f29afbba3c98eaf006842ac Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 27 Apr 2020 00:27:52 -0400 Subject: Rename option `gi_cross_use_{host -> prebuilt}_gi` The old name used "host" according to Yocto's definition, but not Meson's. The new name works for everyone. --- gir/meson.build | 2 +- meson_options.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gir/meson.build b/gir/meson.build index 04f9371a..c4270f1e 100644 --- a/gir/meson.build +++ b/gir/meson.build @@ -41,7 +41,7 @@ gir_files = [ typelibdir = join_paths(get_option('libdir'), 'girepository-1.0') install_data(gir_files, install_dir: girdir) -if get_option('gi_cross_use_host_gi') +if get_option('gi_cross_use_prebuilt_gi') scanner_command = [ 'g-ir-scanner', ] diff --git a/meson_options.txt b/meson_options.txt index 20ccc3b9..dff9be8e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -26,8 +26,8 @@ option('gir_dir_prefix', type: 'string', description: 'Intermediate prefix for gir installation under ${prefix}' ) -option('gi_cross_use_host_gi', type: 'boolean', value : false, - description: 'Use gobject introspection tools installed in the host system (useful when cross-compiling)' +option('gi_cross_use_prebuilt_gi', type: 'boolean', value : false, + description: 'Use gobject introspection tools installed in the build system (useful when cross-compiling)' ) option('gi_cross_binary_wrapper', type: 'string', -- cgit v1.2.1