cit_util/src/RTBrand.m3


 $Id: RTBrand.m3.html,v 1.3 2010-04-29 17:17:56 wagner Exp $ 

UNSAFE MODULE RTBrand;

IMPORT (* M3toC, *) RT0, RTType, Ctypes, Text8CString;

PROCEDURE Get(x : REFANY) : TEXT RAISES { NotBranded } =
  VAR
    b := RTType.Get(TYPECODE(x)).brand_ptr;
    s := LOOPHOLE(b, Ctypes.char_star);
  BEGIN
    IF LOOPHOLE(s,INTEGER) = 0 THEN RAISE NotBranded END;
    (* RETURN M3toC.StoT(s) *)
    RETURN Text8CString.New(s);
  END Get;

PROCEDURE GetByTC(c : RT0.Typecode) : TEXT RAISES { NotBranded } =
  VAR
    b := RTType.Get(c).brand_ptr;
    s := LOOPHOLE(b, Ctypes.char_star);
  BEGIN
    IF LOOPHOLE(s,INTEGER) = 0 THEN RAISE NotBranded END;
    (* RETURN M3toC.StoT(s) *)
    RETURN Text8CString.New(s);
  END GetByTC;

BEGIN END RTBrand.