Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ void convertDoubleToFloat (float* dest, const double* src, Size num) noexcept
float32x2_t f = vcvt_f32_f64 (d);
vst1_f32 (dest + i, f);
}
#elif JUCE_USE_SSE_INTRINSICS
#elif YUP_USE_SSE_INTRINSICS
for (; i + 2 <= num; i += 2)
{
__m128d d = _mm_loadu_pd (src + i);
Expand Down Expand Up @@ -1592,7 +1592,7 @@ void convertFloatToDouble (double* dest, const float* src, Size num) noexcept
float64x2_t d = vcvt_f64_f32 (f);
vst1q_f64 (dest + i, d);
}
#elif JUCE_USE_SSE_INTRINSICS
#elif YUP_USE_SSE_INTRINSICS
for (; i + 4 <= num; i += 4)
{
__m128 f = _mm_loadu_ps (src + i);
Expand Down
3 changes: 1 addition & 2 deletions modules/yup_core/streams/yup_MemoryOutputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ char* MemoryOutputStream::prepareToWrite (size_t numBytes)
if (blockToUse != nullptr)
{
if (storageNeeded >= blockToUse->getSize())
blockToUse->ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & (size_t) (31));
blockToUse->ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~(size_t) 31);

data = static_cast<char*> (blockToUse->getData());
}
Expand Down Expand Up @@ -226,4 +226,3 @@ OutputStream& YUP_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputS
}

} // namespace yup

6 changes: 3 additions & 3 deletions modules/yup_core/system/yup_SystemStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ String SystemStats::getYUPVersion()
return "YUP v" YUP_STRINGIFY (YUP_MAJOR_VERSION) "." YUP_STRINGIFY (YUP_MINOR_VERSION) "." YUP_STRINGIFY (YUP_BUILDNUMBER);
}

#if YUP_ANDROID && ! defined(YUP_DISABLE_YUP_VERSION_PRINTING)
#define YUP_DISABLE_YUP_VERSION_PRINTING 1
#if YUP_ANDROID && ! defined(YUP_DISABLE_VERSION_PRINTING)
#define YUP_DISABLE_VERSION_PRINTING 1
#endif

#if YUP_DEBUG && ! YUP_DISABLE_YUP_VERSION_PRINTING
#if YUP_DEBUG && ! YUP_DISABLE_VERSION_PRINTING
struct YupVersionPrinter
{
YupVersionPrinter()
Expand Down
2 changes: 1 addition & 1 deletion modules/yup_core/system/yup_TargetPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
//==============================================================================
#if YUP_WINDOWS
#ifdef __MINGW32__
#error "MingW is no longer supported by YUP!"
#error "MingW is an unsupported platform in YUP!"
#endif

#ifdef _MSC_VER
Expand Down
6 changes: 3 additions & 3 deletions modules/yup_python/bindings/yup_YupCore_bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ template <class Base = InputStream>
struct PyInputStream : Base
{
private:
#if JUCE_WINDOWS && ! JUCE_MINGW
#if YUP_WINDOWS
using ssize_t = pointer_sized_int;
#endif

Expand Down Expand Up @@ -878,13 +878,13 @@ struct PyThread : Base

void run() override
{
#if JUCE_PYTHON_THREAD_CATCH_EXCEPTION
#if YUP_PYTHON_THREAD_CATCH_EXCEPTION
try
{
#endif
PYBIND11_OVERRIDE_PURE (void, Base, run);

#if JUCE_PYTHON_THREAD_CATCH_EXCEPTION
#if YUP_PYTHON_THREAD_CATCH_EXCEPTION
}
catch (const pybind11::error_already_set& e)
{
Expand Down
2 changes: 1 addition & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ yup_add_default_modules ("${CMAKE_CURRENT_LIST_DIR}/.."
ENABLE_PYTHON ON
DEFINITIONS
YUP_STANDALONE_APPLICATION=1
YUP_DISABLE_JUCE_VERSION_PRINTING=1
YUP_DISABLE_VERSION_PRINTING=1
YUP_MODAL_LOOPS_PERMITTED=1
YUP_CATCH_UNHANDLED_EXCEPTIONS=1
YUP_LOG_ASSERTIONS=1
Expand Down
49 changes: 49 additions & 0 deletions tests/yup_core/yup_MemoryOutputStream.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
==============================================================================

This file is part of the YUP library.
Copyright (c) 2024 - kunitoki@gmail.com

YUP is an open source library subject to open-source licensing.

The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
to use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.

YUP IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.

==============================================================================
*/

#include <gtest/gtest.h>

#include <yup_core/yup_core.h>

using namespace yup;

TEST (MemoryOutputStreamTests, WriteTextUtf16SupportsFullUnicodeCodepoints)
{
static constexpr yup_wchar stringA[] { 0x1F600, 0x00 }; // Grinning face emoji
static constexpr yup_wchar stringB[] { 0xA, 0xB, 0xC, 0x0 }; // ASCII
static constexpr yup_wchar stringC[] { 0xAAAA, 0xBBBB, 0xCCCC, 0x0 }; // two-byte characters

CharPointer_UTF32 pointers[] { CharPointer_UTF32 (stringA),
CharPointer_UTF32 (stringB),
CharPointer_UTF32 (stringC) };

for (auto originalPtr : pointers)
{
MemoryOutputStream stream;
EXPECT_TRUE (stream.writeText (String (originalPtr), true, false, "\n"));
EXPECT_NE (stream.getDataSize(), (size_t) 0);

CharPointer_UTF16 writtenPtr { reinterpret_cast<const CharPointer_UTF16::CharType*> (stream.getData()) };

for (auto currentOriginal = originalPtr; ! currentOriginal.isEmpty(); ++currentOriginal, ++writtenPtr)
EXPECT_EQ (*currentOriginal, *writtenPtr);
}
}
46 changes: 46 additions & 0 deletions tests/yup_core/yup_String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,52 @@ TEST_F (StringTests, StringCreationFromData)
EXPECT_TRUE (empty_from_data.isEmpty());
}

TEST_F (StringTests, CreateStringFromDataHandlesEncodings)
{
const String expectedString (CharPointer_UTF8 ("glass \xc2\xbd full"));
const String emojiExpectedString (CharPointer_UTF8 ("hello JUCE \xf0\x9f\xa7\x83"));

{
SCOPED_TRACE ("createStringFromData reads LE UTF-16");
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";
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
EXPECT_EQ (expectedString, actualString);

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";
const auto emojiActualString = String::createStringFromData (emojiBuffer, static_cast<int> (sizeof (emojiBuffer)));
EXPECT_EQ (emojiExpectedString, emojiActualString);
}

{
SCOPED_TRACE ("createStringFromData reads BE UTF-16");
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";
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
EXPECT_EQ (expectedString, actualString);

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";
const auto emojiActualString = String::createStringFromData (emojiBuffer, static_cast<int> (sizeof (emojiBuffer)));
EXPECT_EQ (emojiExpectedString, emojiActualString);
}

{
SCOPED_TRACE ("createStringFromData reads UTF-8");
constexpr char buffer[] = "glass \xc2\xbd full";
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
EXPECT_EQ (expectedString, actualString);

constexpr char emojiBuffer[] = "hello JUCE \xf0\x9f\xa7\x83";
const auto emojiActualString = String::createStringFromData (emojiBuffer, static_cast<int> (sizeof (emojiBuffer)));
EXPECT_EQ (emojiExpectedString, emojiActualString);
}

{
SCOPED_TRACE ("createStringFromData reads Windows 1252");
constexpr char buffer[] = "glass \xBD full";
const auto actualString = String::createStringFromData (buffer, static_cast<int> (sizeof (buffer)));
EXPECT_EQ (expectedString, actualString);
}
}

TEST_F (StringTests, FromUTF8)
{
// Test fromUTF8
Expand Down
Loading