Packets: Add missing packet diagrams
g0dil [Fri, 30 Jan 2009 14:06:51 +0000 (14:06 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1090 270642c3-0616-0410-b53a-bc976706d245

Packets/MPEGDVBBundle/GREPacket.hh
Packets/MPEGDVBBundle/MPESection.hh
Packets/MPEGDVBBundle/SNDUPacket.hh
Packets/MPEGDVBBundle/TransportPacket.hh
Packets/SConscript
doclib/pkgdraw

index 446ef03..32b8c11 100644 (file)
@@ -74,6 +74,7 @@ namespace senf {
 
         \par Fields:
             \ref GREPacketParser
+            \image html GREPacket.png
 
         \ingroup protocolbundle_mpegdvb
      */
index 7b7879d..e617691 100644 (file)
@@ -113,6 +113,7 @@ namespace senf {
 
         \par Fields:
             \ref MPESectionParser
+            \image html MPESection.png
 
         \ingroup protocolbundle_mpegdvb
      */
index 4f296ac..1b69912 100644 (file)
@@ -88,6 +88,7 @@ namespace senf {
 
         \par Fields:
             \ref SNDUPacketParser
+            \image html SNDUPacket.png
 
         \ingroup protocolbundle_mpegdvb
      */
index ae1f540..13eff46 100644 (file)
@@ -117,6 +117,7 @@ namespace senf {
 
         \par Fields:
             \ref TransportPacketParser
+            \image html TransportPacket.png
 
         \ingroup protocolbundle_mpegdvb
      */
index 2850c57..21b1900 100644 (file)
@@ -46,6 +46,10 @@ SENFSCons.Doxygen(env, extra_sources = [
                 PKGDRAWPACKETS = "MIHPacketParser"),
     env.PkgDraw("80211Bundle/WLANPacket.hh"),
     env.PkgDraw("80211Bundle/RadiotapPacket.hh"),
+    env.PkgDraw("MPEGDVBBundle/GREPacket.hh"),
+    env.PkgDraw("MPEGDVBBundle/MPESection.hh"),
+    env.PkgDraw("MPEGDVBBundle/SNDUPacket.hh"),
+    env.PkgDraw("MPEGDVBBundle/TransportPacket.hh"),
 ])
 SENFSCons.InstallIncludeFiles(env, includes)
 
index 35a6b92..ecadad7 100755 (executable)
@@ -158,7 +158,7 @@ def makeTex(rows):
             if sides == "lrtb" : sides = ""
             else               : sides = "[%s]" % sides
             if area.get('filled', False):
-                line.append(r"\bitbox%s{%s}{\color[gray]{0.7}\rule{\width}{\height}}" % (sides, area['size']))
+                line.append(r"\bitbox%s{%s}{\color[gray]{0.93}\rule{\width}{\height}}" % (sides, area['size']))
             elif area.get('skip', False):
                 line.append(r"\skippedwords")
             elif area.get('dots', False):
@@ -355,17 +355,37 @@ PARSER_END_RE = re.compile(r"PKGDRAW_PARSER_FINALIZE\s*\(([^)]*)\)\s*;")
 PARSER_FIELD_RE = re.compile(r"(?:@@>pkgdraw:(.*)$\s*)?PKGDRAW_PARSER_([A-Z_]+)\s*\(([^;]*)\)\s*;(?:\s*@@<pkgdraw:(.*)$)?", re.M)
 
 def scanPackets(data):
+    global FIELD_TYPES
+    
     packets = {}
+    packetOrder = []
     end = 0
     while True:
         start =  PARSER_START_RE.search(data, end)
-        if not start: return packets
+        if not start: return (packets, packetOrder)
         start = start.end(0)
         end = PARSER_END_RE.search(data, start)
-        if not end: return packets
+        if not end: return (packets, packetOrder)
         name=end.group(1).strip()
         end = end.start(0)
         packets[name] = scanFields(data[start:end])
+        packetOrder.append(name)
+        minsize = maxsize = 0
+        for field in packets[name]:
+            if field.get('size', None) is not None:
+                maxsize += field['size']
+            elif field.get('minsize', None) is not None:
+                maxsize += field['maxsize']
+            if not field.get('optional', False):
+                if field.get('size', None) is not None:
+                    minsize += field['size']
+                elif field.get('minsize', None) is not None:
+                    minsize += field['minsize']
+        if minsize is not None and maxsize is not None:
+            if minsize == maxsize:
+                FIELD_TYPES[name] = { 'size' : minsize }
+            else:
+                FIELD_TYPES[name] = { 'minsize' : minsize, 'maxsize' : maxsize }
 
 def scanFields(data):
     fields = []
@@ -411,7 +431,8 @@ names = []
 gccopts = []
 
 if len(args)<2 or args[0] == '--' or args[1] == '--':
-    sys.stderr.write("Usage: %s <header> <outfile> [<parser name>...] [ -- <cpp options>...]\n")
+    sys.stderr.write("Usage: %s <header> <outfile> [<parser names>...] [-- <cpp options>...]\n"
+                     % sys.argv[0])
     sys.exit(1)
 
 source = args.pop(0)
@@ -420,15 +441,15 @@ target = args.pop(0)
 while args and args[0] != '--' : names.append(args.pop(0))
 if args : gccopts = args[1:]
 
-data = scanPackets(cppExpand(quoteMacros(stripComments(file(source).read())),
-                             gccopts, os.path.dirname(source)))
+data, order = scanPackets(cppExpand(quoteMacros(stripComments(file(source).read())),
+                                    gccopts, os.path.dirname(source)))
 
 texf = file(os.path.join(tmpdir, "fields.tex"),"w")
 texf.write(TEX_HEADER)
 
 if not names:
-    names = data.keys()
-    names.sort()
+    order.reverse()
+    names = order
 
 for name in names:
     texf.write("\\textbf{%s}\n\\bigskip\\par\n" % texquote(name))