Char.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Doug Wyatt, October 8, 1991 2:22 pm PDT
Char: CEDAR DEFINITIONS ~ BEGIN
XCHAR: TYPE ~ MACHINE DEPENDENT {(CARD32.LAST)};
CharCode: TYPE ~ BYTE;
CharSet:
TYPE ~
CARD[0..2**(
BITS[
XCHAR]-
BITS[CharCode]));
Set:
PROC [xchar:
XCHAR]
RETURNS [CharSet]
~ INLINE { RETURN[ORD[xchar] / (2**BITS[CharCode])] };
Code:
PROC [xchar:
XCHAR]
RETURNS [CharCode]
~ INLINE { RETURN[ORD[xchar] MOD (2**BITS[CharCode])] };
Make:
PROC [set: CharSet, code: CharCode]
RETURNS [
XCHAR]
~ INLINE { RETURN[VAL[set*(2**BITS[CharCode])+code]] };
Widen:
PROC [char:
CHAR]
RETURNS [
XCHAR]
~ INLINE { RETURN[VAL[ORD[char]]] };
Narrow:
PROC [xchar:
XCHAR]
RETURNS [
CHAR]
~ INLINE { RETURN[VAL[ORD[xchar]]] }; -- BoundsFault if too big
END.