MODULE\subsection{Utility procedures and abreviations} All procedures that output code in this module use the; IMPORT SOxCoder, Atom, Formatter, SOxCodeUtils, SOxCodeFiles, Type, Wr, ImportList, CodeForType, AtomList; REVEAL T = SOxCoder.T BRANDED OBJECT OVERRIDES InitImports := initImports; Import := import; Head := head; Decls := decls; Main := noMain; Bottom := bottom; END; <* FATAL Wr.Failure*> SOxIntfCBCode
Formatter
module. The following abreviation is used by all procedures in order
to get better readable program text:
WITH Put = Formatter.PutText, Nl = Formatter.NewLine, Tab = Formatter.Begin, EndTab = Formatter.End DOOften used
Formatter
-procedure sequences are combined in the
procdures PutLine
.
PROCEDUREPutLine (fmtWr: Formatter.T; text: TEXT) = BEGIN Formatter.PutText(fmtWr, text); Formatter.NewLine(fmtWr, freshLine := FALSE); END PutLine; VAR extraImports := ARRAY [1..1] OF Atom.T{Atom.FromText("SharedObj")}; PROCEDUREinitImports (<*UNUSED*>self: T; <*UNUSED*>basename: TEXT; imports: ImportList.T) = BEGIN CodeForType.AugmentImportList(imports, extraImports); END initImports; PROCEDUREimport (<*UNUSED*>self: T; type: Type.Object; methods: ImportList.MethodList; umethods: AtomList.T; imports: ImportList.T) = BEGIN CodeForType.ImportLst(type, imports, methods, umethods); CodeForType.ImportCBLst(type, imports, methods, umethods); END import; PROCEDUREhead (self: T; wr: Formatter.T; filename: TEXT; basename: TEXT; imports: ImportList.T) = BEGIN WITH Nl = Formatter.NewLine DO SOxCodeUtils.HeaderComment(wr, filename); self.fbasename := SOxCodeUtils.FileName(basename, SOxCodeFiles.T.CB_I3); PutLine(wr, "INTERFACE " & self.fbasename & ";\n"); CodeForType.ProduceImports(wr, imports); Nl(wr, freshLine := FALSE); END; END head; PROCEDUREdecls (<*UNUSED*>self: T; wr: Formatter.T; typeID: Type.Qid; <*UNUSED*>stypeID: Type.Qid; <*UNUSED*>implName: TEXT; methods: ImportList.MethodList; umethods: AtomList.T) = VAR typTxt : TEXT; identfTxt : TEXT; meth: Atom.T; BEGIN WITH Put = Formatter.PutText, Nl = Formatter.NewLine, Tab = Formatter.Begin, EndTab = Formatter.End DO typTxt := CodeForType.QidToText(typeID); identfTxt := CodeForType.QidToIdentf(typeID); Tab(wr, 2); Put(wr, "TYPE"); Nl(wr, freshLine := FALSE); PutLine(wr, identfTxt & " <: Public" & identfTxt & ";"); Tab(wr, 2); PutLine(wr, "Public" & identfTxt & " = SharedObj.Callback OBJECT"); Tab(wr, 2); PutLine(wr, "METHODS "); Put(wr,"init ("); Tab(wr, 0); Put(wr,"obj: " & typTxt & "): " & identfTxt & ";"); EndTab(wr); Nl(wr, freshLine := FALSE); PutLine(wr,"cancel ();"); Put(wr,"pre_anyChange ("); Tab(wr, 0); Put(wr,"READONLY obj: " & typTxt & ");"); EndTab(wr); Nl(wr, freshLine := FALSE); Put(wr,"post_anyChange ("); Tab(wr, 0); Put(wr,"READONLY obj: " & typTxt & ");"); EndTab(wr); FOR i := 0 TO LAST(methods^) DO meth := methods[i].name; IF AtomList.Member(umethods, meth) THEN Nl(wr, freshLine := FALSE); Put(wr, "pre_" & Atom.ToText(meth) & " ("); Tab(wr, 0); Put(wr, "READONLY obj: " & typTxt); CodeForType.PrintSig(wr, methods[i].sig); Put(wr, "): BOOLEAN;"); EndTab(wr); Nl(wr, freshLine := FALSE); Put(wr, "post_" & Atom.ToText(meth) & " ("); Tab(wr, 0); Put(wr, "READONLY obj: " & typTxt); CodeForType.PrintSig(wr, methods[i].sig); Put(wr, "): BOOLEAN;"); EndTab(wr); END; END; EndTab(wr); Nl(wr, freshLine := FALSE); PutLine(wr, "END;"); EndTab(wr); EndTab(wr); Nl(wr, freshLine := FALSE); END END decls; PROCEDUREnoMain (<*UNUSED*> self: T; <*UNUSED*> wr: Formatter.T; <*UNUSED*> typeID: Type.Qid; <*UNUSED*> type : Type.Object; <*UNUSED*> stypeID: Type.Qid; <*UNUSED*> implName: TEXT; <*UNUSED*> methods: ImportList.MethodList; <*UNUSED*> umethods: AtomList.T) = BEGIN END noMain; PROCEDUREbottom (self: T; wr: Formatter.T; <*UNUSED*>fname: TEXT) = BEGIN PutLine(wr, "END " & self.fbasename & "."); END bottom; BEGIN END SOxIntfCBCode.