]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Support namespace in enum strings generator
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 23 Jan 2011 06:41:41 +0000 (23:41 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 23 Jan 2011 06:41:41 +0000 (23:41 -0700)
For now only one level of namespace is supported.

Header files using namespaces are also required to exist in a sub-folder
of the same name in accordance with the SourceLayout design.

src/mk-string-arrays.awk

index d4b5ec37518cbe76da0a069dbfcf905345a9e70a..42133a3f5cecd1089c4c41a4b43e67966a6996e6 100644 (file)
@@ -14,9 +14,17 @@ BEGIN {
        print "/*"
        print " * Auto-Generated File. Changes will be destroyed."
        print " */"
-       print "#include \"squid.h\""
+       print "#include \"config.h\""
         codeSkip = 1
         e = 0
+        nspath = ""
+}
+
+# when namespace is encountered store it
+/^namespace [a-zA-Z]+/ {
+       nspath = tolower($2) "/"                # nested folder
+       namespace = $2                          # code namespace reconstruct
+       next
 }
 
 # Skip all lines outside of typedef {}
@@ -34,11 +42,17 @@ codeSkip == 1               { next }
        type = t[1]
         codeSkip = 1
 
-       print "#include \"" type ".h\""
+       print "#include \"" nspath type ".h\""
+
+       # if namesapce is not empty ??
+       if (namespace) print "namespace " namespace
+       if (namespace) print "{"
+
        print "\nconst char *" type "_str[] = {"
        for ( i = 1; i < e; ++i)
                print "\t\"" Element[i] "\","
        print "\t\"" Element[i] "\""
        print "};"
+       if (namespace) print "}; // namespace " namespace
        next
 }