Skip to content

Commit 5c01da7

Browse files
Fix macos build (#296)
Co-authored-by: Alex2772 <[email protected]>
1 parent e3aa0f5 commit 5c01da7

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ if(APPLE)
1515
message(STATUS "Configure macos platform module")
1616
endif()
1717

18+
1819
if (UNIX AND NOT APPLE)
1920
add_subdirectory(linux)
2021
message(STATUS "Configure linux platform module")
21-
endif()
22+
endif()

shared/cc/StringUTF16.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ jwm::StringUTF16::StringUTF16(const uint32_t *str) {
7070
}
7171

7272
jwm::JNILocal<jstring> jwm::StringUTF16::toJString(JNIEnv* env) const {
73-
return jwm::JNILocal<jstring>(env, env->NewString(c_str(), static_cast<jsize>(length())));
73+
return jwm::JNILocal<jstring>(env, env->NewString(reinterpret_cast<const jchar*>(c_str()), static_cast<jsize>(length())));
7474
}
7575

7676
jwm::StringUTF16 jwm::StringUTF16::makeFromJString(JNIEnv* env, jstring js) {
7777
jwm::StringUTF16 result;
7878
jsize length = env->GetStringLength(js);
7979
const jchar* chars = env->GetStringChars(js, nullptr);
80-
result = jwm::StringUTF16(chars, length);
80+
81+
const char16_t* signed_chars = reinterpret_cast<const char16_t*>(chars);
82+
result = jwm::StringUTF16(signed_chars, length);
8183
env->ReleaseStringChars(js, chars);
8284
return result;
8385
}

shared/cc/StringUTF16.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace jwm
1010
/**
1111
* @brief std::string which uses jchar as a character type
1212
*/
13-
class StringUTF16: public std::basic_string<jchar> {
13+
class StringUTF16: public std::basic_string<char16_t> {
1414
public:
15-
using std::basic_string<jchar>::basic_string;
15+
using std::basic_string<char16_t>::basic_string;
1616

1717
/**
1818
* Constructs StringUTF16 from C style string.

0 commit comments

Comments
 (0)