[M3devel] This disgusting TEXT business

Darko darko at darko.org
Mon Dec 22 03:52:38 CET 2008


Ah the perils of copy and paste early in the morning. Here is a  
corrected version without extraneous method parameters.


UNICHAR = <enumeration containing all Unicode characters>;
T = TEXT;
T <: TextObj;

TextObj = OBJECT METHODS

  length(): CARDINAL; (* required to be implemented by the encoding *)
  empty(): BOOLEAN; (* required to be implemented by the encoding *)
  hasWideChars(): BOOLEAN; (* required - meaning containing anything  
other than CHAR values *)
  cat(u: T): T; (* required to be implemented by the encoding *)
  iter(VAR index: INTEGER; VAR char: UNICHAR; seek: INTEGER := 1):  
BOOLEAN; (* required - start iterating with index=0, returns the next  
logical character in char and returns true, or false if the char  
doesn't exist. Index is otherwise meaningless and private. Seek allows  
skipping forward or backward a number of characters. *)
  getData(): ADDRESS; (* required - get the raw data, only valid while  
on the stack *)
  setData(adr: ADDRESS; length: CARDINAL); (* required - set the data  
and length of the encoded data *)

  (* the remaining methods are optional for the encoding  
implementation *)
  equal(u: T): BOOLEAN;
  compare(u: T): [-1..1];
  sub(start: CARDINAL;length: CARDINAL := LAST(CARDINAL)): T;
  hash(): Word.T;
  getChar(i: CARDINAL): CHAR;
  getWideChar(i: CARDINAL): WIDECHAR;
  getUniChar(i: CARDINAL): UNICHAR;
  setChars(VAR a: ARRAY OF CHAR; start: CARDINAL := 0);
  setWideChars(VAR a: ARRAY OF WIDECHAR; start: CARDINAL := 0);
  setUniChars(VAR a: ARRAY OF UNICHAR; start: CARDINAL := 0);
  fromChar(ch: CHAR): T;
  fromWideChar(ch: WIDECHAR): T;
  fromUniChar(ch: UNICHAR): T;
  fromChars(READONLY a: ARRAY OF CHAR): T;
  fromWideChars(READONLY a: ARRAY OF WIDECHAR): T;
  fromUniChars(READONLY a: ARRAY OF UNICHAR): T;
  findChar(c: CHAR; start := 0): INTEGER;
  findWideChar(c: WIDECHAR; start := 0): INTEGER;
  findUniChar(c: UNICHAR; start := 0): INTEGER;
  findCharR(c: CHAR; start := LAST(INTEGER)): INTEGER;
  findWideCharR(c: WIDECHAR; start := LAST(INTEGER)): INTEGER;
  findUniCharR(c: UNICHAR; start := LAST(INTEGER)): INTEGER;
END;

PROCEDURE SetTextEnc(tc: INTEGER); (* set the encoding object to use  
from its typecode, must be subtype of TextObj *)
PROCEDURE GetTextEnc(): INTEGER: (* returns the typecode of the  
current encoding object in use *)





More information about the M3devel mailing list