Move nsCString from |operator char*()| to |get()| and |NS_CONST_CAST| where needed. bug=53057, r=dmose, sr=shaver

This commit is contained in:
disttsc%bart.nl 2001-03-20 05:37:56 +00:00
Родитель d2b6ac7c9f
Коммит 497249a5e8
25 изменённых файлов: 56 добавлений и 79 удалений

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

@ -629,8 +629,8 @@ nsPSMComponent::GetControlConnection( CMT_CONTROL * *_retval )
psmStatus = CMT_Hello( mControl,
PROTOCOL_VERSION,
profilenameC,
NS_CONST_CAST(char*,(const char*)profilePath));
NS_CONST_CAST(char*,profilenameC.get()),
NS_CONST_CAST(char*,profilePath.get()));
if (psmStatus == CMTFailure)
goto failure;

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

@ -366,7 +366,7 @@ nsPSMSocketInfo::ProxyStepUp()
nsCAutoString hostName;
hostName.AssignWithConversion(mHostName);
return CMT_ProxyStepUp(mControl, mSocket, this, hostName);
return CMT_ProxyStepUp(mControl, mSocket, this, NS_CONST_CAST(char*,hostName.get()));
}
NS_IMETHODIMP

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

@ -2515,7 +2515,7 @@ nsFontMetricsGTK::SearchNode(nsFontNode* aNode, PRUnichar aChar)
}
static void
GetFontNames(char* aPattern, nsFontNodeArray* aNodes)
GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
{
#ifdef NS_FONT_DEBUG_CALL_TRACE
if (gDebug & NS_FONT_DEBUG_CALL_TRACE) {
@ -2873,7 +2873,7 @@ nsFontMetricsGTK::TryNode(nsCString* aName, PRUnichar aChar)
hyphen = pattern.FindChar('-', PR_FALSE, hyphen + 1);
pattern.Insert("-*-*-*-*-*-*-*-*-*-*", hyphen);
nsFontNodeArray nodes;
GetFontNames(pattern, &nodes);
GetFontNames(pattern.get(), &nodes);
if (nodes.Count() > 0) {
node = nodes.GetElement(0);
}

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

@ -102,7 +102,7 @@ NS_IMPL_ISUPPORTS1(nsAddbookUrl, nsIURI)
// addbook:add?vcard=begin%3Avcard%0Afn%3ARichard%20Pizzarro%0Aemail%3Binternet%3Arhp%40netscape.com%0Aend%3Avcard%0A
//
NS_IMETHODIMP
nsAddbookUrl::CrackAddURL(char *searchPart)
nsAddbookUrl::CrackAddURL(const char *searchPart)
{
return NS_OK;
}
@ -115,12 +115,12 @@ nsAddbookUrl::CrackAddURL(char *searchPart)
// addbook:printall?email=rhp@netscape.com&folder=Netscape%20Address%20Book
//
NS_IMETHODIMP
nsAddbookUrl::CrackPrintURL(char *searchPart, PRInt32 aOperation)
nsAddbookUrl::CrackPrintURL(const char *searchPart, PRInt32 aOperation)
{
nsCString emailAddr;
nsCString folderName;
char *rest = searchPart;
char *rest = NS_CONST_CAST(char*, searchPart);
// okay, first, free up all of our old search part state.....
CleanupAddbookState();
@ -166,13 +166,13 @@ nsAddbookUrl::CrackPrintURL(char *searchPart, PRInt32 aOperation)
if (!emailAddr.IsEmpty())
{
nsUnescape(emailAddr);
nsUnescape(NS_CONST_CAST(char*, emailAddr.get()));
mAbCardProperty->SetCardValue(kPriEmailColumn, NS_ConvertASCIItoUCS2(emailAddr).GetUnicode());
}
if (!folderName.IsEmpty())
{
nsUnescape(folderName);
nsUnescape(NS_CONST_CAST(char*, folderName.get()));
mAbCardProperty->SetCardValue(kWorkAddressBook, NS_ConvertASCIItoUCS2(folderName).GetUnicode());
}
@ -256,7 +256,7 @@ nsresult nsAddbookUrl::ParseUrl()
}
else if (!mOperationPart.IsEmpty())
{
nsUnescape(mOperationPart);
nsUnescape(NS_CONST_CAST(char*, mOperationPart.get()));
}
mOperationPart.ToLowerCase();
@ -264,17 +264,17 @@ nsresult nsAddbookUrl::ParseUrl()
if (!nsCRT::strcmp(mOperationPart, "printone"))
{
mOperationType = nsIAddbookUrlOperation::PrintIndividual;
rv = CrackPrintURL(searchPart, mOperationType);
rv = CrackPrintURL(searchPart.get(), mOperationType);
}
else if (!nsCRT::strcmp(mOperationPart, "printall"))
{
mOperationType = nsIAddbookUrlOperation::PrintAddressBook;
rv = CrackPrintURL(searchPart, mOperationType);
rv = CrackPrintURL(searchPart.get(), mOperationType);
}
else if (!nsCRT::strcmp(mOperationPart, "add"))
{
mOperationType = nsIAddbookUrlOperation::AddToAddressBook;
rv = CrackAddURL(searchPart);
rv = CrackAddURL(searchPart.get());
}
else
mOperationType = nsIAddbookUrlOperation::InvalidUrl;

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

@ -48,8 +48,8 @@ protected:
nsresult ParseUrl(); // This gets the ball rolling...
NS_METHOD CrackAddURL(char *searchPart);
NS_METHOD CrackPrintURL(char *searchPart, PRInt32 aOperation);
NS_METHOD CrackAddURL(const char *searchPart);
NS_METHOD CrackPrintURL(const char *searchPart, PRInt32 aOperation);
NS_METHOD GetAbCardProperty(nsAbCardProperty **aAbCardProp);
nsCString mOperationPart; // string name of operation requested

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

@ -1323,7 +1323,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns
addressToBeRemoved += NS_CONST_CAST(char*, (const char *)email);
}
rv= RemoveDuplicateAddresses(_compFields->GetCc(), (char *)addressToBeRemoved, PR_TRUE, &resultStr);
rv= RemoveDuplicateAddresses(_compFields->GetCc(), addressToBeRemoved.get(), PR_TRUE, &resultStr);
if (NS_SUCCEEDED(rv))
{
_compFields->SetCc(resultStr);
@ -2212,7 +2212,7 @@ nsresult nsMsgCompose::NotifyStateListeners(TStateListenerNotification aNotifica
nsresult nsMsgCompose::AttachmentPrettyName(const char* url, PRUnichar** _retval)
{
nsCAutoString unescapeURL(url);
nsUnescape(unescapeURL);
nsUnescape(NS_CONST_CAST(char*, unescapeURL.get()));
if (unescapeURL.IsEmpty())
{
nsAutoString unicodeUrl;

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

@ -170,21 +170,21 @@ nsresult nsMailtoUrl::ParseMailtoUrl(char * searchPart)
// Now unescape any fields that need escaped...
if (!m_toPart.IsEmpty())
nsUnescape(m_toPart);
nsUnescape(NS_CONST_CAST(char*, m_toPart.get()));
if (!m_ccPart.IsEmpty())
nsUnescape(m_ccPart);
nsUnescape(NS_CONST_CAST(char*, m_ccPart.get()));
if (!m_subjectPart.IsEmpty())
nsUnescape(m_subjectPart);
nsUnescape(NS_CONST_CAST(char*, m_subjectPart.get()));
if (!m_newsgroupPart.IsEmpty())
nsUnescape(m_newsgroupPart);
nsUnescape(NS_CONST_CAST(char*, m_newsgroupPart.get()));
if (!m_referencePart.IsEmpty())
nsUnescape(m_referencePart);
nsUnescape(NS_CONST_CAST(char*, m_referencePart.get()));
if (!m_attachmentPart.IsEmpty())
nsUnescape(m_attachmentPart);
nsUnescape(NS_CONST_CAST(char*, m_attachmentPart.get()));
if (!m_bodyPart.IsEmpty())
nsUnescape(m_bodyPart);
nsUnescape(NS_CONST_CAST(char*, m_bodyPart.get()));
if (!m_newsHostPart.IsEmpty())
nsUnescape(m_newsHostPart);
nsUnescape(NS_CONST_CAST(char*, m_newsHostPart.get()));
return NS_OK;
}
@ -233,7 +233,7 @@ nsresult nsMailtoUrl::ParseUrl()
PRUint32 numExtraChars = m_toPart.Mid(searchPart, startOfSearchPart, -1);
if (!searchPart.IsEmpty())
{
ParseMailtoUrl(searchPart);
ParseMailtoUrl(NS_CONST_CAST(char*, searchPart.get()));
// now we need to strip off the search part from the
// to part....
m_toPart.Cut(startOfSearchPart, numExtraChars);
@ -241,7 +241,7 @@ nsresult nsMailtoUrl::ParseUrl()
}
else if (!m_toPart.IsEmpty())
{
nsUnescape(m_toPart);
nsUnescape(NS_CONST_CAST(char*, m_toPart.get()));
}
return rv;
@ -453,8 +453,8 @@ nsSmtpUrl::SetRecipients(const char * aRecipientsList)
NS_ENSURE_ARG(aRecipientsList);
m_toPart = aRecipientsList;
if (!m_toPart.IsEmpty())
nsUnescape(m_toPart);
return NS_OK;
nsUnescape(NS_CONST_CAST(char*, m_toPart.get()));
return NS_OK;
}

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

@ -2878,8 +2878,8 @@ NS_IMETHODIMP nsImapService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
// now extract lots of fun information...
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl);
nsCAutoString unescapedSpec(aSpec);
nsUnescape(unescapedSpec);
mailnewsUrl->SetSpec((char *) unescapedSpec); // set the url spec...
nsUnescape(NS_CONST_CAST(char*, unescapedSpec.get()));
mailnewsUrl->SetSpec(unescapedSpec.get()); // set the url spec...
nsXPIDLCString userName;
nsXPIDLCString hostName;

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

@ -1201,7 +1201,7 @@ nsPop3Protocol::GurlResponse()
/// the xpidl file which is preventing SetMailAccountURL from taking
// const char *. When that is fixed, we can remove this cast.
if (m_nsIPop3Sink)
m_nsIPop3Sink->SetMailAccountURL((char *) m_commandResponse);
m_nsIPop3Sink->SetMailAccountURL(m_commandResponse.get());
}
else {
m_pop3ConData->capability_flags &= ~POP3_HAS_GURL;

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

@ -257,7 +257,7 @@ nsPop3Sink::IncorporateBegin(const char* uidlString,
nsCAutoString uidlCString("X-UIDL: ");
uidlCString += uidlString;
uidlCString += MSG_LINEBREAK;
WriteLineToMailbox(uidlCString);
WriteLineToMailbox(NS_CONST_CAST(char*, uidlCString.get()));
}
// WriteLineToMailbox("X-Mozilla-Status: 8000" MSG_LINEBREAK);
char *statusLine = PR_smprintf(X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK, flags);

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

@ -1720,7 +1720,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
newAttachName.Append(".tmp");
}
tmpSpec = nsMsgCreateTempFileSpec(newAttachName);
tmpSpec = nsMsgCreateTempFileSpec(NS_CONST_CAST(char*, newAttachName.get()));
}
// This needs to be done so the attachment structure has a handle

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

@ -178,7 +178,7 @@ MimeInlineTextPlainFlowed_parse_begin (MimeObject *obj)
openingDiv += '"';
}
openingDiv += ">";
status = MimeObject_write(obj, openingDiv, openingDiv.Length(), PR_FALSE);
status = MimeObject_write(obj, NS_CONST_CAST(char*, openingDiv.get()), openingDiv.Length(), PR_FALSE);
if (status < 0) return status;
}

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

@ -214,7 +214,7 @@ MimeInlineTextPlain_parse_begin (MimeObject *obj)
}
else
openingDiv = "<pre wrap>";
status = MimeObject_write(obj, openingDiv,openingDiv.Length(), PR_FALSE);
status = MimeObject_write(obj, NS_CONST_CAST(char*, openingDiv.get()), openingDiv.Length(), PR_FALSE);
if (status < 0) return status;
/* text/plain objects always have separators before and after them.

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

@ -707,7 +707,7 @@ nsresult nsHTTPResponse::EmitHeaders(nsCString& aResponseBuffer)
char *statusLine;
statusLine = PR_smprintf("HTTP/%s %3d %s", versionString, mStatus,
(char*)mStatusString);
mStatusString.get());
if (!statusLine)
return NS_ERROR_OUT_OF_MEMORY;

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

@ -503,7 +503,8 @@ nsHTTPServerListener::OnDataAvailable(nsIRequest *request,
nsCString ts(trailerHeader);
ts.StripWhitespace();
char *cp = ts;
// XXXjag convert to new string code sometime
char *cp = NS_CONST_CAST(char*, ts.get());
while (*cp) {
char * pp = PL_strchr(cp , ',');

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

@ -157,7 +157,7 @@ nsIndexedToHTML::Handle201(char* buffer, nsString &pushBuffer)
pushBuffer.AppendWithConversion(filename);
pushBuffer.AppendWithConversion("\"> ");
nsUnescape(filename);
nsUnescape(NS_CONST_CAST(char*, filename.get()));
pushBuffer.AppendWithConversion(filename);
pushBuffer.AppendWithConversion("</a>");
pushBuffer.AppendWithConversion("</td>\n");

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

@ -82,7 +82,7 @@ int writeDBM(int cycles)
nsCAutoString keyName("foo");
keyName.AppendInt( x );
db_key.data = (char*)keyName;
db_key.data = NS_CONST_CAST(char*, keyName.get());
db_key.size = keyName.Length();
db_data.data = data;
@ -95,7 +95,7 @@ int writeDBM(int cycles)
#if USE_ENTRY_ID
db_key.data = (void*)&x;
db_key.size = sizeof(x);
db_data.data = (char*)keyName;
db_data.data = NS_CONST_CAST(char*, keyName.get());
db_data.size = keyName.Length();
if(0 != (*myDB->put)(myDB, &db_key, &db_data, 0)) {
@ -203,7 +203,7 @@ writeFile(int cycles)
fd = PR_OpenFile(filename, PR_WRONLY|PR_TRUNCATE, 0644);
if (!fd)
printf("bad filename? %s\n", (char*)filename);
printf("bad filename? %s\n", filename.get());
i2 = PR_IntervalNow();

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

@ -566,7 +566,7 @@ PRUnichar* nsCString::ToNewUnicode() const {
if (result) {
CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0);
nsAutoString temp(desc);
temp.AssignWithConversion(*this);
temp.AssignWithConversion(mStr);
}
return result;
}
@ -589,7 +589,7 @@ char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) co
CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0);
nsCAutoString temp(theDescr);
temp.Assign(*this, PR_MIN(mLength, aBufLength-1));
temp.Assign(mStr, PR_MIN(mLength, aBufLength-1));
temp.mStr=0;
}
return aBuf;

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

@ -232,7 +232,6 @@ public:
string conversion methods...
*********************************************************************/
//#ifndef STANDALONE_STRING_TESTS
operator char*() {return mStr;}
operator const char*() const {return (const char*)mStr;}
//#endif
@ -528,24 +527,13 @@ class NS_COM NS_ConvertUCS2toUTF8
explicit NS_ConvertUCS2toUTF8( const nsAReadableString& aString );
operator const char*() const // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |const char*| is deprecated, use |get()| instead.");
return get();
}
operator char*() // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |char*| is deprecated, use |NS_CONST_CAST()| and |get()| instead.");
return NS_CONST_CAST(char*, get());
}
protected:
void Append( const PRUnichar* aString, PRUint32 aLength );
private:
// NOT TO BE IMPLEMENTED
NS_ConvertUCS2toUTF8( char );
operator const char*() const; // use |get()|
};

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

@ -855,7 +855,7 @@ void nsClipboard::SelectionGetCB(GtkWidget *widget,
{
dataFlavor = kUnicodeMime;
} else {
dataFlavor = type;
dataFlavor = type.get();
}
// Get data out of transferable.

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

@ -1126,7 +1126,7 @@ nsLocalFile::Spawn(const char **args, PRUint32 count)
my_argv[i+1] = (char *)args[i];
}
// we need to set argv[0] to the program name.
my_argv[0] = mResolvedPath;
my_argv[0] = NS_CONST_CAST(char*, mResolvedPath.get());
// null terminate the array
my_argv[count+1] = NULL;

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

@ -566,7 +566,7 @@ PRUnichar* nsCString::ToNewUnicode() const {
if (result) {
CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0);
nsAutoString temp(desc);
temp.AssignWithConversion(*this);
temp.AssignWithConversion(mStr);
}
return result;
}
@ -589,7 +589,7 @@ char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) co
CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0);
nsCAutoString temp(theDescr);
temp.Assign(*this, PR_MIN(mLength, aBufLength-1));
temp.Assign(mStr, PR_MIN(mLength, aBufLength-1));
temp.mStr=0;
}
return aBuf;

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

@ -232,7 +232,6 @@ public:
string conversion methods...
*********************************************************************/
//#ifndef STANDALONE_STRING_TESTS
operator char*() {return mStr;}
operator const char*() const {return (const char*)mStr;}
//#endif
@ -528,24 +527,13 @@ class NS_COM NS_ConvertUCS2toUTF8
explicit NS_ConvertUCS2toUTF8( const nsAReadableString& aString );
operator const char*() const // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |const char*| is deprecated, use |get()| instead.");
return get();
}
operator char*() // use |get()|
{
NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |char*| is deprecated, use |NS_CONST_CAST()| and |get()| instead.");
return NS_CONST_CAST(char*, get());
}
protected:
void Append( const PRUnichar* aString, PRUint32 aLength );
private:
// NOT TO BE IMPLEMENTED
NS_ConvertUCS2toUTF8( char );
operator const char*() const; // use |get()|
};

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

@ -315,7 +315,7 @@ nsString nsStreamTransfer::SuggestNameFor( nsIChannel *aChannel, char const *sug
// try to overwrite c:\config.sys or something.
nsCOMPtr<nsILocalFile> localFile;
nsCAutoString suggestedFileName(suggestedName);
if ( NS_SUCCEEDED( NS_NewLocalFile( nsUnescape(suggestedFileName), PR_FALSE, getter_AddRefs( localFile ) ) ) ) {
if ( NS_SUCCEEDED( NS_NewLocalFile( nsUnescape(NS_CONST_CAST(char*, suggestedFileName.get())), PR_FALSE, getter_AddRefs( localFile ) ) ) ) {
// We want base part of name only.
nsXPIDLString baseName;
if ( NS_SUCCEEDED( localFile->GetUnicodeLeafName( getter_Copies( baseName ) ) ) ) {

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

@ -295,9 +295,9 @@ PRInt32 nsInstallFile::Complete()
{
nsXPIDLCString path;
mFinalFile->GetPath(getter_Copies(path));
VR_Install( NS_ConvertUCS2toUTF8(*mVersionRegistryName),
(char*)(const char*)path, // DO NOT CHANGE THIS.
NS_ConvertUCS2toUTF8(*mVersionInfo),
VR_Install( NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(*mVersionRegistryName).get()),
NS_CONST_CAST(char*, path.get()),
NS_CONST_CAST(char*, NS_ConvertUCS2toUTF8(*mVersionInfo).get()),
PR_FALSE );
}