move these into intl/unicharutil

This commit is contained in:
ftang%netscape.com 1999-01-08 00:38:14 +00:00
Родитель 6b6ecc2e1e
Коммит c5a137736d
9 изменённых файлов: 0 добавлений и 639 удалений

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

@ -1,6 +0,0 @@
#
#
#
nsICaseConversion.h
nsUnicharUtilCIID.h

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

@ -1,32 +0,0 @@
#!gmake
# 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 = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = unicharutil
EXPORTS = nsICaseConversion.h \
nsUnicharUtilCIID.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
include $(topsrcdir)/config/rules.mk

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

@ -1,28 +0,0 @@
#!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=..\..\..
IGNORE_MANIFEST=1
EXPORTS = \
nsICaseConversion.h \
nsUnicharUtilCIID.h \
$(NULL)
MODULE=unicharutil
include <$(DEPTH)\config\rules.mak>

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

@ -1,54 +0,0 @@
/* -*- 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 nsICaseConversion_h__
#define nsICaseConversion_h__
#include "nsISupports.h"
#include "nscore.h"
// {07D3D8E0-9614-11d2-B3AD-00805F8A6670}
#define NS_ICASECONVERSION_IID \
{ 0x7d3d8e0, 0x9614, 0x11d2, \
{ 0xb3, 0xad, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
class nsICaseConversion : public nsISupports {
public:
// Convert one Unicode character into upper case
NS_IMETHOD ToUpper( PRUnichar aChar, PRUnichar* aReturn) = 0;
// Convert one Unicode character into lower case
NS_IMETHOD ToLower( PRUnichar aChar, PRUnichar* aReturn) = 0;
// Convert one Unicode character into title case
NS_IMETHOD ToTitle( PRUnichar aChar, PRUnichar* aReturn) = 0;
// Convert an array of Unicode characters into upper case
NS_IMETHOD ToUpper( const PRUnichar* anArray, PRUnichar* aReturn, PRUint32 aLen) = 0;
// Convert an array of Unicode characters into lower case
NS_IMETHOD ToLower( const PRUnichar* anArray, PRUnichar* aReturn, PRUint32 aLen) = 0;
// Convert an array of Unicode characters into title case
NS_IMETHOD ToTitle( const PRUnichar* anArray, PRUnichar* aReturn, PRUint32 aLen) = 0;
};
#endif /* nsICaseConversion_h__ */

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

@ -1,29 +0,0 @@
/* -*- 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 nsUnicharUtilCIID_h__
#define nsUnicharUtilCIID_h__
#include "nsISupports.h"
#include "nscore.h"
#define NS_UNICHARUTIL_CID \
{ 0xcc10c750, 0x9ec3, 0x11d2, \
{ 0xb3, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
#endif

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

@ -1,49 +0,0 @@
#
# 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 = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
CPPSRCS = UnicharSelfTest.cpp
include $(topsrcdir)/config/rules.mk
#DEFINES += -DUSE_NSREG
INCLUDES += -I$(srcdir)/../public -I$(DIST)/include
EX_LIBS = $(DIST)/lib/libxpcom.$(LIB_SUFFIX) \
$(NULL)
PROGS = $(addprefix $(OBJDIR)/, $(CPPSRCS:.cpp=))
TARGETS = $(PROGS)
ifeq ($(OS_ARCH),Rhapsody)
$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS)
@$(MAKE_OBJDIR)
$(CC) -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(NSPR_LIBS) $(OS_LIBS)
else
$(PROGS):$(OBJDIR)/%: $(OBJDIR)/%.o $(EX_LIBS)
@$(MAKE_OBJDIR)
$(CCC) -o $@ $@.o $(LDFLAGS) $(EX_LIBS) $(NSPR_LIBS) $(OS_LIBS)
endif
install:: $(PROGS)
$(INSTALL) $(PROGS) $(DIST)/bin

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

@ -1,380 +0,0 @@
/* -*- 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 <iostream.h>
#include "nsISupports.h"
#include "nsRepository.h"
#include "nsICaseConversion.h"
#include "nsUnicharUtilCIID.h"
NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
NS_DEFINE_IID(kCaseConversionIID, NS_ICASECONVERSION_IID);
#ifdef XP_UNIX
#define UNICHARUTIL_DLL_NAME "libunicharutil.so"
#else
#define UNICHARUTIL_DLL_NAME "UNICHARUTIL_DLL"
#endif
#define TESTLEN 29
#define T2LEN TESTLEN
#define T3LEN TESTLEN
#define T4LEN TESTLEN
// test data for ToUpper
static PRUnichar t2data [T2LEN+1] = {
0x0031 , // 0
0x0019 , // 1
0x0043 , // 2
0x0067 , // 3
0x00C8 , // 4
0x00E9 , // 5
0x0147 , // 6
0x01C4 , // 7
0x01C6 , // 8
0x01C5 , // 9
0x03C0 , // 10
0x03B2 , // 11
0x0438 , // 12
0x04A5 , // 13
0x05D0 , // 14
0x0A20 , // 15
0x30B0 , // 16
0x5185 , // 17
0xC021 , // 18
0xFF48 , // 19
0x01C7 , // 20
0x01C8 , // 21
0x01C9 , // 22
0x01CA , // 23
0x01CB , // 24
0x01CC , // 25
0x01F1 , // 26
0x01F2 , // 27
0x01F3 , // 28
0x00
};
// expected result for ToUpper
static PRUnichar t2result[T2LEN+1] = {
0x0031 , // 0
0x0019 , // 1
0x0043 , // 2
0x0047 , // 3
0x00C8 , // 4
0x00C9 , // 5
0x0147 , // 6
0x01C4 , // 7
0x01C4 , // 8
0x01C4 , // 9
0x03A0 , // 10
0x0392 , // 11
0x0418 , // 12
0x04A4 , // 13
0x05D0 , // 14
0x0A20 , // 15
0x30B0 , // 16
0x5185 , // 17
0xC021 , // 18
0xFF28 , // 19
0x01C7 , // 20
0x01C7 , // 21
0x01C7 , // 22
0x01CA , // 23
0x01CA , // 24
0x01CA , // 25
0x01F1 , // 26
0x01F1 , // 27
0x01F1 , // 28
0x00
};
// test data for ToLower
static PRUnichar t3data [T3LEN+1] = {
0x0031 , // 0
0x0019 , // 1
0x0043 , // 2
0x0067 , // 3
0x00C8 , // 4
0x00E9 , // 5
0x0147 , // 6
0x01C4 , // 7
0x01C6 , // 8
0x01C5 , // 9
0x03A0 , // 10
0x0392 , // 11
0x0418 , // 12
0x04A4 , // 13
0x05D0 , // 14
0x0A20 , // 15
0x30B0 , // 16
0x5187 , // 17
0xC023 , // 18
0xFF28 , // 19
0x01C7 , // 20
0x01C8 , // 21
0x01C9 , // 22
0x01CA , // 23
0x01CB , // 24
0x01CC , // 25
0x01F1 , // 26
0x01F2 , // 27
0x01F3 , // 28
0x00
};
// expected result for ToLower
static PRUnichar t3result[T3LEN+1] = {
0x0031 , // 0
0x0019 , // 1
0x0063 , // 2
0x0067 , // 3
0x00E8 , // 4
0x00E9 , // 5
0x0148 , // 6
0x01C6 , // 7
0x01C6 , // 8
0x01C6 , // 9
0x03C0 , // 10
0x03B2 , // 11
0x0438 , // 12
0x04A5 , // 13
0x05D0 , // 14
0x0A20 , // 15
0x30B0 , // 16
0x5187 , // 17
0xC023 , // 18
0xFF48 , // 19
0x01C9 , // 20
0x01C9 , // 21
0x01C9 , // 22
0x01CC , // 23
0x01CC , // 24
0x01CC , // 25
0x01F3 , // 26
0x01F3 , // 27
0x01F3 , // 28
0x00
};
// test data for ToTitle
static PRUnichar t4data [T4LEN+1] = {
0x0031 , // 0
0x0019 , // 1
0x0043 , // 2
0x0067 , // 3
0x00C8 , // 4
0x00E9 , // 5
0x0147 , // 6
0x01C4 , // 7
0x01C6 , // 8
0x01C5 , // 9
0x03C0 , // 10
0x03B2 , // 11
0x0438 , // 12
0x04A5 , // 13
0x05D0 , // 14
0x0A20 , // 15
0x30B0 , // 16
0x5189 , // 17
0xC013 , // 18
0xFF52 , // 19
0x01C7 , // 20
0x01C8 , // 21
0x01C9 , // 22
0x01CA , // 23
0x01CB , // 24
0x01CC , // 25
0x01F1 , // 26
0x01F2 , // 27
0x01F3 , // 28
0x00
};
// expected result for ToTitle
static PRUnichar t4result[T4LEN+1] = {
0x0031 , // 0
0x0019 , // 1
0x0043 , // 2
0x0047 , // 3
0x00C8 , // 4
0x00C9 , // 5
0x0147 , // 6
0x01C5 , // 7
0x01C5 , // 8
0x01C5 , // 9
0x03A0 , // 10
0x0392 , // 11
0x0418 , // 12
0x04A4 , // 13
0x05D0 , // 14
0x0A20 , // 15
0x30B0 , // 16
0x5189 , // 17
0xC013 , // 18
0xFF32 , // 19
0x01C8 , // 20
0x01C8 , // 21
0x01C8 , // 22
0x01CB , // 23
0x01CB , // 24
0x01CB , // 25
0x01F2 , // 26
0x01F2 , // 27
0x01F2 , // 28
0x00
};
void TestCaseConversion()
{
cout << "==============================\n";
cout << "Start nsICaseConversion Test \n";
cout << "==============================\n";
nsICaseConversion *t = NULL;
nsresult res;
res = nsRepository::CreateInstance(kUnicharUtilCID,
NULL,
kCaseConversionIID,
(void**) &t);
cout << "Test 1 - CreateInstance():\n";
if(NS_FAILED(res) || ( t == NULL ) ) {
cout << "\t1st CreateInstance failed\n";
} else {
t->Release();
}
res = nsRepository::CreateInstance(kUnicharUtilCID,
NULL,
kCaseConversionIID,
(void**) &t);
if(NS_FAILED(res) || ( t == NULL ) ) {
cout << "\t2nd CreateInstance failed\n";
} else {
int i;
PRUnichar ch;
PRUnichar buf[256];
nsresult res;
cout << "Test 2 - ToUpper(PRUnichar, PRUnichar*):\n";
for(i=0;i < T2LEN ; i++)
{
res = t->ToUpper(t2data[i], &ch);
if(NS_FAILED(res)) {
cout << "\tFailed!! return value != NS_OK\n";
break;
}
if(ch != t2result[i])
cout << "\tFailed!! result unexpected " << i << "\n";
}
cout << "Test 3 - ToLower(PRUnichar, PRUnichar*):\n";
for(i=0;i < T3LEN; i++)
{
res = t->ToLower(t3data[i], &ch);
if(NS_FAILED(res)) {
cout << "\tFailed!! return value != NS_OK\n";
break;
}
if(ch != t3result[i])
cout << "\tFailed!! result unexpected " << i << "\n";
}
cout << "Test 4 - ToTitle(PRUnichar, PRUnichar*):\n";
for(i=0;i < T4LEN; i++)
{
res = t->ToTitle(t4data[i], &ch);
if(NS_FAILED(res)) {
cout << "\tFailed!! return value != NS_OK\n";
break;
}
if(ch != t4result[i])
cout << "\tFailed!! result unexpected " << i << "\n";
}
cout << "Test 5 - ToUpper(PRUnichar*, PRUnichar*, PRUint32):\n";
res = t->ToUpper(t2data, buf, T2LEN);
if(NS_FAILED(res)) {
cout << "\tFailed!! return value != NS_OK\n";
} else {
for(i = 0; i < T2LEN; i++)
{
if(buf[i] != t2result[i])
{
cout << "\tFailed!! result unexpected " << i << "\n";
break;
}
}
}
cout << "Test 6 - ToLower(PRUnichar*, PRUnichar*, PRUint32):\n";
res = t->ToLower(t3data, buf, T3LEN);
if(NS_FAILED(res)) {
cout << "\tFailed!! return value != NS_OK\n";
} else {
for(i = 0; i < T3LEN; i++)
{
if(buf[i] != t3result[i])
{
cout << "\tFailed!! result unexpected " << i << "\n";
break;
}
}
}
cout << "Test 7 - ToTitle(PRUnichar*, PRUnichar*, PRUint32):\n";
cout << "!!! To Be Implemented !!!\n";
t->Release();
}
cout << "==============================\n";
cout << "Finish nsICaseConversion Test \n";
cout << "==============================\n";
}
void RegisterFactories()
{
nsresult res;
res = nsRepository::RegisterFactory(kUnicharUtilCID,
UNICHARUTIL_DLL_NAME,
PR_FALSE,
PR_TRUE);
if(NS_FAILED(res))
cout << "RegisterFactory failed\n";
}
int main(int argc, char** argv) {
#ifndef USE_NSREG
RegisterFactories();
#endif
// --------------------------------------------
TestCaseConversion();
// --------------------------------------------
cout << "Finish All The Test Cases\n";
nsresult res = NS_OK;
res = nsRepository::FreeLibraries();
if(NS_FAILED(res))
cout << "nsRepository failed\n";
else
cout << "nsRepository FreeLibraries Done\n";
return 0;
}

Двоичный файл не отображается.

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

@ -1,61 +0,0 @@
#!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 = ..\..\..
IGNORE_MANIFEST=1
MAKE_OBJ_TYPE = EXE
PROG1 = .\$(OBJDIR)\UnicharSelfTest.exe
PROGRAMS = $(PROG1)
LCFLAGS=-DUSE_NSREG
REQUIRES=libreg
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\unicharutil -I$(PUBLIC)\raptor
LLIBS= \
$(DIST)\lib\xpcom32.lib \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib
include <$(DEPTH)\config\rules.mak>
install:: $(PROGRAMS)
-for %p in ($(PROGRAMS)) do $(MAKE_INSTALL) %p $(DIST)\bin
clobber::
-for %p in ($(PROGRAMS)) do $(RM) %p $(DIST)\bin\%p
# Move this into config/obj.inc when it's allowed
.cpp{.\$(OBJDIR)\}.exe:
$(CC) @<<$(CFGFILE)
$(CFLAGS)
$(LCFLAGS)
$(LINCS)
$(LINCS_1)
$(INCS)
$(LLIBS)
$(OS_LIBS)
-Fd$(PBDFILE)
-Fe.\$(OBJDIR)\
-Fo.\$(OBJDIR)\
$(CURDIR)$(*B).cpp
<<KEEP
$(PROG1): $(OBJDIR) UnicharSelfTest.cpp