String bundle doesn't offer a scriptable enumerator
r=be
This commit is contained in:
jbetak%netscape.com 2000-05-02 05:08:39 +00:00
Родитель b11ccbafed
Коммит acc4c1956b
17 изменённых файлов: 292 добавлений и 206 удалений

Просмотреть файл

@ -42,7 +42,17 @@ interface nsIStringBundle : nsISupports
{
wstring GetStringFromID(in long aID);
wstring GetStringFromName([const] in wstring aName);
nsIBidirectionalEnumerator GetEnumeration();
/*
Don't use - nsIEnumerator and its subinterfaces have been deprecated
*/
[noscript] nsIBidirectionalEnumerator GetEnumeration();
/*
Implements nsISimpleEnumerator, replaces nsIEnumerator
*/
nsISimpleEnumerator getSimpleEnumeration();
};
[scriptable, uuid(D85A17C0-AA7C-11d2-9B8C-00805F8A16D9)]

Просмотреть файл

@ -124,12 +124,12 @@ nsStringBundle::GetStringFromID(PRInt32 aID, nsString& aResult)
name.AppendInt(aID, 10);
nsresult ret = mProps->GetStringProperty(name, aResult);
#ifdef DEBUG_tao
#ifdef DEBUG_tao_
char *s = aResult.ToNewCString();
printf("\n** GetStringFromID: aResult=%s, len=%d\n", s?s:"null",
aResult.Length());
delete s;
#endif /* DEBUG_tao */
#endif /* DEBUG_tao_ */
return ret;
}
@ -139,13 +139,13 @@ nsStringBundle::GetStringFromName(const nsString& aName, nsString& aResult)
{
NS_ENSURE_TRUE(mProps, NS_ERROR_FAILURE);
nsresult ret = mProps->GetStringProperty(aName, aResult);
#ifdef DEBUG_tao
#ifdef DEBUG_tao_
char *s = aResult.ToNewCString(),
*ss = aName.ToNewCString();
printf("\n** GetStringFromName: aName=%s, aResult=%s, len=%d\n",
ss?ss:"null", s?s:"null", aResult.Length());
delete s;
#endif /* DEBUG_tao */
#endif /* DEBUG_tao_ */
return ret;
}
@ -195,14 +195,26 @@ NS_IMETHODIMP
nsStringBundle::GetEnumeration(nsIBidirectionalEnumerator** elements)
{
nsAutoCMonitor(this);
if (!elements)
return NS_ERROR_INVALID_POINTER;
if (!elements)
return NS_ERROR_INVALID_POINTER;
nsresult ret = mProps->EnumerateProperties(elements);
nsresult ret = mProps->EnumerateProperties(elements);
return ret;
return ret;
}
NS_IMETHODIMP
nsStringBundle::GetSimpleEnumeration(nsISimpleEnumerator** elements)
{
if (!elements)
return NS_ERROR_INVALID_POINTER;
nsresult ret = mProps->SimpleEnumerateProperties(elements);
return ret;
}
nsresult
nsStringBundle::GetInputStream(const char* aURLSpec, nsILocale* aLocale, nsIInputStream*& in)
{
@ -278,7 +290,7 @@ nsStringBundle::GetInputStream(const char* aURLSpec, nsILocale* aLocale, nsIInpu
nsresult
nsStringBundle::OpenInputStream(nsString& aURLStr, nsIInputStream*& in)
{
#ifdef DEBUG_tao
#ifdef DEBUG_tao_
{
char *s = aURLStr.ToNewCString();
printf("\n** nsStringBundle::OpenInputStream: %s\n", s?s:"null");
@ -352,6 +364,7 @@ public:
NS_IMETHOD GetStringFromID(PRInt32 aID, PRUnichar ** aResult);
NS_IMETHOD GetStringFromName(const PRUnichar *aName, PRUnichar ** aResult);
NS_IMETHOD GetEnumeration(nsIBidirectionalEnumerator ** aResult);
NS_IMETHOD GetSimpleEnumeration(nsISimpleEnumerator** elements);
};
NS_IMPL_ISUPPORTS(nsExtensibleStringBundle, NS_GET_IID(nsIStringBundle));
@ -527,6 +540,13 @@ nsresult nsExtensibleStringBundle::GetEnumeration(nsIBidirectionalEnumerator **
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult nsExtensibleStringBundle::GetSimpleEnumeration(nsISimpleEnumerator ** aResult)
{
// XXX write me
*aResult = NULL;
return NS_ERROR_NOT_IMPLEMENTED;
}
/////////////////////////////////////////////////////////////////////////////////////////
#define MAX_CACHED_BUNDLES 10
@ -564,7 +584,7 @@ private:
nsStringBundleService::nsStringBundleService() :
mBundleMap(MAX_CACHED_BUNDLES, PR_TRUE)
{
#ifdef DEBUG_tao
#ifdef DEBUG_tao_
printf("\n++ nsStringBundleService::nsStringBundleService ++\n");
#endif
NS_INIT_REFCNT();
@ -706,7 +726,7 @@ NS_IMETHODIMP
nsStringBundleService::CreateBundle(const char* aURLSpec, nsILocale* aLocale,
nsIStringBundle** aResult)
{
#ifdef DEBUG_tao
#ifdef DEBUG_tao_
printf("\n++ nsStringBundleService::CreateBundle ++\n");
{
nsString aURLStr(aURLSpec);

Просмотреть файл

@ -221,47 +221,54 @@ main(int argc, char *argv[])
nsIBidirectionalEnumerator* propEnum = nsnull;
ret = bundle->GetEnumeration(&propEnum);
if (NS_FAILED(ret)) {
printf("cannot get enumeration\n");
return 1;
printf("cannot get enumeration\n");
return 1;
}
ret = propEnum->First();
if (NS_FAILED(ret))
{
printf("enumerator is empty\n");
return 1;
printf("enumerator is empty\n");
return 1;
}
cout << endl << "Key" << "\t" << "Value" << endl;
cout << "---" << "\t" << "-----" << endl;
while (NS_SUCCEEDED(ret))
{
nsIPropertyElement* propElem = nsnull;
ret = propEnum->CurrentItem((nsISupports**)&propElem);
if (NS_FAILED(ret)) {
printf("failed to get current item\n");
return 1;
}
nsString* key = nsnull;
nsString* val = nsnull;
ret = propElem->GetKey(&key);
if (NS_FAILED(ret)) {
printf("failed to get current element's key\n");
return 1;
}
ret = propElem->GetValue(&val);
if (NS_FAILED(ret)) {
printf("failed to get current element's value\n");
return 1;
}
char* keyCStr = key->ToNewCString();
char* valCStr = val->ToNewCString();
if (keyCStr && valCStr)
cout << keyCStr << "\t" << valCStr << endl;
delete[] keyCStr;
delete[] valCStr;
delete key;
delete val;
ret = propEnum->Next();
nsIPropertyElement* propElem = nsnull;
ret = propEnum->CurrentItem((nsISupports**)&propElem);
if (NS_FAILED(ret)) {
printf("failed to get current item\n");
return 1;
}
PRUnichar *pKey = nsnull;
PRUnichar *pVal = nsnull;
ret = propElem->GetKey(&pKey);
if (NS_FAILED(ret)) {
printf("failed to get current element's key\n");
return 1;
}
ret = propElem->GetValue(&pVal);
if (NS_FAILED(ret)) {
printf("failed to get current element's value\n");
return 1;
}
nsAutoString keyAdjustedLengthBuff(pKey);
nsAutoString valAdjustedLengthBuff(pVal);
char* keyCStr = keyAdjustedLengthBuff.ToNewCString();
char* valCStr = valAdjustedLengthBuff.ToNewCString();
if (keyCStr && valCStr)
cout << keyCStr << "\t" << valCStr << endl;
delete[] keyCStr;
delete[] valCStr;
delete[] pKey;
delete[] pVal;
ret = propEnum->Next();
}
return 0;

Просмотреть файл

@ -9,7 +9,6 @@ nsHashtableEnumerator.h
nsIArena.h
nsIByteBuffer.h
nsIObserverList.h
nsIPersistentProperties.h
nsISimpleEnumerator.h
nsISizeOfHandler.h
nsIUnicharBuffer.h

Просмотреть файл

@ -6,6 +6,8 @@ nsIObserver.idl
nsIObserverService.idl
nsIProperties.idl
nsIStopwatch.idl
nsIProperties.idl
nsIStopwatch.idl
nsIProperties.idl
nsIPersistentProperties2.idl
nsIStopwatch.idl
nsISupportsArray.idl

Просмотреть файл

@ -80,7 +80,6 @@ EXPORTS = \
nsIArena.h \
nsIByteBuffer.h \
nsIObserverList.h \
nsIPersistentProperties.h \
nsISimpleEnumerator.h \
nsISizeOfHandler.h \
nsIUnicharBuffer.h \
@ -115,6 +114,7 @@ XPIDLSRCS = \
nsISupportsArray.idl \
nsISupportsIterators.idl \
nsISupportsPrimitives.idl \
nsIPersistentProperties2.idl \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

Просмотреть файл

@ -39,7 +39,6 @@ EXPORTS = \
nsIArena.h \
nsIByteBuffer.h \
nsIObserverList.h \
nsIPersistentProperties.h \
nsISimpleEnumerator.h \
nsISizeOfHandler.h \
nsIUnicharBuffer.h \
@ -75,6 +74,7 @@ XPIDLSRCS = \
.\nsISupportsArray.idl \
.\nsISupportsIterators.idl \
.\nsISupportsPrimitives.idl \
.\nsIPersistentProperties2.idl \
$(NULL)
################################################################################

Просмотреть файл

@ -1,101 +1,8 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsIProperties_h___
#define nsIProperties_h___
#ifndef __gen_nsIPersistentProperties_h__
#define __gen_nsIPersistentProperties_h__
#include "nsIProperties.h"
#include "nsIEnumerator.h"
#include "nsISupportsArray.h"
#include "nsID.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsString.h"
// "soft" switch over to an IDL generated header file
#include "nsIPersistentProperties2.h"
// {1A180F60-93B2-11d2-9B8B-00805F8A16D9}
#define NS_IPERSISTENTPROPERTIES_IID \
{ 0x1a180f60, 0x93b2, 0x11d2, \
{ 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
#define NS_IPERSISTENTPROPERTIES_CID \
{ 0x2245e573, 0x9464, 0x11d2, \
{ 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
// {2245E573-9464-11d2-9B8B-00805F8A16D9}
//NS_DECLARE_ID(kPersistentPropertiesCID,
// 0x2245e573, 0x9464, 0x11d2, 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9);
static NS_DEFINE_CID(kPersistentPropertiesCID, NS_IPERSISTENTPROPERTIES_CID);
#define NS_PERSISTENTPROPERTIES_PROGID "component://netscape/persistent-properties"
#define NS_PERSISTENTPROPERTIES_CLASSNAME "Persistent Properties"
class nsIPersistentProperties : public nsIProperties
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPERSISTENTPROPERTIES_IID; return iid; }
NS_IMETHOD Load(nsIInputStream* aIn) = 0;
NS_IMETHOD Save(nsIOutputStream* aOut, const nsString& aHeader) = 0;
NS_IMETHOD Subclass(nsIPersistentProperties* aSubclass) = 0;
/**
* Enumerates the properties in the supplied enumerator.
* @return NS_ERROR_FAILURE if no properties to enumerate
*/
NS_IMETHOD EnumerateProperties(nsIBidirectionalEnumerator** aResult) = 0;
// XXX these 2 methods will be subsumed by the ones from
// nsIProperties once we figure this all out
NS_IMETHOD GetStringProperty(const nsString& aKey, nsString& aValue) = 0;
NS_IMETHOD SetStringProperty(const nsString& aKey, nsString& aNewValue,
nsString& aOldValue) = 0;
};
////////////////////////////////////////////////////////////////////////////////
// {C23C10B3-0E1A-11d3-A430-0060B0EB5963}
#define NS_IPROPERTYELEMENT_IID \
{ 0xc23c10b3, 0xe1a, 0x11d3, \
{ 0xa4, 0x30, 0x0, 0x60, 0xb0, 0xeb, 0x59, 0x63 } }
// {579C0568-0E1B-11d3-A430-0060B0EB5963}
//NS_DECLARE_ID(kPropertyElementCID,
// 0x579c0568, 0xe1b, 0x11d3, 0xa4, 0x30, 0x0, 0x60, 0xb0, 0xeb, 0x59, 0x63);
#define NS_IPROPERTYELEMENT_CID \
{ 0x579c0568, 0xe1b, 0x11d3, \
{ 0xa4, 0x30, 0x0, 0x60, 0xb0, 0xeb, 0x59, 0x63 } }
static NS_DEFINE_CID(kPropertyElementCID, NS_IPROPERTYELEMENT_CID);
class nsIPropertyElement : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPROPERTYELEMENT_IID; return iid; }
NS_IMETHOD SetKey(nsString* aKey) = 0;
NS_IMETHOD SetValue(nsString* aValue) = 0;
NS_IMETHOD GetKey(nsString** aReturnKey) = 0;
NS_IMETHOD GetValue(nsString** aReturnValue) = 0;
};
////////////////////////////////////////////////////////////////////////////////
#endif // nsIProperties_h___
#endif /* __gen_nsIPersistentProperties_h__ */

Просмотреть файл

Просмотреть файл

@ -0,0 +1,94 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
%{C++
#include "nsIEnumerator.h"
#include "nsISupportsArray.h"
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsIProperties.h"
#include "nsID.h"
#include "nsString.h"
%}
[ptr] native nsStringPtr(nsString);
[scriptable, uuid(283EE646-1AEF-11D4-98B3-00C04fA0CE9A)]
interface nsIPropertyElement : nsISupports {
[noscript] void SetKey(in nsStringPtr aKey);
[noscript] void SetValue(in nsStringPtr aValue);
wstring getKey();
wstring getValue();
};
%{C++
//{283EE645-1AEF-11D4-98B3-00C04fA0CE9A}
#define NS_IPROPERTYELEMENT_CID \
{ 0x283ee645, 0x1aef, 0x11d4, \
{ 0x98, 0xb3, 0x0, 0xc0, 0x4f, 0xa0, 0xce, 0x9a } }
static NS_DEFINE_CID(kPropertyElementCID, NS_IPROPERTYELEMENT_CID);
// {1A180F60-93B2-11d2-9B8B-00805F8A16D9}
#define NS_IPERSISTENTPROPERTIES_IID \
{ 0x1a180f60, 0x93b2, 0x11d2, \
{ 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
#define NS_IPERSISTENTPROPERTIES_CID \
{ 0x2245e573, 0x9464, 0x11d2, \
{ 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
static NS_DEFINE_CID(kPersistentPropertiesCID, NS_IPERSISTENTPROPERTIES_CID);
#define NS_PERSISTENTPROPERTIES_PROGID "component://netscape/persistent-properties"
#define NS_PERSISTENTPROPERTIES_CLASSNAME "Persistent Properties"
class nsIPersistentProperties : public nsIProperties
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IPERSISTENTPROPERTIES_IID; return iid; }
NS_IMETHOD Load(nsIInputStream* aIn) = 0;
NS_IMETHOD Save(nsIOutputStream* aOut, const nsString& aHeader) = 0;
NS_IMETHOD Subclass(nsIPersistentProperties* aSubclass) = 0;
/**
* Enumerates the properties in the supplied enumerator.
* @return NS_ERROR_FAILURE if no properties to enumerate
*/
NS_IMETHOD EnumerateProperties(nsIBidirectionalEnumerator** aResult) = 0;
NS_IMETHOD SimpleEnumerateProperties(nsISimpleEnumerator** aResult) = 0;
// XXX these 2 methods will be subsumed by the ones from
// nsIProperties once we figure this all out
NS_IMETHOD GetStringProperty(const nsString& aKey, nsString& aValue) = 0;
NS_IMETHOD SetStringProperty(const nsString& aKey, nsString& aNewValue,
nsString& aOldValue) = 0;
};
%}

Просмотреть файл

@ -31,6 +31,7 @@
#include "nsIUnicharInputStream.h"
#include "nsProperties.h"
#include "pratom.h"
#include "nsEnumeratorUtils.h"
static PLHashNumber
HashKey(const PRUnichar *aString)
@ -249,27 +250,57 @@ AddElemToArray(PLHashEntry* he, PRIntn i, void* arg)
NS_IMETHODIMP
nsPersistentProperties::EnumerateProperties(nsIBidirectionalEnumerator** aResult)
{
if (!mTable)
return NS_ERROR_FAILURE;
if (!mTable)
return NS_ERROR_FAILURE;
nsISupportsArray* propArray;
nsresult rv = NS_NewISupportsArray(&propArray);
if (rv != NS_OK)
return rv;
nsISupportsArray* propArray;
nsresult rv = NS_NewISupportsArray(&propArray);
if (rv != NS_OK)
return rv;
// Step through hash entries populating a transient array
// Step through hash entries populating a transient array
PRIntn n = PL_HashTableEnumerateEntries(mTable, AddElemToArray, (void *)propArray);
if ( n < (PRIntn) mTable->nentries )
return NS_ERROR_OUT_OF_MEMORY;
// Convert array into enumerator
rv = NS_NewISupportsArrayEnumerator(propArray, aResult);
if (rv != NS_OK)
return rv;
// Convert array into enumerator
rv = NS_NewISupportsArrayEnumerator(propArray, aResult);
if (rv != NS_OK)
return rv;
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP
nsPersistentProperties::SimpleEnumerateProperties(nsISimpleEnumerator** aResult)
{
nsCOMPtr<nsIBidirectionalEnumerator> iterator;
if (!mTable)
return NS_ERROR_FAILURE;
nsISupportsArray* propArray;
nsresult rv = NS_NewISupportsArray(&propArray);
if (rv != NS_OK)
return rv;
// Step through hash entries populating a transient array
PRIntn n = PL_HashTableEnumerateEntries(mTable, AddElemToArray, (void *)propArray);
if ( n < (PRIntn) mTable->nentries )
return NS_ERROR_OUT_OF_MEMORY;
// Convert array into enumerator
rv = NS_NewISupportsArrayEnumerator(propArray, getter_AddRefs(iterator));
// Convert nsIEnumerator into nsISimpleEnumerator
rv = NS_NewAdapterEnumerator(aResult, iterator);
if (rv != NS_OK)
return rv;
return NS_OK;
}
PRInt32
nsPersistentProperties::Read()
{
@ -383,43 +414,43 @@ nsPropertyElement::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
NS_IMPL_ISUPPORTS1(nsPropertyElement, nsIPropertyElement)
NS_IMETHODIMP
nsPropertyElement::GetKey(nsString** aReturnKey)
nsPropertyElement::GetKey(PRUnichar **aReturnKey)
{
if (aReturnKey)
{
*aReturnKey = mKey;
return NS_OK;
}
if (aReturnKey)
{
*aReturnKey = (PRUnichar *) mKey->ToNewUnicode();
return NS_OK;
}
return NS_ERROR_INVALID_POINTER;
return NS_ERROR_INVALID_POINTER;
}
NS_IMETHODIMP
nsPropertyElement::GetValue(nsString** aReturnValue)
nsPropertyElement::GetValue(PRUnichar **aReturnValue)
{
if (aReturnValue)
{
*aReturnValue = mValue;
return NS_OK;
}
if (aReturnValue)
{
*aReturnValue = (PRUnichar *) mValue->ToNewUnicode();
return NS_OK;
}
return NS_ERROR_INVALID_POINTER;
return NS_ERROR_INVALID_POINTER;
}
NS_IMETHODIMP
nsPropertyElement::SetKey(nsString* aKey)
{
mKey = aKey;
mKey = aKey;
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP
nsPropertyElement::SetValue(nsString* aValue)
{
mValue = aValue;
mValue = aValue;
return NS_OK;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -41,6 +41,7 @@ public:
NS_IMETHOD Save(nsIOutputStream* aOut, const nsString& aHeader);
NS_IMETHOD Subclass(nsIPersistentProperties* aSubclass);
NS_IMETHOD EnumerateProperties(nsIBidirectionalEnumerator* *aResult);
NS_IMETHOD SimpleEnumerateProperties(nsISimpleEnumerator** aResult);
// XXX these 2 methods will be subsumed by the ones from
// nsIProperties once we figure this all out
@ -65,23 +66,23 @@ protected:
class nsPropertyElement : public nsIPropertyElement
{
public:
nsPropertyElement();
virtual ~nsPropertyElement();
nsPropertyElement();
virtual ~nsPropertyElement();
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
static NS_METHOD
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// nsIPropertyElement methods:
NS_IMETHOD GetKey(nsString** aReturnKey);
NS_IMETHOD GetValue(nsString** aReturnValue);
NS_IMETHOD SetKey(nsString* aKey);
NS_IMETHOD SetValue(nsString* aValue);
// nsIPropertyElement methods:
NS_IMETHOD GetKey(PRUnichar **aReturnKey);
NS_IMETHOD GetValue(PRUnichar **aReturnValue);
NS_IMETHOD SetKey(nsString* aKey);
NS_IMETHOD SetValue(nsString* aValue);
protected:
nsString* mKey;
nsString* mValue;
nsString* mKey;
nsString* mValue;
};
#endif /* nsPersistentProperties_h___ */

Просмотреть файл

@ -175,26 +175,32 @@ main(int argc, char* argv[])
printf("failed to get current item\n");
return 1;
}
nsString* key = nsnull;
nsString* val = nsnull;
ret = propElem->GetKey(&key);
PRUnichar *pKey = nsnull;
PRUnichar *pVal = nsnull;
ret = propElem->GetKey(&pKey);
if (NS_FAILED(ret)) {
printf("failed to get current element's key\n");
return 1;
}
ret = propElem->GetValue(&val);
ret = propElem->GetValue(&pVal);
if (NS_FAILED(ret)) {
printf("failed to get current element's value\n");
return 1;
}
char* keyCStr = key->ToNewCString();
char* valCStr = val->ToNewCString();
nsAutoString keyAdjustedLengthBuff(pKey);
nsAutoString valAdjustedLengthBuff(pVal);
char* keyCStr = keyAdjustedLengthBuff.ToNewCString();
char* valCStr = valAdjustedLengthBuff.ToNewCString();
if (keyCStr && valCStr)
cout << keyCStr << "\t" << valCStr << endl;
delete[] keyCStr;
delete[] valCStr;
delete key;
delete val;
delete[] pKey;
delete[] pVal;
ret = propEnum->Next();
}

Просмотреть файл

@ -195,6 +195,7 @@ viewer:defaults:pref:xpinstall.js
viewer:defaults:profile:*
viewer:res:arrow.gif
viewer:res:charsetalias.properties
viewer:res:acceptlanguage.properties
viewer:res:charsetData.properties
viewer:res:charsetTitles.properties
viewer:res:entityTables:*

Просмотреть файл

@ -227,6 +227,7 @@ bin/res/SchemaConcat.tbl
bin/res/URLFieldSchema.tbl
bin/res/arrow.gif
bin/res/charsetalias.properties
bin/res/acceptlanguage.properties
bin/res/unixcharset.properties
bin/res/charsetData.properties
bin/res/charsetTitles.properties

Просмотреть файл

@ -208,6 +208,7 @@ bin\res\wincharset.properties
bin\res\charsetalias.properties
bin\res\charsetData.properties
bin\res\charsetTitles.properties
bin/res/acceptlanguage.properties
bin\res\entityTables\*
bin\res\rdf\article.gif
bin\res\rdf\document.gif

Просмотреть файл

@ -1269,16 +1269,22 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
ret = propEnum->CurrentItem((nsISupports**)&propElem);
if (NS_FAILED(ret))
goto cleanup;
nsString* key = nsnull;
nsString* val = nsnull;
ret = propElem->GetKey(&key);
PRUnichar *pKey = nsnull;
PRUnichar *pVal = nsnull;
ret = propElem->GetKey(&pKey);
if (NS_FAILED(ret))
goto cleanup;
ret = propElem->GetValue(&val);
ret = propElem->GetValue(&pVal);
if (NS_FAILED(ret))
goto cleanup;
char* keyCStr = key->ToNewCString();
PRUnichar* valCStr = val->ToNewUnicode();
nsAutoString keyAdjustedLengthBuff(pKey);
nsAutoString valAdjustedLengthBuff(pVal);
char* keyCStr = keyAdjustedLengthBuff.ToNewCString();
PRUnichar* valCStr = valAdjustedLengthBuff.ToNewUnicode();
if (keyCStr && valCStr)
{
JSString* propValJSStr = JS_NewUCStringCopyZ(cx, (jschar*) valCStr);
@ -1287,10 +1293,10 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur
delete[] keyCStr;
delete[] valCStr;
}
if (key)
delete key;
if (val)
delete val;
if (pKey)
delete[] pKey;
if (pVal)
delete[] pVal;
ret = propEnum->Next();
}