Maybe fix #473 -- MSVC strict about variable declaration placement.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sat, 9 Jan 2010 08:23:13 +0000 (00:23 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sat, 9 Jan 2010 08:23:13 +0000 (00:23 -0800)
Cython/Compiler/Code.py
Cython/Compiler/Nodes.py

index b514047e6ec2f6a29ec14ca013108a5212b493fb..bdc697e033333b36588fee1a003f56d3e441ff02 100644 (file)
@@ -1281,6 +1281,9 @@ class CCodeWriter(object):
     def put_finish_refcount_context(self):
         self.putln("__Pyx_RefNannyFinishContext();")
 
+    def put_trace_declarations(self):
+        self.putln('__Pyx_TraceDeclarations');
+    
     def put_trace_call(self, name, pos):
         self.putln('__Pyx_TraceCall("%s", %s[%s], %s);' % (name, Naming.filetable_cname, self.lookup_filename(pos[0]), pos[1]));
     
index 11a8fc80ef2000d84d09d2c922bd7d1be1b02edb..6c3b101a41e569452127d7a717d0f0c4f159832b 100644 (file)
@@ -1086,6 +1086,8 @@ class FuncDefNode(StatNode, BlockNode):
                     init))
         tempvardecl_code = code.insertion_point()
         self.generate_keyword_list(code)
+        if profile:
+            code.put_trace_declarations()
         # ----- Extern library function declarations
         lenv.generate_library_function_declarations(code)
         # ----- GIL acquisition
@@ -5779,10 +5781,12 @@ profile_utility_code = UtilityCode(proto="""
 #define CYTHON_FRAME_DEL Py_DECREF(%(FRAME)s)
 #endif
 
+#define __Pyx_TraceDeclarations                                  \\
+static PyCodeObject *%(FRAME_CODE)s = NULL;                      \\
+CYTHON_FRAME_MODIFIER PyFrameObject *%(FRAME)s = NULL;           \\
+int __Pyx_use_tracing = 0;                                                         
+
 #define __Pyx_TraceCall(funcname, srcfile, firstlineno)                            \\
-static PyCodeObject *%(FRAME_CODE)s = NULL;                                        \\
-CYTHON_FRAME_MODIFIER PyFrameObject *%(FRAME)s = NULL;                             \\
-int __Pyx_use_tracing = 0;                                                         \\
 if (unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc)) {      \\
     __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&%(FRAME_CODE)s, &%(FRAME)s, funcname, srcfile, firstlineno);  \\
 }
@@ -5808,6 +5812,7 @@ static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const cha
 static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, const char *funcname, const char *srcfile, int firstlineno); /*proto*/
 
 #else
+#define __Pyx_TraceDeclarations
 #define __Pyx_TraceCall(funcname, srcfile, firstlineno) 
 #define __Pyx_TraceException() 
 #define __Pyx_TraceReturn(result)