support interdependencies between utility code fragments
authorStefan Behnel <scoder@users.berlios.de>
Fri, 13 Mar 2009 22:24:36 +0000 (23:24 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 13 Mar 2009 22:24:36 +0000 (23:24 +0100)
Cython/Compiler/Code.py
Cython/Utils.py

index aad42442b2141feffe5973e24e0a3e148f401e82..aa77a037779d77e97a5a2e03cf4f67dedf8c3581 100644 (file)
@@ -419,6 +419,9 @@ class GlobalState(object):
         """
         if name is None: name = id(utility_code)
         if self.check_utility_code_needed_and_register(name):
+            if utility_code.requires:
+                for dependency in utility_code.requires:
+                    self.use_utility_code(dependency)
             if utility_code.proto:
                 self.utilprotowriter.put(utility_code.proto)
             if utility_code.impl:
index a54070b25516c099ba8f155360884cbaf5254b63..811ad4e95bd0cf211ebfc437213276b8230f90d0 100644 (file)
@@ -92,11 +92,12 @@ def long_literal(value):
 # a simple class that simplifies the usage of utility code
 
 class UtilityCode(object):
-    def __init__(self, proto=None, impl=None, init=None, cleanup=None):
+    def __init__(self, proto=None, impl=None, init=None, cleanup=None, requires=None):
         self.proto = proto
         self.impl = impl
         self.init = init
         self.cleanup = cleanup
+        self.requires = requires
 
     def write_init_code(self, writer, pos):
         if not self.init: