split refnanny setup macro in declaration and setup part
authorStefan Behnel <scoder@users.berlios.de>
Sat, 11 Dec 2010 01:12:14 +0000 (02:12 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 11 Dec 2010 01:12:14 +0000 (02:12 +0100)
Cython/Compiler/Code.py
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py

index 6ebe5b19600cc7574f7d300b60bf82e9e9159a3b..58c0599d6521368cbc282ed8fefe117c696738c4 100644 (file)
@@ -475,6 +475,7 @@ class GlobalState(object):
         w.enter_cfunc_scope()
         w.putln("")
         w.putln("static int __Pyx_InitCachedConstants(void) {")
+        w.put_declare_refcount_context()
         w.put_setup_refcount_context("__Pyx_InitCachedConstants")
 
         w = self.parts['init_globals']
@@ -1344,6 +1345,9 @@ class CCodeWriter(object):
     def lookup_filename(self, filename):
         return self.globalstate.lookup_filename(filename)
 
+    def put_declare_refcount_context(self):
+        self.putln('__Pyx_RefNannyDeclareContext')
+
     def put_setup_refcount_context(self, name):
         self.putln('__Pyx_RefNannySetupContext("%s");' % name)
 
index c39128feb9532aee006e5b56305de2d73f9fe9a7..d46d605e9b8b7a0995407914c3b4fb46c3b61fdb 100644 (file)
@@ -2575,8 +2575,9 @@ refnanny_utility_code = UtilityCode(proto="""
     Py_XDECREF(m);
     return (__Pyx_RefNannyAPIStruct *)r;
   }
+  #define __Pyx_RefNannyDeclareContext void *__pyx_refnanny;
   #define __Pyx_RefNannySetupContext(name) \
-          void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
   #define __Pyx_RefNannyFinishContext() \
           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
   #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
@@ -2585,6 +2586,7 @@ refnanny_utility_code = UtilityCode(proto="""
   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
   #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
 #else
+  #define __Pyx_RefNannyDeclareContext
   #define __Pyx_RefNannySetupContext(name)
   #define __Pyx_RefNannyFinishContext()
   #define __Pyx_INCREF(r) Py_INCREF(r)
index eaae035152b21b741a3b1ae390f39ce575d797f8..ebb25d140f0c72434e032c07d01333be85fef4f1 100644 (file)
@@ -1296,6 +1296,7 @@ class FuncDefNode(StatNode, BlockNode):
                     (self.return_type.declaration_code(Naming.retval_cname),
                      init))
         tempvardecl_code = code.insertion_point()
+        code.put_declare_refcount_context()
         if not self.is_generator:
             self.generate_keyword_list(code)
         if profile:
@@ -1918,6 +1919,7 @@ class GeneratorWrapperNode(object):
         code.enter_cfunc_scope()
         code.putln()
         code.putln('%s {' % self.header)
+        code.put_declare_refcount_context()
         self.def_node.generate_keyword_list(code)
         code.put(lenv.scope_class.type.declaration_code(Naming.cur_scope_cname))
         code.putln(";")