2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-03-29 04:46:49 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
Bug 1409635 (part 2) - Fix up nsIPrefLocalizedString. r=froydnj.
nsIPrefLocalizedString is meant to be a wrapper for nsISupportsString,
basically identical but with a different identifier. But it's not a
sub-interface of nsISupportsString. Instead it (almost) duplicates
nsISupportsString's internals.
Specifically, nsISupportsString has `attribute AString data`, resulting in
these C++ methods:
> NS_IMETHOD GetData(nsAString& aData)
> NS_IMETHOD SetData(const nsAString& aData)
nsIPrefLocalizedString has `attribute wstring data`, resulting in these C++
methods:
> NS_IMETHOD GetData(char16_t** aData)
> NS_IMETHOD SetData(const char16_t* aData)
Then we have nsPrefLocalizedString, the concrete subclass of
nsIPrefLocalizedString. It implements the AString methods via
NS_FORWARD_NSISUPPORTSSTRING, which forwards to mUnicodeString. It also
implements the wstring methods explicitly, and they just call the AString
methods. It's all a bit of a mess.
(Both interfaces also have `wstring toString()`. The forwarding works more
smoothly for that method.)
This patch changes nsIPrefLocalizedString so it is a trivial sub-interface of
nsISupportsString. This change eliminates the need for the wstring methods, so
the patch removes them as well. The net result is we have less code, and fewer
conversions between C strings and Gecko strings. The patch also merges the
nsISupportsString and nsIPrefLocalizedString cases in
nsPrefBranch::SetComplexValue(), because they are now identical. (The
nsISupportsString and nsIPrefLocalizedString cases in
nsPrefBranch::GetComplexValue() remain distinct; indeed, that's the whole
reason for having them as separate interfaces.)
2017-10-18 08:51:56 +03:00
|
|
|
#include "nsISupportsPrimitives.idl"
|
2001-03-29 04:46:49 +04:00
|
|
|
|
2001-10-08 23:52:17 +04:00
|
|
|
/**
|
|
|
|
* The nsIPrefLocalizedString interface is simply a wrapper interface for
|
2002-08-06 04:53:19 +04:00
|
|
|
* nsISupportsString so the preferences service can have a unique identifier
|
|
|
|
* to distinguish between requests for normal wide strings (nsISupportsString)
|
2001-10-08 23:52:17 +04:00
|
|
|
* and "localized" wide strings, which get their default values from properites
|
|
|
|
* files.
|
|
|
|
*
|
|
|
|
* @see nsIPrefBranch
|
2002-08-06 04:53:19 +04:00
|
|
|
* @see nsISupportsString
|
2001-03-29 04:46:49 +04:00
|
|
|
*/
|
2019-04-22 17:35:18 +03:00
|
|
|
[scriptable, builtinclass, uuid(ae419e24-1dd1-11b2-b39a-d3e5e7073802)]
|
Bug 1409635 (part 2) - Fix up nsIPrefLocalizedString. r=froydnj.
nsIPrefLocalizedString is meant to be a wrapper for nsISupportsString,
basically identical but with a different identifier. But it's not a
sub-interface of nsISupportsString. Instead it (almost) duplicates
nsISupportsString's internals.
Specifically, nsISupportsString has `attribute AString data`, resulting in
these C++ methods:
> NS_IMETHOD GetData(nsAString& aData)
> NS_IMETHOD SetData(const nsAString& aData)
nsIPrefLocalizedString has `attribute wstring data`, resulting in these C++
methods:
> NS_IMETHOD GetData(char16_t** aData)
> NS_IMETHOD SetData(const char16_t* aData)
Then we have nsPrefLocalizedString, the concrete subclass of
nsIPrefLocalizedString. It implements the AString methods via
NS_FORWARD_NSISUPPORTSSTRING, which forwards to mUnicodeString. It also
implements the wstring methods explicitly, and they just call the AString
methods. It's all a bit of a mess.
(Both interfaces also have `wstring toString()`. The forwarding works more
smoothly for that method.)
This patch changes nsIPrefLocalizedString so it is a trivial sub-interface of
nsISupportsString. This change eliminates the need for the wstring methods, so
the patch removes them as well. The net result is we have less code, and fewer
conversions between C strings and Gecko strings. The patch also merges the
nsISupportsString and nsIPrefLocalizedString cases in
nsPrefBranch::SetComplexValue(), because they are now identical. (The
nsISupportsString and nsIPrefLocalizedString cases in
nsPrefBranch::GetComplexValue() remain distinct; indeed, that's the whole
reason for having them as separate interfaces.)
2017-10-18 08:51:56 +03:00
|
|
|
interface nsIPrefLocalizedString : nsISupportsString {};
|
2001-03-29 04:46:49 +04:00
|
|
|
|
|
|
|
%{C++
|
|
|
|
|
2001-04-04 00:11:54 +04:00
|
|
|
#define NS_PREFLOCALIZEDSTRING_CID \
|
|
|
|
{ /* {064d9cee-1dd2-11b2-83e3-d25ab0193c26} */ \
|
|
|
|
0x064d9cee, \
|
|
|
|
0x1dd2, \
|
|
|
|
0x11b2, \
|
|
|
|
{ 0x83, 0xe3, 0xd2, 0x5a, 0xb0, 0x19, 0x3c, 0x26 } \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_PREFLOCALIZEDSTRING_CONTRACTID "@mozilla.org/pref-localizedstring;1"
|
2001-03-29 04:46:49 +04:00
|
|
|
|
|
|
|
%}
|