stable/src/stableobj.tmpl


% Copyright (C) 1993, Digital Equipment Corporation
% All rights reserved.
% See the file COPYRIGHT for a full description.
%
% Last modified on Fri Feb 10 08:14:45 PST 1995 by kalsow
%      modified on Tue Sep 27 11:47:00 PDT 1994 by weich

if defined ("STABLEGEN")
  % take the version specified by the user
  _STABLEGEN = STABLEGEN
else
  _STABLEGEN = format ("%s%s%s", BIN_USE, SL, "stablegen")  %% - full path
  %% _STABLEGEN = "stablegen"
end

% PROC _stableobj
%
% working procedure which is called by the exported macros.
% First generate names for the stable implementation in "implname"
% and for the instantiation of the generic part of the stable
% implementation (of "StableRep.mg" and "StableRep.ig") in "repname".
%
% Inform quake about generated files (not contained in the users
% m3makefile). Then the generics are instantiated and the generator
% is run if necessary.
%
readonly proc _stableobj(intf, reveals, v) is  % e.g. intf = "Data"
  local implname = format ("Stable%s", intf)     % StableData
  local repname = format ("%sRep", implname)     % StableDataRep
  local intflist = []
  local intffilelist = []

  if empty(reveals)
    intflist = [ intf ]
  else
    intflist = [ reveals, intf ]
  end

  foreach file in intflist
    intffilelist += path_of(file & ".i3")
  end

  if defined("_all")
    if stale(implname & ".m3", intffilelist)
      generate_tfile()  % generate the import table
      exec(_STABLEGEN, "-i", intflist[0], "-o", intf, M3SEARCH_TABLES)
    end
  end

  % StableData.m3
  derived_implementation (implname)
  % StableData.i3:
  build_generic_intf(implname, "Stable", [intf], v)
  % StableDataRep.i3:
  build_generic_intf(repname, "StableRep", [implname], HIDDEN)
  % StableDataRep.m3:
  build_generic_impl(repname, "StableRep", [implname])
end

readonly proc stableobj(intf, reveals) is
  _stableobj(intf, reveals, HIDDEN)
end

readonly proc Stableobj(intf, reveals) is
  _stableobj(intf, reveals, VISIBLE)
end