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
4 changes: 2 additions & 2 deletions .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -34,4 +34,4 @@ runs:
- name: build hxcpp
working-directory: tools/hxcpp
shell: pwsh
run: haxe compile.hxml
run: haxe compile.hxml
5 changes: 4 additions & 1 deletion include/cpp/encoding/Utf16.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ 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<uint8_t>& buffer);
static int encode(const char32_t& codepoint, const cpp::marshal::View<uint8_t>& buffer);
static int64_t encode(const String& string, const cpp::marshal::View<uint8_t>& buffer);

static char32_t codepoint(const cpp::marshal::View<uint8_t>& buffer);
static String decode(const cpp::marshal::View<uint8_t>& buffer);
};
}
}
}
5 changes: 4 additions & 1 deletion include/cpp/encoding/Utf8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ 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<uint8_t>& buffer);
static int encode(const char32_t& codepoint, const cpp::marshal::View<uint8_t>& buffer);
static int64_t encode(const String& string, const cpp::marshal::View<uint8_t>& buffer);

static char32_t codepoint(const cpp::marshal::View<uint8_t>& buffer);
static String decode(const cpp::marshal::View<uint8_t>& buffer);
};
}
}
}
5 changes: 4 additions & 1 deletion include/null.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions src/Dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 19 additions & 1 deletion src/cpp/encoding/Utf16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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<uint8_t>& buffer)
{
hx::NullReference("String", false);
return 0;
}

int64_t cpp::encoding::Utf16::encode(const String& string, const cpp::marshal::View<uint8_t>& buffer)
{
if (null() == string)
Expand Down Expand Up @@ -258,4 +276,4 @@ char32_t cpp::encoding::Utf16::codepoint(const cpp::marshal::View<uint8_t>& buff
{
return static_cast<char32_t>(first);
}
}
}
20 changes: 19 additions & 1 deletion src/cpp/encoding/Utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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<uint8_t>& buffer)
{
hx::NullReference("String", false);
return 0;
}

int64_t cpp::encoding::Utf8::encode(const String& string, const cpp::marshal::View<uint8_t>& buffer)
{
if (null() == string)
Expand Down Expand Up @@ -282,4 +300,4 @@ char32_t cpp::encoding::Utf8::codepoint(const cpp::marshal::View<uint8_t>& buffe
{
return int{ hx::Throw(HX_CSTRING("Failed to read codepoint")) };
}
}
}