1999-01-12 08:34:29 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; 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 "PRIntlpriv.h" */
|
|
|
|
#include "unicpriv.h"
|
|
|
|
|
|
|
|
|
1999-05-10 23:19:21 +00:00
|
|
|
typedef PRUint16 (* MapFormatFunc)(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
|
|
|
typedef PRBool (* HitFormateFunc)(PRUint16 in,const uMapCell *cell);
|
1999-01-12 08:34:29 +00:00
|
|
|
|
|
|
|
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE PRBool uHitFormate0(PRUint16 in,const uMapCell *cell);
|
|
|
|
PRIVATE PRBool uHitFormate1(PRUint16 in,const uMapCell *cell);
|
|
|
|
PRIVATE PRBool uHitFormate2(PRUint16 in,const uMapCell *cell);
|
|
|
|
PRIVATE PRUint16 uMapFormate0(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
|
|
|
PRIVATE PRUint16 uMapFormate1(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
|
|
|
PRIVATE PRUint16 uMapFormate2(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
1999-01-12 08:34:29 +00:00
|
|
|
|
|
|
|
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE const uMapCell *uGetMapCell(const uTable *uT, PRInt16 item);
|
|
|
|
PRIVATE char uGetFormat(const uTable *uT, PRInt16 item);
|
1999-01-12 08:34:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE const MapFormatFunc m_map[uNumFormatTag] =
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
uMapFormate0,
|
|
|
|
uMapFormate1,
|
|
|
|
uMapFormate2,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE const HitFormateFunc m_hit[uNumFormatTag] =
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
uHitFormate0,
|
|
|
|
uHitFormate1,
|
|
|
|
uHitFormate2,
|
|
|
|
};
|
|
|
|
|
1999-05-10 23:19:21 +00:00
|
|
|
#define uHit(format,in,cell) (* m_hit[(format)])((in),(cell))
|
|
|
|
#define uMap(format,in,uT,cell) (* m_map[(format)])((in),(uT),(cell))
|
|
|
|
#define uGetMapCell(uT, item) ((uMapCell *)(((PRUint16 *)uT) + (uT)->offsetToMapCellArray) + (item))
|
|
|
|
#define uGetFormat(uT, item) (((((PRUint16 *)uT) + (uT)->offsetToFormatArray)[(item)>> 2 ] >> (((item)% 4 ) << 2)) & 0x0f)
|
1999-01-12 08:34:29 +00:00
|
|
|
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
|
|
|
MODULE_PRIVATE PRBool uMapCode(uTable *uT, PRUint16 in, PRUint16* out)
|
|
|
|
{
|
|
|
|
PRBool done = PR_FALSE;
|
|
|
|
PRUint16 itemOfList = uT->itemOfList;
|
|
|
|
PRUint16 i;
|
|
|
|
*out = NOMAPPING;
|
|
|
|
for(i=0;i<itemOfList;i++)
|
|
|
|
{
|
1999-05-10 23:19:21 +00:00
|
|
|
const uMapCell* uCell;
|
|
|
|
PRInt8 format = uGetFormat(uT,i);
|
1999-01-12 08:34:29 +00:00
|
|
|
uCell = uGetMapCell(uT,i);
|
|
|
|
if(uHit(format, in, uCell))
|
|
|
|
{
|
|
|
|
*out = uMap(format, in, uT,uCell);
|
|
|
|
done = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ( done && (*out != NOMAPPING));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
member function
|
|
|
|
*/
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE PRBool uHitFormate0(PRUint16 in,const uMapCell *cell)
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
return ( (in >= cell->fmt.format0.srcBegin) &&
|
|
|
|
(in <= cell->fmt.format0.srcEnd) ) ;
|
|
|
|
}
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE PRBool uHitFormate1(PRUint16 in,const uMapCell *cell)
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
return uHitFormate0(in,cell);
|
|
|
|
}
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE PRBool uHitFormate2(PRUint16 in,const uMapCell *cell)
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
return (in == cell->fmt.format2.srcBegin);
|
|
|
|
}
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE PRUint16 uMapFormate0(PRUint16 in,const uTable *uT,const uMapCell *cell)
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
return ((in - cell->fmt.format0.srcBegin) + cell->fmt.format0.destBegin);
|
|
|
|
}
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE PRUint16 uMapFormate1(PRUint16 in,const uTable *uT,const uMapCell *cell)
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
return (*(((PRUint16 *)uT) + uT->offsetToMappingTable
|
|
|
|
+ cell->fmt.format1.mappingOffset + in - cell->fmt.format1.srcBegin));
|
|
|
|
}
|
|
|
|
/*=================================================================================
|
|
|
|
|
|
|
|
=================================================================================*/
|
1999-05-10 23:19:21 +00:00
|
|
|
PRIVATE PRUint16 uMapFormate2(PRUint16 in,const uTable *uT,const uMapCell *cell)
|
1999-01-12 08:34:29 +00:00
|
|
|
{
|
|
|
|
return (cell->fmt.format2.destBegin);
|
|
|
|
}
|
|
|
|
|