Skip to content

Commit 1930aef

Browse files
authored
Assorted set of fixes (#78)
1 parent 177dc8d commit 1930aef

File tree

8 files changed

+106
-12
lines changed

8 files changed

+106
-12
lines changed

modules/yup_audio_basics/buffers/yup_FloatVectorOperations.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ void convertDoubleToFloat (float* dest, const double* src, Size num) noexcept
15641564
float32x2_t f = vcvt_f32_f64 (d);
15651565
vst1_f32 (dest + i, f);
15661566
}
1567-
#elif JUCE_USE_SSE_INTRINSICS
1567+
#elif YUP_USE_SSE_INTRINSICS
15681568
for (; i + 2 <= num; i += 2)
15691569
{
15701570
__m128d d = _mm_loadu_pd (src + i);
@@ -1592,7 +1592,7 @@ void convertFloatToDouble (double* dest, const float* src, Size num) noexcept
15921592
float64x2_t d = vcvt_f64_f32 (f);
15931593
vst1q_f64 (dest + i, d);
15941594
}
1595-
#elif JUCE_USE_SSE_INTRINSICS
1595+
#elif YUP_USE_SSE_INTRINSICS
15961596
for (; i + 4 <= num; i += 4)
15971597
{
15981598
__m128 f = _mm_loadu_ps (src + i);

modules/yup_core/streams/yup_MemoryOutputStream.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ char* MemoryOutputStream::prepareToWrite (size_t numBytes)
9999
if (blockToUse != nullptr)
100100
{
101101
if (storageNeeded >= blockToUse->getSize())
102-
blockToUse->ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & (size_t) (31));
102+
blockToUse->ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~(size_t) 31);
103103

104104
data = static_cast<char*> (blockToUse->getData());
105105
}
@@ -226,4 +226,3 @@ OutputStream& YUP_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputS
226226
}
227227

228228
} // namespace yup
229-

modules/yup_core/system/yup_SystemStats.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ String SystemStats::getYUPVersion()
5757
return "YUP v" YUP_STRINGIFY (YUP_MAJOR_VERSION) "." YUP_STRINGIFY (YUP_MINOR_VERSION) "." YUP_STRINGIFY (YUP_BUILDNUMBER);
5858
}
5959

60-
#if YUP_ANDROID && ! defined(YUP_DISABLE_YUP_VERSION_PRINTING)
61-
#define YUP_DISABLE_YUP_VERSION_PRINTING 1
60+
#if YUP_ANDROID && ! defined(YUP_DISABLE_VERSION_PRINTING)
61+
#define YUP_DISABLE_VERSION_PRINTING 1
6262
#endif
6363

64-
#if YUP_DEBUG && ! YUP_DISABLE_YUP_VERSION_PRINTING
64+
#if YUP_DEBUG && ! YUP_DISABLE_VERSION_PRINTING
6565
struct YupVersionPrinter
6666
{
6767
YupVersionPrinter()

modules/yup_core/system/yup_TargetPlatform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
//==============================================================================
110110
#if YUP_WINDOWS
111111
#ifdef __MINGW32__
112-
#error "MingW is no longer supported by YUP!"
112+
#error "MingW is an unsupported platform in YUP!"
113113
#endif
114114

115115
#ifdef _MSC_VER

modules/yup_python/bindings/yup_YupCore_bindings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ template <class Base = InputStream>
393393
struct PyInputStream : Base
394394
{
395395
private:
396-
#if JUCE_WINDOWS && ! JUCE_MINGW
396+
#if YUP_WINDOWS
397397
using ssize_t = pointer_sized_int;
398398
#endif
399399

@@ -878,13 +878,13 @@ struct PyThread : Base
878878

879879
void run() override
880880
{
881-
#if JUCE_PYTHON_THREAD_CATCH_EXCEPTION
881+
#if YUP_PYTHON_THREAD_CATCH_EXCEPTION
882882
try
883883
{
884884
#endif
885885
PYBIND11_OVERRIDE_PURE (void, Base, run);
886886

887-
#if JUCE_PYTHON_THREAD_CATCH_EXCEPTION
887+
#if YUP_PYTHON_THREAD_CATCH_EXCEPTION
888888
}
889889
catch (const pybind11::error_already_set& e)
890890
{

python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ yup_add_default_modules ("${CMAKE_CURRENT_LIST_DIR}/.."
3030
ENABLE_PYTHON ON
3131
DEFINITIONS
3232
YUP_STANDALONE_APPLICATION=1
33-
YUP_DISABLE_JUCE_VERSION_PRINTING=1
33+
YUP_DISABLE_VERSION_PRINTING=1
3434
YUP_MODAL_LOOPS_PERMITTED=1
3535
YUP_CATCH_UNHANDLED_EXCEPTIONS=1
3636
YUP_LOG_ASSERTIONS=1
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
==============================================================================
3+
4+
This file is part of the YUP library.
5+
Copyright (c) 2024 - [email protected]
6+
7+
YUP is an open source library subject to open-source licensing.
8+
9+
The code included in this file is provided under the terms of the ISC license
10+
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
11+
to use, copy, modify, and/or distribute this software for any purpose with or
12+
without fee is hereby granted provided that the above copyright notice and
13+
this permission notice appear in all copies.
14+
15+
YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
16+
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
17+
DISCLAIMED.
18+
19+
==============================================================================
20+
*/
21+
22+
#include <gtest/gtest.h>
23+
24+
#include <yup_core/yup_core.h>
25+
26+
using namespace yup;
27+
28+
TEST (MemoryOutputStreamTests, WriteTextUtf16SupportsFullUnicodeCodepoints)
29+
{
30+
static constexpr yup_wchar stringA[] { 0x1F600, 0x00 }; // Grinning face emoji
31+
static constexpr yup_wchar stringB[] { 0xA, 0xB, 0xC, 0x0 }; // ASCII
32+
static constexpr yup_wchar stringC[] { 0xAAAA, 0xBBBB, 0xCCCC, 0x0 }; // two-byte characters
33+
34+
CharPointer_UTF32 pointers[] { CharPointer_UTF32 (stringA),
35+
CharPointer_UTF32 (stringB),
36+
CharPointer_UTF32 (stringC) };
37+
38+
for (auto originalPtr : pointers)
39+
{
40+
MemoryOutputStream stream;
41+
EXPECT_TRUE (stream.writeText (String (originalPtr), true, false, "\n"));
42+
EXPECT_NE (stream.getDataSize(), (size_t) 0);
43+
44+
CharPointer_UTF16 writtenPtr { reinterpret_cast<const CharPointer_UTF16::CharType*> (stream.getData()) };
45+
46+
for (auto currentOriginal = originalPtr; ! currentOriginal.isEmpty(); ++currentOriginal, ++writtenPtr)
47+
EXPECT_EQ (*currentOriginal, *writtenPtr);
48+
}
49+
}

tests/yup_core/yup_String.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,52 @@ TEST_F (StringTests, StringCreationFromData)
895895
EXPECT_TRUE (empty_from_data.isEmpty());
896896
}
897897

898+
TEST_F (StringTests, CreateStringFromDataHandlesEncodings)
899+
{
900+
const String expectedString (CharPointer_UTF8 ("glass \xc2\xbd full"));
901+
const String emojiExpectedString (CharPointer_UTF8 ("hello JUCE \xf0\x9f\xa7\x83"));
902+
903+
{
904+
SCOPED_TRACE ("createStringFromData reads LE UTF-16");
905+
constexpr char buffer[] = "\xff\xfe\x67\x00\x6c\x00\x61\x00\x73\x00\x73\x00\x20\x00\xbd\x00\x20\x00\x66\x00\x75\x00\x6c\x00\x6c\x00";
906+
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
907+
EXPECT_EQ (expectedString, actualString);
908+
909+
constexpr char emojiBuffer[] = "\xff\xfe\x68\x00\x65\x00\x6c\x00\x6c\x00\x6f\x00\x20\x00\x4a\x00\x55\x00\x43\x00\x45\x00\x20\x00\x3e\xd8\xc3\xdd";
910+
const auto emojiActualString = String::createStringFromData (emojiBuffer, static_cast<int> (sizeof (emojiBuffer)));
911+
EXPECT_EQ (emojiExpectedString, emojiActualString);
912+
}
913+
914+
{
915+
SCOPED_TRACE ("createStringFromData reads BE UTF-16");
916+
constexpr char buffer[] = "\xfe\xff\x00\x67\x00\x6c\x00\x61\x00\x73\x00\x73\x00\x20\x00\xbd\x00\x20\x00\x66\x00\x75\x00\x6c\x00\x6c";
917+
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
918+
EXPECT_EQ (expectedString, actualString);
919+
920+
constexpr char emojiBuffer[] = "\xfe\xff\x00\x68\x00\x65\x00\x6c\x00\x6c\x00\x6f\x00\x20\x00\x4a\x00\x55\x00\x43\x00\x45\x00\x20\xd8\x3e\xdd\xc3";
921+
const auto emojiActualString = String::createStringFromData (emojiBuffer, static_cast<int> (sizeof (emojiBuffer)));
922+
EXPECT_EQ (emojiExpectedString, emojiActualString);
923+
}
924+
925+
{
926+
SCOPED_TRACE ("createStringFromData reads UTF-8");
927+
constexpr char buffer[] = "glass \xc2\xbd full";
928+
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
929+
EXPECT_EQ (expectedString, actualString);
930+
931+
constexpr char emojiBuffer[] = "hello JUCE \xf0\x9f\xa7\x83";
932+
const auto emojiActualString = String::createStringFromData (emojiBuffer, static_cast<int> (sizeof (emojiBuffer)));
933+
EXPECT_EQ (emojiExpectedString, emojiActualString);
934+
}
935+
936+
{
937+
SCOPED_TRACE ("createStringFromData reads Windows 1252");
938+
constexpr char buffer[] = "glass \xBD full";
939+
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
940+
EXPECT_EQ (expectedString, actualString);
941+
}
942+
}
943+
898944
TEST_F (StringTests, FromUTF8)
899945
{
900946
// Test fromUTF8

0 commit comments

Comments
 (0)