Skip to content

Commit ba8abf7

Browse files
committed
Remove basic_string<unsigned_char> from embind
Only `char`, `wchar`, `char8`, `char16`, and `char32` are valid specialization for `std::basic_string`: https://en.cppreference.com/w/cpp/string/basic_string But libc++ had a base template for `basic_string` that allowed any type to be passed for a long time. It looks there have been several attempts to remove this after which they restored it due to complaints, in chronological order: llvm/llvm-project@aeecef0 llvm/llvm-project@08a0faf llvm/llvm-project@e30a148 llvm/llvm-project#66153 llvm/llvm-project#72694 The last one, llvm/llvm-project#72694, eventually removed it. So `std::basic_string<unsigned_char>` is not allowed anymore. This removes all uses of `std::basic_string<unsigned_char>` from embind. This needs to be done to update libc++ to LLVM 19 (emscripten-core#22994). I'm uploading this as a separate PR because this removes a functionality from embind.
1 parent c35d60a commit ba8abf7

File tree

3 files changed

+0
-34
lines changed

3 files changed

+0
-34
lines changed

system/lib/embind/bind.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ EMSCRIPTEN_BINDINGS(builtin) {
149149
register_float<double>("double");
150150

151151
_embind_register_std_string(TypeID<std::string>::get(), "std::string");
152-
_embind_register_std_string(
153-
TypeID<std::basic_string<unsigned char>>::get(), "std::basic_string<unsigned char>");
154152
_embind_register_std_wstring(TypeID<std::wstring>::get(), sizeof(wchar_t), "std::wstring");
155153
_embind_register_std_wstring(TypeID<std::u16string>::get(), sizeof(char16_t), "std::u16string");
156154
_embind_register_std_wstring(TypeID<std::u32string>::get(), sizeof(char32_t), "std::u32string");

test/embind/embind.test.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -449,33 +449,6 @@ module({
449449
assert.equal('ABCD', e);
450450
});
451451

452-
test("can pass Uint8Array to std::basic_string<unsigned char>", function() {
453-
var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(new Uint8Array([65, 66, 67, 68]));
454-
assert.equal('ABCD', e);
455-
});
456-
457-
test("can pass long string to std::basic_string<unsigned char>", function() {
458-
var s = 'this string is long enough to exceed the short string optimization';
459-
var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(s);
460-
assert.equal(s, e);
461-
});
462-
463-
test("can pass Uint8ClampedArray to std::basic_string<unsigned char>", function() {
464-
var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(new Uint8ClampedArray([65, 66, 67, 68]));
465-
assert.equal('ABCD', e);
466-
});
467-
468-
469-
test("can pass Int8Array to std::basic_string<unsigned char>", function() {
470-
var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char(new Int8Array([65, 66, 67, 68]));
471-
assert.equal('ABCD', e);
472-
});
473-
474-
test("can pass ArrayBuffer to std::basic_string<unsigned char>", function() {
475-
var e = cm.emval_test_take_and_return_std_basic_string_unsigned_char((new Int8Array([65, 66, 67, 68])).buffer);
476-
assert.equal('ABCD', e);
477-
});
478-
479452
test("can pass string to std::string", function() {
480453
var string = stdStringIsUTF8?"aeiáéíαειЖЛФ從獅子€":"ABCD";
481454

test/embind/embind_test.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,6 @@ std::string emval_test_take_and_return_std_string_const_ref(const std::string& s
246246
return str;
247247
}
248248

249-
std::basic_string<unsigned char> emval_test_take_and_return_std_basic_string_unsigned_char(std::basic_string<unsigned char> str) {
250-
return str;
251-
}
252-
253249
std::wstring take_and_return_std_wstring(std::wstring str) {
254250
return str;
255251
}
@@ -1914,7 +1910,6 @@ EMSCRIPTEN_BINDINGS(tests) {
19141910
//function("emval_test_take_and_return_const_char_star", &emval_test_take_and_return_const_char_star);
19151911
function("emval_test_take_and_return_std_string", &emval_test_take_and_return_std_string);
19161912
function("emval_test_take_and_return_std_string_const_ref", &emval_test_take_and_return_std_string_const_ref);
1917-
function("emval_test_take_and_return_std_basic_string_unsigned_char", &emval_test_take_and_return_std_basic_string_unsigned_char);
19181913
function("take_and_return_std_wstring", &take_and_return_std_wstring);
19191914
function("take_and_return_std_u16string", &take_and_return_std_u16string);
19201915
function("take_and_return_std_u32string", &take_and_return_std_u32string);

0 commit comments

Comments
 (0)