Skip to content

Commit 1bea366

Browse files
committed
Update from 1.87.1
1 parent 3bf31d4 commit 1bea366

245 files changed

Lines changed: 10884 additions & 10223 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ IndentPPDirectives: AfterHash
1818
IndentWidth: 4
1919
MacroBlockBegin: "^JSNATIVE_TEST_FUNC_BEGIN$"
2020
MacroBlockEnd: "^JSNATIVE_TEST_FUNC_END$"
21+
Macros:
22+
- GJS_ALWAYS_INLINE=[[always_inline]] # COMPAT: switch in C++20
23+
- GJS_JSAPI_RETURN_CONVENTION=[[nodiscard]]
24+
- GJS_USE=[[nodiscard]]
2125
PointerAlignment: Left # Google style allows both, but clang-format doesn't
2226
SpacesBeforeTrailingComments: 2
2327
---

.clangd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
Diagnostics:
55
ClangTidy:
6-
Remove: bugprone-sizeof-expression # Interferes with g_clear_pointer()
6+
Remove: none*

cjs/atoms.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ bool GjsSymbolAtom::init(JSContext* cx, const char* str) {
3939
* tracing has been set up. */
4040
bool GjsAtoms::init_atoms(JSContext* cx) {
4141
#define INITIALIZE_ATOM(identifier, str) \
42-
if (!identifier.init(cx, str)) \
42+
if (!(identifier).init(cx, str)) \
4343
return false;
4444
FOR_EACH_ATOM(INITIALIZE_ATOM)
4545
FOR_EACH_SYMBOL_ATOM(INITIALIZE_ATOM)
4646
return true;
47+
#undef INITIALIZE_ATOM
4748
}
4849

4950
void GjsAtoms::trace(JSTracer* trc) {
5051
#define TRACE_ATOM(identifier, str) \
51-
JS::TraceEdge<jsid>(trc, identifier.id(), "Atom " str);
52+
JS::TraceEdge<jsid>(trc, (identifier).id(), "Atom " str);
5253
FOR_EACH_ATOM(TRACE_ATOM)
5354
FOR_EACH_SYMBOL_ATOM(TRACE_ATOM)
5455
#undef TRACE_ATOM

cjs/atoms.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
// SPDX-FileCopyrightText: 2018 Philip Chimento <philip.chimento@gmail.com>
44
// SPDX-FileCopyrightText: 2018 Marco Trevisan <marco.trevisan@canonical.com>
55

6-
#ifndef GJS_ATOMS_H_
7-
#define GJS_ATOMS_H_
6+
#pragma once
87

98
#include <config.h>
109

@@ -86,12 +85,13 @@ class JSTracer;
8685
// clang-format on
8786

8887
struct GjsAtom {
89-
GJS_JSAPI_RETURN_CONVENTION bool init(JSContext* cx, const char* str);
88+
GJS_JSAPI_RETURN_CONVENTION bool init(JSContext*, const char* str);
9089

9190
/* It's OK to return JS::HandleId here, to avoid an extra root, with the
9291
* caveat that you should not use this value after the GjsContext has been
9392
* destroyed.*/
94-
[[nodiscard]] JS::HandleId operator()() const {
93+
[[nodiscard]]
94+
JS::HandleId operator()() const {
9595
return JS::HandleId::fromMarkedLocation(&m_jsid.get());
9696
}
9797

@@ -102,16 +102,17 @@ struct GjsAtom {
102102
};
103103

104104
struct GjsSymbolAtom : GjsAtom {
105-
GJS_JSAPI_RETURN_CONVENTION bool init(JSContext* cx, const char* str);
105+
GJS_JSAPI_RETURN_CONVENTION
106+
bool init(JSContext*, const char* str);
106107
};
107108

108109
class GjsAtoms {
109110
public:
110-
GjsAtoms(void) {}
111-
~GjsAtoms(void) {} // prevents giant destructor from being inlined
112-
GJS_JSAPI_RETURN_CONVENTION bool init_atoms(JSContext* cx);
111+
GjsAtoms() = default;
112+
~GjsAtoms() = default; // prevents giant destructor from being inlined
113+
GJS_JSAPI_RETURN_CONVENTION bool init_atoms(JSContext*);
113114

114-
void trace(JSTracer* trc);
115+
void trace(JSTracer*);
115116

116117
#define DECLARE_ATOM_MEMBER(identifier, str) GjsAtom identifier;
117118
#define DECLARE_SYMBOL_ATOM_MEMBER(identifier, str) GjsSymbolAtom identifier;
@@ -125,5 +126,3 @@ class GjsAtoms {
125126
# undef FOR_EACH_ATOM
126127
# undef FOR_EACH_SYMBOL_ATOM
127128
#endif
128-
129-
#endif // GJS_ATOMS_H_

cjs/auto.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <glib-object.h>
1717
#include <glib.h>
18+
// IWYU pragma: no_forward_declare _GVariant
1819

1920
#include <js/Utility.h> // for UniqueChars
2021

@@ -128,9 +129,12 @@ struct AutoPointer {
128129
constexpr operator ConstPtr() const { return m_ptr; }
129130
constexpr operator bool() const { return m_ptr != nullptr; }
130131

131-
constexpr Ptr get() const { return m_ptr; }
132-
constexpr Ptr* out() { return &m_ptr; }
133-
constexpr ConstPtr* out() const { return const_cast<ConstPtr*>(&m_ptr); }
132+
[[nodiscard]] constexpr Ptr get() const { return m_ptr; }
133+
[[nodiscard]] constexpr Ptr* out() { return &m_ptr; }
134+
[[nodiscard]]
135+
constexpr ConstPtr* out() const {
136+
return const_cast<ConstPtr*>(&m_ptr);
137+
}
134138

135139
constexpr Ptr release() {
136140
auto* ptr = m_ptr;
@@ -197,7 +201,8 @@ using AutoChar =
197201
// free(). It would cause crashes if SpiderMonkey were to stop supporting
198202
// embedders using the system allocator in the future. In that case, this
199203
// function would have to copy the string.
200-
[[nodiscard]] inline AutoChar js_chars_to_glib(JS::UniqueChars&& js_chars) {
204+
[[nodiscard]]
205+
inline AutoChar js_chars_to_glib(JS::UniqueChars&& js_chars) {
201206
return {js_chars.release()};
202207
}
203208

cjs/byteArray.cpp

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <js/experimental/TypedData.h>
2323
#include <jsapi.h> // for JS_NewPlainObject
2424

25-
#include "gi/boxed.h"
25+
#include "gi/struct.h"
2626
#include "cjs/atoms.h"
2727
#include "cjs/byteArray.h"
2828
#include "cjs/context-private.h"
@@ -43,35 +43,35 @@ static bool to_string_func(JSContext* cx, unsigned argc, JS::Value* vp) {
4343
return false;
4444

4545
const char* actual_encoding = encoding ? encoding.get() : "utf-8";
46-
JS::RootedString str(
47-
cx, gjs_decode_from_uint8array(cx, byte_array, actual_encoding,
48-
GjsStringTermination::ZERO_TERMINATED, true));
46+
JS::RootedString str{cx, gjs_decode_from_uint8array(
47+
cx, byte_array, actual_encoding,
48+
GjsStringTermination::ZERO_TERMINATED, true)};
4949
if (!str)
5050
return false;
5151

5252
args.rval().setString(str);
5353
return true;
5454
}
5555

56-
/* Workaround to keep existing code compatible. This function is tacked onto
57-
* any Uint8Array instances created in situations where previously a ByteArray
58-
* would have been created. It logs a compatibility warning. */
56+
/* Workaround to keep existing code compatible. This function is tacked onto any
57+
* Uint8Array instances created in situations where previously a ByteArray would
58+
* have been created. It logs a compatibility warning. */
5959
GJS_JSAPI_RETURN_CONVENTION
6060
static bool instance_to_string_func(JSContext* cx, unsigned argc,
6161
JS::Value* vp) {
6262
GJS_GET_THIS(cx, argc, vp, args, this_obj);
6363
JS::UniqueChars encoding;
6464

65-
_gjs_warn_deprecated_once_per_callsite(
65+
gjs_warn_deprecated_once_per_callsite(
6666
cx, GjsDeprecationMessageId::ByteArrayInstanceToString);
6767

6868
if (!gjs_parse_call_args(cx, "toString", args, "|s", "encoding", &encoding))
6969
return false;
7070

7171
const char* actual_encoding = encoding ? encoding.get() : "utf-8";
72-
JS::RootedString str(
73-
cx, gjs_decode_from_uint8array(cx, this_obj, actual_encoding,
74-
GjsStringTermination::ZERO_TERMINATED, true));
72+
JS::RootedString str{cx, gjs_decode_from_uint8array(
73+
cx, this_obj, actual_encoding,
74+
GjsStringTermination::ZERO_TERMINATED, true)};
7575
if (!str)
7676
return false;
7777

@@ -86,7 +86,7 @@ static bool define_legacy_tostring(JSContext* cx, JS::HandleObject array) {
8686
instance_to_string_func, 1, 0);
8787
}
8888

89-
/* fromString() function implementation */
89+
// fromString() function implementation
9090
GJS_JSAPI_RETURN_CONVENTION
9191
static bool from_string_func(JSContext* cx, unsigned argc, JS::Value* vp) {
9292
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
@@ -108,38 +108,32 @@ static bool from_string_func(JSContext* cx, unsigned argc, JS::Value* vp) {
108108
}
109109

110110
GJS_JSAPI_RETURN_CONVENTION
111-
static bool
112-
from_gbytes_func(JSContext *context,
113-
unsigned argc,
114-
JS::Value *vp)
115-
{
116-
JS::CallArgs argv = JS::CallArgsFromVp (argc, vp);
117-
JS::RootedObject bytes_obj(context);
118-
GBytes *gbytes;
119-
120-
if (!gjs_parse_call_args(context, "fromGBytes", argv, "o",
121-
"bytes", &bytes_obj))
111+
static bool from_gbytes_func(JSContext* cx, unsigned argc, JS::Value* vp) {
112+
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
113+
JS::RootedObject bytes_obj{cx};
114+
115+
if (!gjs_parse_call_args(cx, "fromGBytes", args, "o", "bytes", &bytes_obj))
122116
return false;
123117

124-
if (!BoxedBase::typecheck(context, bytes_obj, G_TYPE_BYTES))
118+
if (!StructBase::typecheck(cx, bytes_obj, G_TYPE_BYTES))
125119
return false;
126120

127-
gbytes = BoxedBase::to_c_ptr<GBytes>(context, bytes_obj);
121+
GBytes* gbytes = StructBase::to_c_ptr<GBytes>(cx, bytes_obj);
128122
if (!gbytes)
129123
return false;
130124

131125
size_t len;
132126
const void* data = g_bytes_get_data(gbytes, &len);
133127
if (len == 0) {
134-
JS::RootedObject empty_array(context, JS_NewUint8Array(context, 0));
135-
if (!empty_array || !define_legacy_tostring(context, empty_array))
128+
JS::RootedObject empty_array{cx, JS_NewUint8Array(cx, 0)};
129+
if (!empty_array || !define_legacy_tostring(cx, empty_array))
136130
return false;
137131

138-
argv.rval().setObject(*empty_array);
132+
args.rval().setObject(*empty_array);
139133
return true;
140134
}
141135

142-
JS::RootedObject array_buffer{context, JS::NewArrayBuffer(context, len)};
136+
JS::RootedObject array_buffer{cx, JS::NewArrayBuffer(cx, len)};
143137
if (!array_buffer)
144138
return false;
145139

@@ -152,12 +146,12 @@ from_gbytes_func(JSContext *context,
152146
std::copy_n(static_cast<const uint8_t*>(data), len, storage);
153147
}
154148

155-
JS::RootedObject obj(
156-
context, JS_NewUint8ArrayWithBuffer(context, array_buffer, 0, -1));
157-
if (!obj || !define_legacy_tostring(context, obj))
149+
JS::RootedObject obj{cx,
150+
JS_NewUint8ArrayWithBuffer(cx, array_buffer, 0, -1)};
151+
if (!obj || !define_legacy_tostring(cx, obj))
158152
return false;
159153

160-
argv.rval().setObject(*obj);
154+
args.rval().setObject(*obj);
161155
return true;
162156
}
163157

@@ -211,10 +205,8 @@ static JSFunctionSpec gjs_byte_array_module_funcs[] = {
211205
JS_FN("toString", to_string_func, 2, 0),
212206
JS_FS_END};
213207

214-
bool
215-
gjs_define_byte_array_stuff(JSContext *cx,
216-
JS::MutableHandleObject module)
217-
{
208+
bool gjs_define_byte_array_stuff(JSContext* cx,
209+
JS::MutableHandleObject module) {
218210
module.set(JS_NewPlainObject(cx));
219211
return JS_DefineFunctions(cx, module, gjs_byte_array_module_funcs);
220212
}

cjs/byteArray.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
33
// SPDX-FileCopyrightText: 2010 litl, LLC
44

5-
#ifndef GJS_BYTEARRAY_H_
6-
#define GJS_BYTEARRAY_H_
5+
#pragma once
76

87
#include <config.h>
98

@@ -16,18 +15,13 @@
1615
#include "cjs/macros.h"
1716

1817
GJS_JSAPI_RETURN_CONVENTION
19-
bool gjs_define_byte_array_stuff(JSContext *context,
20-
JS::MutableHandleObject module);
18+
bool gjs_define_byte_array_stuff(JSContext*, JS::MutableHandleObject module);
2119

2220
GJS_JSAPI_RETURN_CONVENTION
23-
JSObject* gjs_byte_array_from_data_copy(JSContext* cx, size_t nbytes,
24-
void* data);
21+
JSObject* gjs_byte_array_from_data_copy(JSContext*, size_t nbytes, void* data);
2522

2623
GJS_JSAPI_RETURN_CONVENTION
27-
JSObject * gjs_byte_array_from_byte_array (JSContext *context,
28-
GByteArray *array);
24+
JSObject* gjs_byte_array_from_byte_array(JSContext*, GByteArray*);
2925

30-
[[nodiscard]] GByteArray* gjs_byte_array_get_byte_array(JSObject* obj);
31-
[[nodiscard]] GBytes* gjs_byte_array_get_bytes(JSObject* obj);
32-
33-
#endif // GJS_BYTEARRAY_H_
26+
[[nodiscard]] GByteArray* gjs_byte_array_get_byte_array(JSObject*);
27+
[[nodiscard]] GBytes* gjs_byte_array_get_bytes(JSObject*);

cjs/cjs_pch.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <algorithm>
99
#include <array>
1010
#include <atomic>
11+
#include <chrono>
1112
#include <cmath>
1213
#include <cstddef>
1314
#include <deque>
@@ -16,6 +17,7 @@
1617
#include <limits>
1718
#include <memory>
1819
#include <new>
20+
#include <ratio>
1921
#include <sstream>
2022
#include <string>
2123
#include <string_view>

0 commit comments

Comments
 (0)