/**** * * Class RSLToDict contains functions to translate an RSL spec into dictionary * format. The dictionary is in two major parts -- the first part for objects * and the second part for operations. The specifics of dictionary formats are * covered in the user documentation for the rsldoc tool, q.v. Additional * information on the files generated by each of rsldoc components is given in * the top-level rsldoc class, RSLDoc. * */ #ifndef rsltodatadictIncluded #define rsltodatadictIncluded #include #include #include "trans-interface.h" #include "images.h" extern "C" SymtabEntry* BrowserLookup(char* name); extern "C" int BrowserTypeSize(nodep); class RSLToDict { public: RSLToDict(TransInterface* ti); /* * Construct this by initializing the local TransInterface pointer to the * given TransInterface instance. */ void Generate(BrowserSymLists* syms); /* * Generate data and operation dictionaries from the given browser symbol * lists. The output is sent directly to file named "dd.html", containing * the data and operation dictionaries. * * As documented in trans-interface.h, BrowserSymLists is the packet of * info containing the alphabetically sorted object and operation lists * extracted from the RSL source. The list elements are full * SymtabEntries, with everything we need to generate the dictionaries. * * The generation strategy is straightforward -- traverse each list, tunnel * down as necessary in the SymtabEntries to get the info, and then output * the info in an appropriate HTML format. */ protected: /** * Protected Functions */ bool OpenFiles(); /* * Open all of the output files. Return true if all files open * successfully, false if not. */ bool OpenFile(ofstream& filestream, char* filename); /* * Open the given output filestream on the file of the given filename. */ void WriteHtmlIndex(); /* * Write the index.html, with the basic frame layout and standard * header/footer info. */ void GenerateModObjOpIndices(BrowserSymLists* syms); /* * Generate the module, object, and operation indices into the respective * files, which are viewed in the three left frames. */ void GenerateModIndex(EntityStructList* mods); /* * Generate the module index for the top-left frame. */ void GenerateObjOpIndex(EntityStructList* ents, ofstream& file, char* title); /* * Generate the objects and ops index for the middle-left and bottom-left * frames. */ void WriteHtmlIndexHeader(ofstream& file, char* title); /* * Write a generic html header for an index file. */ void WriteHtmlIndexFooter(ofstream& file); /* * Write a generic html footer for an index file. */ void WriteDDHeader(); /* * Write top label and table headings for the data dictionary. */ void GenerateDD(EntityStructList* objs); /* * Generate the data dictionary on the top of the dd.html file. */ bool IsTopLevelObject(SymtabEntry* sym); /* * Return true if the given entry is that of an object that has not * component or class parents. */ void PutInTopLevelList(EntityStruct* e); /* SymtabEntry* sym); */ /* * Put the given entry in this->toplist, which is the list of top-level * objects sorted by size. The size value is computed courtesy of the * translator. It is the transitive count of all object components. */ void WriteLinkInfo(char* name, SrcLoc loc); /* * Write a space-delimited 4-tuple out to the dd-links.dat file, of the * form: * * obj/op-name source-file line-number column-number * * The information is obtained form the standard SrcLoc struct built by the * translator. (Thanks for that.) */ void PrintName(char* name); /* * Print a table entry for the name. */ void PrintComponents(SymtabEntry* sym); /* * Print a table entry for the components, via PrettyPrintType. */ void PrettyPrintType(nodep t); void PrettyPrintIdentType(nodep t); void PrettyPrintTupleType(nodep t); void PrettyPrintUnionType(nodep t); void PrettyPrintListType(nodep t); void PrettyPrintOpType(nodep t); void PrintOpTypeParms(nodep parms); bool IsBuiltInAtomicType(char* tname); /* * Return true if the give typename is not one of the rsl built-in atomic * types. */ void PrintDescription(nodep attrs); /* * Print a table entry for the description. */ void WriteODHeader(); /* * Write the table ender for the data dict and then the top label and table * headings for the data dictionary. */ void GenerateOD(EntityStructList* ops); /* * Generate the operation dictionary, following the data dictionary in * dd.html. */ void RSLToDict::PrintParms(EntityStructList* ins); /* * Print a table entry for a list of operation inputs or outputs. */ void WriteDictFooter(); /* * Write the table ender for the op dict as well as for the complete dict * file. */ void WriteTreeViewHeader(); /* * Write the ASCII version of the object hierarchy to the tree-view file. */ void GenerateTreeView(); /* * Generate tree view using class RSLToUML ideas. Later we'll fix things * up nicely and get this out the dict-gen class altogether. */ void GenerateDescendents(EntityStruct* e, int indent, StrList* vstk, EntitySymtab* vsymt); /* * Generate the component and inherting descendents of the given sym, * indented to the right the given indent amount. The vstk and vsymt are a * visited stack and symbol table, used respectively to not visit recursive * defs and not redescend into already-descended symbols. */ bool GenerateDescendent(EntityStruct* kid, int indent, char* icon, EntitySymtab* vsymt); /* * Generate the object-hierarchy entry for the given kid sym to the given * level of indent. The icon is either "inheritance" or "component", which * is used to output the appropriate hierarchy symbol icon. The vsymt is * used to lookup whether the given kid has already been visited and * descended into. If not, the entry has a data dict href around it. * Otherwise, the entry has no data dict href around it, but instead a * right-pointing arrow to the previous entry in the object hierarchy for * this kid. This avoids overly repetitive diagarams. */ void WriteTreeViewFooter(); /* * Write the ASCII version of the object hierarchy to the tree-view file. */ /** * Protected Data */ Images* im; // The image-writing helper dude TransInterface* ti; // Companion translator interface ofstream index; // Stream for index.html ofstream module_index; // Stream for module-index.html ofstream all_objs_index; // Stream for all-objs-index.html ofstream all_ops_index; // Stream for all-ops-index.html ofstream all_dict; // Stream for all-dict.html ofstream all_tree; // Stream for all-tree.html // ofstream rsl_html_files[]; // Streams for each infile.rsl.html // At present, these are created by the // Emacs script and are thus not needed // here. ofstream dd_links_file; // Stream for dd-links.html EntityStructList* toplist; // List of top-level objects }; #endif