diff --git a/.github/workflows/setup/action.yml b/.github/workflows/setup/action.yml index c5e4d60ed..49905937e 100644 --- a/.github/workflows/setup/action.yml +++ b/.github/workflows/setup/action.yml @@ -7,7 +7,7 @@ runs: using: composite steps: - name: install haxe - uses: Aidan63/setup-haxe@3d3101bcd0a2001699fc8295f4d9eddd0724d3e9 + uses: krdlab/setup-haxe@hotfix/download-failure with: haxe-version: ${{ inputs.haxe }} @@ -34,4 +34,4 @@ runs: - name: build hxcpp working-directory: tools/hxcpp shell: pwsh - run: haxe compile.hxml \ No newline at end of file + run: haxe compile.hxml diff --git a/include/cpp/encoding/Utf16.hpp b/include/cpp/encoding/Utf16.hpp index 992c0635d..ae2aacf31 100644 --- a/include/cpp/encoding/Utf16.hpp +++ b/include/cpp/encoding/Utf16.hpp @@ -8,12 +8,15 @@ namespace cpp { static bool isEncoded(const String& string); + static int getByteCount(const null&); static int getByteCount(const char32_t& codepoint); static int64_t getByteCount(const String& string); + static int getCharCount(const null&); static int getCharCount(const char32_t& codepoint); static int64_t getCharCount(const String& string); + static int encode(const null&, const cpp::marshal::View& buffer); static int encode(const char32_t& codepoint, const cpp::marshal::View& buffer); static int64_t encode(const String& string, const cpp::marshal::View& buffer); @@ -21,4 +24,4 @@ namespace cpp static String decode(const cpp::marshal::View& buffer); }; } -} \ No newline at end of file +} diff --git a/include/cpp/encoding/Utf8.hpp b/include/cpp/encoding/Utf8.hpp index 11497a692..9636b8b51 100644 --- a/include/cpp/encoding/Utf8.hpp +++ b/include/cpp/encoding/Utf8.hpp @@ -6,12 +6,15 @@ namespace cpp { struct Utf8 final { + static int getByteCount(const null&); static int getByteCount(const char32_t& codepoint); static int64_t getByteCount(const String& string); + static int getCharCount(const null&); static int getCharCount(const char32_t& codepoint); static int64_t getCharCount(const String& string); + static int encode(const null&, const cpp::marshal::View& buffer); static int encode(const char32_t& codepoint, const cpp::marshal::View& buffer); static int64_t encode(const String& string, const cpp::marshal::View& buffer); @@ -19,4 +22,4 @@ namespace cpp static String decode(const cpp::marshal::View& buffer); }; } -} \ No newline at end of file +} diff --git a/include/null.h b/include/null.h index d01f97ad8..98dd40a8b 100644 --- a/include/null.h +++ b/include/null.h @@ -91,6 +91,7 @@ class null operator unsigned char () { return 0; } operator signed char () { return 0; } operator char16_t () { return 0; } + operator char32_t () { return 0; } operator short () { return 0; } operator unsigned short () { return 0; } operator cpp::UInt64 () { return 0; } @@ -145,7 +146,8 @@ class null HX_NULL_COMPARE_OPS(unsigned short) HX_NULL_COMPARE_OPS(signed char) HX_NULL_COMPARE_OPS(unsigned char) - HX_NULL_COMPARE_OPS(char16_t) + HX_NULL_COMPARE_OPS(char16_t) + HX_NULL_COMPARE_OPS(char32_t) HX_NULL_COMPARE_OPS(cpp::Int64) HX_NULL_COMPARE_OPS(cpp::UInt64) HX_NULL_COMPARE_MOST_OPS(String) @@ -215,6 +217,7 @@ HX_COMPARE_NULL_OPS(unsigned short) HX_COMPARE_NULL_OPS(signed char) HX_COMPARE_NULL_OPS(unsigned char) HX_COMPARE_NULL_OPS(char16_t) +HX_COMPARE_NULL_OPS(char32_t) HX_COMPARE_NULL_OPS(cpp::UInt64) HX_COMPARE_NULL_OPS(cpp::Int64) diff --git a/src/Dynamic.cpp b/src/Dynamic.cpp index 1e3631b8f..0f6514740 100644 --- a/src/Dynamic.cpp +++ b/src/Dynamic.cpp @@ -502,6 +502,7 @@ DYN_OP_ADD(unsigned short) DYN_OP_ADD(signed char) DYN_OP_ADD(unsigned char) DYN_OP_ADD(char16_t) +DYN_OP_ADD(char32_t) DYN_OP_ADD(cpp::Int64) DYN_OP_ADD(cpp::UInt64) diff --git a/src/cpp/encoding/Utf16.cpp b/src/cpp/encoding/Utf16.cpp index f3b595a09..930513259 100644 --- a/src/cpp/encoding/Utf16.cpp +++ b/src/cpp/encoding/Utf16.cpp @@ -68,6 +68,12 @@ bool cpp::encoding::Utf16::isEncoded(const String& string) return string.isUTF16Encoded(); } +int cpp::encoding::Utf16::getByteCount(const null&) +{ + hx::NullReference("String", false); + return 0; +} + int cpp::encoding::Utf16::getByteCount(const char32_t& codepoint) { return codepoint <= 0xFFFF ? 2 : 4; @@ -96,6 +102,12 @@ int64_t cpp::encoding::Utf16::getByteCount(const String& string) } } +int cpp::encoding::Utf16::getCharCount(const null&) +{ + hx::NullReference("String", false); + return 0; +} + int cpp::encoding::Utf16::getCharCount(const char32_t& codepoint) { return getByteCount(codepoint) / sizeof(char16_t); @@ -106,6 +118,12 @@ int64_t cpp::encoding::Utf16::getCharCount(const String& string) return getByteCount(string) / sizeof(char16_t); } +int cpp::encoding::Utf16::encode(const null&, const cpp::marshal::View& buffer) +{ + hx::NullReference("String", false); + return 0; +} + int64_t cpp::encoding::Utf16::encode(const String& string, const cpp::marshal::View& buffer) { if (null() == string) @@ -258,4 +276,4 @@ char32_t cpp::encoding::Utf16::codepoint(const cpp::marshal::View& buff { return static_cast(first); } -} \ No newline at end of file +} diff --git a/src/cpp/encoding/Utf8.cpp b/src/cpp/encoding/Utf8.cpp index b6b7c4eb5..6ff51af96 100644 --- a/src/cpp/encoding/Utf8.cpp +++ b/src/cpp/encoding/Utf8.cpp @@ -24,6 +24,12 @@ namespace } } +int cpp::encoding::Utf8::getByteCount(const null&) +{ + hx::NullReference("String", false); + return 0; +} + int cpp::encoding::Utf8::getByteCount(const char32_t& codepoint) { if (codepoint <= 0x7F) @@ -77,6 +83,12 @@ int64_t cpp::encoding::Utf8::getByteCount(const String& string) #endif } +int cpp::encoding::Utf8::getCharCount(const null&) +{ + hx::NullReference("String", false); + return 0; +} + int cpp::encoding::Utf8::getCharCount(const char32_t& codepoint) { return getByteCount(codepoint) / sizeof(char); @@ -87,6 +99,12 @@ int64_t cpp::encoding::Utf8::getCharCount(const String& string) return getByteCount(string) / sizeof(char); } +int cpp::encoding::Utf8::encode(const null&, const cpp::marshal::View& buffer) +{ + hx::NullReference("String", false); + return 0; +} + int64_t cpp::encoding::Utf8::encode(const String& string, const cpp::marshal::View& buffer) { if (null() == string) @@ -282,4 +300,4 @@ char32_t cpp::encoding::Utf8::codepoint(const cpp::marshal::View& buffe { return int{ hx::Throw(HX_CSTRING("Failed to read codepoint")) }; } -} \ No newline at end of file +}