Open Bug 1488626 Opened 6 years ago Updated 2 years ago

[meta] Remove wstring from XPIDL

Categories

(Core :: XPConnect, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: n.nethercote, Unassigned)

References

Details

(Keywords: meta)

XPIDL has `wstring`, which maps to `char16_t*`. The XPIDL docs (https://developer.mozilla.org/en-US/docs/Mozilla/XPIDL) are blunt: "Most of the time you don't want to use this type but AString."

More specifically, the use of `wstring` typically involves mixing raw `char16_t*` use with `nsString` use, necessitating the use of null checks, and `getter_Copies()` and `ToNewUnicode()`. Changing `wstring` occurrences to `AString` almost always makes the C++ code shorter and simpler and less error-prone. Occasionally you have to use something like `NS_LITERAL_STRING("foo") instead of `u"foo"`, but such cases are rare.

Once `wstring` occurrences are removed, it would be nice to remove `wstring` support entirely from XPIDL, but comm-central has quite a few occurrences too :(

(All the above is true for `string`, but it is used more, especially with string literal arguments, so removing it is more difficult. Once `wstring` is gone we can consider removing `string`.)
Depends on: 1488628
Another difficulty is that `wstring` arguments can be passed null. nsString doesn't have a good equivalent for that; there is the whole SetIsVoid/IsVoid thing but it's kinda gross.
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.