зеркало из https://github.com/mozilla/pjs.git
Checked in nsILocale, nsILocaleFactory. Added all the build dependencites in mozilla/intl as well.
This commit is contained in:
Родитель
111c086347
Коммит
692516a02d
|
@ -0,0 +1,23 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS= public \
|
||||
src
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
|
@ -26,6 +26,9 @@ EXPORTS=\
|
|||
nsDateTimeFormatCID.h \
|
||||
nsICollation.h \
|
||||
nsIDateTimeFormat.h \
|
||||
nsILocale.h \
|
||||
nsILocaleFactory.h \
|
||||
nsLocaleCID.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsILocale_h__
|
||||
#define nsILocale_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {DDD50DD0-AB3F-11d2-AF09-0060089FE59B}
|
||||
#define NS_ILOCALE_IID \
|
||||
{ 0xddd50dd0,0xab3f,0x11d2, \
|
||||
{ 0xaf,0x9,0x0,0x60,0x8,0x9f,0xe5,0x9b} }
|
||||
|
||||
|
||||
class nsILocale : public nsISupports {
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD GetCatagory(const nsString* catagory, nsString* result) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- 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.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
#ifndef nsILocaleManager_h__
|
||||
#define nsILocaleManager_h__
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsILocale.h"
|
||||
|
||||
|
||||
// {00932BE1-B65A-11d2-AF0B-0060089FE59B}
|
||||
#define NS_ILOCALEFACTORY_IID \
|
||||
{ 0x932be1, 0xb65a, 0x11d2, \
|
||||
{ 0xaf, 0xb, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b }}
|
||||
|
||||
|
||||
class nsILocaleFactory : public nsIFactory
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NS_IMETHOD NewLocale(nsString** catagoryList,nsString**
|
||||
valueList, PRUint8 count, nsILocale** locale) = 0;
|
||||
|
||||
NS_IMETHOD NewLocale(const nsString* localeName, nsILocale** locale) = 0;
|
||||
|
||||
NS_IMETHOD GetSystemLocale(nsILocale** systemLocale) = 0;
|
||||
|
||||
NS_IMETHOD GetApplicationLocale(nsILocale** applicationLocale) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsILocaleManager_h__ */
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsLocaleCID_h__
|
||||
#define nsLocaleCID_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {DAD86119-B643-11d2-AF0B-0060089FE59B}
|
||||
#define NS_LOCALE_CID \
|
||||
{ 0xdad86119, 0xb643, 0x11d2, \
|
||||
{ 0xaf, 0xb, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
|
||||
|
||||
|
||||
// {DAD86117-B643-11d2-AF0B-0060089FE59B}
|
||||
#define NS_LOCALEFACTORY_CID \
|
||||
{ 0xdad86117, 0xb643, 0x11d2, \
|
||||
{ 0xaf, 0xb, 0x0, 0x60, 0x8, 0x9f, 0xe5, 0x9b } }
|
||||
|
||||
#endif // nsLocaleCID_h__
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
|
@ -15,37 +18,48 @@
|
|||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
DEPTH = ..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
#DIRS = windows
|
||||
DEFINES = -D_IMPL_NS_INTL -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
LIBRARY_NAME=locale_s
|
||||
MODULE=locale
|
||||
REQUIRES=xpcom
|
||||
MODULE = locale
|
||||
REQUIRES = xpcom unicharutil
|
||||
DIRS = windows
|
||||
|
||||
INCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\locale -I$(PUBLIC)\unicharutil -I$(PUBLIC)\raptor
|
||||
LIBRARY_NAME = nslocale_s
|
||||
|
||||
DEFINES=-DWIN32_LEAN_AND_MEAN
|
||||
CPPSRCS = nsLocale.cpp \
|
||||
nsLocaleFactory.cpp \
|
||||
nsCollation.cpp
|
||||
|
||||
CPPSRCS=nsCollation.cpp
|
||||
|
||||
EXPORTS=nsCollation.h
|
||||
CPP_OBJS = .\$(OBJDIR)\nsLocale.obj \
|
||||
.\$(OBJDIR)\nsLocaleFactory.obj \
|
||||
.\$(OBJDIR)\nsCollation.obj
|
||||
|
||||
CPP_OBJS=.\$(OBJDIR)\nsCollation.obj
|
||||
LINCS = -I. \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\locale \
|
||||
-I$(PUBLIC)\unicharutil
|
||||
|
||||
LINCS= \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
LLIBS = $(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
MISCDEP = $(LLIBS)
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
LCFLAGS = $(LCFLAGS) \
|
||||
$(DEFINES)
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
@echo $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).lib
|
||||
rm -f $(DIST)\bin\$(DLLNAME).lib
|
|
@ -0,0 +1,139 @@
|
|||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsString.h"
|
||||
#include "pratom.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsILocale.h"
|
||||
#include "nsLocale.h"
|
||||
#include "nsLocaleCID.h"
|
||||
|
||||
#define LOCALE_HASH_SIZE 0xFF
|
||||
|
||||
|
||||
NS_DEFINE_IID(kILocaleIID, NS_ILOCALE_IID);
|
||||
NS_DEFINE_IID(kLocaleCID, NS_LOCALE_CID);
|
||||
|
||||
/* nsILocale */
|
||||
NS_IMPL_ISUPPORTS(nsLocale,kILocaleIID)
|
||||
|
||||
|
||||
nsLocale::nsLocale(nsString** catagoryList,nsString** valueList, PRUint32 count)
|
||||
: fHashtable(NULL),
|
||||
fCatagoryCount(0)
|
||||
{
|
||||
|
||||
PRUint32 i;
|
||||
nsString* key, *value;
|
||||
|
||||
|
||||
fHashtable = PL_NewHashTable(LOCALE_HASH_SIZE,&nsLocale::Hash_HashFunction,
|
||||
&nsLocale::Hash_CompareNSString,&nsLocale::Hash_CompareNSString,NULL,NULL);
|
||||
NS_ASSERTION(fHashtable!=NULL,"nsLocale: failed to allocate PR_Hashtable");
|
||||
|
||||
if (fHashtable!=NULL)
|
||||
{
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
key = new nsString(*catagoryList[i]);
|
||||
NS_ASSERTION(key!=NULL,"nsLocale: failed to allocate internal hash key");
|
||||
value = new nsString(*valueList[i]);
|
||||
NS_ASSERTION(value!=NULL,"nsLocale: failed to allocate internal hash value");
|
||||
(void)PL_HashTableAdd(fHashtable,key,value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nsLocale::~nsLocale(void)
|
||||
{
|
||||
|
||||
// enumerate all the entries with a delete function to
|
||||
// safely delete all the keys and values
|
||||
PL_HashTableEnumerateEntries(fHashtable,&nsLocale::Hash_EnmerateDelete,NULL);
|
||||
|
||||
PL_HashTableDestroy(fHashtable);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocale::GetCatagory(const nsString* catagory,nsString* result)
|
||||
{
|
||||
|
||||
const nsString* value;
|
||||
|
||||
value = (const nsString*)PL_HashTableLookup(fHashtable,catagory);
|
||||
if (value!=NULL)
|
||||
{
|
||||
(*result)=(*value);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
PLHashNumber
|
||||
nsLocale::Hash_HashFunction(const void* key)
|
||||
{
|
||||
const nsString* stringKey;
|
||||
PLHashNumber hash;
|
||||
PRInt32 length;
|
||||
|
||||
stringKey = (const nsString*)key;
|
||||
|
||||
hash = (PLHashNumber)0;
|
||||
length = stringKey->Length();
|
||||
|
||||
for(length-=1;length>=0;length--)
|
||||
hash += (PLHashNumber)((*stringKey)[length]);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
PRIntn
|
||||
nsLocale::Hash_CompareNSString(const void* s1, const void* s2)
|
||||
{
|
||||
const nsString* string1;
|
||||
const nsString* string2;
|
||||
|
||||
string1 = (const nsString*)s1;
|
||||
string2 = (const nsString*)s2;
|
||||
|
||||
return string1->Equals(*string2);
|
||||
}
|
||||
|
||||
|
||||
PRIntn
|
||||
nsLocale::Hash_EnmerateDelete(PLHashEntry *he, PRIntn index, void *arg)
|
||||
{
|
||||
nsString* key, *value;
|
||||
|
||||
key = (nsString*)he->key;
|
||||
value = (nsString*)he->value;
|
||||
|
||||
// delete the keys
|
||||
delete key;
|
||||
delete value;
|
||||
|
||||
|
||||
return (HT_ENUMERATE_NEXT | HT_ENUMERATE_REMOVE);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef nsLocale_h__
|
||||
#define nsLocale_h__
|
||||
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsILocale.h"
|
||||
|
||||
#include "plhash.h"
|
||||
|
||||
class nsLocale : public nsILocale {
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
|
||||
nsLocale(nsString** catagoryList,nsString** valueList, PRUint32 count);
|
||||
~nsLocale(void);
|
||||
|
||||
NS_IMETHOD GetCatagory(const nsString* catagory, nsString* result);
|
||||
|
||||
private:
|
||||
|
||||
static PLHashNumber Hash_HashFunction(const void* key);
|
||||
static PRIntn Hash_CompareNSString(const void* s1, const void* s2);
|
||||
static PRIntn Hash_EnmerateDelete(PLHashEntry *he, PRIntn index, void *arg);
|
||||
|
||||
PLHashTable* fHashtable;
|
||||
PRUint32 fCatagoryCount;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- 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.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
#ifndef nsLocaleManager_h__
|
||||
#define nsLocaleManager_h__
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsILocale.h"
|
||||
#include "nsILocaleFactory.h"
|
||||
|
||||
|
||||
class nsLocaleFactory : public nsILocaleFactory
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
|
||||
nsString** fCatagoryList;
|
||||
nsILocale* fSystemLocale;
|
||||
nsILocale* fApplicationLocale;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
nsLocaleFactory(void);
|
||||
virtual ~nsLocaleFactory(void);
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports* aOuter, REFNSIID aIID,
|
||||
void** aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
NS_IMETHOD NewLocale(nsString** catagoryList,nsString** valueList,
|
||||
PRUint8 count, nsILocale** locale);
|
||||
|
||||
NS_IMETHOD NewLocale(const nsString* localeName, nsILocale** locale);
|
||||
|
||||
NS_IMETHOD GetSystemLocale(nsILocale** systemLocale);
|
||||
|
||||
NS_IMETHOD GetApplicationLocale(nsILocale** applicationLocale);
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsILocaleManager_h__ */
|
|
@ -14,53 +14,57 @@
|
|||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
DLLNAME = nslocale
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
#RESFILE = $(DLLNAME).res
|
||||
|
||||
MODULE=raptor
|
||||
|
||||
DEFINES=-DWIN32_LEAN_AND_MEAN
|
||||
|
||||
MISCDEP= \
|
||||
$(DIST)\lib\nslocale_s.lib
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\nsCollationWin.obj \
|
||||
.\$(OBJDIR)\nsDateTimeFormatWin.obj \
|
||||
.\$(OBJDIR)\nsLocaleFactoryWin.obj \
|
||||
.\$(OBJDIR)\nsLocaleDLL.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS= \
|
||||
-I..\
|
||||
-I$(PUBLIC)\locale \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\unicharutil \
|
||||
-I$(PUBLIC)\raptor \
|
||||
$(NULL)
|
||||
|
||||
DEFINES= -DWIN32_LEAN_AND_MEAN
|
||||
LIBRARY_NAME=locale
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS= \
|
||||
nsCollationWin.cpp \
|
||||
nsDateTimeFormatWin.cpp \
|
||||
nsLocaleFactoryWin.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsCollationWin.obj \
|
||||
.\$(OBJDIR)\nsDateTimeFormatWin.obj \
|
||||
.\$(OBJDIR)\nsLocaleFactoryWin.obj \
|
||||
$(NULL)
|
||||
|
||||
MODULE=locale
|
||||
|
||||
REQUIRES=xpcom
|
||||
|
||||
INCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\locale -I$(PUBLIC)\unicharutil -I$(PUBLIC)\raptor -I..\
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=locale
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\locale_s.lib \
|
||||
$(LIBNSPR)
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\nslocale_s.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(DLL) $(LIBRARY)
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\$(DLLNAME).dll
|
||||
rm -f $(DIST)\bin\$(DLLNAME).lib
|
||||
rm -f $(DIST)\lib\$(DLLNAME).lib
|
||||
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/* -*- 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.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
#include "nsRepository.h"
|
||||
#include "nsIFactory.h"
|
||||
|
||||
#include "nsILocaleFactory.h"
|
||||
#include "nsLocaleFactory.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsCollationWin.h"
|
||||
#include "nsDateTimeFormatWin.h"
|
||||
#include "nsLocaleFactoryWin.h"
|
||||
|
||||
//
|
||||
// kLocaleFactory for the nsILocaleFactory interface
|
||||
//
|
||||
NS_DEFINE_IID(kLocaleFactoryCID, NS_LOCALEFACTORY_CID);
|
||||
NS_DEFINE_IID(kILocaleFactoryIID,NS_ILOCALEFACTORY_IID);
|
||||
|
||||
//
|
||||
// for the collation and formatting interfaces
|
||||
//
|
||||
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_DEFINE_IID(kICollationFactoryIID, NS_ICOLLATIONFACTORY_IID);
|
||||
NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
|
||||
NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
nsIFactory* factoryInstance;
|
||||
nsresult res;
|
||||
|
||||
if (aFactory == NULL) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//
|
||||
// first check for the nsILocaleFactory interfaces
|
||||
//
|
||||
if (aCID.Equals(kLocaleFactoryCID))
|
||||
{
|
||||
nsLocaleFactory *factory = new nsLocaleFactory();
|
||||
res = factory->QueryInterface(kILocaleFactoryIID, (void **) aFactory);
|
||||
|
||||
if (NS_FAILED(res))
|
||||
{
|
||||
*aFactory = NULL;
|
||||
delete factory;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
//
|
||||
// let the nsLocaleFactoryWin logic take over from here
|
||||
//
|
||||
factoryInstance = new nsLocaleWinFactory(aCID);
|
||||
|
||||
if(NULL == factoryInstance)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
res = factoryInstance->QueryInterface(kIFactoryIID, (void**)aFactory);
|
||||
if (NS_FAILED(res))
|
||||
{
|
||||
*aFactory = NULL;
|
||||
delete factoryInstance;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/* -*- 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.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
#ifndef nsLocaleDll_h___
|
||||
#define nsLocaleDll_h___
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
#endif /* nsUConvDll_h___ */
|
|
@ -21,6 +21,7 @@
|
|||
#include "nsIFactory.h"
|
||||
#include "nsCollationWin.h"
|
||||
#include "nsDateTimeFormatWin.h"
|
||||
#include "nsLocalefactoryWin.h"
|
||||
|
||||
|
||||
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
@ -30,30 +31,6 @@ NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
|
|||
NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
|
||||
|
||||
|
||||
class nsLocaleWinFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
// nsISupports methods
|
||||
NS_IMETHOD QueryInterface(const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsLocaleWinFactory(const nsCID &aClass);
|
||||
~nsLocaleWinFactory();
|
||||
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
nsCID mClassID;
|
||||
};
|
||||
|
||||
nsLocaleWinFactory::nsLocaleWinFactory(const nsCID &aClass)
|
||||
{
|
||||
mRefCnt = 0;
|
||||
|
@ -148,26 +125,3 @@ nsresult nsLocaleWinFactory::LockFactory(PRBool aLock)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// return the proper factory to the caller
|
||||
//
|
||||
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsIFactory **aFactory)
|
||||
{
|
||||
if (NULL == aFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsIFactory *inst = NULL;
|
||||
|
||||
inst = new nsLocaleWinFactory(aCID);
|
||||
if(NULL == inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult res = inst->QueryInterface(kIFactoryIID, (void**)aFactory);
|
||||
if (NS_FAILED(res)) {
|
||||
*aFactory = NULL;
|
||||
delete inst;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsCollationWin.h"
|
||||
#include "nsDateTimeFormatWin.h"
|
||||
|
||||
class nsLocaleWinFactory : public nsIFactory
|
||||
{
|
||||
public:
|
||||
// nsISupports methods
|
||||
NS_IMETHOD QueryInterface(const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
nsLocaleWinFactory(const nsCID &aClass);
|
||||
~nsLocaleWinFactory();
|
||||
|
||||
private:
|
||||
nsrefcnt mRefCnt;
|
||||
nsCID mClassID;
|
||||
};
|
|
@ -27,7 +27,7 @@
|
|||
#ifdef XP_MAC
|
||||
#define LOCALE_DLL_NAME "LOCALE_DLL"
|
||||
#else
|
||||
#define LOCALE_DLL_NAME "LOCALE.DLL"
|
||||
#define LOCALE_DLL_NAME "NSLOCALE.DLL"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ IGNORE_MANIFEST=1
|
|||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
PROG1 = .\$(OBJDIR)\LocaleSelfTest.exe
|
||||
PROGRAMS = $(PROG1)
|
||||
PROG2 = .\$(OBJDIR)\nsLocaleTest.exe
|
||||
PROGRAMS = $(PROG1) $(PROG2)
|
||||
|
||||
LCFLAGS=-DUSE_NSREG
|
||||
|
||||
|
@ -33,7 +34,8 @@ LLIBS= \
|
|||
$(DIST)\lib\xpcom32.lib \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\libplc21.lib
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\nslocale.lib
|
||||
|
||||
LLFLAGS= /NODEFAULTLIB msvcirt.lib msvcrt.lib
|
||||
|
||||
|
@ -62,3 +64,6 @@ clobber::
|
|||
<<KEEP
|
||||
|
||||
$(PROG1): $(OBJDIR) LocaleSelfTest.cpp
|
||||
|
||||
$(PROG2): $(OBJDIR) nsLocaleTest.cpp
|
||||
|
||||
|
|
|
@ -0,0 +1,310 @@
|
|||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "nsILocale.h"
|
||||
#include "nsILocaleFactory.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsRepository.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define LOCALE_DLL_NAME "NSLOCALE_DLL"
|
||||
#else
|
||||
#define LOCALE_DLL_NAME "NSLOCALE.DLL"
|
||||
#endif
|
||||
|
||||
|
||||
NS_DEFINE_CID(kLocaleFactoryCID, NS_LOCALEFACTORY_CID);
|
||||
NS_DEFINE_IID(kILocaleFactoryIID, NS_ILOCALEFACTORY_IID);
|
||||
NS_DEFINE_CID(kLocaleCID, NS_LOCALE_CID);
|
||||
NS_DEFINE_IID(kILocaleIID, NS_ILOCALE_IID);
|
||||
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
char* localeCatagoryList[6] = { "NSILOCALE_TIME",
|
||||
"NSILOCALE_COLLATE",
|
||||
"NSILOCALE_CTYPE",
|
||||
"NSILOCALE_MONETARY",
|
||||
"NSILOCALE_MESSAGES",
|
||||
"NSILOCALE_NUMERIC"
|
||||
};
|
||||
|
||||
void
|
||||
factory_create_interface(void)
|
||||
{
|
||||
nsresult result;
|
||||
nsILocaleFactory* localeFactory;
|
||||
nsIFactory* genericFactory;
|
||||
|
||||
result = nsRepository::CreateInstance(kLocaleFactoryCID,
|
||||
NULL,
|
||||
kILocaleFactoryIID,
|
||||
(void**)&localeFactory);
|
||||
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed");
|
||||
|
||||
localeFactory->Release();
|
||||
|
||||
result = nsRepository::CreateInstance(kLocaleFactoryCID,
|
||||
NULL,
|
||||
kIFactoryIID,
|
||||
(void**)&genericFactory);
|
||||
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed");
|
||||
|
||||
genericFactory->Release();
|
||||
}
|
||||
|
||||
void
|
||||
factory_test_isupports(void)
|
||||
{
|
||||
nsresult result;
|
||||
nsILocaleFactory* localeFactory;
|
||||
nsISupports* genericInterface1, *genericInterface2;
|
||||
nsIFactory* genericFactory1, *genericFactory2;
|
||||
|
||||
result = nsRepository::FindFactory(kLocaleFactoryCID,
|
||||
(nsIFactory**)&localeFactory);
|
||||
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed");
|
||||
|
||||
//
|
||||
// test AddRef
|
||||
localeFactory->AddRef();
|
||||
|
||||
//
|
||||
// test Release
|
||||
//
|
||||
localeFactory->Release();
|
||||
|
||||
//
|
||||
// test generic interface
|
||||
//
|
||||
result = localeFactory->QueryInterface(kISupportsIID,(void**)&genericInterface1);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_test_isupports failed.");
|
||||
NS_ASSERTION(genericInterface1!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
||||
|
||||
result = localeFactory->QueryInterface(kISupportsIID,(void**)&genericInterface2);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_test_isupports failed.");
|
||||
NS_ASSERTION(genericInterface2!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
||||
NS_ASSERTION(genericInterface1==genericInterface2,"nsLocaleTest: factory_test_isupports failed.");
|
||||
|
||||
genericInterface1->Release();
|
||||
genericInterface2->Release();
|
||||
|
||||
//
|
||||
// test generic factory
|
||||
//
|
||||
result = localeFactory->QueryInterface(kIFactoryIID,(void**)&genericFactory1);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_test_isupports failed.");
|
||||
NS_ASSERTION(genericFactory1!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
||||
|
||||
result = localeFactory->QueryInterface(kIFactoryIID,(void**)&genericFactory2);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_test_isupports failed.");
|
||||
NS_ASSERTION(genericFactory1!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
||||
NS_ASSERTION(genericFactory1==genericFactory2,"nsLocaleTest: factory_test_isupports failed.");
|
||||
|
||||
genericFactory1->Release();
|
||||
genericFactory2->Release();
|
||||
|
||||
localeFactory->Release();
|
||||
}
|
||||
|
||||
void
|
||||
factory_new_locale(void)
|
||||
{
|
||||
nsresult result;
|
||||
nsILocaleFactory* localeFactory;
|
||||
nsILocale* locale;
|
||||
nsString* localeName, *catagory, *value;
|
||||
int i;
|
||||
nsString** catagoryList, **valueList;
|
||||
|
||||
result = nsRepository::FindFactory(kLocaleFactoryCID,
|
||||
(nsIFactory**)&localeFactory);
|
||||
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed");
|
||||
|
||||
|
||||
//
|
||||
// test NewLocale
|
||||
//
|
||||
localeName = new nsString("ja-JP");
|
||||
result = localeFactory->NewLocale(localeName,&locale);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_new_interface failed");
|
||||
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_new_interface failed");
|
||||
|
||||
for(i=0;i<6;i++)
|
||||
{
|
||||
catagory = new nsString(localeCatagoryList[i]);
|
||||
value = new nsString();
|
||||
|
||||
result = locale->GetCatagory(catagory,value);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_new_interface failed");
|
||||
NS_ASSERTION(value->Equals(*localeName)==PR_TRUE,"nsLocaleTest: factory_new_interface failed");
|
||||
|
||||
delete catagory;
|
||||
delete value;
|
||||
}
|
||||
|
||||
locale->Release();
|
||||
|
||||
catagoryList = new nsString*[6];
|
||||
valueList = new nsString*[6];
|
||||
|
||||
for(i=0;i<6;i++)
|
||||
{
|
||||
catagoryList[i] = new nsString(localeCatagoryList[i]);
|
||||
valueList[i] = new nsString("x-netscape");
|
||||
}
|
||||
|
||||
result = localeFactory->NewLocale(catagoryList,valueList,6,&locale);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_new_interface failed");
|
||||
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_new_interface failed");
|
||||
|
||||
for(i=0;i<6;i++)
|
||||
{
|
||||
value = new nsString();
|
||||
result = locale->GetCatagory(catagoryList[i],value);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_new_interface failed");
|
||||
NS_ASSERTION(value->Equals(*(valueList[i]))==PR_TRUE,"nsLocaleTest: factory_new_interface failed");
|
||||
|
||||
delete value;
|
||||
}
|
||||
|
||||
for(i=0;i<6;i++)
|
||||
{
|
||||
delete catagoryList[i];
|
||||
delete valueList[i];
|
||||
}
|
||||
|
||||
delete [] catagoryList;
|
||||
delete [] valueList;
|
||||
|
||||
locale->Release();
|
||||
|
||||
localeFactory->Release();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
factory_get_locale(void)
|
||||
{
|
||||
nsresult result;
|
||||
nsILocaleFactory* localeFactory;
|
||||
nsILocale* locale;
|
||||
nsString* catagory;
|
||||
nsString* value;
|
||||
|
||||
result = nsRepository::FindFactory(kLocaleFactoryCID,
|
||||
(nsIFactory**)&localeFactory);
|
||||
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_create_interface failed");
|
||||
|
||||
//
|
||||
// get the application locale
|
||||
//
|
||||
result = localeFactory->GetApplicationLocale(&locale);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_get_locale failed");
|
||||
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_get_locale failed");
|
||||
|
||||
//
|
||||
// test and make sure the locale is a valid Interface
|
||||
//
|
||||
locale->AddRef();
|
||||
|
||||
catagory = new nsString("NSILOCALE_CTYPE");
|
||||
value = new nsString();
|
||||
|
||||
result = locale->GetCatagory(catagory,value);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_get_locale failed");
|
||||
NS_ASSERTION(value->Length()>0,"nsLocaleTest: factory_get_locale failed");
|
||||
|
||||
locale->Release();
|
||||
locale->Release();
|
||||
|
||||
delete catagory;
|
||||
delete value;
|
||||
|
||||
//
|
||||
// test GetSystemLocale
|
||||
//
|
||||
result = localeFactory->GetSystemLocale(&locale);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_get_locale failed");
|
||||
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_get_locale failed");
|
||||
|
||||
//
|
||||
// test and make sure the locale is a valid Interface
|
||||
//
|
||||
locale->AddRef();
|
||||
|
||||
catagory = new nsString("NSILOCALE_CTYPE");
|
||||
value = new nsString();
|
||||
|
||||
result = locale->GetCatagory(catagory,value);
|
||||
NS_ASSERTION(result==NS_OK,"nsLocaleTest: factory_get_locale failed");
|
||||
NS_ASSERTION(value->Length()>0,"nsLocaleTest: factory_get_locale failed");
|
||||
|
||||
locale->Release();
|
||||
locale->Release();
|
||||
|
||||
delete catagory;
|
||||
delete value;
|
||||
|
||||
localeFactory->Release();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
//
|
||||
// what are we doing?
|
||||
//
|
||||
printf("Starting nsLocaleTest\n");
|
||||
printf("---------------------\n");
|
||||
printf("This test has completed successfully if no error messages are printed.\n");
|
||||
|
||||
//
|
||||
// register the Locale Factory
|
||||
//
|
||||
res = nsRepository::RegisterFactory(kLocaleFactoryCID,
|
||||
LOCALE_DLL_NAME,
|
||||
PR_FALSE,
|
||||
PR_FALSE);
|
||||
NS_ASSERTION(res==NS_OK,"nsLocaleTest: RegisterFactory failed.");
|
||||
|
||||
//
|
||||
// run the nsILocaleFactory tests (nsILocale gets tested in the prcoess)
|
||||
//
|
||||
factory_create_interface();
|
||||
factory_get_locale();
|
||||
factory_new_locale();
|
||||
|
||||
//
|
||||
// we done
|
||||
//
|
||||
printf("---------------------\n");
|
||||
printf("Finished nsLocaleTest\n");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -17,6 +17,6 @@
|
|||
|
||||
DEPTH=..
|
||||
|
||||
DIRS=uconv
|
||||
DIRS=uconv unicharutil locale
|
||||
|
||||
include <$(DEPTH)\layout\config\rules.mak>
|
||||
|
|
|
@ -81,8 +81,9 @@ nsresult nsUnicharUtilFactory::CreateInstance(nsISupports *aDelegate,
|
|||
return res;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID,
|
||||
nsIFactory **aFactory) {
|
||||
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID, nsISupports* serviceMgr,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (aFactory == NULL) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче