Thank you Simon, that looks way more ergonomic! A bummer, I'll have to modify my in-flight patches though :-)
Do you intend to update existing documentation at <https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Guide/Internal_strings> (or move it to firefox source docs)? Am 01.07.20 um 16:53 schrieb Simon Giesecke: > Hi, > > until Bug 1648010, there were some macros widely used for the handling of > string literals, i.e. NS_LITERAL_STRING, NS_LITERAL_CSTRING, > NS_NAMED_LITERAL_STRING, NS_NAMED_LITERAL_CSTRING. These macros have resp. > will have been removed once all patches for that bug landed. > > The non-NAMED variants are now replaced by user-defined literals using the > _ns suffix: > > - NS_LITERAL_CSTRING("foo") becomes "foo"_ns > - NS_LITERAL_STRING("bar") becomes u"bar"_ns > > This makes the string literals somewhat more concise and more consistent > with normal literals. > > Note that the "base" literal needs to use the correct underlying character > type (char vs. char16_t), which is why the same user-defined literal is > used for both cases. > > For cases where a macro is used to construct a nsString-like literal, > either > - the definition of the macro can be changed to make use of the > user-defined literal already, > - the macro can be changed to a constexpr constant > - in cases where neither of these is possible or desirable, the (new) macro > NS_LITERAL_STRING_FROM_CSTRING can be used, which behaves just like > NS_LITERAL_STRING did, but has intentionally a somewhat more verbose name > to avoid its widespread use where it is not required > > The NAMED variants have produced a non-standard syntax for declaring > variables that are subsequently referenced by user code. These are now > replaced by regular variable/constant declarations such as: > > constexpr auto kNamedCLiteral = "foo"_ns; > constexpr auto kNamedLiteral = u"bar"_ns; > > This is slightly longer than the use of the NAMED macros, but uses a > standard syntax. > > Best wishes > Simon > _______________________________________________ > dev-platform mailing list > [email protected] > https://lists.mozilla.org/listinfo/dev-platform > _______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

