зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1262324 (part 2) - Introduce nsUConvProp. r=emk.
This patch fixes the hack of using a trio of |const char*| pointers to represent a property that has two strings and a length. --HG-- extra : rebase_source : 9f603b768146a78baf9fa2b4096cccfae9f87322
This commit is contained in:
Родитель
827c11faae
Коммит
c8c2a2bc4d
|
@ -15,11 +15,11 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
static const char* const labelsEncodings[][3] = {
|
||||
static const nsUConvProp labelsEncodings[] = {
|
||||
#include "labelsencodings.properties.h"
|
||||
};
|
||||
|
||||
static const char* const encodingsGroups[][3] = {
|
||||
static const nsUConvProp encodingsGroups[] = {
|
||||
#include "encodingsgroups.properties.h"
|
||||
};
|
||||
|
||||
|
|
|
@ -15,15 +15,15 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
static const char* const localesFallbacks[][3] = {
|
||||
static const nsUConvProp localesFallbacks[] = {
|
||||
#include "localesfallbacks.properties.h"
|
||||
};
|
||||
|
||||
static const char* const domainsFallbacks[][3] = {
|
||||
static const nsUConvProp domainsFallbacks[] = {
|
||||
#include "domainsfallbacks.properties.h"
|
||||
};
|
||||
|
||||
static const char* const nonParticipatingDomains[][3] = {
|
||||
static const nsUConvProp nonParticipatingDomains[] = {
|
||||
#include "nonparticipatingdomains.properties.h"
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
static const char* const kLangGroups[][3] = {
|
||||
static const nsUConvProp kLangGroups[] = {
|
||||
#include "langGroups.properties.h"
|
||||
};
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "nsIStringBundle.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsUConvPropertySearch.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
#define NS_LANGUAGEATOMSERVICE_CID \
|
||||
|
|
|
@ -13,8 +13,8 @@ struct PropertyComparator
|
|||
{
|
||||
const nsCString& mKey;
|
||||
explicit PropertyComparator(const nsCString& aKey) : mKey(aKey) {}
|
||||
int operator()(const char* const (&aProperty)[3]) const {
|
||||
return mKey.Compare(aProperty[0]);
|
||||
int operator()(const nsUConvProp& aProperty) const {
|
||||
return mKey.Compare(aProperty.mKey);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@ struct PropertyComparator
|
|||
|
||||
// static
|
||||
nsresult
|
||||
nsUConvPropertySearch::SearchPropertyValue(const char* const aProperties[][3],
|
||||
nsUConvPropertySearch::SearchPropertyValue(const nsUConvProp aProperties[],
|
||||
int32_t aNumberOfProperties,
|
||||
const nsACString& aKey,
|
||||
nsACString& aValue)
|
||||
|
@ -33,8 +33,8 @@ nsUConvPropertySearch::SearchPropertyValue(const char* const aProperties[][3],
|
|||
size_t index;
|
||||
if (BinarySearchIf(aProperties, 0, aNumberOfProperties,
|
||||
PropertyComparator(flat), &index)) {
|
||||
nsDependentCString val(aProperties[index][1],
|
||||
NS_PTR_TO_UINT32(aProperties[index][2]));
|
||||
nsDependentCString val(aProperties[index].mValue,
|
||||
aProperties[index].mValueLength);
|
||||
aValue.Assign(val);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,13 @@
|
|||
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
struct nsUConvProp
|
||||
{
|
||||
const char* const mKey;
|
||||
const char* const mValue;
|
||||
const uint32_t mValueLength;
|
||||
};
|
||||
|
||||
class nsUConvPropertySearch
|
||||
{
|
||||
public:
|
||||
|
@ -21,7 +28,7 @@ class nsUConvPropertySearch
|
|||
* the return value (empty string if not found)
|
||||
* @return NS_OK if found or NS_ERROR_FAILURE if not found
|
||||
*/
|
||||
static nsresult SearchPropertyValue(const char* const aProperties[][3],
|
||||
static nsresult SearchPropertyValue(const nsUConvProp aProperties[],
|
||||
int32_t aNumberOfProperties,
|
||||
const nsACString& aKey,
|
||||
nsACString& aValue);
|
||||
|
|
|
@ -21,7 +21,7 @@ def main(header, propFile):
|
|||
header.write("// This is a generated file. Please do not edit.\n")
|
||||
header.write("// Please edit the corresponding .properties file instead.\n")
|
||||
|
||||
entries = ['{ "%s", "%s", (const char*)NS_INT32_TO_PTR(%d) }'
|
||||
entries = ['{ "%s", "%s", %d }'
|
||||
% (key, mappings[key], len(mappings[key])) for key in keys]
|
||||
header.write(',\n'.join(entries) + '\n')
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
using mozilla::dom::EncodingUtils;
|
||||
using namespace mozilla;
|
||||
|
||||
static const char* const kUnixCharsets[][3] = {
|
||||
static const nsUConvProp kUnixCharsets[] = {
|
||||
#include "unixcharset.properties.h"
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
static const char* const kWinCharsets[][3] = {
|
||||
static const nsUConvProp kWinCharsets[] = {
|
||||
#include "wincharset.properties.h"
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче