Accepting request 952635 from GNOME:Next

- Update to version 1.70.1:
  + Build and crash fixes backported from the development branch.
  + Closed bugs and merge requests:
    - Handle optional out parameters in callbacks
    - Link fails on Debian armel|mipsel|powerpc: needs more
      -latomic
    - gjs/jsapi-util.cpp: fix build on gcc-12
- Drop patches fixed upstream:
  + b9e122044a7ccc1e2a3374c680b6ea82066bfa59.patch
  + 62025d4a2738a36ea5f1a7cebef08b22b5eef613.patch

OBS-URL: https://build.opensuse.org/request/show/952635
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/gjs?expand=0&rev=204
This commit is contained in:
Bjørn Lie 2022-02-08 11:07:05 +00:00 committed by Git OBS Bridge
parent 6da4f8b49b
commit acd46e2002
6 changed files with 19 additions and 142 deletions

View File

@ -1,106 +0,0 @@
From 62025d4a2738a36ea5f1a7cebef08b22b5eef613 Mon Sep 17 00:00:00 2001
From: Evan Welsh <contact@evanwelsh.com>
Date: Fri, 24 Sep 2021 22:17:04 +0000
Subject: [PATCH] Handle optional out parameters in callbacks
Fixes #439
---
gi/arg.cpp | 26 ++++++++++++++++++++------
gi/arg.h | 6 ++----
gi/function.cpp | 14 ++++++++------
3 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 0b8af141..49f36d76 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -1861,17 +1861,31 @@ void gjs_gi_argument_init_default(GITypeInfo* type_info, GIArgument* arg) {
}
}
-bool
-gjs_value_to_arg(JSContext *context,
- JS::HandleValue value,
- GIArgInfo *arg_info,
- GIArgument *arg)
-{
+bool gjs_value_to_callback_out_arg(JSContext* context, JS::HandleValue value,
+ GIArgInfo* arg_info, GIArgument* arg) {
+ GIDirection direction [[maybe_unused]] = g_arg_info_get_direction(arg_info);
+ g_assert(
+ (direction == GI_DIRECTION_OUT || direction == GI_DIRECTION_INOUT) &&
+ "gjs_value_to_callback_out_arg does not handle in arguments.");
+
GjsArgumentFlags flags = GjsArgumentFlags::NONE;
GITypeInfo type_info;
g_arg_info_load_type(arg_info, &type_info);
+ // If the argument is optional and we're passed nullptr,
+ // ignore the GJS value.
+ if (g_arg_info_is_optional(arg_info) && !arg)
+ return true;
+
+ // Otherwise, throw an error to prevent a segfault.
+ if (!arg) {
+ gjs_throw(context,
+ "Return value %s is not optional but was passed NULL",
+ g_base_info_get_name(arg_info));
+ return false;
+ }
+
if (g_arg_info_may_be_null(arg_info))
flags |= GjsArgumentFlags::MAY_BE_NULL;
if (g_arg_info_is_caller_allocates(arg_info))
diff --git a/gi/arg.h b/gi/arg.h
index c81c2979..c5c81760 100644
--- a/gi/arg.h
+++ b/gi/arg.h
@@ -44,10 +44,8 @@ enum class GjsArgumentFlags : uint8_t {
GjsArgumentType arg_type);
GJS_JSAPI_RETURN_CONVENTION
-bool gjs_value_to_arg(JSContext *context,
- JS::HandleValue value,
- GIArgInfo *arg_info,
- GIArgument *arg);
+bool gjs_value_to_callback_out_arg(JSContext* context, JS::HandleValue value,
+ GIArgInfo* arg_info, GIArgument* arg);
GJS_JSAPI_RETURN_CONVENTION
bool gjs_array_to_explicit_array(JSContext* cx, JS::HandleValue value,
diff --git a/gi/function.cpp b/gi/function.cpp
index 25fea26f..da060607 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -532,9 +532,10 @@ bool GjsCallbackTrampoline::callback_closure_inner(
if (g_arg_info_get_direction(&arg_info) == GI_DIRECTION_IN)
continue;
- if (!gjs_value_to_arg(context, rval, &arg_info,
- get_argument_for_arg_info(&arg_info, args,
- i + c_args_offset)))
+ if (!gjs_value_to_callback_out_arg(
+ context, rval, &arg_info,
+ get_argument_for_arg_info(&arg_info, args,
+ i + c_args_offset)))
return false;
break;
@@ -587,9 +588,10 @@ bool GjsCallbackTrampoline::callback_closure_inner(
if (!JS_GetElement(context, out_array, elem_idx, &elem))
return false;
- if (!gjs_value_to_arg(context, elem, &arg_info,
- get_argument_for_arg_info(&arg_info, args,
- i + c_args_offset)))
+ if (!gjs_value_to_callback_out_arg(
+ context, elem, &arg_info,
+ get_argument_for_arg_info(&arg_info, args,
+ i + c_args_offset)))
return false;
elem_idx++;
--
GitLab

View File

@ -1,27 +0,0 @@
From b9e122044a7ccc1e2a3374c680b6ea82066bfa59 Mon Sep 17 00:00:00 2001
From: Evan Miller <emmiller@gmail.com>
Date: Sun, 12 Sep 2021 15:22:22 -0400
Subject: [PATCH] arg: Replace gsize with size_t
This is causing problems on 32-bit ppc architecture; see
https://gitlab.gnome.org/GNOME/glib/-/issues/2493
---
gi/arg.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gi/arg.cpp b/gi/arg.cpp
index cff40e10..0b8af141 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -1706,7 +1706,7 @@ bool gjs_value_to_g_argument(JSContext* context, JS::HandleValue value,
case GI_TYPE_TAG_ARRAY: {
GjsAutoPointer<void> data;
- gsize length;
+ size_t length;
GIArrayType array_type = g_type_info_get_array_type(type_info);
/* First, let's handle the case where we're passed an instance
--
GitLab

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4b0629341a318a02374e113ab97f9a9f3325423269fc1e0b043a5ffb01861c5f
size 595292

3
gjs-1.70.1.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bbdc0eec7cf25fbc534769f6a1fb2c7a18e17b871efdb0ca58e9abf08b28003f
size 598444

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Tue Feb 8 09:07:55 UTC 2022 - Bjørn Lie <bjorn.lie@gmail.com>
- Update to version 1.70.1:
+ Build and crash fixes backported from the development branch.
+ Closed bugs and merge requests:
- Handle optional out parameters in callbacks
- Link fails on Debian armel|mipsel|powerpc: needs more
-latomic
- gjs/jsapi-util.cpp: fix build on gcc-12
- Drop patches fixed upstream:
+ b9e122044a7ccc1e2a3374c680b6ea82066bfa59.patch
+ 62025d4a2738a36ea5f1a7cebef08b22b5eef613.patch
-------------------------------------------------------------------
Mon Oct 4 17:12:28 UTC 2021 - Bjørn Lie <bjorn.lie@gmail.com>

View File

@ -1,7 +1,7 @@
#
# spec file for package gjs
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -17,17 +17,13 @@
Name: gjs
Version: 1.70.0
Version: 1.70.1
Release: 0
Summary: JavaScript bindings based on gobject-introspection and Mozilla
License: LGPL-2.0-or-later AND MIT
Group: Development/Libraries/GNOME
URL: https://wiki.gnome.org/Projects/Gjs
Source0: https://download.gnome.org/sources/gjs/1.70/%{name}-%{version}.tar.xz
# PATCH-FIX-UPSTREAM b9e122044a7ccc1e2a3374c680b6ea82066bfa59.patch -- arg: Replace gsize with size_t
Patch0: b9e122044a7ccc1e2a3374c680b6ea82066bfa59.patch
# PATCH-FIX-UPSTREAM 62025d4a2738a36ea5f1a7cebef08b22b5eef613.patch -- Handle optional out parameters in callbacks
Patch1: 62025d4a2738a36ea5f1a7cebef08b22b5eef613.patch
BuildRequires: c++_compiler
BuildRequires: git