From 2621466b2119907fdec4b2fba858a448d5f37388 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 9 Jan 2010 00:23:13 -0800 Subject: [PATCH] Maybe fix #473 -- MSVC strict about variable declaration placement. --- Cython/Compiler/Code.py | 3 +++ Cython/Compiler/Nodes.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index b514047e..bdc697e0 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -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])); diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 11a8fc80..6c3b101a 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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) -- 2.26.2