Change location of VES5.0 code
[demo.git] / vnfs / VES5.0 / doxygen-1.8.12 / html / arch.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <meta name="generator" content="Doxygen 1.8.12"/>
7 <meta name="viewport" content="width=device-width, initial-scale=1"/>
8 <title>Doxygen: Doxygen&#39;s Internals</title>
9 <link href="tabs.css" rel="stylesheet" type="text/css"/>
10 <script type="text/javascript" src="jquery.js"></script>
11 <script type="text/javascript" src="dynsections.js"></script>
12 <link href="navtree.css" rel="stylesheet" type="text/css"/>
13 <script type="text/javascript" src="resize.js"></script>
14 <script type="text/javascript" src="navtreedata.js"></script>
15 <script type="text/javascript" src="navtree.js"></script>
16 <script type="text/javascript">
17   $(document).ready(initResizable);
18 </script>
19 <link href="doxygen_manual.css" rel="stylesheet" type="text/css" />
20 </head>
21 <body>
22 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
23 <div id="titlearea">
24 <table cellspacing="0" cellpadding="0">
25  <tbody>
26  <tr style="height: 56px;">
27   <td id="projectalign" style="padding-left: 0.5em;">
28    <div id="projectname">Doxygen
29    </div>
30   </td>
31  </tr>
32  </tbody>
33 </table>
34 </div>
35 <!-- end header part -->
36 <!-- Generated by Doxygen 1.8.12 -->
37 </div><!-- top -->
38 <div id="side-nav" class="ui-resizable side-nav-resizable">
39   <div id="nav-tree">
40     <div id="nav-tree-contents">
41       <div id="nav-sync" class="sync"></div>
42     </div>
43   </div>
44   <div id="splitbar" style="-moz-user-select:none;" 
45        class="ui-resizable-handle">
46   </div>
47 </div>
48 <script type="text/javascript">
49 $(document).ready(function(){initNavTree('arch.html','');});
50 </script>
51 <div id="doc-content">
52 <div class="header">
53   <div class="headertitle">
54 <div class="title">Doxygen's Internals </div>  </div>
55 </div><!--header-->
56 <div class="contents">
57 <div class="textblock"><h3>Doxygen's internals</h3>
58 <p><b>Note that this section is still under construction!</b></p>
59 <p>The following picture shows how source files are processed by doxygen.</p>
60 <div class="image">
61 <img src="archoverview.gif" alt="archoverview.gif"/>
62 <div class="caption">
63 Data flow overview</div></div>
64 <p>The following sections explain the steps above in more detail.</p>
65 <h3>Config parser</h3>
66 <p>The configuration file that controls the settings of a project is parsed and the settings are stored in the singleton class <code>Config</code> in <code>src/config.h</code>. The parser itself is written using <code>flex</code> and can be found in <code>src/config.l</code>. This parser is also used directly by <code>doxywizard</code>, so it is put in a separate library.</p>
67 <p>Each configuration option has one of 5 possible types: <code>String</code>, <code>List</code>, <code>Enum</code>, <code>Int</code>, or <code>Bool</code>. The values of these options are available through the global functions <code>Config_getXXX()</code>, where <code>XXX</code> is the type of the option. The argument of these function is a string naming the option as it appears in the configuration file. For instance: <code>Config_getBool</code>("GENERATE_TESTLIST") returns a reference to a boolean value that is <code>TRUE</code> if the test list was enabled in the config file.</p>
68 <p>The function <code>readConfiguration()</code> in <code>src/doxygen.cpp</code> reads the command line options and then calls the configuration parser.</p>
69 <h3>C Preprocessor</h3>
70 <p>The input files mentioned in the config file are (by default) fed to the C Preprocessor (after being piped through a user defined filter if available).</p>
71 <p>The way the preprocessor works differs somewhat from a standard C Preprocessor. By default it does not do macro expansion, although it can be configured to expand all macros. Typical usage is to only expand a user specified set of macros. This is to allow macro names to appear in the type of function parameters for instance.</p>
72 <p>Another difference is that the preprocessor parses, but not actually includes code when it encounters a <code>#include</code> (with the exception of <code>#include</code> found inside { ... } blocks). The reasons behind this deviation from the standard is to prevent feeding multiple definitions of the same functions/classes to doxygen's parser. If all source files would include a common header file for instance, the class and type definitions (and their documentation) would be present in each translation unit.</p>
73 <p>The preprocessor is written using <code>flex</code> and can be found in <code>src/pre.l</code>. For condition blocks (<code>#if</code>) evaluation of constant expressions is needed. For this a <code>yacc</code> based parser is used, which can be found in <code>src/constexp.y</code> and <code>src/constexp.l</code>.</p>
74 <p>The preprocessor is invoked for each file using the <code>preprocessFile()</code> function declared in <code>src/pre.h</code>, and will append the preprocessed result to a character buffer. The format of the character buffer is</p>
75 <pre class="fragment">0x06 file name 1 
76 0x06 preprocessed contents of file 1
77 ...
78 0x06 file name n
79 0x06 preprocessed contents of file n
80 </pre><h3>Language parser</h3>
81 <p>The preprocessed input buffer is fed to the language parser, which is implemented as a big state machine using <code>flex</code>. It can be found in the file <code>src/scanner.l</code>. There is one parser for all languages (C/C++/Java/IDL). The state variables <code>insideIDL</code> and <code>insideJava</code> are uses at some places for language specific choices.</p>
82 <p>The task of the parser is to convert the input buffer into a tree of entries (basically an abstract syntax tree). An entry is defined in <code>src/entry.h</code> and is a blob of loosely structured information. The most important field is <code>section</code> which specifies the kind of information contained in the entry.</p>
83 <p>Possible improvements for future versions:</p><ul>
84 <li>Use one scanner/parser per language instead of one big scanner.</li>
85 <li>Move the first pass parsing of documentation blocks to a separate module.</li>
86 <li>Parse defines (these are currently gathered by the preprocessor, and ignored by the language parser).</li>
87 </ul>
88 <h3>Data organizer</h3>
89 <p>This step consists of many smaller steps, that build dictionaries of the extracted classes, files, namespaces, variables, functions, packages, pages, and groups. Besides building dictionaries, during this step relations (such as inheritance relations), between the extracted entities are computed.</p>
90 <p>Each step has a function defined in <code>src/doxygen.cpp</code>, which operates on the tree of entries, built during language parsing. Look at the "Gathering information" part of <code>parseInput()</code> for details.</p>
91 <p>The result of this step is a number of dictionaries, which can be found in the doxygen "namespace" defined in <code>src/doxygen.h</code>. Most elements of these dictionaries are derived from the class <code>Definition</code>; The class <code>MemberDef</code>, for instance, holds all information for a member. An instance of such a class can be part of a file ( class <code>FileDef</code> ), a class ( class <code>ClassDef</code> ), a namespace ( class <code>NamespaceDef</code> ), a group ( class <code>GroupDef</code> ), or a Java package ( class <code>PackageDef</code> ).</p>
92 <h3>Tag file parser</h3>
93 <p>If tag files are specified in the configuration file, these are parsed by a SAX based XML parser, which can be found in <code>src/tagreader.cpp</code>. The result of parsing a tag file is the insertion of <code>Entry</code> objects in the entry tree. The field <code>Entry::tagInfo</code> is used to mark the entry as external, and holds information about the tag file.</p>
94 <h3>Documentation parser</h3>
95 <p>Special comment blocks are stored as strings in the entities that they document. There is a string for the brief description and a string for the detailed description. The documentation parser reads these strings and executes the commands it finds in it (this is the second pass in parsing the documentation). It writes the result directly to the output generators.</p>
96 <p>The parser is written in C++ and can be found in src/docparser.cpp. The tokens that are eaten by the parser come from src/doctokenizer.l. Code fragments found in the comment blocks are passed on to the source parser.</p>
97 <p>The main entry point for the documentation parser is <code>validatingParseDoc()</code> declared in <code>src/docparser.h</code>. For simple texts with special commands <code>validatingParseText()</code> is used.</p>
98 <h3>Source parser</h3>
99 <p>If source browsing is enabled or if code fragments are encountered in the documentation, the source parser is invoked.</p>
100 <p>The code parser tries to cross-reference to source code it parses with documented entities. It also does syntax highlighting of the sources. The output is directly written to the output generators.</p>
101 <p>The main entry point for the code parser is <code>parseCode()</code> declared in <code>src/code.h</code>.</p>
102 <h3>Output generators</h3>
103 <p>After data is gathered and cross-referenced, doxygen generates output in various formats. For this it uses the methods provided by the abstract class <code>OutputGenerator</code>. In order to generate output for multiple formats at once, the methods of <code>OutputList</code> are called instead. This class maintains a list of concrete output generators, where each method called is delegated to all generators in the list.</p>
104 <p>To allow small deviations in what is written to the output for each concrete output generator, it is possible to temporarily disable certain generators. The OutputList class contains various <code>disable()</code> and <code>enable()</code> methods for this. The methods <code>OutputList::pushGeneratorState()</code> and <code>OutputList::popGeneratorState()</code> are used to temporarily save the set of enabled/disabled output generators on a stack.</p>
105 <p>The XML is generated directly from the gathered data structures. In the future XML will be used as an intermediate language (IL). The output generators will then use this IL as a starting point to generate the specific output formats. The advantage of having an IL is that various independently developed tools written in various languages, could extract information from the XML output. Possible tools could be:</p><ul>
106 <li>an interactive source browser</li>
107 <li>a class diagram generator</li>
108 <li>computing code metrics.</li>
109 </ul>
110 <h3>Debugging</h3>
111 <p>Since doxygen uses a lot of <code>flex</code> code it is important to understand how <code>flex</code> works (for this one should read the man page) and to understand what it is doing when <code>flex</code> is parsing some input. Fortunately, when flex is used with the <code>-d</code> option it outputs what rules matched. This makes it quite easy to follow what is going on for a particular input fragment.</p>
112 <p>To make it easier to toggle debug information for a given flex file I wrote the following perl script, which automatically adds or removes <code>-d</code> from the correct line in the <code>Makefile:</code> </p>
113 <pre class="fragment">#!/usr/bin/perl 
114
115 $file = shift @ARGV;
116 print "Toggle debugging mode for $file\n";
117 if (!-e "../src/${file}.l")
118 {
119   print STDERR "Error: file ../src/${file}.l does not exist!";
120   exit 1;
121 }
122 system("touch ../src/${file}.l");
123 unless (rename "src/CMakeFiles/_doxygen.dir/build.make","src/CMakefiles/_doxygen.dir/build.make.old") {
124   print STDERR "Error: cannot rename src/CMakeFiles/_doxygen.dir/build.make!\n";
125   exit 1;
126 }
127 if (open(F,"&lt;src/CMakeFiles/_doxygen.dir/build.make.old")) {
128   unless (open(G,"&gt;src/CMakefiles/_doxygen.dir/build.make")) {
129     print STDERR "Error: opening file build.make for writing\n";
130     exit 1;
131   }
132   print "Processing build.make...\n";
133   while (&lt;F&gt;) {
134     if ( s/flex \$\(LEX_FLAGS\) -P${file}YY/flex \$(LEX_FLAGS) -d -P${file}YY/ ) {
135       print "Enabling debug info for $file.l\n";
136     }
137     elsif ( s/flex \$\(LEX_FLAGS\) -d -P${file}YY/flex \$(LEX_FLAGS) -P${file}YY/ ) {
138       print "Disabling debug info for $file\n";
139     }
140     print G "$_";
141   }
142   close F;
143   unlink "src/CMakeFiles/_doxygen.dir/build.make.old";
144 }
145 else {
146   print STDERR "Warning file src/CMakeFiles/_doxygen.dir/build.make does not exist!\n"; 
147 }
148
149 # touch the file
150 $now = time;
151 utime $now, $now, $file
152 </pre><p> Another way to get rules matching / debugging information from the flex code is setting LEX_FLAGS with cmake.</p>
153 <p>Note that by running doxygen with <code>-d lex</code> you get information about which flex codefile is used.</p>
154 <p> 
155 Return to the <a href="index.html">index</a>.
156  </p>
157 </div></div><!-- contents -->
158 </div><!-- doc-content -->
159 <!-- start footer part -->
160 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
161   <ul>
162     <li class="footer">Generated by
163     <a href="http://www.doxygen.org/index.html">
164     <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.12 </li>
165   </ul>
166 </div>
167 </body>
168 </html>