Handle different signatures for global or env versions of functions
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 8 Mar 2010 16:56:14 +0000 (16:56 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 8 Mar 2010 16:56:14 +0000 (16:56 +0000)
by the signature specification from the <scons_function> tag to
the <arguments> tag.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4699 fdb21ef1-2011-0410-befe-b5e4ea1792b1

bin/SConsDoc.py
bin/scons-proc.py

index cd78195aba575321a26d05b6cba0237e4a7984fc..3f64a2585784eab53607a4c55077c23f732c08f6 100644 (file)
@@ -134,10 +134,9 @@ class Builder(Item):
     pass
 
 class Function(Item):
-    def __init__(self, name, global_signature, env_signature):
+    def __init__(self, name):
         super(Function, self).__init__(name)
-        self.global_signature = global_signature
-        self.env_signature = env_signature
+        self.arguments = []
 
 class Tool(Item):
     def __init__(self, name):
@@ -160,10 +159,11 @@ class Chunk:
         self.body.append(data)
 
 class Arguments:
-    def __init__(self, body=None):
+    def __init__(self, signature, body=None):
         if not body:
             body = []
         self.body = body
+        self.signature = signature
     def __str__(self):
         s = ''.join(self.body).strip()
         result = []
@@ -299,9 +299,7 @@ class SConsDocHandler(xml.sax.handler.ContentHandler,
         try:
             function = self.functions[name]
         except KeyError:
-            function = Function(name,
-                                attrs.get('global', "1"),
-                                attrs.get('env', "1"))
+            function = Function(name)
             self.functions[name] = function
         self.begin_xxx(function)
     def end_scons_function(self):
@@ -330,8 +328,8 @@ class SConsDocHandler(xml.sax.handler.ContentHandler,
         self.end_xxx()
 
     def start_arguments(self, attrs):
-        arguments = Arguments()
-        self.current_object.arguments = arguments
+        arguments = Arguments(attrs.get('signature', "both"))
+        self.current_object.arguments.append(arguments)
         self.begin_xxx(arguments)
         self.begin_collecting(arguments)
     def end_arguments(self):
index 41ff09a53e15c3db5c9d22fabeb2f2357f214056..a02ee6d29fc8af9ee6f8c5f082cb12df6602883e 100644 (file)
@@ -291,14 +291,19 @@ class Function(Proxy):
         return ['\n', "'\\" + '"'*69 + '\n']
     def initial_chunks(self):
         try:
-            x = self.arguments
+            arguments = self.arguments
         except AttributeError:
-            x = '()'
+            arguments = ['()']
         result = []
-        if self.global_signature != "0":
-            result.append('.TP\n.RI %s%s\n' % (self.name, x))
-        if self.env_signature != "0":
-            result.append('.TP\n.IR env .%s%s\n' % (self.name, x))
+        for arg in arguments:
+            try:
+                signature = arg.signature
+            except AttributeError:
+                signature = "both"
+            if signature in ('both', 'global'):
+                result.append('.TP\n.RI %s%s\n' % (self.name, arg))
+            if signature in ('both', 'env'):
+                result.append('.TP\n.IR env .%s%s\n' % (self.name, arg))
         return result
 
 class Tool(Proxy):