• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kunitoki / popsicle / 8195308623

07 Mar 2024 09:55PM UTC coverage: 20.126% (+1.3%) from 18.801%
8195308623

Pull #24

github

kunitoki
More pixel tests
Pull Request #24: More tests coverage

283 of 398 new or added lines in 6 files covered. (71.11%)

45 existing lines in 5 files now uncovered.

23757 of 118043 relevant lines covered (20.13%)

3617.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.14
/modules/juce_python/bindings/ScriptJuceCoreBindings.cpp
1
/**
2
 * juce_python - Python bindings for the JUCE framework.
3
 *
4
 * This file is part of the popsicle project.
5
 *
6
 * Copyright (c) 2024 - kunitoki <kunitoki@gmail.com>
7
 *
8
 * popsicle is an open source library subject to commercial or open-source licensing.
9
 *
10
 * By using popsicle, you agree to the terms of the popsicle License Agreement, which can
11
 * be found at https://raw.githubusercontent.com/kunitoki/popsicle/master/LICENSE
12
 *
13
 * Or: You may also use this code under the terms of the GPL v3 (see www.gnu.org/licenses).
14
 *
15
 * POPSICLE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED
16
 * OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED.
17
 */
18

19
#include "ScriptJuceCoreBindings.h"
20

21
#define JUCE_PYTHON_INCLUDE_PYBIND11_FUNCTIONAL
22
#define JUCE_PYTHON_INCLUDE_PYBIND11_STL
23
#include "../utilities/PyBind11Includes.h"
24

25
#include "../utilities/CrashHandling.h"
26

27
#include <optional>
28
#include <string_view>
29

30
namespace PYBIND11_NAMESPACE {
31
namespace detail {
32

33
// =================================================================================================
34

35
bool type_caster<juce::StringRef>::load (handle src, bool convert)
549✔
36
{
37
    juce::ignoreUnused (convert);
549✔
38

39
    if (! src)
549✔
40
        return false;
×
41

42
    if (! PyUnicode_Check (src.ptr()))
549✔
43
        return load_raw(src);
51✔
44

45
    Py_ssize_t size = -1;
498✔
46
    const auto* buffer = reinterpret_cast<const char*> (PyUnicode_AsUTF8AndSize (src.ptr(), &size));
498✔
47
    if (buffer == nullptr)
498✔
48
        return false;
×
49

50
    value = buffer;
498✔
51

52
    loader_life_support::add_patient (src);
498✔
53

54
    return true;
498✔
55
}
56

57
handle type_caster<juce::StringRef>::cast (const juce::StringRef& src, return_value_policy policy, handle parent)
2✔
58
{
59
    juce::ignoreUnused (policy, parent);
2✔
60

61
    return PyUnicode_FromStringAndSize (static_cast<const char*> (src.text), static_cast<Py_ssize_t> (src.length()));
2✔
62
}
63

64
bool type_caster<juce::StringRef>::load_raw (handle src)
51✔
65
{
66
    if (PYBIND11_BYTES_CHECK (src.ptr()))
51✔
67
    {
68
        const char* bytes = PYBIND11_BYTES_AS_STRING (src.ptr());
×
69
        if (! bytes)
×
70
            pybind11_fail ("Unexpected PYBIND11_BYTES_AS_STRING() failure.");
×
71

72
        value = bytes;
×
73
        return true;
×
74
    }
75

76
    if (PyByteArray_Check (src.ptr()))
51✔
77
    {
78
        const char* bytearray = PyByteArray_AsString (src.ptr());
×
79
        if (! bytearray)
×
80
            pybind11_fail ("Unexpected PyByteArray_AsString() failure.");
×
81

82
        value = bytearray;
×
83
        return true;
×
84
    }
85

86
    return false;
51✔
87
}
88

89
// =================================================================================================
90

91
bool type_caster<juce::String>::load (handle src, bool convert)
10,953✔
92
{
93
    juce::ignoreUnused (convert);
10,953✔
94

95
    if (! src)
10,953✔
96
        return false;
×
97

98
    if (! PyUnicode_Check (src.ptr()))
10,953✔
99
        return load_raw(src);
167✔
100

101
    Py_ssize_t size = -1;
10,786✔
102
    const auto* buffer = reinterpret_cast<const char*> (PyUnicode_AsUTF8AndSize (src.ptr(), &size));
10,786✔
103
    if (buffer == nullptr)
10,786✔
104
        return false;
×
105

106
    value = juce::String::fromUTF8 (buffer, static_cast<int> (size));
10,786✔
107
    return true;
10,786✔
108
}
109

110
handle type_caster<juce::String>::cast (const juce::String& src, return_value_policy policy, handle parent)
697✔
111
{
112
    juce::ignoreUnused (policy, parent);
697✔
113

114
    return PyUnicode_FromStringAndSize (src.toRawUTF8(), static_cast<Py_ssize_t> (src.getNumBytesAsUTF8()));
697✔
115
}
116

117
bool type_caster<juce::String>::load_raw (handle src)
167✔
118
{
119
    if (PYBIND11_BYTES_CHECK (src.ptr()))
167✔
120
    {
121
        const char* bytes = PYBIND11_BYTES_AS_STRING (src.ptr());
×
122
        if (! bytes)
×
123
            pybind11_fail ("Unexpected PYBIND11_BYTES_AS_STRING() failure.");
×
124

125
        value = juce::String::fromUTF8 (bytes, static_cast<int> (PYBIND11_BYTES_SIZE (src.ptr())));
×
126
        return true;
×
127
    }
128

129
    if (PyByteArray_Check (src.ptr()))
167✔
130
    {
131
        const char* bytearray = PyByteArray_AsString (src.ptr());
×
132
        if (! bytearray)
×
133
            pybind11_fail ("Unexpected PyByteArray_AsString() failure.");
×
134

135
        value = juce::String::fromUTF8 (bytearray, static_cast<int> (PyByteArray_Size (src.ptr())));
×
136
        return true;
×
137
    }
138

139
    return false;
167✔
140
}
141

142
// =================================================================================================
143

144
bool type_caster<juce::Identifier>::load (handle src, bool convert)
22,434✔
145
{
146
    if (! src)
22,434✔
147
        return false;
×
148

149
    if (base_type::load (src, convert))
22,434✔
150
    {
151
        value = *reinterpret_cast<juce::Identifier*> (base_type::value);
111✔
152
        return true;
111✔
153
    }
154

155
    if (! PyUnicode_Check (src.ptr()))
22,323✔
156
        return load_raw(src);
3✔
157

158
    Py_ssize_t size = -1;
22,320✔
159
    const auto* buffer = reinterpret_cast<const char*> (PyUnicode_AsUTF8AndSize (src.ptr(), &size));
22,320✔
160
    if (buffer == nullptr)
22,320✔
161
        return false;
×
162

163
    value = juce::Identifier (juce::String::fromUTF8 (buffer, static_cast<int> (size)));
22,320✔
164
    return true;
22,320✔
165
}
166

167
handle type_caster<juce::Identifier>::cast (const juce::Identifier& src, return_value_policy policy, handle parent)
22✔
168
{
169
    juce::ignoreUnused (policy, parent);
22✔
170

171
    if (auto result = base_type::cast (src, policy, parent))
22✔
172
        return result;
22✔
173

174
    return make_caster<juce::String>::cast (src.toString(), policy, parent);
×
175
}
176

177
bool type_caster<juce::Identifier>::load_raw (handle src)
3✔
178
{
179
    if (PYBIND11_BYTES_CHECK (src.ptr()))
3✔
180
    {
181
        const char* bytes = PYBIND11_BYTES_AS_STRING (src.ptr());
×
182
        if (! bytes)
×
183
            pybind11_fail ("Unexpected PYBIND11_BYTES_AS_STRING() failure.");
×
184

185
        value = juce::Identifier (juce::String::fromUTF8 (bytes, static_cast<int> (PYBIND11_BYTES_SIZE (src.ptr()))));
×
186
        return true;
×
187
    }
188

189
    if (PyByteArray_Check (src.ptr()))
3✔
190
    {
191
        const char* bytearray = PyByteArray_AsString (src.ptr());
×
192
        if (! bytearray)
×
193
            pybind11_fail ("Unexpected PyByteArray_AsString() failure.");
×
194

195
        value = juce::Identifier (juce::String::fromUTF8 (bytearray, static_cast<int> (PyByteArray_Size (src.ptr()))));
×
196
        return true;
×
197
    }
198

199
    return false;
3✔
200
}
201

202
// =================================================================================================
203

204
bool type_caster<juce::var>::load (handle src, bool convert)
30,248✔
205
{
206
    PyObject* source = src.ptr();
30,248✔
207

208
    if (PyNone_Check(source))
30,248✔
209
        value = juce::var::undefined();
3✔
210

211
    else if (PyBool_Check(source))
30,245✔
212
        value = PyObject_IsTrue (source) ? true : false;
28✔
213

214
    else if (PyLong_Check (source))
30,217✔
215
        value = static_cast<int> (PyLong_AsLong (source));
81✔
216

217
    else if (PyFloat_Check (source))
30,136✔
218
        value = PyFloat_AsDouble (source);
8✔
219

220
    else if (PyUnicode_Check (source))
30,128✔
221
    {
222
        Py_ssize_t size = -1;
30,108✔
223
        const auto* buffer = reinterpret_cast<const char*> (PyUnicode_AsUTF8AndSize (src.ptr(), &size));
30,108✔
224
        if (buffer == nullptr)
30,108✔
225
            return false;
×
226

227
        value = juce::String::fromUTF8 (buffer, static_cast<int> (size));
30,108✔
228
    }
229

230
    else if (PYBIND11_BYTES_CHECK (source))
20✔
231
    {
232
        const char* bytes = PYBIND11_BYTES_AS_STRING (source);
1✔
233
        if (! bytes)
1✔
234
            return false;
×
235

236
        value = juce::var (bytes, static_cast<size_t> (PYBIND11_BYTES_SIZE (source)));
1✔
237
    }
238

239
    else if (PyByteArray_Check (source))
19✔
240
    {
241
        const char* bytearray = PyByteArray_AsString (source);
×
242
        if (! bytearray)
×
243
            return false;
×
244

245
        value = juce::var (bytearray, static_cast<size_t> (PyByteArray_Size (source)));
×
246
    }
247

248
    else if (PyTuple_Check (source))
19✔
249
    {
250
        value = juce::var();
1✔
251

252
        const auto tupleSize = PyTuple_Size(source);
1✔
253
        for (Py_ssize_t i = 0; i < tupleSize; ++i)
4✔
254
        {
255
            make_caster<juce::var> conv;
3✔
256

257
            if (! conv.load (PyTuple_GetItem(source, i), convert))
3✔
258
                return false;
×
259

260
            value.append (cast_op<juce::var&&> (std::move (conv)));
3✔
261
        }
262
    }
263

264
    else if (PyList_Check (source))
18✔
265
    {
266
        value = juce::var();
4✔
267

268
        const auto tupleSize = PyList_Size(source);
4✔
269
        for (Py_ssize_t i = 0; i < tupleSize; ++i)
19✔
270
        {
271
            make_caster<juce::var> conv;
15✔
272

273
            if (! conv.load (PyList_GetItem(source, i), convert))
15✔
274
                return false;
×
275

276
            value.append (cast_op<juce::var&&> (std::move (conv)));
15✔
277
        }
278
    }
279

280
    else if (PyDict_Check (source))
14✔
281
    {
282
        juce::DynamicObject::Ptr obj = new juce::DynamicObject;
13✔
283

284
        value = juce::var (obj.get());
13✔
285

286
        PyObject* key;
287
        PyObject* val;
288
        Py_ssize_t pos = 0;
13✔
289

290
        while (PyDict_Next (source, &pos, &key, &val))
48✔
291
        {
292
            make_caster<juce::Identifier> convKey;
35✔
293
            make_caster<juce::var> convValue;
35✔
294

295
            if (! convKey.load (key, convert) || ! convValue.load (val, convert))
35✔
296
                return false;
×
297

298
            obj->setProperty (
70✔
299
                cast_op<juce::Identifier&&> (std::move (convKey)),
35✔
300
                cast_op<juce::var&&> (std::move (convValue)));
35✔
301
        }
302
    }
303

304
    else if (isinstance<juce::MemoryBlock&> (src))
1✔
305
    {
306
        value = juce::var (src.cast<juce::MemoryBlock&>());
1✔
307
    }
308

309
    else
310
    {
311
        value = juce::var::undefined();
×
312
    }
313

314
    // TODO - raise
315

316
    return !PyErr_Occurred();
30,248✔
317
}
318

319
handle type_caster<juce::var>::cast (const juce::var& src, return_value_policy policy, handle parent)
118✔
320
{
321
    if (src.isVoid() || src.isUndefined())
118✔
322
        return Py_None;
10✔
323

324
    if (src.isBool())
108✔
325
        return PyBool_FromLong (static_cast<bool> (src));
7✔
326

327
    if (src.isInt())
101✔
328
        return PyLong_FromLong (static_cast<int> (src));
46✔
329

330
    if (src.isInt64())
55✔
331
        return PyLong_FromLongLong (static_cast<juce::int64> (src));
×
332

333
    if (src.isDouble())
55✔
334
        return PyFloat_FromDouble (static_cast<double> (src));
7✔
335

336
    if (src.isString())
48✔
337
        return make_caster<juce::String>::cast (src, policy, parent);
28✔
338

339
    if (src.isArray())
20✔
340
    {
341
        list list;
12✔
342

343
        if (auto array = src.getArray())
6✔
344
        {
345
            for (const auto& value : *array)
26✔
346
                list.append (value);
20✔
347
        }
348

349
        return list.release();
6✔
350
    }
351

352
    auto dynamicObject = src.getDynamicObject();
14✔
353
    if (src.isObject() && dynamicObject != nullptr)
14✔
354
    {
355
        dict result;
20✔
356

357
        for (const auto& props : dynamicObject->getProperties())
32✔
358
            result [make_caster<juce::String>::cast (props.name.toString(), policy, parent)] = props.value;
22✔
359

360
        return result.release();
10✔
361
    }
362

363
    if (src.isBinaryData())
4✔
364
    {
365
        if (auto data = src.getBinaryData())
4✔
366
            return bytes (static_cast<const char*> (data->getData()), static_cast<Py_ssize_t> (data->getSize())).release();
8✔
367
    }
368

369
    if (src.isMethod())
×
370
    {
371
        return cpp_function ([src]
×
372
        {
373
            juce::var::NativeFunctionArgs args (juce::var(), nullptr, 0);
×
374
            return src.getNativeFunction() (args);
×
375
        }).release();
×
376
    }
377

378
    return Py_None;
×
379
}
380

381
}} // namespace PYBIND11_NAMESPACE::detail
382

383
namespace popsicle::Bindings {
384

385
using namespace juce;
386

387
namespace py = pybind11;
388
using namespace py::literals;
389

390
// ============================================================================================
391

392
template <template <class> class Class, class... Types>
393
void registerMathConstants (py::module_& m)
1✔
394
{
395
    py::dict type;
2✔
396

397
    ([&]
7✔
398
    {
399
        using ValueType = Types;
400
        using T = Class<ValueType>;
401

402
        const auto className = popsicle::Helpers::pythonizeCompoundClassName ("MathConstants", typeid (Types).name());
4✔
403

404
        auto class_ = py::class_<T> (m, className.toRawUTF8())
2✔
405
            .def_readonly_static ("pi", &T::pi)
2✔
406
            .def_readonly_static ("twoPi", &T::twoPi)
2✔
407
            .def_readonly_static ("halfPi", &T::halfPi)
2✔
408
            .def_readonly_static ("euler", &T::euler)
2✔
409
            .def_readonly_static ("sqrt2", &T::sqrt2)
2✔
410
        ;
411

412
        type[py::type::of (py::cast (Types{}))] = class_;
2✔
413

414
        return true;
4✔
415
    }() && ...);
1✔
416

417
    m.add_object ("MathConstants", type);
1✔
418
}
1✔
419

420
// ============================================================================================
421

422
template <template <class> class Class, class... Types>
423
void registerRange (py::module_& m)
1✔
424
{
425
    py::dict type;
2✔
426

427
    ([&]
10✔
428
    {
429
        using ValueType = underlying_type_t<Types>;
430
        using T = Class<ValueType>;
431

432
        const auto className = popsicle::Helpers::pythonizeCompoundClassName ("Range", typeid (ValueType).name());
6✔
433

434
        auto class_ = py::class_<T> (m, className.toRawUTF8())
3✔
435
            .def (py::init<>())
3✔
436
            .def (py::init<ValueType, ValueType>())
3✔
437
            .def_static ("between", &T::between)
3✔
438
            .def_static ("withStartAndLength", &T::withStartAndLength)
3✔
439
            .def_static ("emptyRange", &T::emptyRange)
3✔
440
            .def ("getStart", &T::getStart)
3✔
441
            .def ("getLength", &T::getLength)
3✔
442
            .def ("getEnd", &T::getEnd)
3✔
443
            .def ("isEmpty", &T::isEmpty)
3✔
444
            .def ("setStart", &T::setStart)
3✔
445
            .def ("withStart", &T::withStart)
3✔
446
            .def ("movedToStartAt", &T::movedToStartAt)
3✔
447
            .def ("setEnd", &T::setEnd)
3✔
448
            .def ("withEnd", &T::withEnd)
3✔
449
            .def ("movedToEndAt", &T::movedToEndAt)
3✔
450
            .def ("setLength", &T::setLength)
3✔
451
            .def ("expanded", &T::expanded)
3✔
452
            .def (py::self += ValueType())
3✔
453
            .def (py::self -= ValueType())
3✔
454
            .def (py::self + ValueType())
3✔
455
            .def (py::self - ValueType())
3✔
456
            .def (py::self == py::self)
3✔
457
            .def (py::self != py::self)
3✔
458
            .def ("contains", py::overload_cast<const ValueType> (&T::contains, py::const_))
3✔
459
            .def ("clipValue", &T::clipValue)
3✔
460
            .def ("contains", py::overload_cast<T> (&T::contains, py::const_))
3✔
461
            .def ("intersects", &T::intersects)
3✔
462
            .def ("getIntersectionWith", &T::getIntersectionWith)
3✔
463
            .def ("getUnionWith", py::overload_cast<T> (&T::getUnionWith, py::const_))
3✔
464
            .def ("getUnionWith", py::overload_cast<const ValueType> (&T::getUnionWith, py::const_))
3✔
465
            .def ("constrainRange", &T::constrainRange)
3✔
466
        //.def_static ("findMinAndMax", [](const T& self, py::buffer values, int numValues)
467
        //{
468
        //  auto info = values.request();
469
        //  return self.findMinAndMax (reinterpret_cast<ValueType*> (info.ptr), numValues);
470
        //})
471
            .def ("__repr__", [](const T& self)
3✔
472
            {
473
                String result;
×
474
                result
475
                    << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name())
×
476
                    << "(" << self.getStart() << ", " << self.getEnd() << ")";
×
477
                return result;
×
478
            })
479
        ;
480

481
        if constexpr (! std::is_same_v<ValueType, Types>)
482
            class_.def (py::init ([](Types start, Types end) { return T (static_cast<ValueType> (start), static_cast<ValueType> (end)); }));
1✔
483

484
        type[py::type::of (py::cast (Types{}))] = class_;
3✔
485

486
        return true;
6✔
487
    }() && ...);
1✔
488

489
    m.add_object ("Range", type);
1✔
490
}
1✔
491

492
// ============================================================================================
493

494
template <template <class> class Class, class... Types>
495
void registerNormalisableRange (py::module_& m)
1✔
496
{
497
    py::dict type;
2✔
498

499
    ([&]
3✔
500
    {
501
        using ValueType = underlying_type_t<Types>;
502
        using T = Class<ValueType>;
503
        using ValueRemapFunction = typename T::ValueRemapFunction;
504

505
        const auto className = popsicle::Helpers::pythonizeCompoundClassName ("NormalisableRange", typeid (ValueType).name());
2✔
506

507
        auto class_ = py::class_<T> (m, className.toRawUTF8())
1✔
508
            .def (py::init<>())
1✔
509
            .def (py::init<ValueType, ValueType>(), "rangeStart"_a, "rangeEnd"_a)
1✔
510
            .def (py::init<ValueType, ValueType, ValueType, ValueType, bool>(), "rangeStart"_a, "rangeEnd"_a, "intervalValue"_a, "skewFactor"_a, "useSymmetricSkew"_a = false)
2✔
511
            .def (py::init<ValueType, ValueType, ValueType>(), "rangeStart"_a, "rangeEnd"_a, "intervalValue"_a)
1✔
512
            .def (py::init<Range<ValueType>>(), "range"_a)
1✔
513
            .def (py::init<Range<ValueType>, ValueType>(), "range"_a, "intervalValue"_a)
1✔
514
            .def (py::init<ValueType, ValueType, ValueRemapFunction, ValueRemapFunction, ValueRemapFunction>(), "rangeStart"_a, "rangeEnd"_a, "convertFrom0To1Func"_a, "convertTo0To1Func"_a, "snapToLegalValueFunc"_a = ValueRemapFunction())
2✔
515
            .def (py::init<const T&>())
1✔
516
            .def ("convertTo0to1", &T::convertTo0to1)
1✔
517
            .def ("convertFrom0to1", &T::convertFrom0to1)
1✔
518
            .def ("snapToLegalValue", &T::snapToLegalValue)
1✔
519
            .def ("getRange", &T::getRange)
1✔
520
            .def ("setSkewForCentre", &T::setSkewForCentre)
1✔
521
            .def_readwrite ("start", &T::start)
1✔
522
            .def_readwrite ("end", &T::end)
1✔
523
            .def_readwrite ("interval", &T::interval)
1✔
524
            .def_readwrite ("skew", &T::skew)
1✔
525
            .def_readwrite ("symmetricSkew", &T::symmetricSkew)
1✔
526
            .def ("__repr__", [](const T& self)
1✔
527
            {
NEW
528
                String result;
×
529
                result
NEW
530
                    << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name())
×
NEW
531
                    << "(" << self.start << ", " << self.end << ", " << self.interval << ", " << self.skew << ", " << (self.symmetricSkew ? "True" : "False") << ")";
×
NEW
532
                return result;
×
533
            })
534
        ;
535

536
        type[py::type::of (py::cast (Types{}))] = class_;
1✔
537

538
        return true;
2✔
539
    }() && ...);
1✔
540

541
    m.add_object ("NormalisableRange", type);
1✔
542
}
1✔
543

544
// ============================================================================================
545

546
template <template <class> class Class, class... Types>
547
void registerAtomic (py::module_& m)
1✔
548
{
549
    py::dict type;
2✔
550

551
    ([&]
10✔
552
    {
553
        using ValueType = underlying_type_t<Types>;
554
        using T = Class<ValueType>;
555

556
        const auto className = popsicle::Helpers::pythonizeCompoundClassName ("Atomic", typeid (ValueType).name());
6✔
557

558
        auto class_ = py::class_<T> (m, className.toRawUTF8())
3✔
559
            .def (py::init<>())
3✔
560
            .def (py::init<ValueType>())
3✔
561
            .def (py::init<const T&>())
3✔
562
            .def ("get", &T::get)
3✔
563
            .def ("set", &T::set)
3✔
564
            .def ("exchange", &T::exchange)
3✔
565
            .def ("compareAndSetBool", &T::compareAndSetBool)
3✔
566
            .def ("memoryBarrier", &T::memoryBarrier)
3✔
567
        ;
568

569
        if constexpr (! std::is_same_v<ValueType, Types>)
570
            class_.def (py::init ([](Types value) { return T (static_cast<ValueType> (value)); }));
571

572
        if constexpr (!std::is_same_v<ValueType, bool> && !std::is_floating_point_v<ValueType>)
573
        {
574
            class_
575
                .def ("__iadd__", &T::operator+=)
1✔
576
                .def ("__isub__", &T::operator-=)
1✔
577
            ;
578
        }
579

580
        type[py::type::of (py::cast (Types{}))] = class_;
3✔
581

582
        return true;
6✔
583
    }() && ...);
1✔
584

585
    m.add_object ("Atomic", type);
1✔
586
}
1✔
587

588
// ============================================================================================
589

590
template <template <class> class Class, class... Types>
591
void registerSparseSet (pybind11::module_& m)
1✔
592
{
593
    using namespace juce;
594

595
    namespace py = pybind11;
596
    using namespace py::literals;
597

598
    auto type = py::hasattr (m, "SparseSet") ? m.attr ("SparseSet").cast<py::dict>() : py::dict{};
1✔
599

600
    ([&]
3✔
601
    {
602
        using ValueType = underlying_type_t<Types>;
603
        using T = Class<ValueType>;
604

605
        const auto className = popsicle::Helpers::pythonizeCompoundClassName ("SparseSet", typeid (ValueType).name());
2✔
606

607
        py::class_<T> class_ (m, className.toRawUTF8());
1✔
608

609
        class_
610
            .def (py::init<>())
1✔
611
            .def (py::init<const T&>())
1✔
612
            .def ("clear", &T::clear)
1✔
613
            .def ("isEmpty", &T::isEmpty)
1✔
614
            .def ("size", &T::size)
1✔
615
            .def ("__getitem__", &T::operator[])
1✔
616
            .def ("contains", &T::contains)
1✔
617
            .def ("getNumRanges", &T::getNumRanges)
1✔
618
            .def ("getRange", &T::getRange)
1✔
619
            .def ("getTotalRange", &T::getTotalRange)
1✔
620
            .def ("addRange", &T::addRange)
1✔
621
            .def ("removeRange", &T::removeRange)
1✔
622
            .def ("invertRange", &T::invertRange)
1✔
623
            .def ("overlapsRange", &T::overlapsRange)
1✔
624
            .def ("containsRange", &T::containsRange)
1✔
625
            .def ("__len__", &T::size)
1✔
626
            .def ("__repr__", [className](T& self)
1✔
627
            {
NEW
628
                String result;
×
629
                result
NEW
630
                    << "<" << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (T).name(), 1)
×
NEW
631
                    << " object at " << String::formatted ("%p", std::addressof (self)) << ">";
×
NEW
632
                return result;
×
633
            })
634
        ;
635

636
        if constexpr (isEqualityComparable<ValueType>::value)
637
        {
638
            class_
639
                .def (py::self == py::self)
1✔
640
                .def (py::self != py::self)
1✔
641
            ;
642
        }
643

644
        type[py::type::of (py::cast (Types{}))] = class_;
1✔
645

646
        return true;
2✔
647
    }() && ...);
1✔
648

649
    m.attr ("SparseSet") = type;
1✔
650
}
1✔
651

652
void registerJuceCoreBindings (py::module_& m)
1✔
653
{
654
#if !JUCE_PYTHON_EMBEDDED_INTERPRETER
655
    juce::SystemStats::setApplicationCrashHandler (Helpers::applicationCrashHandler);
1✔
656
#endif
657

658
    // ============================================================================================ GenericInteger<T>
659

660
    py::class_<GenericInteger<int8>> (m, "int8")
1✔
661
        .def (py::init<int8>())
1✔
662
        .def ("get", &GenericInteger<int8>::get);
1✔
663

664
    py::class_<GenericInteger<uint8>> (m, "uint8")
1✔
665
        .def (py::init<uint8>())
1✔
666
        .def ("get", &GenericInteger<uint8>::get);
1✔
667

668
    py::class_<GenericInteger<int16>> (m, "int16")
1✔
669
        .def (py::init<int16>())
1✔
670
        .def ("get", &GenericInteger<int16>::get);
1✔
671

672
    py::class_<GenericInteger<uint16>> (m, "uint16")
1✔
673
        .def (py::init<uint16>())
1✔
674
        .def ("get", &GenericInteger<uint16>::get);
1✔
675

676
    py::class_<GenericInteger<int32>> (m, "int32")
1✔
677
        .def (py::init<int32>())
1✔
678
        .def ("get", &GenericInteger<int32>::get);
1✔
679

680
    py::class_<GenericInteger<uint32>> (m, "uint32")
1✔
681
        .def (py::init<uint32>())
1✔
682
        .def ("get", &GenericInteger<uint32>::get);
1✔
683

684
    py::class_<GenericInteger<int64>> (m, "int64")
1✔
685
        .def (py::init<int64>())
1✔
686
        .def ("get", &GenericInteger<int64>::get);
1✔
687

688
    py::class_<GenericInteger<uint64>> (m, "uint64")
1✔
689
        .def (py::init<uint64>())
1✔
690
        .def ("get", &GenericInteger<uint64>::get);
1✔
691

692
    // ============================================================================================ juce::Math
693

694
    m.def ("juce_hypot", &juce_hypot<float>);
1✔
695
    m.def ("juce_hypot", &juce_hypot<double>);
1✔
696
    m.def ("degreesToRadians", &degreesToRadians<float>);
1✔
697
    m.def ("degreesToRadians", &degreesToRadians<double>);
1✔
698
    m.def ("radiansToDegrees", &radiansToDegrees<float>);
1✔
699
    m.def ("radiansToDegrees", &radiansToDegrees<double>);
1✔
700
    m.def ("juce_isfinite", &juce_isfinite<float>);
1✔
701
    m.def ("juce_isfinite", &juce_isfinite<double>);
1✔
702
    m.def ("exactlyEqual", &exactlyEqual<float>);
1✔
703
    m.def ("exactlyEqual", &exactlyEqual<double>);
1✔
704
    m.def ("absoluteTolerance", &absoluteTolerance<float>);
1✔
705
    m.def ("absoluteTolerance", &absoluteTolerance<double>);
1✔
706
    m.def ("relativeTolerance", &relativeTolerance<float>);
1✔
707
    m.def ("relativeTolerance", &relativeTolerance<double>);
1✔
708
    m.def ("approximatelyEqual", [](int a, int b) { return approximatelyEqual (a, b); });
7✔
709
    m.def ("approximatelyEqual", [](int64 a, int64 b) { return approximatelyEqual (a, b); });
1✔
710
    m.def ("approximatelyEqual", [](float a, float b) { return approximatelyEqual (a, b); });
63✔
711
    m.def ("approximatelyEqual", [](double a, double b) { return approximatelyEqual (a, b); });
1✔
712
    m.def ("nextFloatUp", &nextFloatUp<float>);
1✔
713
    m.def ("nextFloatUp", &nextFloatUp<double>);
1✔
714
    m.def ("nextFloatDown", &nextFloatDown<float>);
1✔
715
    m.def ("nextFloatDown", &nextFloatDown<double>);
1✔
716
    m.def ("mapToLog10", &mapToLog10<float>);
1✔
717
    m.def ("mapToLog10", &mapToLog10<double>);
1✔
718
    m.def ("mapFromLog10", &mapFromLog10<float>);
1✔
719
    m.def ("mapFromLog10", &mapFromLog10<double>);
1✔
720
    //m.def ("findMinimum", &findMinimum<float, int>);
721
    //m.def ("findMaximum", &findMaximum<float, int>);
722
    //m.def ("findMinAndMax", &findMaximum<float>);
723
    //m.def ("jlimit", &jlimit<?>);
724
    //m.def ("isPositiveAndBelow", &isPositiveAndBelow<?>);
725
    //m.def ("isPositiveAndNotGreaterThan", &isPositiveAndNotGreaterThan<?>);
726
    //m.def ("isWithin", &isWithin<?>);
727
    m.def ("roundToInt", &roundToInt<int>);
1✔
728
    m.def ("roundToInt", &roundToInt<float>);
1✔
729
    m.def ("roundToInt", &roundToInt<double>);
1✔
730
    m.def ("roundToIntAccurate", &roundToIntAccurate);
1✔
731
    m.def ("truncatePositiveToUnsignedInt", &truncatePositiveToUnsignedInt<float>);
1✔
732
    m.def ("truncatePositiveToUnsignedInt", &truncatePositiveToUnsignedInt<double>);
1✔
733
    m.def ("isPowerOfTwo", &isPowerOfTwo<int>);
1✔
734
    m.def ("isPowerOfTwo", &isPowerOfTwo<int64>);
1✔
735
    m.def ("nextPowerOfTwo", &nextPowerOfTwo);
1✔
736
    m.def ("nextPowerOfTwo", &nextPowerOfTwo);
1✔
737
    m.def ("findHighestSetBit", &findHighestSetBit);
1✔
738
    m.def ("countNumberOfBits", static_cast<int (*)(uint32) noexcept> (&countNumberOfBits));
1✔
739
    m.def ("countNumberOfBits", static_cast<int (*)(uint64) noexcept> (&countNumberOfBits));
1✔
740
    m.def ("negativeAwareModulo", &negativeAwareModulo<char>);
1✔
741
    m.def ("negativeAwareModulo", &negativeAwareModulo<uint8>);
1✔
742
    m.def ("negativeAwareModulo", &negativeAwareModulo<short>);
1✔
743
    m.def ("negativeAwareModulo", &negativeAwareModulo<int>);
1✔
744
    m.def ("negativeAwareModulo", &negativeAwareModulo<int64>);
1✔
745
    m.def ("negativeAwareModulo", &negativeAwareModulo<int64>);
1✔
746
    //m.def ("square", &square<?>);
747
    m.def ("writeLittleEndianBitsInBuffer", [](py::buffer target, uint32 startBit, uint32 numBits, uint32 value)
1,000✔
748
    {
749
        auto info = target.request (true);
2,000✔
750
        if ((startBit + numBits) >= static_cast<uint32> (info.size) * 8)
1,000✔
751
             py::pybind11_fail ("Insufficient bytes to write into provided buffer");
×
752
        writeLittleEndianBitsInBuffer (info.ptr, startBit, numBits, value);
1,000✔
753
    });
1,001✔
754
    m.def ("readLittleEndianBitsInBuffer", [](py::buffer target, uint32 startBit, uint32 numBits)
5,000✔
755
    {
756
        auto info = target.request();
10,000✔
757
        if ((startBit + numBits) >= static_cast<uint32> (info.size) * 8)
5,000✔
758
             py::pybind11_fail ("Insufficient bytes to write into provided buffer");
×
759
        return readLittleEndianBitsInBuffer (info.ptr, startBit, numBits);
10,000✔
760
    });
1✔
761

762
    // ============================================================================================ juce::MathConstants
763

764
    registerMathConstants<MathConstants, float, double> (m);
1✔
765

766
    // ============================================================================================ juce::Range<>
767

768
    registerRange<Range, int, GenericInteger<int64>, float> (m);
1✔
769

770
    // ============================================================================================ juce::NormalisableRange<>
771

772
    registerNormalisableRange<NormalisableRange, float> (m);
1✔
773

774
    // ============================================================================================ juce::Atomic
775

776
    registerAtomic<Atomic, bool, int, float> (m);
1✔
777

778
    // ============================================================================================ juce::Identifier
779

780
    py::class_<Identifier> classIdentifier (m, "Identifier");
2✔
781

782
    classIdentifier
783
        .def (py::init<>())
1✔
784
        .def (py::init<const String&>())
1✔
785
        .def (py::init<const Identifier&>())
1✔
786
        .def (py::self == py::self)
1✔
787
        .def (py::self != py::self)
1✔
788
        .def (py::self > py::self)
1✔
789
        .def (py::self >= py::self)
1✔
790
        .def (py::self < py::self)
1✔
791
        .def (py::self <= py::self)
1✔
792
        .def ("toString", &Identifier::toString)
1✔
793
        .def ("isValid", &Identifier::isValid)
1✔
794
        .def ("isNull", &Identifier::isNull)
1✔
795
        .def_static ("isValidIdentifier", &Identifier::isValidIdentifier)
1✔
796
        .def ("__repr__", Helpers::makeRepr<Identifier> (&Identifier::toString))
1✔
797
        .def ("__str__", &Identifier::toString)
1✔
798
    ;
799

800
    // ============================================================================================ juce::ByteOrder
801

802
    py::class_<ByteOrder> classByteOrder (m, "ByteOrder");
2✔
803

804
    classByteOrder
805
        .def_static ("swap", static_cast<uint16 (*)(uint16)> (&ByteOrder::swap))
1✔
806
        .def_static ("swap", static_cast<int16 (*)(int16)> (&ByteOrder::swap))
1✔
807
        .def_static ("swap", static_cast<uint32 (*)(uint32)> (&ByteOrder::swap))
1✔
808
        .def_static ("swap", static_cast<int32 (*)(int32)> (&ByteOrder::swap))
1✔
809
        .def_static ("swap", static_cast<uint64 (*)(uint64)> (&ByteOrder::swap))
1✔
810
        .def_static ("swap", static_cast<int64 (*)(int64)> (&ByteOrder::swap))
1✔
811
        .def_static ("swap", static_cast<float (*)(float)> (&ByteOrder::swap))
1✔
812
        .def_static ("swap", static_cast<double (*)(double)> (&ByteOrder::swap))
1✔
813
        .def_static ("littleEndianInt", [](py::buffer data)
2✔
814
        {
815
            auto info = data.request();
4✔
816
            if (static_cast <size_t> (info.size) < sizeof (int))
2✔
817
                py::pybind11_fail ("Insufficient bytes to construct an 32bit integer");
×
818
            return ByteOrder::littleEndianInt (info.ptr);
4✔
819
        })
1✔
820
        .def_static ("littleEndianInt64", [](py::buffer data)
2✔
821
        {
822
            auto info = data.request();
4✔
823
            if (static_cast <size_t> (info.size) < sizeof (int64))
2✔
824
                py::pybind11_fail ("Insufficient bytes to construct an 64bit integer");
×
825
            return ByteOrder::littleEndianInt64 (info.ptr);
4✔
826
        })
1✔
827
        .def_static ("littleEndianShort", [](py::buffer data)
2✔
828
        {
829
            auto info = data.request();
4✔
830
            if (static_cast <size_t> (info.size) < sizeof (short))
2✔
831
                py::pybind11_fail ("Insufficient bytes to construct an 16bit integer");
×
832
            return ByteOrder::littleEndianShort (info.ptr);
4✔
833
        })
1✔
834
        .def_static ("littleEndian24Bit", [](py::buffer data)
×
835
        {
836
            auto info = data.request();
×
837
            if (static_cast <size_t> (info.size) < sizeof (int8) * 3)
×
838
                py::pybind11_fail ("Insufficient bytes to construct an 24bit integer");
×
839
            return ByteOrder::littleEndian24Bit (info.ptr);
×
840
        })
1✔
841
    //.def_static ("littleEndian24BitToChars", &ByteOrder::littleEndian24BitToChars)
842
        .def_static ("bigEndianInt", [](py::buffer data)
2✔
843
        {
844
            auto info = data.request();
4✔
845
            if (static_cast <size_t> (info.size) < sizeof (int))
2✔
846
                py::pybind11_fail ("Insufficient bytes to construct an 32bit integer");
×
847
            return ByteOrder::bigEndianInt (info.ptr);
4✔
848
        })
1✔
849
        .def_static ("bigEndianInt64", [](py::buffer data)
2✔
850
        {
851
            auto info = data.request();
4✔
852
            if (static_cast <size_t> (info.size) < sizeof (int64))
2✔
853
                py::pybind11_fail ("Insufficient bytes to construct an 64bit integer");
×
854
            return ByteOrder::bigEndianInt64 (info.ptr);
4✔
855
        })
1✔
856
        .def_static ("bigEndianShort", [](py::buffer data)
2✔
857
        {
858
            auto info = data.request();
4✔
859
            if (static_cast <size_t> (info.size) < sizeof (short))
2✔
860
                py::pybind11_fail ("Insufficient bytes to construct an 16bit integer");
×
861
            return ByteOrder::bigEndianShort (info.ptr);
4✔
862
        })
1✔
863
        .def_static ("bigEndian24Bit", [](py::buffer data)
×
864
        {
865
            auto info = data.request();
×
866
            if (static_cast <size_t> (info.size) < sizeof (char) * 3)
×
867
                py::pybind11_fail ("Insufficient bytes to construct an 24bit integer");
×
868
            return ByteOrder::bigEndian24Bit (info.ptr);
×
869
        })
1✔
870
    //.def_static ("bigEndian24BitToChars", [](py::buffer data) { auto info = data.request(); return ByteOrder::bigEndian24BitToChars (info.ptr); })
871
        .def_static ("makeInt", static_cast<uint16 (*)(uint8, uint8)> (&ByteOrder::makeInt))
1✔
872
        .def_static ("makeInt", static_cast<uint32 (*)(uint8, uint8, uint8, uint8)> (&ByteOrder::makeInt))
1✔
873
        .def_static ("makeInt", static_cast<uint64 (*)(uint8, uint8, uint8, uint8, uint8, uint8, uint8, uint8)> (&ByteOrder::makeInt))
1✔
874
        .def_static ("isBigEndian", &ByteOrder::isBigEndian)
1✔
875
    ;
876

877
    // ============================================================================================ juce::StringArray
878

879
    py::class_<StringArray> classStringArray (m, "StringArray");
2✔
880

881
    classStringArray
882
        .def (py::init<>())
1✔
883
        .def (py::init<const String&>())
1✔
884
        .def (py::init<const StringArray&>())
1✔
885
        .def (py::init ([](const String& firstValue, py::args values)
×
886
        {
887
            auto result = StringArray();
1✔
888
            result.add (firstValue);
1✔
889

890
            for (auto value : values)
3✔
891
                result.add (static_cast<std::string> (value.cast<py::str>()).c_str());
2✔
892

893
            return result;
1✔
894
        }))
1✔
895
        .def (py::init ([](py::list values)
×
896
        {
897
            auto result = StringArray();
41✔
898

899
            for (auto value : values)
161✔
900
                result.add (static_cast<std::string> (value.cast<py::str>()).c_str());
120✔
901

902
            return result;
41✔
903
        }))
1✔
904
        .def ("swapWith", &StringArray::swapWith)
1✔
905
        .def (py::self == py::self)
1✔
906
        .def (py::self != py::self)
1✔
907
        .def ("__getitem__", [](const StringArray& self, int index) { return self[index]; })
78✔
908
        .def ("__setitem__", [](StringArray& self, int index, const String& value) { return self.set (index, value); })
1✔
909
        .def("__iter__", [](const StringArray& self)
4✔
910
        {
911
            return py::make_iterator (self.begin(), self.end());
4✔
912
        }, py::keep_alive<0, 1>())
1✔
913
        .def ("__len__", &StringArray::size)
1✔
914
        .def ("size", &StringArray::size)
1✔
915
        .def ("isEmpty", &StringArray::isEmpty)
1✔
916
        .def ("getReference", py::overload_cast<int> (&StringArray::getReference), py::return_value_policy::reference)
1✔
917
        .def ("contains", &StringArray::contains, "stringToLookFor"_a, "ignoreCase"_a = false)
1✔
918
        .def ("indexOf", &StringArray::indexOf, "stringToLookFor"_a, "ignoreCase"_a = false, "startIndex"_a = 0)
2✔
919
        .def ("add", &StringArray::add)
1✔
920
        .def ("insert", &StringArray::insert)
1✔
921
        .def ("addIfNotAlreadyThere", &StringArray::addIfNotAlreadyThere, "stringToAdd"_a, "ignoreCase"_a = false)
2✔
922
        .def ("set", &StringArray::set)
1✔
923
        .def ("addArray", [](StringArray& self, const StringArray& other, int startIndex, int numElementsToAdd)
1✔
924
        {
925
            self.addArray (other, startIndex, numElementsToAdd);
1✔
926
        }, "other"_a, "startIndex"_a = 0, "numElementsToAdd"_a = -1)
2✔
927
        .def ("addArray", [](StringArray& self, py::list other, int startIndex, int numElementsToAdd)
×
928
        {
929
            numElementsToAdd = numElementsToAdd < 0 ? static_cast<int> (other.size()) : (startIndex + numElementsToAdd);
×
930
            for (int i = startIndex; i < numElementsToAdd; ++i)
×
931
                self.add (static_cast<std::string> (other[static_cast<size_t> (i)].cast<py::str>()).c_str());
×
932
        }, "other"_a, "startIndex"_a = 0, "numElementsToAdd"_a = -1)
2✔
933
        .def ("mergeArray", &StringArray::mergeArray, "other"_a, "ignoreCase"_a = false)
2✔
934
        .def ("addTokens", py::overload_cast<StringRef, bool> (&StringArray::addTokens),
1✔
935
            "stringToTokenise"_a, "preserveQuotedStrings"_a)
2✔
936
        .def ("addTokens", py::overload_cast<StringRef, StringRef, StringRef> (&StringArray::addTokens),
1✔
937
            "stringToTokenise"_a, "breakCharacters"_a, "quoteCharacters"_a)
2✔
938
        .def ("addLines", &StringArray::addLines)
1✔
939
        .def_static ("fromTokens", static_cast<StringArray (*)(StringRef, bool)> (&StringArray::fromTokens),
×
940
            "stringToTokenise"_a, "preserveQuotedStrings"_a)
1✔
941
        .def_static ("fromTokens", static_cast<StringArray (*)(StringRef, StringRef, StringRef)> (&StringArray::fromTokens),
×
942
            "stringToTokenise"_a, "breakCharacters"_a, "quoteCharacters"_a)
1✔
943
        .def_static ("fromLines", &StringArray::fromLines)
1✔
944
        .def ("clear", &StringArray::clear)
1✔
945
        .def ("clearQuick", &StringArray::clearQuick)
1✔
946
        .def ("remove", &StringArray::remove)
1✔
947
        .def ("removeString", &StringArray::removeString, "stringToRemove"_a, "ignoreCase"_a = false)
2✔
948
        .def ("removeRange", &StringArray::removeRange)
1✔
949
        .def ("removeDuplicates", &StringArray::removeDuplicates)
1✔
950
        .def ("removeEmptyStrings", &StringArray::removeEmptyStrings, "removeWhitespaceStrings"_a = true)
2✔
951
        .def ("move", &StringArray::move)
1✔
952
        .def ("trim", &StringArray::trim)
1✔
953
        .def ("appendNumbersToDuplicates", [](StringArray& self, bool ignoreCaseWhenComparing, bool appendNumberToFirstInstance, const String* preNumberString, const String* postNumberString)
×
954
        {
955
            self.appendNumbersToDuplicates (ignoreCaseWhenComparing, appendNumberToFirstInstance,
×
956
                preNumberString != nullptr ? preNumberString->toUTF8() : CharPointer_UTF8(nullptr),
×
957
                postNumberString != nullptr ? postNumberString->toUTF8() : CharPointer_UTF8(nullptr));
×
958
        }, "ignoreCaseWhenComparing"_a, "appendNumberToFirstInstance"_a, "preNumberString"_a = static_cast<const String*> (nullptr), "postNumberString"_a = static_cast<const String*> (nullptr))
2✔
959
        .def ("joinIntoString", &StringArray::joinIntoString, "separatorString"_a, "startIndex"_a = 0, "numberOfElements"_a = -1)
2✔
960
        .def ("sort", &StringArray::sort, "ignoreCase"_a)
1✔
961
        .def ("sortNatural", &StringArray::sortNatural)
1✔
962
        .def ("ensureStorageAllocated", &StringArray::ensureStorageAllocated)
1✔
963
        .def ("minimiseStorageOverheads", &StringArray::minimiseStorageOverheads)
2✔
964
        .def_readwrite ("strings", &StringArray::strings)
1✔
965
    ;
966

967
    // ============================================================================================ juce::StringPairArray
968

969
    py::class_<StringPairArray> classStringPairArray (m, "StringPairArray");
2✔
970

971
    classStringPairArray
972
        .def (py::init<bool>(), "ignoreCaseWhenComparingKeys"_a = true)
1✔
973
        .def (py::init<const StringPairArray&>())
1✔
974
        .def (py::self == py::self)
1✔
975
        .def (py::self != py::self)
1✔
976
        .def ("__len__", &StringPairArray::size)
1✔
977
        .def ("__getitem__", [](const StringPairArray& self, StringRef key) { return self[ key]; }, "key"_a)
9✔
978
        .def ("getValue", &StringPairArray::getValue, "key"_a, "defaultReturnValue"_a)
1✔
979
        .def ("containsKey", &StringPairArray::containsKey)
1✔
980
        .def ("getAllKeys", &StringPairArray::getAllKeys)
1✔
981
        .def ("getAllValues", &StringPairArray::getAllValues)
1✔
982
        .def ("size", &StringPairArray::size)
1✔
983
        .def ("set", &StringPairArray::set, "key"_a, "value"_a)
1✔
984
        .def ("addArray", &StringPairArray::addArray, "other"_a)
1✔
985
        .def ("clear", &StringPairArray::clear)
1✔
986
        .def ("remove", py::overload_cast<StringRef> (&StringPairArray::remove), "key"_a)
1✔
987
        .def ("remove", py::overload_cast<int> (&StringPairArray::remove), "index"_a)
1✔
988
        .def ("setIgnoresCase", &StringPairArray::setIgnoresCase, "shouldIgnoreCase"_a)
1✔
989
        .def ("getIgnoresCase", &StringPairArray::getIgnoresCase)
1✔
990
        .def ("getDescription", &StringPairArray::getDescription)
1✔
991
        .def ("minimiseStorageOverheads", &StringPairArray::minimiseStorageOverheads)
1✔
992
        .def ("addMap", &StringPairArray::addMap)
1✔
993
        .def ("addUnorderedMap", &StringPairArray::addUnorderedMap)
1✔
994
    ;
995

996
    // ============================================================================================ juce::NamedValueSet
997

998
    py::class_<NamedValueSet> classNamedValueSet (m, "NamedValueSet");
2✔
999

1000
    py::class_<NamedValueSet::NamedValue> classNamedValueSetNamedValue (classNamedValueSet, "NamedValue");
2✔
1001

1002
    classNamedValueSetNamedValue
1003
        .def (py::init<>())
1✔
1004
        .def (py::init<const Identifier&, const var&>())
1✔
1005
        .def (py::init<const NamedValueSet::NamedValue&>())
1✔
1006
        .def (py::self == py::self)
1✔
1007
        .def (py::self != py::self)
1✔
1008
        .def_readwrite ("name", &NamedValueSet::NamedValue::name)
1✔
1009
        .def_readwrite ("value", &NamedValueSet::NamedValue::value)
1✔
1010
    ;
1011

1012
    classNamedValueSet
1013
        .def (py::init<>())
1✔
1014
        .def (py::init<const NamedValueSet&>())
1✔
1015
        .def (py::init ([](py::list list)
×
1016
        {
1017
            auto result = NamedValueSet();
3✔
1018

1019
            for (auto item : list)
12✔
1020
            {
1021
                py::detail::make_caster<NamedValueSet::NamedValue> conv;
9✔
1022

1023
                if (! conv.load (item, true))
9✔
1024
                    py::pybind11_fail("Invalid property type of a \"NamedValueSet\", needs to be \"NamedValueSet::NamedValue\"");
×
1025

1026
                auto namedValue = py::detail::cast_op<NamedValueSet::NamedValue&&> (std::move (conv));
18✔
1027

1028
                result.set(namedValue.name, namedValue.value);
9✔
1029
            }
1030

1031
            return result;
3✔
1032
        }))
1✔
1033
        .def (py::init ([](py::dict dict)
×
1034
        {
1035
            auto result = NamedValueSet();
15✔
1036

1037
            for (auto item : dict)
61✔
1038
            {
1039
                py::detail::make_caster<Identifier> convKey;
92✔
1040
                py::detail::make_caster<var> convValue;
92✔
1041

1042
                if (! convKey.load (item.first, true))
46✔
1043
                    py::pybind11_fail("Invalid property type of a \"NamedValueSet\", needs to be \"str\" or \"Identifier\"");
×
1044

1045
                if (! convValue.load (item.second, true))
46✔
1046
                    py::pybind11_fail("Invalid property type of a \"NamedValueSet\", needs to be a \"var\" convertible");
×
1047

1048
                result.set(
46✔
1049
                    py::detail::cast_op<juce::Identifier&&> (std::move (convKey)),
46✔
1050
                    py::detail::cast_op<juce::var&&> (std::move (convValue)));
46✔
1051
            }
1052

1053
            return result;
15✔
1054
        }))
1✔
1055
        .def (py::self == py::self)
1✔
1056
        .def (py::self != py::self)
1✔
1057
        .def("__iter__", [](const NamedValueSet& self)
×
1058
        {
1059
            return py::make_iterator (self.begin(), self.end());
×
1060
        }, py::keep_alive<0, 1>())
1✔
1061
        .def ("size", &NamedValueSet::size)
1✔
1062
        .def ("isEmpty", &NamedValueSet::isEmpty)
1✔
1063
        .def ("__getitem__", [](const NamedValueSet& self, const Identifier& name) { return self[name]; }, py::return_value_policy::reference)
8✔
1064
        .def ("__setitem__", [](NamedValueSet& self, const Identifier& name, juce::var value) { return self.set (name, std::move (value)); })
1✔
1065
        .def ("getWithDefault", &NamedValueSet::getWithDefault)
1✔
1066
        .def ("set", py::overload_cast<const Identifier&, const var&> (&NamedValueSet::set))
1✔
1067
        .def ("contains", &NamedValueSet::contains)
1✔
1068
        .def ("remove", &NamedValueSet::remove)
1✔
1069
        .def ("getName", &NamedValueSet::getName)
1✔
1070
        .def ("getVarPointer", py::overload_cast<const Identifier&> (&NamedValueSet::getVarPointer), py::return_value_policy::reference)
1✔
1071
        .def ("getValueAt", &NamedValueSet::getValueAt, py::return_value_policy::reference)
1✔
1072
        .def ("getVarPointerAt", py::overload_cast<int> (&NamedValueSet::getVarPointerAt), py::return_value_policy::reference)
1✔
1073
        .def ("indexOf", &NamedValueSet::indexOf)
1✔
1074
        .def ("clear", &NamedValueSet::clear)
1✔
1075
        .def ("setFromXmlAttributes", &NamedValueSet::setFromXmlAttributes)
1✔
1076
        .def ("copyToXmlAttributes", &NamedValueSet::copyToXmlAttributes)
1✔
1077
    ;
1078

1079
    // ============================================================================================ juce::BigInteger
1080

1081
    py::class_<BigInteger> classBigInteger (m, "BigInteger");
2✔
1082

1083
    classBigInteger
1084
        .def (py::init<>())
1✔
1085
        .def (py::init<int32>())
1✔
1086
        .def (py::init<int64>())
1✔
1087
        .def (py::init<const BigInteger&>())
1✔
1088
        .def ("swapWith", &BigInteger::swapWith)
1✔
1089
        .def ("isZero", &BigInteger::isZero)
1✔
1090
        .def ("isOne", &BigInteger::isOne)
1✔
1091
        .def ("toInteger", &BigInteger::toInteger)
1✔
1092
        .def ("toInt64", &BigInteger::toInt64)
1✔
1093
        .def ("clear", &BigInteger::clear, py::return_value_policy::reference)
1✔
1094
        .def ("clearBit", &BigInteger::clearBit, py::return_value_policy::reference)
1✔
1095
        .def ("setBit", py::overload_cast<int> (&BigInteger::setBit), py::return_value_policy::reference)
1✔
1096
        .def ("setBit", py::overload_cast<int, bool> (&BigInteger::setBit), py::return_value_policy::reference)
1✔
1097
        .def ("setRange", &BigInteger::setRange, py::return_value_policy::reference)
1✔
1098
        .def ("insertBit", &BigInteger::insertBit, py::return_value_policy::reference)
1✔
1099
        .def ("getBitRange", &BigInteger::getBitRange, py::return_value_policy::reference)
1✔
1100
        .def ("getBitRangeAsInt", &BigInteger::getBitRangeAsInt, py::return_value_policy::reference)
1✔
1101
        .def ("setBitRangeAsInt", &BigInteger::setBitRangeAsInt, py::return_value_policy::reference)
1✔
1102
        .def ("shiftBits", &BigInteger::shiftBits, py::return_value_policy::reference)
1✔
1103
        .def ("countNumberOfSetBits", &BigInteger::countNumberOfSetBits)
1✔
1104
        .def ("findNextSetBit", &BigInteger::findNextSetBit)
1✔
1105
        .def ("findNextClearBit", &BigInteger::findNextClearBit)
1✔
1106
        .def ("getHighestBit", &BigInteger::getHighestBit)
1✔
1107
        .def ("isNegative", &BigInteger::isNegative)
1✔
1108
        .def ("setNegative", &BigInteger::setNegative)
1✔
1109
        .def ("negate", &BigInteger::negate)
1✔
1110
        .def (py::self += py::self)
1✔
1111
        .def (py::self -= py::self)
1✔
1112
        .def (py::self *= py::self)
1✔
1113
        .def (py::self /= py::self)
1✔
1114
        .def (py::self |= py::self)
1✔
1115
        .def (py::self &= py::self)
1✔
1116
        .def (py::self ^= py::self)
1✔
1117
        .def (py::self %= py::self)
1✔
1118
        .def (py::self <<= int())
1✔
1119
        .def (py::self >>= int())
1✔
1120
        .def (-py::self)
1✔
1121
        .def (py::self + py::self)
1✔
1122
        .def (py::self - py::self)
1✔
1123
        .def (py::self * py::self)
1✔
1124
        .def (py::self / py::self)
1✔
1125
        .def (py::self | py::self)
1✔
1126
        .def (py::self & py::self)
1✔
1127
        .def (py::self ^ py::self)
1✔
1128
        .def (py::self % py::self)
1✔
1129
        .def (py::self << int())
1✔
1130
        .def (py::self >> int())
1✔
1131
        .def (py::self == py::self)
1✔
1132
        .def (py::self != py::self)
1✔
1133
        .def (py::self < py::self)
1✔
1134
        .def (py::self <= py::self)
1✔
1135
        .def (py::self > py::self)
1✔
1136
        .def (py::self >= py::self)
1✔
1137
        .def (py::self == int())
1✔
1138
        .def (py::self != int())
1✔
1139
        .def (py::self < int())
1✔
1140
        .def (py::self <= int())
1✔
1141
        .def (py::self > int())
1✔
1142
        .def (py::self >= int())
1✔
1143
        .def ("compare", &BigInteger::compare)
1✔
1144
        .def ("compareAbsolute", &BigInteger::compareAbsolute)
1✔
1145
        .def ("divideBy", &BigInteger::divideBy)
1✔
1146
        .def ("findGreatestCommonDivisor", &BigInteger::findGreatestCommonDivisor)
1✔
1147
        .def ("exponentModulo", &BigInteger::exponentModulo)
1✔
1148
        .def ("inverseModulo", &BigInteger::inverseModulo)
1✔
1149
        .def ("montgomeryMultiplication", &BigInteger::montgomeryMultiplication)
1✔
1150
        .def ("extendedEuclidean", &BigInteger::extendedEuclidean)
1✔
1151
        .def ("toString", &BigInteger::toString)
1✔
1152
        .def ("parseString", &BigInteger::parseString)
1✔
1153
        .def ("toMemoryBlock", &BigInteger::toMemoryBlock)
1✔
1154
        .def ("loadFromMemoryBlock", &BigInteger::loadFromMemoryBlock)
1✔
1155
        .def ("__repr__", [](const BigInteger& self)
×
1156
        {
1157
            String result;
×
1158
            result << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name()) << "('" << self.toString (16) << "')";
×
1159
            return result;
×
1160
        })
1✔
1161
        .def ("__str__", &BigInteger::toString)
1✔
1162
    ;
1163

1164
    // ============================================================================================ juce::Base64
1165

1166
    py::class_<Base64> classBase64 (m, "Base64");
2✔
1167

1168
    classBase64
1169
        .def_static ("convertToBase64", [](OutputStream& base64Result, py::buffer data)
1✔
1170
        {
1171
            auto info = data.request();
2✔
1172
            return Base64::convertToBase64 (base64Result, info.ptr, static_cast<size_t> (info.size));
2✔
1173
        })
1✔
1174
        .def_static ("convertFromBase64", &Base64::convertFromBase64)
1✔
1175
        .def_static ("toBase64", [](py::buffer data)
1✔
1176
        {
1177
            auto info = data.request();
2✔
1178
            return Base64::toBase64 (info.ptr, static_cast<size_t> (info.size));
2✔
1179
        })
1✔
1180
        .def_static ("toBase64", static_cast<String (*)(const String &)> (&Base64::toBase64))
1✔
1181
    ;
1182

1183
    // ============================================================================================ juce::Result
1184

1185
    py::class_<Result> classResult (m, "Result");
2✔
1186

1187
    classResult
1188
        .def (py::init<const Result&>())
1✔
1189
        .def_static ("ok", &Result::ok)
1✔
1190
        .def_static ("fail", &Result::fail)
1✔
1191
        .def ("wasOk", &Result::wasOk)
1✔
1192
        .def ("failed", &Result::failed)
1✔
1193
        .def ("getErrorMessage", &Result::getErrorMessage)
1✔
1194
        .def (py::self == py::self)
1✔
1195
        .def (py::self != py::self)
1✔
1196
        .def (!py::self)
1✔
1197
    ;
1198

1199
    // ============================================================================================ juce::Uuid
1200

1201
    py::class_<Uuid> classUuid (m, "Uuid");
2✔
1202

1203
    classUuid
1204
        .def (py::init<>())
1✔
1205
        .def (py::init<const Uuid&>())
1✔
1206
        .def (py::init ([](py::buffer data)
×
1207
        {
1208
            auto info = data.request();
8✔
1209

1210
            if (info.size != 16)
4✔
1211
                py::pybind11_fail ("Invalid length of bytes to construct a Uuid class, needs to be 16");
×
1212

1213
            return Uuid (static_cast<const uint8*> (info.ptr));
8✔
1214
        }))
1✔
1215
        .def (py::init<const String&>())
1✔
1216
        .def (py::init ([](py::object obj)
×
1217
        {
1218
            auto uuid = py::module_::import ("uuid").attr ("UUID");
2✔
1219
            if (! py::isinstance (obj, uuid))
1✔
1220
                py::pybind11_fail ("Invalid object to construct a Uuid class, only uuid.UUID is supported");
×
1221

1222
            auto buffer = obj.attr ("bytes").cast<py::bytes>();
1✔
1223
            return Uuid (reinterpret_cast<const uint8*> (static_cast<std::string_view> (buffer).data()));
2✔
1224
        }))
1✔
1225
        .def ("isNull", &Uuid::isNull)
1✔
1226
        .def_static ("null", &Uuid::null)
1✔
1227
        .def (py::self == py::self)
1✔
1228
        .def (py::self != py::self)
1✔
1229
        .def (py::self == String())
1✔
1230
        .def (py::self != String())
2✔
1231
        .def (py::self < py::self)
1✔
1232
        .def (py::self > py::self)
1✔
1233
        .def (py::self <= py::self)
1✔
1234
        .def (py::self >= py::self)
1✔
1235
        .def ("toString", &Uuid::toString)
1✔
1236
        .def ("toDashedString", &Uuid::toDashedString)
1✔
1237
        .def ("getTimeLow", &Uuid::getTimeLow)
1✔
1238
        .def ("getTimeMid", &Uuid::getTimeMid)
1✔
1239
        .def ("getTimeHighAndVersion", &Uuid::getTimeHighAndVersion)
1✔
1240
        .def ("getClockSeqAndReserved", &Uuid::getClockSeqAndReserved)
1✔
1241
        .def ("getClockSeqLow", &Uuid::getClockSeqLow)
1✔
1242
        .def ("getNode", &Uuid::getNode)
1✔
1243
        .def ("hash", &Uuid::hash)
1✔
1244
        .def ("getRawData", [](const Uuid& self)
2✔
1245
        {
1246
            return py::memoryview::from_memory (self.getRawData(), 16);
2✔
1247
        }, py::return_value_policy::reference_internal)
1✔
1248
        .def ("__repr__", [](const Uuid& self)
1✔
1249
        {
1250
            String result;
1✔
1251
            result << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name()) << "('{" << self.toDashedString () << "}')";
1✔
1252
            return result;
1✔
1253
        })
1✔
1254
        .def ("__str__", &Uuid::toDashedString)
1✔
1255
    ;
1256

1257
    // ============================================================================================ juce::RelativeTime
1258

1259
    py::class_<RelativeTime> classRelativeTime (m, "RelativeTime");
2✔
1260

1261
    classRelativeTime
1262
        .def (py::init<double>(), "seconds"_a = 0.0)
1✔
1263
        .def (py::init<const RelativeTime&>())
1✔
1264
        .def_static ("milliseconds", static_cast<RelativeTime (*)(int64)> (&RelativeTime::milliseconds))
1✔
1265
        .def_static ("seconds", &RelativeTime::seconds)
1✔
1266
        .def_static ("minutes", &RelativeTime::minutes)
1✔
1267
        .def_static ("hours", &RelativeTime::hours)
1✔
1268
        .def_static ("days", &RelativeTime::days)
1✔
1269
        .def_static ("weeks", &RelativeTime::weeks)
1✔
1270
        .def ("inMilliseconds", &RelativeTime::inMilliseconds)
1✔
1271
        .def ("inSeconds", &RelativeTime::inSeconds)
1✔
1272
        .def ("inMinutes", &RelativeTime::inMinutes)
1✔
1273
        .def ("inHours", &RelativeTime::inHours)
1✔
1274
        .def ("inDays", &RelativeTime::inDays)
1✔
1275
        .def ("inWeeks", &RelativeTime::inWeeks)
1✔
1276
        .def ("getDescription", &RelativeTime::getDescription, "returnValueForZeroTime"_a = "0")
2✔
1277
        .def ("getApproximateDescription", &RelativeTime::getApproximateDescription)
1✔
1278
        .def (py::self + py::self)
1✔
1279
        .def (py::self - py::self)
1✔
1280
        .def (py::self += py::self)
1✔
1281
        .def (py::self -= py::self)
1✔
1282
        .def (py::self += double())
1✔
1283
        .def (py::self -= double())
1✔
1284
        .def ("__repr__", [](const RelativeTime& self)
×
1285
        {
1286
            String result;
×
1287
            result << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name()) << "('" << self.getDescription() << "')";
×
1288
            return result;
×
1289
        })
1✔
1290
        .def ("__str__", [](const RelativeTime& self) { return self.getDescription(); })
1✔
1291
    ;
1292

1293
    // ============================================================================================ juce::Time
1294

1295
    py::class_<Time> classTime (m, "Time");
2✔
1296

1297
    classTime
1298
        .def (py::init<>())
1✔
1299
        .def (py::init<int64>())
1✔
1300
        .def (py::init<const Time&>())
1✔
1301
        .def (py::init<int, int, int, int, int, int, int, bool>(),
1✔
1302
            "year"_a, "month"_a, "day"_a, "hours"_a, "minutes"_a, "seconds"_a = 0, "milliseconds"_a = 0, "useLocalTime"_a = true)
3✔
1303
        .def_static ("getCurrentTime", &Time::getCurrentTime)
1✔
1304
        .def ("toMilliseconds", &Time::toMilliseconds)
1✔
1305
        .def ("getYear", &Time::getYear)
1✔
1306
        .def ("getMonth", &Time::getMonth)
1✔
1307
        .def ("getMonthName", py::overload_cast<bool> (&Time::getMonthName, py::const_))
1✔
1308
    //.def_static ("getMonthName", static_cast<String (*)(int, bool)> (&Time::getMonthName))
1309
        .def ("getDayOfMonth", &Time::getDayOfMonth)
1✔
1310
        .def ("getDayOfWeek", &Time::getDayOfWeek)
1✔
1311
        .def ("getDayOfYear", &Time::getDayOfYear)
1✔
1312
        .def ("getWeekdayName", py::overload_cast<bool> (&Time::getWeekdayName, py::const_))
1✔
1313
    //.def_static ("getWeekdayName", static_cast<String (*)(int, bool)> (&Time::getWeekdayName))
1314
        .def ("getHours", &Time::getHours)
1✔
1315
        .def ("isAfternoon", &Time::isAfternoon)
1✔
1316
        .def ("getHoursInAmPmFormat", &Time::getHoursInAmPmFormat)
1✔
1317
        .def ("getMinutes", &Time::getMinutes)
1✔
1318
        .def ("getSeconds", &Time::getSeconds)
1✔
1319
        .def ("getMilliseconds", &Time::getMilliseconds)
1✔
1320
        .def ("isDaylightSavingTime", &Time::isDaylightSavingTime)
1✔
1321
        .def ("getTimeZone", &Time::getTimeZone)
1✔
1322
        .def ("getUTCOffsetSeconds", &Time::getUTCOffsetSeconds)
1✔
1323
        .def ("getUTCOffsetString", &Time::getUTCOffsetString)
1✔
1324
        .def ("toString", &Time::toString, "includeDate"_a, "includeTime"_a, "includeSeconds"_a = true, "use24HourClock"_a = false)
2✔
1325
        .def ("formatted", &Time::formatted)
1✔
1326
        .def ("toISO8601", &Time::toISO8601, "includeDividerCharacters"_a)
1✔
1327
        .def_static ("fromISO8601", &Time::fromISO8601)
1✔
1328
        .def (py::self + RelativeTime())
2✔
1329
        .def (py::self - RelativeTime())
2✔
1330
        .def (py::self += RelativeTime())
2✔
1331
        .def (py::self -= RelativeTime())
2✔
1332
        .def ("setSystemTimeToThisTime", &Time::setSystemTimeToThisTime)
1✔
1333
        .def_static ("currentTimeMillis", &Time::currentTimeMillis)
1✔
1334
        .def_static ("getMillisecondCounter", &Time::getMillisecondCounter)
1✔
1335
        .def_static ("getMillisecondCounterHiRes", &Time::getMillisecondCounterHiRes)
1✔
1336
        .def_static ("waitForMillisecondCounter", &Time::waitForMillisecondCounter)
1✔
1337
        .def_static ("getApproximateMillisecondCounter", &Time::getApproximateMillisecondCounter)
1✔
1338
        .def_static ("getHighResolutionTicks", &Time::getHighResolutionTicks)
1✔
1339
        .def_static ("getHighResolutionTicksPerSecond", &Time::getHighResolutionTicksPerSecond)
1✔
1340
        .def_static ("highResolutionTicksToSeconds", &Time::highResolutionTicksToSeconds)
1✔
1341
        .def_static ("secondsToHighResolutionTicks", &Time::secondsToHighResolutionTicks)
1✔
1342
        .def_static ("getCompilationDate", &Time::getCompilationDate)
1✔
1343
        .def (py::self == py::self)
1✔
1344
        .def (py::self != py::self)
1✔
1345
        .def (py::self < py::self)
1✔
1346
        .def (py::self <= py::self)
1✔
1347
        .def (py::self > py::self)
1✔
1348
        .def (py::self >= py::self)
1✔
1349
        .def ("__repr__", [](const Time& self)
1✔
1350
        {
1351
            String result;
1✔
1352
            result << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name()) << "('" << self.toISO8601 (false) << "')";
1✔
1353
            return result;
1✔
1354
        })
1✔
1355
        .def ("__str__", [](const Time& self) { return self.toISO8601 (false); })
2✔
1356
    ;
1357

1358
    // ============================================================================================ juce::MemoryBlock
1359

1360
    py::class_<MemoryBlock> classMemoryBlock (m, "MemoryBlock");
2✔
1361

1362
    classMemoryBlock
1363
        .def (py::init<>())
1✔
1364
        .def (py::init<const size_t, bool>(), "initialSize"_a, "initialiseToZero"_a = false)
1✔
1365
        .def (py::init ([](py::list list)
×
1366
        {
1367
            auto mb = MemoryBlock (list.size());
22✔
1368

1369
            if (list.size() > 0)
22✔
1370
            {
1371
                char* data = reinterpret_cast<char*> (mb.getData());
22✔
1372

1373
                if (py::isinstance<py::int_> (list[0]))
22✔
1374
                    for (const auto& item : list)
107✔
1375
                        *data++ = static_cast<char> (item.cast<int>());
86✔
1376
                else
1377
                    for (const auto& item : list)
6✔
1378
                        *data++ = item.cast<char>();
5✔
1379
            }
1380

1381
            return mb;
22✔
1382
        }))
1✔
1383
        .def (py::init ([](py::buffer data)
×
1384
        {
1385
            auto info = data.request();
22✔
1386
            return MemoryBlock (info.ptr, static_cast<size_t> (info.size));
22✔
1387
        }))
1✔
1388
        .def (py::init<const MemoryBlock&>())
1✔
1389
        .def (py::self == py::self)
1✔
1390
        .def (py::self != py::self)
1✔
1391
        .def ("matches", Helpers::makeVoidPointerAndSizeCallable<MemoryBlock> (&MemoryBlock::matches))
1✔
1392
        .def ("getData", [](MemoryBlock* self)
22✔
1393
        {
1394
            return py::memoryview::from_memory (self->getData(), static_cast<Py_ssize_t> (self->getSize()));
22✔
1395
        }, py::return_value_policy::reference_internal)
1✔
1396
        .def ("getData", [](const MemoryBlock* self)
×
1397
        {
1398
            return py::memoryview::from_memory (self->getData(), static_cast<Py_ssize_t> (self->getSize()));
×
1399
        }, py::return_value_policy::reference_internal)
1✔
1400
        .def ("__getitem__", [](const MemoryBlock& self, int index) { return self[index]; })
4✔
1401
        .def ("__setitem__", [](MemoryBlock* self, int index, char value) { self->operator[] (index) = value; })
2✔
1402
        .def ("__setitem__", [](MemoryBlock* self, int index, int value) { self->operator[] (index) = static_cast<char> (value); })
2✔
1403
        .def ("isEmpty", &MemoryBlock::isEmpty)
1✔
1404
        .def ("getSize", &MemoryBlock::getSize)
1✔
1405
        .def ("setSize", &MemoryBlock::setSize, "newSize"_a, "initialiseNewSpaceToZero"_a = false)
2✔
1406
        .def ("ensureSize", &MemoryBlock::ensureSize, "newSize"_a, "initialiseNewSpaceToZero"_a = false)
2✔
1407
        .def ("reset", &MemoryBlock::reset)
1✔
1408
        .def ("fillWith", &MemoryBlock::fillWith)
1✔
1409
        .def ("append", Helpers::makeVoidPointerAndSizeCallable<MemoryBlock> (&MemoryBlock::append))
1✔
1410
        .def ("replaceAll", Helpers::makeVoidPointerAndSizeCallable<MemoryBlock> (&MemoryBlock::replaceAll))
1✔
1411
        .def ("insert", [](MemoryBlock* self, py::buffer data, size_t insertPosition)
1✔
1412
        {
1413
            auto info = data.request();
2✔
1414
            self->insert (info.ptr, static_cast<size_t> (info.size), insertPosition);
1✔
1415
        })
2✔
1416
        .def ("removeSection", &MemoryBlock::removeSection)
1✔
1417
        .def ("copyFrom", [](MemoryBlock* self, py::buffer data, int destinationOffset)
1✔
1418
        {
1419
            auto info = data.request();
2✔
1420
            self->copyFrom (info.ptr, destinationOffset, static_cast<size_t> (info.size));
1✔
1421
        })
2✔
1422
        .def ("copyTo", [](const MemoryBlock* self, py::buffer data, int sourceOffset)
1✔
1423
        {
1424
            auto info = data.request (true);
2✔
1425
            self->copyTo (info.ptr, sourceOffset, static_cast<size_t> (info.size));
1✔
1426
        })
2✔
1427
        .def ("swapWith", &MemoryBlock::swapWith)
1✔
1428
        .def ("toString", &MemoryBlock::toString)
1✔
1429
        .def ("loadFromHexString", &MemoryBlock::loadFromHexString)
1✔
1430
        .def ("setBitRange", &MemoryBlock::setBitRange)
1✔
1431
        .def ("getBitRange", &MemoryBlock::getBitRange)
1✔
1432
        .def ("toBase64Encoding", &MemoryBlock::toBase64Encoding)
1✔
1433
        .def ("fromBase64Encoding", &MemoryBlock::fromBase64Encoding)
1✔
1434
        .def ("__repr__", [](const MemoryBlock& self)
1✔
1435
        {
1436
            String result;
1✔
1437
            result << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name()) << "(b'";
1✔
1438

1439
            for (size_t index = 0; index < jmin (size_t (8), self.getSize()); ++index)
6✔
1440
                result << "\\x" << String::toHexString (self[index]).paddedLeft(L'0', 2);
5✔
1441

1442
            if (self.getSize() > 8)
1✔
1443
                result << "...";
×
1444

1445
            result << "')";
1✔
1446
            return result;
1✔
1447
        })
1✔
1448
        .def ("__str__", &MemoryBlock::toString)
1✔
1449
    ;
1450

1451
    // ============================================================================================ juce::InputStream
1452

1453
    py::class_<InputStream, PyInputStream<>> classInputStream (m, "InputStream");
2✔
1454

1455
    classInputStream
1456
        .def (py::init<>())
1✔
1457
        .def ("getTotalLength", &InputStream::getTotalLength)
1✔
1458
        .def ("getNumBytesRemaining", &InputStream::getNumBytesRemaining)
1✔
1459
        .def ("isExhausted", &InputStream::isExhausted)
1✔
1460
        .def ("read", [](InputStream& self, py::buffer data)
5✔
1461
        {
1462
            auto info = data.request(false);
10✔
1463
            return self.read (info.ptr, static_cast<size_t> (info.size));
10✔
1464
        }, "buffer"_a)
1✔
1465
        .def ("readByte", &InputStream::readByte)
1✔
1466
        .def ("readBool", &InputStream::readBool)
1✔
1467
        .def ("readShort", &InputStream::readShort)
1✔
1468
        .def ("readShortBigEndian", &InputStream::readShortBigEndian)
1✔
1469
        .def ("readInt", &InputStream::readInt)
1✔
1470
        .def ("readIntBigEndian", &InputStream::readIntBigEndian)
1✔
1471
        .def ("readInt64", &InputStream::readInt64)
1✔
1472
        .def ("readInt64BigEndian", &InputStream::readInt64BigEndian)
1✔
1473
        .def ("readFloat", &InputStream::readFloat)
1✔
1474
        .def ("readFloatBigEndian", &InputStream::readFloatBigEndian)
1✔
1475
        .def ("readDouble", &InputStream::readDouble)
1✔
1476
        .def ("readDoubleBigEndian", &InputStream::readDoubleBigEndian)
1✔
1477
        .def ("readCompressedInt", &InputStream::readCompressedInt)
1✔
1478
        .def ("readNextLine", &InputStream::readNextLine)
1✔
1479
        .def ("readString", &InputStream::readString)
1✔
1480
        .def ("readEntireStreamAsString", &InputStream::readEntireStreamAsString)
1✔
1481
        .def ("readIntoMemoryBlock", &InputStream::readIntoMemoryBlock, "destBlock"_a, "maxNumBytesToRead"_a = -1)
1✔
1482
        .def ("getPosition", &InputStream::getPosition)
1✔
1483
        .def ("setPosition", &InputStream::setPosition, "pos"_a)
1✔
1484
        .def ("skipNextBytes", &InputStream::skipNextBytes, "numBytesToSkip"_a)
1✔
1485
    ;
1486

1487
    py::class_<BufferedInputStream, InputStream, PyInputStream<BufferedInputStream>> classBufferedInputStream (m, "BufferedInputStream");
2✔
1488

1489
    classBufferedInputStream
1490
        .def (py::init<InputStream&, int>(), "sourceStream"_a, "bufferSize"_a)
1✔
1491
        .def ("peekByte", &BufferedInputStream::peekByte)
1✔
1492
    ;
1493

1494
    py::class_<MemoryInputStream, InputStream, PyInputStream<MemoryInputStream>> classMemoryInputStream (m, "MemoryInputStream");
2✔
1495

1496
    classMemoryInputStream
1497
        .def (py::init<const MemoryBlock&, bool>(), "data"_a, "keepInternalCopyOfData"_a)
1✔
1498
        .def (py::init ([](py::buffer data, bool keepInternalCopyOfData)
×
1499
        {
1500
            auto info = data.request();
28✔
1501
            return new MemoryInputStream (info.ptr, static_cast<size_t> (info.size), keepInternalCopyOfData);
56✔
1502
        }), "data"_a, "keepInternalCopyOfData"_a)
1✔
1503
        .def ("getData", [](const MemoryInputStream& self)
8✔
1504
        {
1505
            return py::memoryview::from_memory (self.getData(), static_cast<Py_ssize_t> (self.getDataSize()));
8✔
1506
        }, py::return_value_policy::reference_internal)
1✔
1507
        .def ("getDataSize", &MemoryInputStream::getDataSize)
1✔
1508
    ;
1509

1510
    py::class_<SubregionStream, InputStream, PyInputStream<SubregionStream>> classSubregionStream (m, "SubregionStream");
2✔
1511

1512
    classSubregionStream
1513
        .def (py::init<InputStream*, int64, int64, bool>(),
1✔
1514
            "sourceStream"_a, "startPositionInSourceStream"_a, "lengthOfSourceStream"_a, "deleteSourceWhenDestroyed"_a)
2✔
1515
    ;
1516

1517
    py::class_<GZIPDecompressorInputStream, InputStream, PyInputStream<GZIPDecompressorInputStream>> classGZIPDecompressorInputStream (m, "GZIPDecompressorInputStream");
2✔
1518

1519
    py::enum_<GZIPDecompressorInputStream::Format> (classGZIPDecompressorInputStream, "Format")
2✔
1520
        .value ("zlibFormat", GZIPDecompressorInputStream::Format::zlibFormat)
1✔
1521
        .value ("deflateFormat", GZIPDecompressorInputStream::Format::deflateFormat)
1✔
1522
        .value ("gzipFormat", GZIPDecompressorInputStream::Format::gzipFormat)
1✔
1523
        .export_values();
1✔
1524

1525
    classGZIPDecompressorInputStream
1526
        .def (py::init<InputStream*, bool, GZIPDecompressorInputStream::Format, int64>(),
1✔
1527
            "sourceStream"_a, "deleteSourceWhenDestroyed"_a = false, "sourceFormat"_a = GZIPDecompressorInputStream::zlibFormat, "uncompressedStreamLength"_a = -1)
3✔
1528
        .def (py::init<InputStream&>(), "sourceStream"_a)
1✔
1529
    ;
1530

1531
    // ============================================================================================ juce::InputSource
1532

1533
    py::class_<InputSource, PyInputSource<>> classInputSource (m, "InputSource");
2✔
1534

1535
    classInputSource
1536
        .def (py::init<>())
1✔
1537
        .def ("createInputStream", &InputSource::createInputStream)
1✔
1538
        .def ("createInputStreamFor", &InputSource::createInputStreamFor)
1✔
1539
        .def ("hashCode", &InputSource::hashCode)
1✔
1540
    ;
1541

1542
    // ============================================================================================ juce::OutputStream
1543

1544
    py::class_<OutputStream, PyOutputStream<>> classOutputStream (m, "OutputStream");
2✔
1545

1546
    classOutputStream
1547
        .def (py::init<>())
1✔
1548
        .def ("flush", &OutputStream::flush)
1✔
1549
        .def ("setPosition", &OutputStream::setPosition, "pos"_a)
1✔
1550
        .def ("getPosition", &OutputStream::getPosition)
1✔
1551
        .def ("write", popsicle::Helpers::makeVoidPointerAndSizeCallable<OutputStream> (&OutputStream::write))
1✔
1552
        .def ("writeByte", &OutputStream::writeByte)
1✔
1553
        .def ("writeBool", &OutputStream::writeBool)
1✔
1554
        .def ("writeShort", &OutputStream::writeShort)
1✔
1555
        .def ("writeShortBigEndian", &OutputStream::writeShortBigEndian)
1✔
1556
        .def ("writeInt", &OutputStream::writeInt)
1✔
1557
        .def ("writeIntBigEndian", &OutputStream::writeIntBigEndian)
1✔
1558
        .def ("writeInt64", &OutputStream::writeInt64)
1✔
1559
        .def ("writeInt64BigEndian", &OutputStream::writeInt64BigEndian)
1✔
1560
        .def ("writeFloat", &OutputStream::writeFloat)
1✔
1561
        .def ("writeFloatBigEndian", &OutputStream::writeFloatBigEndian)
1✔
1562
        .def ("writeDouble", &OutputStream::writeDouble)
1✔
1563
        .def ("writeDoubleBigEndian", &OutputStream::writeDoubleBigEndian)
1✔
1564
        .def ("writeRepeatedByte", &OutputStream::writeRepeatedByte)
1✔
1565
        .def ("writeCompressedInt", &OutputStream::writeCompressedInt)
1✔
1566
        .def ("writeString", &OutputStream::writeString)
1✔
1567
        .def ("writeText", &OutputStream::writeText)
1✔
1568
        .def ("writeFromInputStream", &OutputStream::writeFromInputStream)
1✔
1569
        .def ("setNewLineString", &OutputStream::setNewLineString)
1✔
1570
        .def ("getNewLineString", &OutputStream::getNewLineString, py::return_value_policy::reference_internal)
1✔
1571
    ;
1572

1573
    py::class_<MemoryOutputStream, OutputStream, PyOutputStream<MemoryOutputStream>> classMemoryOutputStream (m, "MemoryOutputStream");
2✔
1574

1575
    classMemoryOutputStream
1576
        .def (py::init<size_t>(), "initialSize"_a = 256)
1✔
1577
        .def (py::init<MemoryBlock&, bool>(), "memoryBlockToWriteTo"_a, "appendToExistingBlockContent"_a)
1✔
1578
        .def (py::init ([](py::buffer data)
×
1579
        {
1580
            auto info = data.request();
×
1581
            return new MemoryOutputStream (info.ptr, static_cast<size_t> (info.size));
×
1582
        }), "destBuffer"_a)
1✔
1583
        .def ("getData", [](const MemoryOutputStream* self)
×
1584
        {
1585
            return py::memoryview::from_memory (self->getData(), static_cast<Py_ssize_t> (self->getDataSize()));
×
1586
        }, py::return_value_policy::reference_internal)
1✔
1587
        .def ("getDataSize", &MemoryOutputStream::getDataSize)
1✔
1588
        .def ("reset", &MemoryOutputStream::reset)
1✔
1589
        .def ("preallocate", &MemoryOutputStream::preallocate, "bytesToPreallocate"_a)
1✔
1590
        .def ("appendUTF8Char", &MemoryOutputStream::appendUTF8Char, "c"_a)
1✔
1591
        .def ("toUTF8", &MemoryOutputStream::toUTF8)
1✔
1592
        .def ("toString", &MemoryOutputStream::toString)
1✔
1593
        .def ("getMemoryBlock", &MemoryOutputStream::getMemoryBlock)
1✔
1594
        .def ("flush", &MemoryOutputStream::flush)
1✔
1595
        .def ("__str__", &MemoryOutputStream::toString)
1✔
1596
    ;
1597

1598
    py::class_<GZIPCompressorOutputStream, OutputStream, PyOutputStream<GZIPCompressorOutputStream>> classGZIPCompressorOutputStream (m, "GZIPCompressorOutputStream");
2✔
1599

1600
    py::enum_<GZIPCompressorOutputStream::WindowBitsValues> (classGZIPCompressorOutputStream, "WindowBitsValues")
2✔
1601
        .value ("windowBitsRaw", GZIPCompressorOutputStream::WindowBitsValues::windowBitsRaw)
1✔
1602
        .value ("windowBitsGZIP", GZIPCompressorOutputStream::WindowBitsValues::windowBitsGZIP)
1✔
1603
        .export_values();
1✔
1604

1605
    classGZIPCompressorOutputStream
1606
        .def (py::init<OutputStream&, int, int>(), "destStream"_a, "compressionLevel"_a = -1, "windowBits"_a = 0)
2✔
1607
        .def (py::init<OutputStream*, int, bool, int>(), "destStream"_a, "compressionLevel"_a = -1, "deleteDestStreamWhenDestroyed"_a = false, "windowBits"_a = 0)
1✔
1608
    ;
1609

1610
    // ============================================================================================ juce::Random
1611

1612
    py::class_<Random> classRandom (m, "Random");
2✔
1613

1614
    classRandom
1615
        .def (py::init<>())
1✔
1616
        .def (py::init<int64>(), "seedValue"_a)
1✔
1617
        .def ("nextInt", py::overload_cast<> (&Random::nextInt))
1✔
1618
        .def ("nextInt", py::overload_cast<int> (&Random::nextInt), "maxValue"_a)
1✔
1619
        .def ("nextInt", py::overload_cast<Range<int>> (&Random::nextInt), "range"_a)
1✔
1620
        .def ("nextInt64", &Random::nextInt64)
1✔
1621
        .def ("nextFloat", &Random::nextFloat)
1✔
1622
        .def ("nextDouble", &Random::nextDouble)
1✔
1623
        .def ("nextBool", &Random::nextBool)
1✔
1624
        .def ("nextLargeNumber", &Random::nextLargeNumber, "maximumValue"_a)
1✔
1625
        .def ("fillBitsRandomly", [](Random& self, py::buffer data)
×
1626
        {
1627
            auto info = data.request (true);
×
1628
            self.fillBitsRandomly (info.ptr, static_cast<size_t> (info.size));
×
1629
        }, "bufferToFill"_a)
1✔
1630
        .def ("fillBitsRandomly", py::overload_cast<BigInteger&, int, int> (&Random::fillBitsRandomly), "arrayToChange"_a, "startBit"_a, "numBits"_a)
1✔
1631
        .def ("setSeed", &Random::setSeed, "newSeed"_a)
1✔
1632
        .def ("getSeed", &Random::getSeed)
1✔
1633
        .def ("combineSeed", &Random::combineSeed)
1✔
1634
        .def ("setSeedRandomly", &Random::setSeedRandomly)
1✔
1635
        .def_static ("getSystemRandom", &Random::getSystemRandom, py::return_value_policy::reference)
1✔
1636
    ;
1637

1638
    // ============================================================================================ juce::File
1639

1640
    py::class_<File> classFile (m, "File");
2✔
1641

1642
    py::enum_<File::SpecialLocationType> (classFile, "SpecialLocationType")
2✔
1643
        .value ("commonApplicationDataDirectory", File::SpecialLocationType::commonApplicationDataDirectory)
1✔
1644
        .value ("commonDocumentsDirectory", File::SpecialLocationType::commonDocumentsDirectory)
1✔
1645
        .value ("currentApplicationFile", File::SpecialLocationType::currentApplicationFile)
1✔
1646
        .value ("currentExecutableFile", File::SpecialLocationType::currentExecutableFile)
1✔
1647
        .value ("globalApplicationsDirectory", File::SpecialLocationType::globalApplicationsDirectory)
1✔
1648
        .value ("hostApplicationPath", File::SpecialLocationType::hostApplicationPath)
1✔
1649
        .value ("invokedExecutableFile", File::SpecialLocationType::invokedExecutableFile)
1✔
1650
        .value ("tempDirectory", File::SpecialLocationType::tempDirectory)
1✔
1651
        .value ("userApplicationDataDirectory", File::SpecialLocationType::userApplicationDataDirectory)
1✔
1652
        .value ("userDesktopDirectory", File::SpecialLocationType::userDesktopDirectory)
1✔
1653
        .value ("userDocumentsDirectory", File::SpecialLocationType::userDocumentsDirectory)
1✔
1654
        .value ("userHomeDirectory", File::SpecialLocationType::userHomeDirectory)
1✔
1655
        .value ("userMoviesDirectory", File::SpecialLocationType::userMoviesDirectory)
1✔
1656
        .value ("userMusicDirectory", File::SpecialLocationType::userMusicDirectory)
1✔
1657
        .value ("userPicturesDirectory", File::SpecialLocationType::userPicturesDirectory)
1✔
1658
        .export_values();
1✔
1659

1660
    py::enum_<File::TypesOfFileToFind> (classFile, "TypesOfFileToFind")
2✔
1661
        .value ("findDirectories", File::TypesOfFileToFind::findDirectories)
1✔
1662
        .value ("findFiles", File::TypesOfFileToFind::findFiles)
1✔
1663
        .value ("findFilesAndDirectories", File::TypesOfFileToFind::findFilesAndDirectories)
1✔
1664
        .value ("ignoreHiddenFiles", File::TypesOfFileToFind::ignoreHiddenFiles)
1✔
1665
        .export_values();
1✔
1666

1667
    py::enum_<File::FollowSymlinks> (classFile, "FollowSymlinks")
2✔
1668
        .value ("no", File::FollowSymlinks::no)
1✔
1669
        .value ("noCycles", File::FollowSymlinks::noCycles)
1✔
1670
        .value ("yes", File::FollowSymlinks::yes);
1✔
1671

1672
    classFile
1673
        .def (py::init<>())
1✔
1674
        .def (py::init<const String&>(), "absolutePath"_a)
1✔
1675
        .def (py::init<const File&>(), "other"_a)
1✔
1676
        .def ("exists", &File::exists)
1✔
1677
        .def ("existsAsFile", &File::existsAsFile)
1✔
1678
        .def ("isDirectory", &File::isDirectory)
1✔
1679
        .def ("isRoot", &File::isRoot)
1✔
1680
        .def ("getSize", &File::getSize)
1✔
1681
        .def_static ("descriptionOfSizeInBytes", &File::descriptionOfSizeInBytes, "bytes"_a)
1✔
1682
        .def ("getFullPathName", &File::getFullPathName)
1✔
1683
        .def ("getFileName", &File::getFileName)
1✔
1684
        .def ("getRelativePathFrom", &File::getRelativePathFrom, "directoryToBeRelativeTo"_a)
1✔
1685
        .def ("getFileExtension", &File::getFileExtension)
1✔
1686
        .def ("hasFileExtension", &File::hasFileExtension, "extensionToTest"_a)
1✔
1687
        .def ("withFileExtension", &File::withFileExtension, "newExtension"_a)
1✔
1688
        .def ("getFileNameWithoutExtension", &File::getFileNameWithoutExtension)
1✔
1689
        .def ("hashCode", &File::hashCode)
1✔
1690
        .def ("hashCode64", &File::hashCode64)
1✔
1691
        .def ("getChildFile", &File::getChildFile, "relativeOrAbsolutePath"_a)
1✔
1692
        .def ("getSiblingFile", &File::getSiblingFile, "siblingFileName"_a)
1✔
1693
        .def ("getParentDirectory", &File::getParentDirectory)
1✔
1694
        .def ("isAChildOf", &File::isAChildOf, "potentialParentDirectory"_a)
1✔
1695
        .def ("getNonexistentChildFile", &File::getNonexistentChildFile, "prefix"_a, "suffix"_a, "putNumbersInBrackets"_a = true)
1✔
1696
        .def ("getNonexistentSibling", &File::getNonexistentSibling, "putNumbersInBrackets"_a = true)
2✔
1697
        .def (py::self == py::self)
1✔
1698
        .def (py::self != py::self)
1✔
1699
        .def (py::self < py::self)
1✔
1700
        .def (py::self > py::self)
1✔
1701
        .def ("hasWriteAccess", &File::hasWriteAccess)
1✔
1702
        .def ("hasReadAccess", &File::hasReadAccess)
1✔
1703
        .def ("setReadOnly", &File::setReadOnly, "shouldBeReadOnly"_a, "applyRecursively"_a = false)
2✔
1704
        .def ("setExecutePermission", &File::setExecutePermission, "shouldBeExecutable"_a)
1✔
1705
        .def ("isHidden", &File::isHidden)
1✔
1706
        .def ("getFileIdentifier", &File::getFileIdentifier)
1✔
1707
        .def ("getLastModificationTime", &File::getLastModificationTime)
1✔
1708
        .def ("getLastAccessTime", &File::getLastAccessTime)
1✔
1709
        .def ("getCreationTime", &File::getCreationTime)
1✔
1710
        .def ("setLastModificationTime", &File::setLastModificationTime, "newTime"_a)
1✔
1711
        .def ("setLastAccessTime", &File::setLastAccessTime, "newTime"_a)
1✔
1712
        .def ("setCreationTime", &File::setCreationTime, "newTime"_a)
1✔
1713
        .def ("getVersion", &File::getVersion)
1✔
1714
        .def ("create", &File::create)
1✔
1715
        .def ("createDirectory", &File::createDirectory)
1✔
1716
        .def ("deleteFile", &File::deleteFile)
1✔
1717
        .def ("deleteRecursively", &File::deleteRecursively, "followSymlinks"_a = false)
2✔
1718
        .def ("moveToTrash", &File::moveToTrash)
1✔
1719
        .def ("moveFileTo", &File::moveFileTo, "targetLocation"_a)
1✔
1720
        .def ("copyFileTo", &File::copyFileTo, "targetLocation"_a)
1✔
1721
        .def ("replaceFileIn", &File::replaceFileIn, "targetLocation"_a)
1✔
1722
        .def ("copyDirectoryTo", &File::copyDirectoryTo, "newDirectory"_a)
1✔
1723
        .def ("findChildFiles", py::overload_cast<int, bool, const String &, File::FollowSymlinks> (&File::findChildFiles, py::const_),
1✔
1724
            "whatToLookFor"_a, "searchRecursively"_a, "wildCardPattern"_a = "*", "followSymlinks"_a = File::FollowSymlinks::yes)
3✔
1725
        .def ("findChildFiles", py::overload_cast<Array<File>&, int, bool, const String &, File::FollowSymlinks> (&File::findChildFiles, py::const_),
1✔
1726
             "results"_a, "whatToLookFor"_a, "searchRecursively"_a, "wildCardPattern"_a = "*", "followSymlinks"_a = File::FollowSymlinks::yes)
3✔
1727
        .def ("getNumberOfChildFiles", &File::getNumberOfChildFiles, "whatToLookFor"_a, "wildCardPattern"_a = "*")
2✔
1728
        .def ("containsSubDirectories", &File::containsSubDirectories)
1✔
1729
        .def ("createInputStream", &File::createInputStream)
1✔
1730
        .def ("createOutputStream", &File::createOutputStream, "bufferSize"_a = 0x8000)
2✔
1731
        .def ("loadFileAsData", &File::loadFileAsData, "result"_a)
1✔
1732
        .def ("loadFileAsString", &File::loadFileAsString)
1✔
1733
        .def ("readLines", &File::readLines, "destLines"_a)
1✔
1734
        .def ("appendData", [](const File& self, py::buffer data)
2✔
1735
        {
1736
            auto info = data.request();
4✔
1737
            return self.appendData (info.ptr, static_cast<size_t> (info.size));
4✔
1738
        }, "dataToAppend"_a)
1✔
1739
        .def ("replaceWithData", [](const File& self, py::buffer data)
4✔
1740
        {
1741
            auto info = data.request();
8✔
1742
            return self.replaceWithData (info.ptr, static_cast<size_t> (info.size));
8✔
1743
        }, "dataToWrite"_a)
1✔
1744
        .def ("appendText", &File::appendText,
×
1745
            "textToAppend"_a, "asUnicode"_a = false, "writeUnicodeHeaderBytes"_a = false, "lineEndings"_a = "\r\n")
2✔
1746
        .def ("replaceWithText", &File::replaceWithText,
×
1747
            "textToWrite"_a, "asUnicode"_a = false, "writeUnicodeHeaderBytes"_a = false, "lineEndings"_a = "\r\n")
2✔
1748
        .def ("hasIdenticalContentTo", &File::hasIdenticalContentTo, "other"_a)
1✔
1749
        .def_static ("findFileSystemRoots", &File::findFileSystemRoots)
1✔
1750
        .def ("getVolumeLabel", &File::getVolumeLabel)
1✔
1751
        .def ("getVolumeSerialNumber", &File::getVolumeSerialNumber)
1✔
1752
        .def ("getBytesFreeOnVolume", &File::getBytesFreeOnVolume)
1✔
1753
        .def ("getVolumeTotalSize", &File::getVolumeTotalSize)
1✔
1754
        .def ("isOnCDRomDrive", &File::isOnCDRomDrive)
1✔
1755
        .def ("isOnHardDisk", &File::isOnHardDisk)
1✔
1756
        .def ("isOnRemovableDrive", &File::isOnRemovableDrive)
1✔
1757
        .def ("startAsProcess", &File::startAsProcess, "parameters"_a = String())
2✔
1758
        .def ("revealToUser", &File::revealToUser)
1✔
1759
        .def_static ("getSpecialLocation", &File::getSpecialLocation, "type"_a)
1✔
1760
        .def_static ("createTempFile", &File::createTempFile, "fileNameEnding"_a)
1✔
1761
        .def_static ("getCurrentWorkingDirectory", &File::getCurrentWorkingDirectory)
1✔
1762
        .def ("setAsCurrentWorkingDirectory", &File::setAsCurrentWorkingDirectory)
1✔
1763
        .def_static ("getSeparatorChar", [] { return static_cast<uint32> (File::getSeparatorChar()); })
2✔
1764
        .def_static ("getSeparatorString", &File::getSeparatorString)
1✔
1765
        .def_static ("createLegalFileName", &File::createLegalFileName, "fileNameToFix"_a)
1✔
1766
        .def_static ("createLegalPathName", &File::createLegalPathName, "pathNameToFix"_a)
1✔
1767
        .def_static ("areFileNamesCaseSensitive", &File::areFileNamesCaseSensitive)
1✔
1768
        .def_static ("isAbsolutePath", &File::isAbsolutePath, "path"_a)
1✔
1769
        .def_static ("createFileWithoutCheckingPath", &File::createFileWithoutCheckingPath, "absolutePath"_a)
1✔
1770
        .def_static ("addTrailingSeparator", &File::addTrailingSeparator, "path"_a)
1✔
1771
        .def ("createSymbolicLink", py::overload_cast<const File&, bool> (&File::createSymbolicLink, py::const_), "linkFileToCreate"_a, "overwriteExisting"_a)
1✔
1772
    //.def_static ("createSymbolicLink", [](const File& linkFileToCreate, const String& nativePathOfTarget, bool overwriteExisting) {
1773
    //    return File::createSymbolicLink (linkFileToCreate, nativePathOfTarget, overwriteExisting);
1774
    //}, "linkFileToCreate"_a, "nativePathOfTarget"_a, "overwriteExisting"_a)
1775
        .def ("isSymbolicLink", &File::isSymbolicLink)
1✔
1776
        .def ("getLinkedTarget", &File::getLinkedTarget)
1✔
1777
        .def ("getNativeLinkedTarget", &File::getNativeLinkedTarget)
1✔
1778
#if JUCE_WINDOWS
1779
        .def ("createShortcut", &File::createShortcut, "description"_a, "linkFileToCreate"_a)
1780
        .def ("isShortcut", &File::isShortcut)
1781
#elif JUCE_MAC
1782
        .def ("getMacOSType", &File::getMacOSType)
1783
        .def ("isBundle", &File::isBundle)
1784
        .def ("addToDock", &File::addToDock)
1785
        .def_static ("getContainerForSecurityApplicationGroupIdentifier", &File::getContainerForSecurityApplicationGroupIdentifier, "appGroup"_a)
1786
#endif
1787
        .def ("__repr__", [](const File& self)
2✔
1788
        {
1789
            String result;
2✔
1790
            result << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name()) << "('" << self.getFullPathName() << "')";
2✔
1791
            return result;
2✔
1792
        })
1✔
1793
    ;
1794

1795
    // ============================================================================================ juce::File*Stream
1796

1797
    py::class_<FileInputStream, InputStream, PyInputStream<FileInputStream>> classFileInputStream (m, "FileInputStream");
2✔
1798

1799
    classFileInputStream
1800
        .def (py::init<const File&>(), "fileToRead"_a)
1✔
1801
        .def ("getFile", &FileInputStream::getFile, py::return_value_policy::reference_internal)
1✔
1802
        .def ("getStatus", &FileInputStream::getStatus, py::return_value_policy::reference_internal)
1✔
1803
        .def ("failedToOpen", &FileInputStream::failedToOpen)
1✔
1804
        .def ("openedOk", &FileInputStream::openedOk)
1✔
1805
    ;
1806

1807
    py::class_<FileInputSource, InputSource> classFileInputSource (m, "FileInputSource");
2✔
1808

1809
    classFileInputSource
1810
        .def (py::init<const File&, bool>(), "file"_a, "useFileTimeInHashGeneration"_a = false)
1✔
1811
    ;
1812

1813
    py::class_<FileOutputStream, OutputStream, PyOutputStream<FileOutputStream>> classFileOutputStream (m, "FileOutputStream");
2✔
1814

1815
    classFileOutputStream
1816
        .def (py::init<const File&, size_t>(), "fileToWriteTo"_a, "bufferSizeToUse"_a = 16384)
1✔
1817
        .def ("getFile", &FileOutputStream::getFile, py::return_value_policy::reference_internal)
1✔
1818
        .def ("getStatus", &FileOutputStream::getStatus, py::return_value_policy::reference_internal)
1✔
1819
        .def ("failedToOpen", &FileOutputStream::failedToOpen)
1✔
1820
        .def ("openedOk", &FileOutputStream::openedOk)
1✔
1821
        .def ("truncate", &FileOutputStream::truncate)
1✔
1822
    ;
1823

1824
    // ============================================================================================ juce::MemoryMappedFile
1825

1826
    py::class_<MemoryMappedFile> classMemoryMappedFile (m, "MemoryMappedFile");
2✔
1827

1828
    py::enum_<MemoryMappedFile::AccessMode> (classMemoryMappedFile, "AccessMode")
2✔
1829
        .value ("readOnly", MemoryMappedFile::AccessMode::readOnly)
1✔
1830
        .value ("readWrite", MemoryMappedFile::AccessMode::readWrite)
1✔
1831
        .export_values();
1✔
1832

1833
    classMemoryMappedFile
1834
        .def (py::init<const File&, MemoryMappedFile::AccessMode, bool>(), "file"_a, "mode"_a, "exclusive"_a = false)
1✔
1835
        .def (py::init<const File&, const Range<int64>&, MemoryMappedFile::AccessMode, bool>(), "file"_a, "fileRange"_a, "mode"_a, "exclusive"_a = false)
2✔
1836
        .def ("getData", [](const MemoryMappedFile& self) -> std::optional<py::memoryview>
7✔
1837
        {
1838
            if (self.getData() == nullptr)
7✔
1839
                return std::nullopt;
1✔
1840

1841
            return py::memoryview::from_memory (self.getData(), static_cast<Py_ssize_t> (self.getSize()));
12✔
1842
        }, py::return_value_policy::reference_internal)
1✔
1843
        .def ("getSize", &MemoryMappedFile::getSize)
1✔
1844
        .def ("getRange", &MemoryMappedFile::getRange)
1✔
1845
    ;
1846

1847
    // ============================================================================================ juce::FileFilter
1848

1849
    py::class_<FileSearchPath> classFileSearchPath (m, "FileSearchPath");
2✔
1850

1851
    classFileSearchPath
1852
        .def (py::init<>())
1✔
1853
        .def (py::init<const String&>())
1✔
1854
        .def ("getNumPaths", &FileSearchPath::getNumPaths)
1✔
1855
        .def ("__getitem__", [](const FileSearchPath& self, int index) { return self[index]; })
1✔
1856
        .def ("getRawString", &FileSearchPath::getRawString)
1✔
1857
        .def ("toString", &FileSearchPath::toString)
1✔
1858
        .def ("toStringWithSeparator", &FileSearchPath::toStringWithSeparator)
1✔
1859
        .def ("add", &FileSearchPath::add)
1✔
1860
        .def ("addIfNotAlreadyThere", &FileSearchPath::addIfNotAlreadyThere)
1✔
1861
        .def ("remove", &FileSearchPath::remove)
1✔
1862
        .def ("addPath", &FileSearchPath::addPath)
1✔
1863
        .def ("removeRedundantPaths", &FileSearchPath::removeRedundantPaths)
1✔
1864
        .def ("removeNonExistentPaths", &FileSearchPath::removeNonExistentPaths)
1✔
1865
        .def ("findChildFiles", py::overload_cast<int, bool, const String&> (&FileSearchPath::findChildFiles, py::const_),
1✔
1866
            "whatToLookFor"_a, "searchRecursively"_a, "wildCardPattern"_a = "*")
2✔
1867
        //.def ("findChildFiles", [](const FileSearchPath& self, int whatToLookFor, bool searchRecursively, const String& wildCardPattern)
1868
        //{
1869
        //}, "whatToLookFor"_a, "searchRecursively"_a, "wildCardPattern"_a = "*")
1870
        .def ("isFileInPath", &FileSearchPath::isFileInPath)
1✔
1871
    ;
1872

1873
    // ============================================================================================ juce::FileFilter
1874

1875
    py::class_<FileFilter, PyFileFilter<>> classFileFilter (m, "FileFilter");
2✔
1876

1877
    classFileFilter
1878
        .def (py::init<const String&>())
1✔
1879
        .def ("getDescription", &FileFilter::getDescription, py::return_value_policy::reference_internal)
1✔
1880
        .def ("isFileSuitable", &FileFilter::isFileSuitable)
1✔
1881
        .def ("isDirectorySuitable", &FileFilter::isDirectorySuitable)
1✔
1882
    ;
1883

1884
    py::class_<WildcardFileFilter, FileFilter, PyFileFilter<WildcardFileFilter>> classWildcardFileFilter (m, "WildcardFileFilter");
2✔
1885

1886
    classWildcardFileFilter
1887
        .def (py::init<const String&, const String&, const String&>())
1✔
1888
    ;
1889

1890
    // ============================================================================================ juce::TemporaryFile
1891

1892
    py::class_<TemporaryFile> classTemporaryFile (m, "TemporaryFile");
2✔
1893

1894
    py::enum_<TemporaryFile::OptionFlags> (classTemporaryFile, "OptionFlags", py::arithmetic())
2✔
1895
        .value ("useHiddenFile", TemporaryFile::OptionFlags::useHiddenFile)
1✔
1896
        .value ("putNumbersInBrackets", TemporaryFile::OptionFlags::putNumbersInBrackets)
1✔
1897
        .export_values();
1✔
1898

1899
    classTemporaryFile
1900
        .def (py::init<const String&, int>(), "suffix"_a = String(), "optionFlags"_a = 0)
2✔
1901
        .def (py::init<const File&, int>(), "targetFile"_a, "optionFlags"_a = 0)
2✔
1902
        .def (py::init<const File&, const File&>(), "targetFile"_a, "temporaryFile"_a)
1✔
1903
        .def ("getFile", &TemporaryFile::getFile)
1✔
1904
        .def ("getTargetFile", &TemporaryFile::getTargetFile)
1✔
1905
        .def ("overwriteTargetFileWithTemporary", &TemporaryFile::overwriteTargetFileWithTemporary)
1✔
1906
        .def ("deleteTemporaryFile", &TemporaryFile::deleteTemporaryFile)
1✔
1907
        .def ("__enter__", [](TemporaryFile& self)
1✔
1908
        {
1909
            return std::addressof(self);
1✔
1910
        }, py::return_value_policy::reference)
1✔
1911
        .def ("__exit__", [](TemporaryFile& self, const std::optional<py::type>&, const std::optional<py::object>&, const std::optional<py::object>&)
1✔
1912
        {
1913
            self.overwriteTargetFileWithTemporary();
1✔
1914
        })
1✔
1915
    ;
1916

1917
    // ============================================================================================ juce::URL
1918

1919
    py::class_<DirectoryEntry> classDirectoryEntry (m, "DirectoryEntry");
2✔
1920

1921
    classDirectoryEntry
1922
        .def (py::init<>())
1✔
1923
        .def ("getFile", &DirectoryEntry::getFile)
1✔
1924
        .def ("getModificationTime", &DirectoryEntry::getModificationTime)
1✔
1925
        .def ("getCreationTime", &DirectoryEntry::getCreationTime)
1✔
1926
        .def ("getFileSize", &DirectoryEntry::getFileSize)
1✔
1927
        .def ("isDirectory", &DirectoryEntry::isDirectory)
1✔
1928
        .def ("isHidden", &DirectoryEntry::isHidden)
1✔
1929
        .def ("isReadOnly", &DirectoryEntry::isReadOnly)
1✔
1930
        .def ("getEstimatedProgress", &DirectoryEntry::getEstimatedProgress)
1✔
1931
    ;
1932

1933
    py::class_<RangedDirectoryIterator> classRangedDirectoryIterator (m, "RangedDirectoryIterator");
2✔
1934

1935
    classRangedDirectoryIterator
1936
        .def (py::init<>())
1✔
1937
        .def (py::init<const File&, bool, const String&, int, File::FollowSymlinks>(),
1✔
1938
            "directory"_a, "isRecursive"_a, "wildCard"_a = "*", "whatToLookFor"_a = File::findFiles, "followSymlinks"_a = File::FollowSymlinks::yes)
3✔
1939
        .def (py::self == py::self)
1✔
1940
        .def (py::self != py::self)
1✔
1941
        .def ("__iter__", [](const RangedDirectoryIterator& self)
2✔
1942
        {
1943
            return py::make_iterator (begin (self), end (self));
4✔
1944
        }, py::keep_alive<0, 1>())
1✔
1945
    ;
1946

1947
    // ============================================================================================ juce::JSON
1948

1949
    py::class_<JSON> classJSON (m, "JSON");
2✔
1950

1951
    py::enum_<JSON::Spacing> (classJSON, "Spacing")
2✔
1952
        .value ("none", JSON::Spacing::none)
1✔
1953
        .value ("singleLine", JSON::Spacing::singleLine)
1✔
1954
        .value ("multiLine", JSON::Spacing::multiLine);
1✔
1955

1956
    py::class_<JSON::FormatOptions> classJSONFormatOptions (classJSON, "FormatOptions");
2✔
1957

1958
    classJSONFormatOptions
1959
        .def (py::init<>())
1✔
1960
        .def ("withSpacing", &JSON::FormatOptions::withSpacing)
1✔
1961
        .def ("withMaxDecimalPlaces", &JSON::FormatOptions::withMaxDecimalPlaces)
1✔
1962
        .def ("withIndentLevel", &JSON::FormatOptions::withIndentLevel)
1✔
1963
        .def ("getSpacing", &JSON::FormatOptions::getSpacing)
1✔
1964
        .def ("getMaxDecimalPlaces", &JSON::FormatOptions::getMaxDecimalPlaces)
1✔
1965
        .def ("getIndentLevel", &JSON::FormatOptions::getIndentLevel)
1✔
1966
    ;
1967

1968
    classJSON
1969
        .def_static ("parse", static_cast<Result (*)(const String&, var&)> (&JSON::parse))
1✔
1970
        .def_static ("parse", static_cast<var (*)(const String&)> (&JSON::parse))
1✔
1971
        .def_static ("parse", static_cast<var (*)(const File&)> (&JSON::parse))
1✔
1972
        .def_static ("parse", static_cast<var (*)(InputStream&)> (&JSON::parse))
1✔
NEW
1973
        .def_static ("toString", static_cast<String (*)(const var&, bool, int)> (&JSON::toString),
×
1974
            "objectToFormat"_a, "allOnOneLine"_a = false, "maximumDecimalPlaces"_a = 15)
2✔
1975
        .def_static ("toString", static_cast<String (*)(const var&, const JSON::FormatOptions&)> (&JSON::toString))
1✔
1976
        .def_static ("fromString", &JSON::fromString)
1✔
NEW
1977
        .def_static ("writeToStream", static_cast<void (*)(OutputStream&, const var&, bool, int)> (&JSON::writeToStream),
×
1978
            "output"_a, "objectToFormat"_a, "allOnOneLine"_a = false, "maximumDecimalPlaces"_a = 15)
2✔
1979
        .def_static ("writeToStream", static_cast<void (*)(OutputStream&, const var&, const JSON::FormatOptions&)> (&JSON::writeToStream))
1✔
1980
        .def_static ("escapeString", &JSON::escapeString)
1✔
1981
    //.def_static ("parseQuotedString", &JSON::parseQuotedString)
1982
    ;
1983

1984
    // ============================================================================================ juce::URL
1985

1986
    py::class_<URL> classURL (m, "URL");
2✔
1987

1988
    py::enum_<URL::ParameterHandling> (classURL, "ParameterHandling")
2✔
1989
        .value ("inAddress", URL::ParameterHandling::inAddress)
1✔
1990
        .value ("inPostData", URL::ParameterHandling::inPostData);
1✔
1991

1992
    classURL
1993
        .def (py::init<>())
1✔
1994
        .def (py::init<const String&>())
1✔
1995
        .def (py::init<File>())
1✔
1996
        .def (py::self == py::self)
1✔
1997
        .def (py::self != py::self)
1✔
1998
        .def ("toString", &URL::toString, "includeGetParameters"_a)
1✔
1999
        .def ("isEmpty", &URL::isEmpty)
1✔
2000
        .def ("isWellFormed", &URL::isWellFormed)
1✔
2001
        .def ("getDomain", &URL::getDomain)
1✔
2002
        .def ("getSubPath", &URL::getSubPath)
1✔
2003
        .def ("getQueryString", &URL::getQueryString)
1✔
2004
        .def ("getAnchorString", &URL::getAnchorString)
1✔
2005
        .def ("getScheme", &URL::getScheme)
1✔
2006
        .def ("isLocalFile", &URL::isLocalFile)
1✔
2007
        .def ("getLocalFile", &URL::getLocalFile)
1✔
2008
        .def ("getFileName", &URL::getFileName)
1✔
2009
        .def ("getPort", &URL::getPort)
1✔
2010
        .def ("withNewDomainAndPath", &URL::withNewDomainAndPath)
1✔
2011
        .def ("withNewSubPath", &URL::withNewSubPath)
1✔
2012
        .def ("getParentURL", &URL::getParentURL)
1✔
2013
        .def ("getChildURL", &URL::getChildURL)
1✔
2014
        .def ("withParameter", &URL::withParameter)
1✔
2015
        .def ("withParameters", &URL::withParameters)
1✔
2016
        .def ("withAnchor", &URL::withAnchor)
1✔
2017
        .def ("withFileToUpload", &URL::withFileToUpload)
1✔
2018
        .def ("withDataToUpload", &URL::withDataToUpload)
1✔
2019
        .def ("getParameterNames", &URL::getParameterNames)
1✔
2020
        .def ("getParameterValues", &URL::getParameterValues)
1✔
2021
        .def ("withPOSTData", py::overload_cast<const String &> (&URL::withPOSTData, py::const_))
1✔
2022
        .def ("withPOSTData", py::overload_cast<const MemoryBlock &> (&URL::withPOSTData, py::const_))
1✔
2023
        .def ("getPostData", &URL::getPostData)
1✔
2024
        .def ("getPostDataAsMemoryBlock", &URL::getPostDataAsMemoryBlock)
1✔
2025
        .def ("launchInDefaultBrowser", &URL::launchInDefaultBrowser)
1✔
2026
        .def_static ("isProbablyAWebsiteURL", &URL::isProbablyAWebsiteURL)
1✔
2027
        .def_static ("isProbablyAnEmailAddress", &URL::isProbablyAnEmailAddress)
1✔
2028
        .def ("createInputStream", py::overload_cast<const URL::InputStreamOptions &> (&URL::createInputStream, py::const_))
1✔
2029
        .def ("createOutputStream", &URL::createOutputStream)
1✔
2030
        .def ("downloadToFile", py::overload_cast<const File &, const URL::DownloadTaskOptions &> (&URL::downloadToFile))
1✔
2031
        .def ("readEntireBinaryStream", &URL::readEntireBinaryStream)
1✔
2032
        .def ("readEntireTextStream", &URL::readEntireTextStream)
1✔
2033
        .def ("readEntireXmlStream", &URL::readEntireXmlStream)
1✔
2034
        .def_static ("addEscapeChars", &URL::addEscapeChars)
1✔
2035
        .def_static ("removeEscapeChars", &URL::removeEscapeChars)
1✔
2036
        .def_static ("createWithoutParsing", &URL::createWithoutParsing)
1✔
2037
        .def ("__repr__", [](const URL& self)
×
2038
        {
2039
            String result;
×
2040
            result << Helpers::pythonizeModuleClassName (PythonModuleName, typeid (self).name()) << "('" << self.toString (true) << "')";
×
2041
            return result;
×
2042
        })
1✔
2043
        .def ("__str__", [](const URL& self) { return self.toString (true); })
1✔
2044
    ;
2045

2046
    py::class_<URL::InputStreamOptions> classURLInputStreamOptions (classURL, "InputStreamOptions");
2✔
2047

2048
    classURLInputStreamOptions
2049
        .def (py::init<URL::ParameterHandling>())
1✔
2050
        .def ("withProgressCallback", &URL::InputStreamOptions::withProgressCallback)
1✔
2051
        .def ("withExtraHeaders", &URL::InputStreamOptions::withExtraHeaders)
1✔
2052
        .def ("withConnectionTimeoutMs", &URL::InputStreamOptions::withConnectionTimeoutMs)
1✔
2053
        .def ("withResponseHeaders", &URL::InputStreamOptions::withResponseHeaders)
1✔
2054
        .def ("withStatusCode", &URL::InputStreamOptions::withStatusCode)
1✔
2055
        .def ("withNumRedirectsToFollow", &URL::InputStreamOptions::withNumRedirectsToFollow)
1✔
2056
        .def ("withHttpRequestCmd", &URL::InputStreamOptions::withHttpRequestCmd)
1✔
2057
        .def ("getParameterHandling", &URL::InputStreamOptions::getParameterHandling)
1✔
2058
        .def ("getProgressCallback", &URL::InputStreamOptions::getProgressCallback)
1✔
2059
        .def ("getExtraHeaders", &URL::InputStreamOptions::getExtraHeaders)
1✔
2060
        .def ("getConnectionTimeoutMs", &URL::InputStreamOptions::getConnectionTimeoutMs)
1✔
2061
        .def ("getResponseHeaders", &URL::InputStreamOptions::getResponseHeaders)
1✔
2062
        .def ("getStatusCode", &URL::InputStreamOptions::getStatusCode)
1✔
2063
        .def ("getNumRedirectsToFollow", &URL::InputStreamOptions::getNumRedirectsToFollow)
1✔
2064
        .def ("getHttpRequestCmd", &URL::InputStreamOptions::getHttpRequestCmd)
1✔
2065
    ;
2066

2067
    py::class_<URL::DownloadTask> classURLDownloadTask (classURL, "DownloadTask");
2✔
2068
    py::class_<URL::DownloadTaskListener, PyURLDownloadTaskListener> classURLDownloadTaskListener (classURL, "DownloadTaskListener");
2✔
2069

2070
    classURLDownloadTaskListener
2071
        .def (py::init<>())
1✔
2072
        .def ("finished", &URL::DownloadTaskListener::finished)
1✔
2073
        .def ("progress", &URL::DownloadTaskListener::progress)
1✔
2074
    ;
2075

2076
    classURLDownloadTask
2077
        .def ("getTotalLength", &URL::DownloadTask::getTotalLength)
1✔
2078
        .def ("getLengthDownloaded", &URL::DownloadTask::getLengthDownloaded)
1✔
2079
        .def ("isFinished", &URL::DownloadTask::isFinished)
1✔
2080
        .def ("statusCode", &URL::DownloadTask::statusCode)
1✔
2081
        .def ("hadError", &URL::DownloadTask::hadError)
1✔
2082
        .def ("getTargetLocation", &URL::DownloadTask::getTargetLocation)
1✔
2083
        .def_property_readonly("Listener", [classURLDownloadTaskListener](const URL::DownloadTask&) { return classURLDownloadTaskListener; })
1✔
2084
    ;
2085

2086
    py::class_<URL::DownloadTaskOptions> classURLDownloadTaskOptions (classURL, "DownloadTaskOptions");
2✔
2087

2088
    classURLDownloadTaskOptions
2089
        .def (py::init<>())
1✔
2090
        .def ("withExtraHeaders", &URL::DownloadTaskOptions::withExtraHeaders)
1✔
2091
        .def ("withSharedContainer", &URL::DownloadTaskOptions::withSharedContainer)
1✔
2092
        .def ("withListener", &URL::DownloadTaskOptions::withListener)
1✔
2093
        .def ("withUsePost", &URL::DownloadTaskOptions::withUsePost)
1✔
2094
        .def_readwrite ("extraHeaders", &URL::DownloadTaskOptions::extraHeaders)
1✔
2095
        .def_readwrite ("sharedContainer", &URL::DownloadTaskOptions::sharedContainer)
1✔
2096
        .def_readwrite ("listener", &URL::DownloadTaskOptions::listener)
1✔
2097
        .def_readwrite ("usePost", &URL::DownloadTaskOptions::usePost)
1✔
2098
    ;
2099

2100
    // ============================================================================================ juce::URLInputSource
2101

2102
    py::class_<URLInputSource, InputSource, PyInputSource<URLInputSource>> classURLInputSource (m, "URLInputSource");
2✔
2103

2104
    classURLInputSource
2105
        .def (py::init<const URL&>())
1✔
2106
    ;
2107

2108
    // ============================================================================================ juce::PerformanceCounter
2109

2110
    py::class_<PerformanceCounter> classPerformanceCounter (m, "PerformanceCounter");
2✔
2111
    py::class_<PerformanceCounter::Statistics> classPerformanceCounterStatistics (classPerformanceCounter, "Statistics");
2✔
2112

2113
    classPerformanceCounterStatistics
2114
        .def (py::init<>())
1✔
2115
        .def ("clear", &PerformanceCounter::Statistics::clear)
1✔
2116
        .def ("toString", &PerformanceCounter::Statistics::toString)
1✔
2117
        .def ("addResult", &PerformanceCounter::Statistics::addResult)
1✔
2118
        .def_readwrite ("name", &PerformanceCounter::Statistics::name)
1✔
2119
        .def_readwrite ("averageSeconds", &PerformanceCounter::Statistics::averageSeconds)
1✔
2120
        .def_readwrite ("maximumSeconds", &PerformanceCounter::Statistics::maximumSeconds)
1✔
2121
        .def_readwrite ("minimumSeconds", &PerformanceCounter::Statistics::minimumSeconds)
1✔
2122
        .def_readwrite ("totalSeconds", &PerformanceCounter::Statistics::totalSeconds)
1✔
2123
        .def_readwrite ("numRuns", &PerformanceCounter::Statistics::numRuns)
1✔
2124
        .def ("__str__", &PerformanceCounter::Statistics::toString)
1✔
2125
    ;
2126

2127
    classPerformanceCounter
2128
        .def (py::init<const String&, int, const File&>(), "counterName"_a, "runsPerPrintout"_a = 100, "loggingFile"_a = File())
2✔
2129
        .def ("start", &PerformanceCounter::start)
1✔
2130
        .def ("stop", &PerformanceCounter::stop)
1✔
2131
        .def ("printStatistics", &PerformanceCounter::printStatistics)
1✔
2132
        .def ("getStatisticsAndReset", &PerformanceCounter::getStatisticsAndReset)
1✔
NEW
2133
        .def ("__enter__", [](PerformanceCounter& self)
×
2134
        {
NEW
2135
            self.start();
×
2136
        }, py::return_value_policy::reference)
1✔
NEW
2137
        .def ("__exit__", [](PerformanceCounter& self, const std::optional<py::type>&, const std::optional<py::object>&, const std::optional<py::object>&)
×
2138
        {
NEW
2139
            self.stop();
×
NEW
2140
            return self.getStatisticsAndReset();
×
2141
        })
1✔
2142
    ;
2143

2144
    // ============================================================================================ juce::CriticalSection
2145

2146
    py::class_<CriticalSection> classCriticalSection (m, "CriticalSection");
2✔
2147

2148
    classCriticalSection
2149
        .def (py::init<>())
1✔
2150
        .def ("enter", &CriticalSection::enter, py::call_guard<py::gil_scoped_release>())
1✔
2151
        .def ("tryEnter", &CriticalSection::tryEnter)
1✔
2152
        .def ("exit", &CriticalSection::exit)
1✔
2153
    ;
2154

2155
    py::class_<PyGenericScopedLock<CriticalSection>> classScopedLockCriticalSection (classCriticalSection, "ScopedLockType");
2✔
2156

2157
    classScopedLockCriticalSection
2158
        .def (py::init<CriticalSection&>(), "lock"_a)
1✔
2159
        .def ("__enter__", [](PyGenericScopedLock<CriticalSection>& self) -> PyGenericScopedLock<CriticalSection>*
1✔
2160
        {
2161
            self.enter();
1✔
2162
            return std::addressof (self);
1✔
2163
        }, py::return_value_policy::reference, py::call_guard<py::gil_scoped_release>())
1✔
2164
        .def ("__exit__", [](PyGenericScopedLock<CriticalSection>& self, const std::optional<py::type>&, const std::optional<py::object>&, const std::optional<py::object>&)
1✔
2165
        {
2166
            self.exit();
1✔
2167
        })
1✔
2168
    ;
2169

2170
    py::class_<PyGenericScopedUnlock<CriticalSection>> classScopedUnlockCriticalSection (classCriticalSection, "ScopedUnlockType");
2✔
2171

2172
    classScopedUnlockCriticalSection
2173
        .def (py::init<CriticalSection&>(), "lock"_a)
1✔
NEW
2174
        .def ("__enter__", [](PyGenericScopedUnlock<CriticalSection>& self) -> PyGenericScopedUnlock<CriticalSection>*
×
2175
        {
NEW
2176
            self.enter();
×
NEW
2177
            return std::addressof (self);
×
2178
        }, py::return_value_policy::reference, py::call_guard<py::gil_scoped_release>())
1✔
NEW
2179
        .def ("__exit__", [](PyGenericScopedUnlock<CriticalSection>& self, const std::optional<py::type>&, const std::optional<py::object>&, const std::optional<py::object>&)
×
2180
        {
NEW
2181
            self.exit();
×
2182
        })
1✔
2183
    ;
2184

2185
    py::class_<PyGenericScopedTryLock<CriticalSection>> classScopedTryLockCriticalSection (classCriticalSection, "ScopedTryLock");
2✔
2186

2187
    classScopedTryLockCriticalSection
2188
        .def (py::init<CriticalSection&, int>(), "lock"_a, "acquireLockOnInitialisation"_a = true)
1✔
NEW
2189
        .def ("__enter__", [](PyGenericScopedTryLock<CriticalSection>& self) -> PyGenericScopedTryLock<CriticalSection>*
×
2190
        {
NEW
2191
            self.enter();
×
NEW
2192
            return std::addressof (self);
×
2193
        }, py::return_value_policy::reference, py::call_guard<py::gil_scoped_release>())
1✔
NEW
2194
        .def ("__exit__", [](PyGenericScopedTryLock<CriticalSection>& self, const std::optional<py::type>&, const std::optional<py::object>&, const std::optional<py::object>&)
×
2195
        {
NEW
2196
            self.exit();
×
2197
        })
1✔
2198
    ;
2199

2200
    // ============================================================================================ juce::SpinLock
2201

2202
    py::class_<SpinLock> classSpinLock (m, "SpinLock");
2✔
2203

2204
    classSpinLock
2205
        .def (py::init<>())
1✔
2206
        .def ("enter", &SpinLock::enter, py::call_guard<py::gil_scoped_release>())
1✔
2207
        .def ("tryEnter", &SpinLock::tryEnter)
1✔
2208
        .def ("exit", &SpinLock::exit)
1✔
2209
    ;
2210

2211
    // ============================================================================================ juce::WaitableEvent
2212

2213
    py::class_<WaitableEvent> classWaitableEvent (m, "WaitableEvent");
2✔
2214

2215
    classWaitableEvent
2216
        .def (py::init<bool>(), "manualReset"_a = false)
1✔
2217
        .def ("wait", &WaitableEvent::wait, "timeOutMilliseconds"_a = -1.0, py::call_guard<py::gil_scoped_release>())
2✔
2218
        .def ("signal", &WaitableEvent::signal)
1✔
2219
        .def ("reset", &WaitableEvent::reset)
1✔
2220
    ;
2221

2222
    // ============================================================================================ juce::ReadWriteLock
2223

2224
    py::class_<ReadWriteLock> classReadWriteLock (m, "ReadWriteLock");
2✔
2225

2226
    classReadWriteLock
2227
        .def (py::init<>())
1✔
2228
        .def ("enterRead", &ReadWriteLock::enterRead, py::call_guard<py::gil_scoped_release>())
1✔
2229
        .def ("tryEnterRead", &ReadWriteLock::tryEnterRead)
1✔
2230
        .def ("exitRead", &ReadWriteLock::exitRead, py::call_guard<py::gil_scoped_release>())
1✔
2231
        .def ("enterWrite", &ReadWriteLock::enterWrite, py::call_guard<py::gil_scoped_release>())
1✔
2232
        .def ("tryEnterWrite", &ReadWriteLock::tryEnterWrite)
1✔
2233
        .def ("exitWrite", &ReadWriteLock::exitWrite, py::call_guard<py::gil_scoped_release>())
1✔
2234
    ;
2235

2236
    // ============================================================================================ juce::InterProcessLock
2237

2238
    py::class_<InterProcessLock> classInterProcessLock (m, "InterProcessLock");
2✔
2239

2240
    classInterProcessLock
2241
        .def (py::init<const String&>())
1✔
2242
        .def ("enter", &InterProcessLock::enter, "timeOutMillisecs"_a = -1, py::call_guard<py::gil_scoped_release>())
1✔
2243
        .def ("exit", &InterProcessLock::exit)
1✔
2244
    ;
2245

2246
    // ============================================================================================ juce::HighResolutionTimer
2247

2248
    py::class_<HighResolutionTimer, PyHighResolutionTimer> classHighResolutionTimer (m, "HighResolutionTimer");
2✔
2249

2250
    classHighResolutionTimer
2251
        .def (py::init<>())
1✔
2252
        .def ("hiResTimerCallback", &HighResolutionTimer::hiResTimerCallback)
1✔
2253
        .def ("startTimer", &HighResolutionTimer::startTimer)
1✔
2254
        .def ("stopTimer", &HighResolutionTimer::stopTimer)
1✔
2255
        .def ("isTimerRunning", &HighResolutionTimer::isTimerRunning)
1✔
2256
        .def ("getTimerInterval", &HighResolutionTimer::getTimerInterval)
1✔
2257
    ;
2258

2259
    // ============================================================================================ juce::ChildProcess
2260

2261
    py::class_<ChildProcess> classChildProcess (m, "ChildProcess");
2✔
2262

2263
    py::enum_<ChildProcess::StreamFlags> (classChildProcess, "StreamFlags", py::arithmetic())
2✔
2264
        .value ("wantStdOut", ChildProcess::StreamFlags::wantStdOut)
1✔
2265
        .value ("wantStdErr", ChildProcess::StreamFlags::wantStdErr);
1✔
2266

2267
    classChildProcess
2268
        .def (py::init<>())
1✔
2269
        .def ("start", py::overload_cast<const String&, int> (&ChildProcess::start), "command"_a, "streamFlags"_a = ChildProcess::wantStdOut | ChildProcess::wantStdErr)
1✔
2270
        .def ("start", py::overload_cast<const StringArray&, int> (&ChildProcess::start), "command"_a, "streamFlags"_a = ChildProcess::wantStdOut | ChildProcess::wantStdErr)
2✔
NEW
2271
        .def ("start", [](ChildProcess& self, const String& command, ChildProcess::StreamFlags streamFlags)
×
2272
            { return self.start (command, streamFlags); }, "command"_a, "streamFlags"_a)
1✔
NEW
2273
        .def ("start", [](ChildProcess& self, const StringArray& command, ChildProcess::StreamFlags streamFlags)
×
2274
            { return self.start (command, streamFlags); }, "command"_a, "streamFlags"_a)
1✔
2275
        .def ("isRunning", &ChildProcess::isRunning)
1✔
2276
        .def ("readProcessOutput", [](ChildProcess& self, py::buffer data)
×
2277
        {
2278
            auto info = data.request();
×
2279
            return self.readProcessOutput (info.ptr, static_cast<int> (info.size));
×
2280
        })
1✔
2281
        .def ("readAllProcessOutput", &ChildProcess::readAllProcessOutput)
1✔
2282
        .def ("waitForProcessToFinish", &ChildProcess::waitForProcessToFinish)
1✔
2283
        .def ("getExitCode", &ChildProcess::getExitCode)
1✔
2284
        .def ("kill", &ChildProcess::kill)
1✔
2285
    ;
2286

2287
    // ============================================================================================ juce::Thread
2288

2289
    py::class_<Thread, PyThread<>> classThread (m, "Thread");
2✔
2290

2291
    py::enum_<Thread::Priority> (classThread, "Priority")
2✔
2292
        .value ("highest", Thread::Priority::highest)
1✔
2293
        .value ("high", Thread::Priority::high)
1✔
2294
        .value ("normal", Thread::Priority::normal)
1✔
2295
        .value ("low", Thread::Priority::low)
1✔
2296
        .value ("background", Thread::Priority::background);
1✔
2297

2298
    py::class_<Thread::RealtimeOptions> classThreadRealtimeOptions (classThread, "RealtimeOptions");
2✔
2299

2300
    classThreadRealtimeOptions
2301
        .def (py::init<>())
1✔
2302
        .def ("withPriority", [](Thread::RealtimeOptions& self, Thread::Priority priority) { return self.withPriority (static_cast<int> (priority)); })
1✔
2303
        .def ("withProcessingTimeMs", &Thread::RealtimeOptions::withProcessingTimeMs)
1✔
2304
        .def ("withMaximumProcessingTimeMs", &Thread::RealtimeOptions::withMaximumProcessingTimeMs)
1✔
2305
        .def ("withApproximateAudioProcessingTime", &Thread::RealtimeOptions::withApproximateAudioProcessingTime)
1✔
2306
        .def ("withPeriodMs", &Thread::RealtimeOptions::withPeriodMs)
1✔
2307
        .def ("withPeriodHz", &Thread::RealtimeOptions::withPeriodHz)
1✔
2308
        .def ("getPriority", [](Thread::RealtimeOptions& self) { return static_cast<Thread::Priority> (self.getPriority()); })
1✔
2309
        .def ("getProcessingTimeMs", &Thread::RealtimeOptions::getProcessingTimeMs)
1✔
2310
        .def ("getMaximumProcessingTimeMs", &Thread::RealtimeOptions::getMaximumProcessingTimeMs)
1✔
2311
        .def ("getPeriodMs", &Thread::RealtimeOptions::getPeriodMs)
1✔
2312
    ;
2313

2314
    py::class_<Thread::Listener, PyThreadListener> classThreadListener (classThread, "Listener");
2✔
2315

2316
    classThreadListener
2317
        .def (py::init<>())
1✔
2318
        .def ("exitSignalSent", &Thread::Listener::exitSignalSent)
1✔
2319
    ;
2320

2321
    classThread
2322
        .def (py::init<const String&, size_t>(), "threadName"_a, "threadStackSize"_a = Thread::osDefaultStackSize)
1✔
2323
        .def ("run", &Thread::run)
1✔
2324
        .def ("startThread", py::overload_cast<> (&Thread::startThread))
1✔
2325
        .def ("startThread", py::overload_cast<Thread::Priority> (&Thread::startThread))
1✔
2326
        .def ("startRealtimeThread", &Thread::startRealtimeThread)
1✔
2327
        .def ("stopThread", &Thread::stopThread, py::call_guard<py::gil_scoped_release>())
1✔
2328
    //.def_static ("launch", static_cast<bool (*)(std::function<void()>)> (&Thread::launch))
2329
    //.def_static ("launch", static_cast<bool (*)(Thread::Priority priority, std::function<void()>)> (&Thread::launch))
2330
        .def ("isThreadRunning", &Thread::isThreadRunning)
1✔
2331
        .def ("signalThreadShouldExit", &Thread::signalThreadShouldExit)
1✔
2332
        .def ("threadShouldExit", &Thread::threadShouldExit)
1✔
2333
        .def_static ("currentThreadShouldExit", &Thread::currentThreadShouldExit)
1✔
2334
        .def ("waitForThreadToExit", &Thread::waitForThreadToExit, py::call_guard<py::gil_scoped_release>())
1✔
2335
        .def ("addListener", &Thread::addListener)
1✔
2336
        .def ("removeListener", &Thread::removeListener)
1✔
2337
        .def ("isRealtime", &Thread::isRealtime)
1✔
2338
        .def ("setAffinityMask", &Thread::setAffinityMask)
1✔
2339
        .def_static ("setCurrentThreadAffinityMask", &Thread::setCurrentThreadAffinityMask)
1✔
2340
        .def_static ("sleep", &Thread::sleep, py::call_guard<py::gil_scoped_release>())
1✔
2341
        .def_static ("yield", &Thread::yield, py::call_guard<py::gil_scoped_release>())
1✔
2342
        .def ("wait", &Thread::wait, py::call_guard<py::gil_scoped_release>())
1✔
2343
        .def ("notify", &Thread::notify)
1✔
2344
        .def_static ("getCurrentThreadId", [] { return PyThreadID (Thread::getCurrentThreadId()); })
3✔
2345
        .def_static ("getCurrentThread", &Thread::getCurrentThread, py::return_value_policy::reference)
1✔
2346
        .def ("getThreadId", [](const Thread& self) { return PyThreadID (self.getThreadId()); })
1✔
2347
        .def ("getThreadName", &Thread::getThreadName)
1✔
2348
        .def_static ("setCurrentThreadName", &Thread::setCurrentThreadName)
1✔
2349
    //.def ("getPriority", &Thread::getPriority)
2350
    //.def ("setPriority", &Thread::setPriority)
2351
    ;
2352

2353
    py::class_<PyThreadID> classThreadID (classThread, "ThreadID");
2✔
2354

2355
    classThreadID
2356
        .def (py::init([](Thread::ThreadID value)
×
2357
        {
2358
            return PyThreadID (value);
×
2359
        }))
1✔
2360
        .def (py::init([](const PyThreadID& other)
×
2361
        {
2362
            return PyThreadID (static_cast<Thread::ThreadID> (other));
×
2363
        }))
1✔
2364
        .def (py::self == py::self)
1✔
2365
        .def (py::self != py::self)
1✔
2366
        .def ("__str__", [](const PyThreadID& self)
×
2367
        {
2368
            return String::formatted ("%p", static_cast<Thread::ThreadID> (self));
×
2369
        })
1✔
2370
    ;
2371

2372
    // ============================================================================================ juce::ThreadPool
2373

2374
    py::class_<ThreadPoolJob, PyThreadPoolJob> classThreadPoolJob (m, "ThreadPoolJob");
2✔
2375

2376
    py::enum_<ThreadPoolJob::JobStatus> (classThreadPoolJob, "JobStatus")
2✔
2377
        .value ("jobHasFinished", ThreadPoolJob::JobStatus::jobHasFinished)
1✔
2378
        .value ("jobNeedsRunningAgain", ThreadPoolJob::JobStatus::jobNeedsRunningAgain)
1✔
2379
        .export_values();
1✔
2380

2381
    classThreadPoolJob
2382
        .def (py::init<const String&>())
1✔
2383
        .def ("getJobName", &ThreadPoolJob::getJobName)
1✔
2384
        .def ("setJobName", &ThreadPoolJob::setJobName)
1✔
2385
        .def ("runJob", &ThreadPoolJob::runJob)
1✔
2386
        .def ("isRunning", &ThreadPoolJob::isRunning)
1✔
2387
        .def ("shouldExit", &ThreadPoolJob::shouldExit)
1✔
2388
        .def ("signalJobShouldExit", &ThreadPoolJob::signalJobShouldExit)
1✔
2389
        .def ("addListener", &ThreadPoolJob::addListener)
1✔
2390
        .def ("removeListener", &ThreadPoolJob::removeListener)
1✔
2391
        .def_static ("getCurrentThreadPoolJob", &ThreadPoolJob::getCurrentThreadPoolJob, py::return_value_policy::reference)
1✔
2392
    ;
2393

2394
    py::class_<ThreadPoolOptions> classThreadPoolOptions (m, "ThreadPoolOptions");
2✔
2395

2396
    classThreadPoolOptions
2397
        .def (py::init<>())
1✔
2398
        .def ("withThreadName", &ThreadPoolOptions::withThreadName)
1✔
2399
        .def ("withNumberOfThreads", &ThreadPoolOptions::withNumberOfThreads)
1✔
2400
        .def ("withThreadStackSizeBytes", &ThreadPoolOptions::withThreadStackSizeBytes)
1✔
2401
        .def ("withDesiredThreadPriority", &ThreadPoolOptions::withDesiredThreadPriority)
1✔
2402
        .def_readwrite ("threadName", &ThreadPoolOptions::threadName)
1✔
2403
        .def_readwrite ("numberOfThreads", &ThreadPoolOptions::numberOfThreads)
1✔
2404
        .def_readwrite ("threadStackSizeBytes", &ThreadPoolOptions::threadStackSizeBytes)
1✔
2405
        .def_readwrite ("desiredThreadPriority", &ThreadPoolOptions::desiredThreadPriority)
1✔
2406
    ;
2407

2408
    py::class_<ThreadPool> classThreadPool (m, "ThreadPool");
2✔
2409

2410
    py::class_<ThreadPool::JobSelector, PyThreadPoolJobSelector> classThreadPoolJobSelector (classThreadPool, "JobSelector");
2✔
2411

2412
    classThreadPoolJobSelector
2413
        .def (py::init<>())
1✔
2414
        .def ("isJobSuitable", &ThreadPool::JobSelector::isJobSuitable)
1✔
2415
    ;
2416

2417
    classThreadPool
2418
        .def (py::init<>())
1✔
2419
        .def (py::init<const ThreadPoolOptions&>(), "options"_a)
1✔
2420
        .def (py::init<int, size_t, Thread::Priority>(),
1✔
2421
            "numberOfThreads"_a, "threadStackSizeBytes"_a = Thread::osDefaultStackSize, "desiredThreadPriority"_a = Thread::Priority::normal)
3✔
2422
        .def ("addJob", [](ThreadPool& self, ThreadPoolJob* job) { return self.addJob (job, false); })
3✔
2423
        .def ("addJob", py::overload_cast<std::function<ThreadPoolJob::JobStatus()>> (&ThreadPool::addJob))
1✔
2424
        .def ("addJob", py::overload_cast<std::function<void()>> (&ThreadPool::addJob))
1✔
2425
        .def ("removeJob", &ThreadPool::removeJob, py::call_guard<py::gil_scoped_release>())
1✔
2426
        .def ("removeAllJobs", [](ThreadPool& self, bool interruptRunningJobs, int timeOutMilliseconds, ThreadPool::JobSelector* selectedJobsToRemove)
1✔
2427
        {
2428
            self.removeAllJobs (interruptRunningJobs, timeOutMilliseconds, selectedJobsToRemove);
1✔
2429
        }, "interruptRunningJobs"_a, "timeOutMilliseconds"_a, "selectedJobsToRemove"_a = nullptr, py::call_guard<py::gil_scoped_release>())
2✔
2430
        .def ("getNumJobs", &ThreadPool::getNumJobs)
1✔
2431
        .def ("getNumThreads", &ThreadPool::getNumThreads)
1✔
2432
        .def ("getJob", &ThreadPool::getJob, py::return_value_policy::reference)
1✔
2433
        .def ("contains", &ThreadPool::contains)
1✔
2434
        .def ("isJobRunning", &ThreadPool::isJobRunning)
1✔
2435
        .def ("waitForJobToFinish", &ThreadPool::waitForJobToFinish, py::call_guard<py::gil_scoped_release>())
1✔
2436
        .def ("moveJobToFront", &ThreadPool::moveJobToFront, py::call_guard<py::gil_scoped_release>())
1✔
2437
        .def ("getNamesOfAllJobs", &ThreadPool::getNamesOfAllJobs)
1✔
2438
    ;
2439

2440
    // ============================================================================================ juce::TimeSliceThread
2441

2442
    py::class_<TimeSliceThread, Thread, PyThread<TimeSliceThread>> classTimeSliceThread (m, "TimeSliceThread");
2✔
2443
    py::class_<TimeSliceClient, PyTimeSliceClient> classTimeSliceClient (m, "TimeSliceClient");
2✔
2444

2445
    classTimeSliceClient
2446
        .def (py::init<>())
1✔
2447
        .def ("useTimeSlice", &TimeSliceClient::useTimeSlice)
1✔
2448
    ;
2449

2450
    classTimeSliceThread
2451
        .def (py::init<const String&>(), "threadName"_a)
1✔
2452
        .def ("addTimeSliceClient", &TimeSliceThread::addTimeSliceClient)
1✔
2453
        .def ("moveToFrontOfQueue", &TimeSliceThread::moveToFrontOfQueue)
1✔
2454
        .def ("removeTimeSliceClient", &TimeSliceThread::removeTimeSliceClient)
1✔
2455
        .def ("removeAllClients", &TimeSliceThread::removeAllClients)
1✔
2456
        .def ("getNumClients", &TimeSliceThread::getNumClients)
1✔
2457
        .def ("getClient", &TimeSliceThread::getClient, py::return_value_policy::reference)
1✔
2458
        .def ("contains", &TimeSliceThread::contains)
1✔
2459
    ;
2460

2461
    // ============================================================================================ juce::Process
2462

2463
    py::class_<Process> classProcess (m, "Process");
2✔
2464

2465
    py::enum_<Process::ProcessPriority> (classProcess, "ProcessPriority")
2✔
2466
        .value ("LowPriority", Process::ProcessPriority::LowPriority)
1✔
2467
        .value ("NormalPriority", Process::ProcessPriority::NormalPriority)
1✔
2468
        .value ("HighPriority", Process::ProcessPriority::HighPriority)
1✔
2469
        .value ("RealtimePriority", Process::ProcessPriority::RealtimePriority)
1✔
2470
        .export_values();
1✔
2471

2472
    classProcess
2473
        .def_static ("setPriority", &Process::setPriority)
1✔
2474
        .def_static ("terminate", &Process::terminate)
1✔
2475
        .def_static ("isForegroundProcess", &Process::isForegroundProcess)
1✔
2476
        .def_static ("makeForegroundProcess", &Process::makeForegroundProcess)
1✔
2477
        .def_static ("hide", &Process::hide)
1✔
2478
        .def_static ("raisePrivilege", &Process::raisePrivilege)
1✔
2479
        .def_static ("lowerPrivilege", &Process::lowerPrivilege)
1✔
2480
        .def_static ("isRunningUnderDebugger", &Process::isRunningUnderDebugger)
1✔
2481
        .def_static ("openDocument", &Process::openDocument)
1✔
2482
        .def_static ("openEmailWithAttachments", &Process::openEmailWithAttachments)
1✔
2483
#if JUCE_MAC
2484
        .def_static ("setDockIconVisible", &Process::setDockIconVisible)
2485
#endif
2486
#if JUCE_MAC || JUCE_LINUX || JUCE_BSD
2487
        .def_static ("setMaxNumberOfFileHandles", &Process::setMaxNumberOfFileHandles)
1✔
2488
#endif
2489
    ;
2490

2491
    // ============================================================================================ juce::XmlElement
2492

2493
    py::class_<XmlElement, std::unique_ptr<XmlElement>> classXmlElement (m, "XmlElement");
2✔
2494
    py::class_<XmlElement::TextFormat> classXmlElementTextFormat (classXmlElement, "TextFormat");
2✔
2495
    py::class_<PyXmlElementComparator> classXmlElementComparator (classXmlElement, "Comparator");
2✔
2496

2497
    classXmlElementComparator
2498
        .def (py::init<>())
1✔
2499
        .def ("compareElements", &PyXmlElementComparator::compareElements)
1✔
2500
    ;
2501

2502
    classXmlElementTextFormat
2503
        .def (py::init<>())
1✔
2504
        .def_readwrite ("dtd", &XmlElement::TextFormat::dtd)
1✔
2505
        .def_readwrite ("customHeader", &XmlElement::TextFormat::customHeader)
1✔
2506
        .def_readwrite ("customEncoding", &XmlElement::TextFormat::customEncoding)
1✔
2507
        .def_readwrite ("addDefaultHeader", &XmlElement::TextFormat::addDefaultHeader)
1✔
2508
        .def_readwrite ("lineWrapLength", &XmlElement::TextFormat::lineWrapLength)
1✔
2509
        .def_readwrite ("newLineChars", &XmlElement::TextFormat::newLineChars)
1✔
2510
        .def ("singleLine", &XmlElement::TextFormat::singleLine)
1✔
2511
        .def ("withoutHeader", &XmlElement::TextFormat::withoutHeader)
1✔
2512
    ;
2513

2514
    classXmlElement
2515
        .def (py::init<const char*>())
1✔
2516
        .def (py::init<const String&>())
1✔
2517
        .def (py::init<const Identifier&>())
1✔
2518
        .def (py::init<const XmlElement&>())
1✔
2519
        .def ("isEquivalentTo", &XmlElement::isEquivalentTo, "other"_a, "ignoreOrderOfAttributes"_a)
1✔
2520
        .def ("toString", &XmlElement::toString, "format"_a = XmlElement::TextFormat())
2✔
2521
        .def ("writeTo", py::overload_cast<OutputStream&, const XmlElement::TextFormat&> (&XmlElement::writeTo, py::const_), "output"_a, "format"_a = XmlElement::TextFormat())
2✔
2522
        .def ("writeTo", py::overload_cast<const File& , const XmlElement::TextFormat&> (&XmlElement::writeTo, py::const_), "output"_a, "format"_a = XmlElement::TextFormat())
2✔
2523
        .def ("getTagName", &XmlElement::getTagName)
1✔
2524
        .def ("getNamespace", &XmlElement::getNamespace)
1✔
2525
        .def ("getTagNameWithoutNamespace", &XmlElement::getTagNameWithoutNamespace)
1✔
2526
        .def ("hasTagName", &XmlElement::hasTagName)
1✔
2527
        .def ("hasTagNameIgnoringNamespace", &XmlElement::hasTagNameIgnoringNamespace)
1✔
2528
        .def ("setTagName", &XmlElement::setTagName)
1✔
2529
        .def ("getNumAttributes", &XmlElement::getNumAttributes)
1✔
2530
        .def ("getAttributeName", &XmlElement::getAttributeName)
1✔
2531
        .def ("getAttributeValue", &XmlElement::getAttributeValue)
1✔
2532
        .def ("hasAttribute", &XmlElement::hasAttribute)
1✔
2533
        .def ("getStringAttribute", py::overload_cast<StringRef> (&XmlElement::getStringAttribute, py::const_))
1✔
2534
        .def ("getStringAttribute", py::overload_cast<StringRef, const String&> (&XmlElement::getStringAttribute, py::const_))
1✔
2535
        .def ("compareAttribute", &XmlElement::compareAttribute, "attributeName"_a, "stringToCompareAgainst"_a, "ignoreCase"_a = false)
2✔
2536
        .def ("getIntAttribute", &XmlElement::getIntAttribute, "attributeName"_a, "defaultReturnValue"_a = 0)
2✔
2537
        .def ("getDoubleAttribute", &XmlElement::getDoubleAttribute, "attributeName"_a, "defaultReturnValue"_a = 0.0)
2✔
2538
        .def ("getBoolAttribute", &XmlElement::getBoolAttribute, "attributeName"_a, "defaultReturnValue"_a = false)
2✔
2539
        .def ("setAttribute", py::overload_cast<const Identifier&, const String&> (&XmlElement::setAttribute))
1✔
2540
        .def ("setAttribute", [](XmlElement& self, const String& name, const String& value) { self.setAttribute (name, value); })
1✔
2541
        .def ("setAttribute", py::overload_cast<const Identifier&, int> (&XmlElement::setAttribute))
1✔
2542
        .def ("setAttribute", [](XmlElement& self, const String& name, int value) { self.setAttribute (name, value); })
1✔
2543
        .def ("setAttribute", py::overload_cast<const Identifier&, double> (&XmlElement::setAttribute))
1✔
2544
        .def ("setAttribute", [](XmlElement& self, const String& name, double value) { self.setAttribute (name, value); })
1✔
2545
        .def ("removeAttribute", &XmlElement::removeAttribute)
1✔
2546
        .def ("removeAttribute", [](XmlElement& self, const String& name) { self.removeAttribute (name); })
1✔
2547
        .def ("removeAllAttributes", &XmlElement::removeAllAttributes)
1✔
2548
        .def ("getFirstChildElement", &XmlElement::getFirstChildElement, py::return_value_policy::reference_internal)
1✔
2549
        .def ("getNextElement", &XmlElement::getNextElement, py::return_value_policy::reference_internal)
1✔
2550
        .def ("getNextElementWithTagName", &XmlElement::getNextElementWithTagName, py::return_value_policy::reference_internal)
1✔
2551
        .def ("getNumChildElements", &XmlElement::getNumChildElements)
1✔
2552
        .def ("getChildElement", &XmlElement::getChildElement, py::return_value_policy::reference_internal)
1✔
2553
        .def ("getChildByName", &XmlElement::getChildByName, py::return_value_policy::reference_internal)
1✔
2554
        .def ("getChildByAttribute", &XmlElement::getChildByAttribute, py::return_value_policy::reference_internal)
1✔
2555
        .def ("addChildElement", [](XmlElement& self, py::object newChildElement)
4✔
2556
            { self.addChildElement (newChildElement.release().cast<XmlElement*>()); })
5✔
2557
        .def ("insertChildElement", [](XmlElement& self, py::object newChildElement, int index)
×
2558
            { self.insertChildElement (newChildElement.release().cast<XmlElement*>(), index); })
1✔
2559
        .def ("prependChildElement", [](XmlElement& self, py::object newChildElement)
1✔
2560
            { self.prependChildElement (newChildElement.release().cast<XmlElement*>()); })
2✔
2561
        .def ("createNewChildElement", &XmlElement::createNewChildElement, py::return_value_policy::reference_internal)
1✔
2562
        .def ("replaceChildElement", [](XmlElement& self, XmlElement* currentChildElement, py::object newChildElement)
×
2563
            { self.replaceChildElement (currentChildElement, newChildElement.release().cast<XmlElement*>()); })
1✔
2564
        .def ("removeChildElement", &XmlElement::removeChildElement)
1✔
2565
        .def ("deleteAllChildElements", &XmlElement::deleteAllChildElements)
1✔
2566
        .def ("deleteAllChildElementsWithTagName", &XmlElement::deleteAllChildElementsWithTagName)
1✔
2567
        .def ("containsChildElement", &XmlElement::containsChildElement)
1✔
2568
        .def ("findParentElementOf", &XmlElement::findParentElementOf, py::return_value_policy::reference_internal)
1✔
2569
        .def ("sortChildElements", &XmlElement::template sortChildElements<PyXmlElementComparator>, "comparator"_a, "retainOrderOfEquivalentItems"_a = false)
2✔
2570
        .def ("sortChildElements", [](XmlElement& self, py::function fn, bool retainOrderOfEquivalentItems)
1✔
2571
        {
2572
            PyXmlElementCallableComparator comparator (std::move (fn));
2✔
2573
            return self.sortChildElements (comparator, retainOrderOfEquivalentItems);
2✔
2574
        }, "comparator"_a, "retainOrderOfEquivalentItems"_a = false)
2✔
2575
        .def ("isTextElement", &XmlElement::isTextElement)
1✔
2576
        .def ("getText", &XmlElement::getText)
1✔
2577
        .def ("setText", &XmlElement::setText)
1✔
2578
        .def ("getAllSubText", &XmlElement::getAllSubText)
1✔
2579
        .def ("getChildElementAllSubText", &XmlElement::getChildElementAllSubText, "childTagName"_a, "defaultReturnValue"_a)
1✔
2580
        .def ("addTextElement", &XmlElement::addTextElement)
1✔
2581
        .def ("deleteAllTextElements", &XmlElement::deleteAllTextElements)
1✔
2582
        .def_static ("createTextElement", &XmlElement::createTextElement)
1✔
2583
        .def_static ("isValidXmlName", &XmlElement::isValidXmlName)
1✔
2584
        .def ("getChildIterator", [](const XmlElement& self)
2✔
2585
        {
2586
            auto range = self.getChildIterator();
2✔
2587
            return py::make_iterator (std::begin (range), std::end (range));
4✔
2588
        })
1✔
2589
        .def ("getChildIterator", [](const XmlElement& self, StringRef name)
×
2590
        {
2591
            auto range = self.getChildWithTagNameIterator (name);
×
2592
            return py::make_iterator (std::begin (range), std::end (range));
×
2593
        })
1✔
2594
    ;
2595

2596
    // ============================================================================================ juce::XmlDocument
2597

2598
    py::class_<XmlDocument> classXmlDocument (m, "XmlDocument");
2✔
2599

2600
    classXmlDocument
2601
        .def (py::init<const File&>(), "file"_a)
1✔
2602
        .def (py::init<const String&>(), "textToParse"_a)
1✔
2603
        .def ("getDocumentElement", &XmlDocument::getDocumentElement, "onlyReadOuterDocumentElement"_a = false)
1✔
2604
        .def ("getDocumentElementIfTagMatches", &XmlDocument::getDocumentElementIfTagMatches, "requiredTag"_a)
1✔
2605
        .def ("getLastParseError", &XmlDocument::getLastParseError)
1✔
2606
        .def ("setInputSource", [](XmlDocument& self, py::object source) { self.setInputSource (source.release().cast<InputSource*>()); })
1✔
2607
        .def ("setEmptyTextElementsIgnored", &XmlDocument::setEmptyTextElementsIgnored, "shouldBeIgnored"_a)
1✔
2608
        .def_static ("parse", static_cast<std::unique_ptr<XmlElement> (*)(const File&)> (&XmlDocument::parse), "file"_a)
1✔
2609
        .def_static ("parse", static_cast<std::unique_ptr<XmlElement> (*)(const String&)> (&XmlDocument::parse), "textToParse"_a)
1✔
2610
    ;
2611

2612
    // ============================================================================================ juce::PropertySet
2613

2614
    py::class_<PropertySet> classPropertySet (m, "PropertySet");
2✔
2615

2616
    classPropertySet
2617
        .def (py::init<>())
1✔
2618
        .def (py::init<const PropertySet&>())
1✔
2619
        .def ("getValue", &PropertySet::getValue, "keyName"_a, "defaultReturnValue"_a = String())
2✔
2620
        .def ("getIntValue", &PropertySet::getIntValue, "keyName"_a, "defaultReturnValue"_a = 0)
2✔
2621
        .def ("getDoubleValue", &PropertySet::getDoubleValue, "keyName"_a, "defaultReturnValue"_a = 0.0)
2✔
2622
        .def ("getBoolValue", &PropertySet::getBoolValue, "keyName"_a, "defaultReturnValue"_a = false)
2✔
2623
        .def ("getXmlValue", &PropertySet::getXmlValue, "keyName"_a)
1✔
2624
        .def ("setValue", py::overload_cast<StringRef, const var&> (&PropertySet::setValue), "keyName"_a, "value"_a)
1✔
2625
        .def ("setValue", py::overload_cast<StringRef, const XmlElement*> (&PropertySet::setValue), "keyName"_a, "xml"_a)
1✔
2626
        .def ("addAllPropertiesFrom", &PropertySet::addAllPropertiesFrom, "source"_a)
1✔
2627
        .def ("removeValue", &PropertySet::removeValue, "keyName"_a)
1✔
2628
        .def ("containsKey", &PropertySet::containsKey, "keyName"_a)
1✔
2629
        .def ("clear", &PropertySet::clear)
1✔
2630
        .def ("getAllProperties", &PropertySet::getAllProperties, py::return_value_policy::reference_internal)
1✔
2631
        .def ("getLock", &PropertySet::getLock, py::return_value_policy::reference_internal)
1✔
2632
        .def ("createXml", &PropertySet::createXml, "nodeName"_a)
1✔
2633
        .def ("restoreFromXml", &PropertySet::restoreFromXml, "xml"_a)
1✔
2634
        .def ("setFallbackPropertySet", &PropertySet::setFallbackPropertySet, "fallbackProperties"_a)
1✔
2635
        .def ("getFallbackPropertySet", &PropertySet::getFallbackPropertySet, py::return_value_policy::reference_internal)
1✔
2636
    ;
2637

2638
    // ============================================================================================ juce::ZipFile
2639

2640
    py::class_<ZipFile> classZipFile (m, "ZipFile");
2✔
2641
    py::class_<ZipFile::ZipEntry> classZipFileZipEntry (classZipFile, "ZipEntry");
2✔
2642
    py::class_<ZipFile::Builder> classZipFileBuilder (classZipFile, "Builder");
2✔
2643

2644
    py::enum_<ZipFile::OverwriteFiles> (classZipFile, "OverwriteFiles")
2✔
2645
        .value ("no", ZipFile::OverwriteFiles::no)
1✔
2646
        .value ("yes", ZipFile::OverwriteFiles::yes);
1✔
2647

2648
    py::enum_<ZipFile::FollowSymlinks> (classZipFile, "FollowSymlinks")
2✔
2649
        .value ("no", ZipFile::FollowSymlinks::no)
1✔
2650
        .value ("yes", ZipFile::FollowSymlinks::yes);
1✔
2651

2652
    classZipFileZipEntry
2653
        .def (py::init<>())
1✔
2654
        .def_readwrite ("filename", &ZipFile::ZipEntry::filename)
1✔
2655
        .def_readwrite ("uncompressedSize", &ZipFile::ZipEntry::uncompressedSize)
1✔
2656
        .def_readwrite ("fileTime", &ZipFile::ZipEntry::fileTime)
1✔
2657
        .def_readwrite ("isSymbolicLink", &ZipFile::ZipEntry::isSymbolicLink)
1✔
2658
        .def_readwrite ("externalFileAttributes", &ZipFile::ZipEntry::externalFileAttributes)
1✔
2659
    ;
2660

2661
    classZipFileBuilder
2662
        .def (py::init<>())
1✔
2663
        .def ("addFile", &ZipFile::Builder::addFile, "fileToAdd"_a, "compressionLevel"_a, "storedPathName"_a = String())
2✔
2664
        .def ("addEntry", [](ZipFile::Builder& self, py::object stream, int compression, const String& path, Time time)
9✔
2665
        {
2666
            self.addEntry (stream.release().cast<InputStream*>(), compression, path, time);
9✔
2667
        }, "streamToRead"_a, "compressionLevel"_a, "storedPathName"_a, "fileModificationTime"_a)
10✔
2668
        .def ("writeToStream", [](const ZipFile::Builder& self, OutputStream& target) { return self.writeToStream (target, nullptr); }, "target"_a)
19✔
2669
    ;
2670

2671
    classZipFile
2672
        .def (py::init<const File&>(), "file"_a)
1✔
2673
        .def (py::init<InputStream&>(), "inputStream"_a)
1✔
2674
        .def (py::init ([](py::object inputSource)
×
2675
        {
2676
            return new ZipFile (inputSource.release().cast<InputSource*>());
1✔
2677
        }), "inputSource"_a)
1✔
2678
        .def ("getNumEntries", &ZipFile::getNumEntries)
1✔
2679
        .def ("getIndexOfFileName", &ZipFile::getIndexOfFileName, "fileName"_a, "ignoreCase"_a = false)
1✔
2680
        .def ("getEntry", py::overload_cast<int> (&ZipFile::getEntry, py::const_), "index"_a, py::return_value_policy::reference_internal)
1✔
2681
        .def ("getEntry", py::overload_cast<const String&, bool> (&ZipFile::getEntry, py::const_), "fileName"_a, "ignoreCase"_a = false, py::return_value_policy::reference_internal)
2✔
2682
        .def ("sortEntriesByFilename", &ZipFile::sortEntriesByFilename)
1✔
2683
        .def ("createStreamForEntry", py::overload_cast<int> (&ZipFile::createStreamForEntry))
1✔
2684
        .def ("createStreamForEntry", py::overload_cast<const ZipFile::ZipEntry&> (&ZipFile::createStreamForEntry))
1✔
2685
        .def ("uncompressTo", &ZipFile::uncompressTo, "targetDirectory"_a, "shouldOverwriteFiles"_a = true)
2✔
2686
        .def ("uncompressEntry", py::overload_cast<int, const File&, bool> (&ZipFile::uncompressEntry), "index"_a, "targetDirectory"_a, "shouldOverwriteFiles"_a = true)
2✔
2687
        .def ("uncompressEntry", py::overload_cast<int, const File&, ZipFile::OverwriteFiles, ZipFile::FollowSymlinks> (&ZipFile::uncompressEntry), "index"_a, "targetDirectory"_a, "overwriteFiles"_a, "followSymlinks"_a)
1✔
2688
    ;
2689

2690
    // ============================================================================================ juce::SystemStats
2691

2692
    py::class_<SystemStats> classSystemStats (m, "SystemStats");
1✔
2693

2694
    Helpers::makeArithmeticEnum<SystemStats::OperatingSystemType> (classSystemStats, "OperatingSystemType")
2✔
2695
        .value ("UnknownOS", SystemStats::OperatingSystemType::UnknownOS)
1✔
2696
        .value ("MacOSX", SystemStats::OperatingSystemType::MacOSX)
1✔
2697
        .value ("Windows", SystemStats::OperatingSystemType::Windows)
1✔
2698
        .value ("Linux", SystemStats::OperatingSystemType::Linux)
1✔
2699
        .value ("Android", SystemStats::OperatingSystemType::Android)
1✔
2700
        .value ("iOS", SystemStats::OperatingSystemType::iOS)
1✔
2701
        .value ("WASM", SystemStats::OperatingSystemType::WASM)
1✔
2702
        .value ("MacOSX_10_7", SystemStats::OperatingSystemType::MacOSX_10_7)
1✔
2703
        .value ("MacOSX_10_8", SystemStats::OperatingSystemType::MacOSX_10_8)
1✔
2704
        .value ("MacOSX_10_9", SystemStats::OperatingSystemType::MacOSX_10_9)
1✔
2705
        .value ("MacOSX_10_10", SystemStats::OperatingSystemType::MacOSX_10_10)
1✔
2706
        .value ("MacOSX_10_11", SystemStats::OperatingSystemType::MacOSX_10_11)
1✔
2707
        .value ("MacOSX_10_12", SystemStats::OperatingSystemType::MacOSX_10_12)
1✔
2708
        .value ("MacOSX_10_13", SystemStats::OperatingSystemType::MacOSX_10_13)
1✔
2709
        .value ("MacOSX_10_14", SystemStats::OperatingSystemType::MacOSX_10_14)
1✔
2710
        .value ("MacOSX_10_15", SystemStats::OperatingSystemType::MacOSX_10_15)
1✔
2711
        .value ("MacOS_11", SystemStats::OperatingSystemType::MacOS_11)
1✔
2712
        .value ("MacOS_12", SystemStats::OperatingSystemType::MacOS_12)
1✔
2713
        .value ("MacOS_13", SystemStats::OperatingSystemType::MacOS_13)
1✔
2714
        .value ("Win2000", SystemStats::OperatingSystemType::Win2000)
1✔
2715
        .value ("WinXP", SystemStats::OperatingSystemType::WinXP)
1✔
2716
        .value ("WinVista", SystemStats::OperatingSystemType::WinVista)
1✔
2717
        .value ("Windows7", SystemStats::OperatingSystemType::Windows7)
1✔
2718
        .value ("Windows8_0", SystemStats::OperatingSystemType::Windows8_0)
1✔
2719
        .value ("Windows8_1", SystemStats::OperatingSystemType::Windows8_1)
1✔
2720
        .value ("Windows10", SystemStats::OperatingSystemType::Windows10)
1✔
2721
        .value ("Windows11", SystemStats::OperatingSystemType::Windows11)
1✔
2722
        .export_values();
1✔
2723

2724
    py::enum_<SystemStats::MachineIdFlags> (classSystemStats, "MachineIdFlags")
2✔
2725
        .value ("macAddresses", SystemStats::MachineIdFlags::macAddresses)
1✔
2726
        .value ("fileSystemId", SystemStats::MachineIdFlags::fileSystemId)
1✔
2727
        .value ("legacyUniqueId", SystemStats::MachineIdFlags::legacyUniqueId)
1✔
2728
        .value ("uniqueId", SystemStats::MachineIdFlags::uniqueId)
1✔
2729
        .export_values();
1✔
2730

2731
    classSystemStats
2732
        .def_static ("getJUCEVersion", &SystemStats::getJUCEVersion)
1✔
2733
        .def_static ("getOperatingSystemType", &SystemStats::getOperatingSystemType)
1✔
2734
        .def_static ("getOperatingSystemName", &SystemStats::getOperatingSystemName)
1✔
2735
        .def_static ("isOperatingSystem64Bit", &SystemStats::isOperatingSystem64Bit)
1✔
2736
        .def_static ("getEnvironmentVariable", &SystemStats::getEnvironmentVariable)
1✔
2737
        .def_static ("getLogonName", &SystemStats::getLogonName)
1✔
2738
        .def_static ("getFullUserName", &SystemStats::getFullUserName)
1✔
2739
        .def_static ("getComputerName", &SystemStats::getComputerName)
1✔
2740
        .def_static ("getUserLanguage", &SystemStats::getUserLanguage)
1✔
2741
        .def_static ("getUserRegion", &SystemStats::getUserRegion)
1✔
2742
        .def_static ("getDisplayLanguage", &SystemStats::getDisplayLanguage)
1✔
2743
        .def_static ("getDeviceDescription", &SystemStats::getDeviceDescription)
1✔
2744
        .def_static ("getDeviceManufacturer", &SystemStats::getDeviceManufacturer)
1✔
2745
        .def_static ("getUniqueDeviceID", &SystemStats::getUniqueDeviceID)
1✔
2746
        .def_static ("getMachineIdentifiers", &SystemStats::getMachineIdentifiers)
1✔
2747
        .def_static ("getNumCpus", &SystemStats::getNumCpus)
1✔
2748
        .def_static ("getNumPhysicalCpus", &SystemStats::getNumPhysicalCpus)
1✔
2749
        .def_static ("getCpuSpeedInMegahertz", &SystemStats::getCpuSpeedInMegahertz)
1✔
2750
        .def_static ("getCpuVendor", &SystemStats::getCpuVendor)
1✔
2751
        .def_static ("getCpuModel", &SystemStats::getCpuModel)
1✔
2752
        .def_static ("hasMMX", &SystemStats::hasMMX)
1✔
2753
        .def_static ("has3DNow", &SystemStats::has3DNow)
1✔
2754
        .def_static ("hasFMA3", &SystemStats::hasFMA3)
1✔
2755
        .def_static ("hasFMA4", &SystemStats::hasFMA4)
1✔
2756
        .def_static ("hasSSE", &SystemStats::hasSSE)
1✔
2757
        .def_static ("hasSSE2", &SystemStats::hasSSE2)
1✔
2758
        .def_static ("hasSSE3", &SystemStats::hasSSE3)
1✔
2759
        .def_static ("hasSSSE3", &SystemStats::hasSSSE3)
1✔
2760
        .def_static ("hasSSE41", &SystemStats::hasSSE41)
1✔
2761
        .def_static ("hasSSE42", &SystemStats::hasSSE42)
1✔
2762
        .def_static ("hasAVX", &SystemStats::hasAVX)
1✔
2763
        .def_static ("hasAVX2", &SystemStats::hasAVX2)
1✔
2764
        .def_static ("hasAVX512F", &SystemStats::hasAVX512F)
1✔
2765
        .def_static ("hasAVX512BW", &SystemStats::hasAVX512BW)
1✔
2766
        .def_static ("hasAVX512CD", &SystemStats::hasAVX512CD)
1✔
2767
        .def_static ("hasAVX512DQ", &SystemStats::hasAVX512DQ)
1✔
2768
        .def_static ("hasAVX512ER", &SystemStats::hasAVX512ER)
1✔
2769
        .def_static ("hasAVX512IFMA", &SystemStats::hasAVX512IFMA)
1✔
2770
        .def_static ("hasAVX512PF", &SystemStats::hasAVX512PF)
1✔
2771
        .def_static ("hasAVX512VBMI", &SystemStats::hasAVX512VBMI)
1✔
2772
        .def_static ("hasAVX512VL", &SystemStats::hasAVX512VL)
1✔
2773
        .def_static ("hasAVX512VPOPCNTDQ", &SystemStats::hasAVX512VPOPCNTDQ)
1✔
2774
        .def_static ("hasNeon", &SystemStats::hasNeon)
1✔
2775
        .def_static ("getMemorySizeInMegabytes", &SystemStats::getMemorySizeInMegabytes)
1✔
2776
        .def_static ("getPageSize", &SystemStats::getPageSize)
1✔
2777
        .def_static ("getStackBacktrace", &SystemStats::getStackBacktrace)
1✔
2778
    //.def_static ("setApplicationCrashHandler", &SystemStats::setApplicationCrashHandler)
2779
    ;
2780

2781
    // ============================================================================================ juce::Array<>
2782

2783
    registerArray<Array, bool, int, float, String, File> (m);
1✔
2784

2785
    // ============================================================================================ juce::SparseSet<>
2786

2787
    registerSparseSet<SparseSet, int> (m);
1✔
2788

2789
    // ============================================================================================ testing
2790

2791
    m.def ("__raise_cpp_exception__", [](const juce::String& what) { throw std::runtime_error (what.toStdString()); });
1✔
2792
    m.def ("__terminate__", [] { std::terminate(); });
1✔
2793
}
1✔
2794

2795
} // namespace popsicle::Bindings
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc