Standalone xpcom.

This commit is contained in:
dp%netscape.com 2000-05-14 22:46:24 +00:00
parent 3e0a608172
commit faaf62dfd6
6 changed files with 57 additions and 8 deletions

View File

@ -34,9 +34,11 @@
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#define NS_IMPL_IDS
#ifndef XPCOM_STANDALONE
#include "nsIPlatformCharset.h"
#include "nsICharsetConverterManager.h"
#include "nsIUnicodeDecoder.h"
#endif /* XPCOM_STANDALONE */
#include <string.h>
#include <stdio.h>
@ -827,7 +829,9 @@ nsFilePath nsFilePath::operator +(const char* inRelativeUnixPath) const
// nsFileSpec implementation
//========================================================================================
#ifndef XPCOM_STANDALONE
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
#endif /* XPCOM_STANDALONE */
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
@ -1149,6 +1153,7 @@ PRBool nsFileSpec::IsChildOf(nsFileSpec &possibleParent)
void nsFileSpec::GetFileSystemCharset(nsString & fileSystemCharset)
//----------------------------------------------------------------------------------------
{
#ifndef XPCOM_STANDALONE
// From mozilla/widget/src/windows/nsFileWidget.cpp
static nsAutoString aCharset;
@ -1164,6 +1169,7 @@ void nsFileSpec::GetFileSystemCharset(nsString & fileSystemCharset)
aCharset.AssignWithConversion("ISO-8859-1");
}
fileSystemCharset = aCharset;
#endif /* XPCOM_STANDALONE */
}
@ -1171,11 +1177,13 @@ void nsFileSpec::GetFileSystemCharset(nsString & fileSystemCharset)
PRUnichar * nsFileSpec::ConvertFromFileSystemCharset(const char *inString)
//----------------------------------------------------------------------------------------
{
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
PRUnichar *outString = nsnull;
#ifndef XPCOM_STANDALONE
// From mozilla/widget/src/windows/nsFileWidget.cpp
nsIUnicodeDecoder *aUnicodeDecoder = nsnull;
PRUnichar *outString = nsnull;
nsresult rv = NS_OK;
rv = NS_OK;
// get file system charset and create a unicode encoder
nsAutoString fileSystemCharset;
@ -1203,6 +1211,7 @@ PRUnichar * nsFileSpec::ConvertFromFileSystemCharset(const char *inString)
}
}
NS_IF_RELEASE(aUnicodeDecoder);
#endif /* XPCOM_STANDALONE */
return NS_SUCCEEDED(rv) ? outString : nsnull;
}

View File

@ -20,12 +20,14 @@
* Contributor(s):
*/
#include "nsIServiceManager.h"
#ifndef XPCOM_STANDALONE
#include "nsIPlatformCharset.h"
#include "nsICharsetConverterManager.h"
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#endif /* XPCOM_STANDALONE */
/* nsFileSpec stuff. put here untill it got obsoleted */
#include "nsFileSpec.h"
@ -57,8 +59,10 @@ private:
NS_IMETHOD PrepareEncoder();
NS_IMETHOD PrepareDecoder();
nsAutoString mFSCharset;
#ifndef XPCOM_STANDALONE
nsCOMPtr<nsIUnicodeEncoder> mEncoder;
nsCOMPtr<nsIUnicodeDecoder> mDecoder;
#endif /* XPCOM_STANDALONE */
};
@ -117,13 +121,17 @@ nsFSStringConversion gConverter;
nsFSStringConversion::nsFSStringConversion()
{
#ifndef XPCOM_STANDALONE
mEncoder = nsnull;
mDecoder = nsnull;
#endif /* XPCOM_STANDALONE */
}
NS_IMETHODIMP
nsFSStringConversion::PrepareFSCharset()
{
nsresult res = NS_OK;
nsresult res = NS_ERROR_NOT_IMPLEMENTED;
#ifndef XPCOM_STANDALONE
res = NS_OK;
if(mFSCharset.Length() == 0)
{
// lazy eval of the file system charset
@ -133,12 +141,15 @@ nsFSStringConversion::PrepareFSCharset()
res = pcharset->GetCharset(kPlatformCharsetSel_FileName, mFSCharset);
}
}
#endif /* XPCOM_STANDALONE */
return res;
}
NS_IMETHODIMP
nsFSStringConversion::PrepareEncoder()
{
nsresult res = NS_OK;
nsresult res = NS_ERROR_NOT_IMPLEMENTED;
#ifndef XPCOM_STANDALONE
res = NS_OK;
if(! mEncoder)
{
res = PrepareFSCharset();
@ -153,12 +164,15 @@ nsFSStringConversion::PrepareEncoder()
"cannot find the unicode encoder");
}
}
#endif /* XPCOM_STANDALONE */
return res;
}
NS_IMETHODIMP
nsFSStringConversion::PrepareDecoder()
{
nsresult res = NS_OK;
nsresult res = NS_ERROR_NOT_IMPLEMENTED;
#ifndef XPCOM_STANDALONE
res = NS_OK;
if(! mDecoder)
{
res = PrepareFSCharset();
@ -173,12 +187,15 @@ nsFSStringConversion::PrepareDecoder()
"cannot find the unicode decoder");
}
}
#endif /* XPCOM_STANDALONE */
return res;
}
NS_IMETHODIMP
nsFSStringConversion::UCSToNewFS( const PRUnichar* aIn, char** aOut)
{
nsresult res = PrepareEncoder();
nsresult res = NS_ERROR_NOT_IMPLEMENTED;
#ifndef XPCOM_STANDALONE
res = PrepareEncoder();
if(NS_SUCCEEDED(res))
{
PRInt32 inLength = nsCRT::strlen(aIn);
@ -199,12 +216,15 @@ nsFSStringConversion::UCSToNewFS( const PRUnichar* aIn, char** aOut)
}
}
}
#endif /* XPCOM_STANDALONE */
return res;
}
NS_IMETHODIMP
nsFSStringConversion::FSToNewUCS( const char* aIn, PRUnichar** aOut)
{
nsresult res = PrepareDecoder();
nsresult res = NS_ERROR_NOT_IMPLEMENTED;
#ifndef XPCOM_STANDALONE
res = PrepareDecoder();
if(NS_SUCCEEDED(res))
{
PRInt32 inLength = nsCRT::strlen(aIn);
@ -225,6 +245,7 @@ nsFSStringConversion::FSToNewUCS( const char* aIn, PRUnichar** aOut)
}
}
}
#endif /* XPCOM_STANDALONE */
return res;
}

View File

@ -21,6 +21,8 @@
* IBM Corp.
*/
#ifndef XPCOM_STANDALONE
#define NS_IMPL_IDS
#include "nsIUnicharInputStream.h"
#include "nsIByteBuffer.h"
@ -322,3 +324,4 @@ NS_NewConverterStream(nsIUnicharInputStream** aInstancePtrResult,
return it->QueryInterface(NS_GET_IID(nsIUnicharInputStream),
(void **) aInstancePtrResult);
}
#endif /* XPCOM_STANDALONE */

View File

@ -89,6 +89,7 @@ xptiInterfaceInfoManager::xptiInterfaceInfoManager()
{
NS_INIT_ISUPPORTS();
#ifndef XPCOM_STANDALONE
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_PROGID);
if(prefs)
{
@ -130,6 +131,7 @@ xptiInterfaceInfoManager::xptiInterfaceInfoManager()
nsCRT::free(autoRegFilename);
}
}
#endif /* XPCOM_STANDALONE */
}
xptiInterfaceInfoManager::~xptiInterfaceInfoManager()

View File

@ -32,6 +32,7 @@ xptiZipLoader::EnumerateZipEntries(nsILocalFile* file,
xptiEntrySink* sink,
xptiWorkingSet* aWorkingSet)
{
#ifndef XPCOM_STANDALONE
NS_ASSERTION(file, "loser!");
NS_ASSERTION(sink, "loser!");
NS_ASSERTION(aWorkingSet, "loser!");
@ -96,6 +97,9 @@ xptiZipLoader::EnumerateZipEntries(nsILocalFile* file,
} while(1);
return PR_TRUE;
#else
return PR_FALSE;
#endif /* XPCOM_STANDALONE */
}
// static
@ -104,6 +108,7 @@ xptiZipLoader::ReadXPTFileFromZip(nsILocalFile* file,
const char* entryName,
xptiWorkingSet* aWorkingSet)
{
#ifndef XPCOM_STANDALONE
nsCOMPtr<nsIZipReader> zip =
do_CreateInstance(g_ZipReaderProgID);
if(!zip)
@ -130,8 +135,12 @@ xptiZipLoader::ReadXPTFileFromZip(nsILocalFile* file,
}
return ReadXPTFileFromOpenZip(zip, entry, entryName, aWorkingSet);
#else
return nsnull;
#endif /* XPCOM_STANDALONE */
}
#ifndef XPCOM_STANDALONE
// static
XPTHeader*
xptiZipLoader::ReadXPTFileFromOpenZip(nsIZipReader* zip,
@ -219,6 +228,7 @@ xptiZipLoader::ReadXPTFileFromOpenZip(nsIZipReader* zip,
delete [] whole;
return header;
}
#endif /* XPCOM_STANDALONE */

View File

@ -49,9 +49,11 @@
#include "nsInt64.h"
#include "nsQuickSort.h"
#ifndef XPCOM_STANDALONE
#include "nsIZipReader.h"
#include "nsIInputStream.h"
#include "nsIPref.h"
#endif /* XPCOM_STANDALONE */
#include "nsIInputStream.h"
#include "nsAutoLock.h"
@ -583,11 +585,13 @@ public:
xptiWorkingSet* aWorkingSet);
private:
#ifndef XPCOM_STANDALONE
static XPTHeader*
ReadXPTFileFromOpenZip(nsIZipReader * zip,
nsIZipEntry* entry,
const char* entryName,
xptiWorkingSet* aWorkingSet);
#endif /* XPCOM_STANDALONE */
};
/***************************************************************************/