Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecated use of std::char_traits<unsigned short>::length #791

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions src/main/java/org/bytedeco/javacpp/tools/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1031,18 +1031,18 @@ boolean classes(boolean handleExceptions, boolean defineAdapters, boolean conver
out.println(" return JavaCPP_createStringFromBytes(env, ptr, std::char_traits<char>::length(ptr));");
out.println("}");
out.println();
out.println("static JavaCPP_noinline jstring JavaCPP_createStringFromUTF16(JNIEnv* env, const unsigned short* ptr, size_t length) {");
out.println("static JavaCPP_noinline jstring JavaCPP_createStringFromUTF16(JNIEnv* env, const char16_t* ptr, size_t length) {");
out.println(" if (ptr == NULL) {");
out.println(" return NULL;");
out.println(" }");
out.println(" return env->NewString(ptr, length);");
out.println("}");
out.println();
out.println("static JavaCPP_noinline jstring JavaCPP_createStringFromUTF16(JNIEnv* env, const unsigned short* ptr) {");
out.println("static JavaCPP_noinline jstring JavaCPP_createStringFromUTF16(JNIEnv* env, const char16_t* ptr) {");
out.println(" if (ptr == NULL) {");
out.println(" return NULL;");
out.println(" }");
out.println(" return JavaCPP_createStringFromUTF16(env, ptr, std::char_traits<unsigned short>::length(ptr));");
out.println(" return JavaCPP_createStringFromUTF16(env, ptr, std::char_traits<char16_t>::length(ptr));");
out.println("}");
out.println();
}
Expand Down Expand Up @@ -2569,7 +2569,7 @@ void call(MethodInformation methodInfo, String returnPrefix, boolean secondCall)
// special considerations for char arrays as strings
if (asUtf16(methodInfo, k)) {
out.print(indent + "memcpy(");
suffix = ", (std::char_traits<unsigned short>::length(ptr" + k + ") + 1) * sizeof(unsigned short))";
suffix = ", (std::char_traits<char16_t>::length(ptr" + k + ") + 1) * sizeof(unsigned short))";
} else {
out.print(indent + "strcpy((char*)");
}
Expand Down
Loading