1 |
#ifdef ASCXX_USE_PYTHON |
#include "config.h" |
2 |
# include <Python.h> |
#include "reporter.h" |
|
#endif |
|
3 |
|
|
4 |
#include <cstdio> |
#include <cstdio> |
5 |
#include <iostream> |
#include <iostream> |
6 |
using namespace std; |
using namespace std; |
7 |
|
|
8 |
#include "reporter.h" |
#ifndef ASCXX_USE_PYTHON |
9 |
|
# error "Where's ASCXX_USE_PYTHON?" |
10 |
|
#endif |
11 |
|
|
12 |
|
|
13 |
static const int REPORTER_MAX_ERROR_MSG = 1024; |
static const int REPORTER_MAX_ERROR_MSG = 1024; |
14 |
|
|
63 |
Reporter::reportErrorPython(ERROR_REPORTER_CALLBACK_ARGS){ |
Reporter::reportErrorPython(ERROR_REPORTER_CALLBACK_ARGS){ |
64 |
PyObject *pyfunc, *pyarglist, *pyresult; |
PyObject *pyfunc, *pyarglist, *pyresult; |
65 |
pyfunc = (PyObject *)client_data; |
pyfunc = (PyObject *)client_data; |
66 |
|
|
67 |
char msg[REPORTER_MAX_ERROR_MSG]; |
char msg[REPORTER_MAX_ERROR_MSG]; |
68 |
vsprintf(msg,fmt,args); |
vsprintf(msg,fmt,args); |
69 |
|
|
70 |
//cerr << "reportErrorPython: msg=" << msg ; |
cerr << "reportErrorPython: msg=" << msg ; |
71 |
//cerr << "reportErrorPython: pyfunc=" << pyfunc << endl; |
cerr << "reportErrorPython: pyfunc=" << pyfunc << endl; |
72 |
|
|
73 |
pyarglist = Py_BuildValue("(H,z,i,z)",sev,filename,line,msg); // Build argument list |
pyarglist = Py_BuildValue("(H,z,i,z)",sev,filename,line,msg); // Build argument list |
74 |
pyresult = PyEval_CallObject(pyfunc,pyarglist); // Call Python |
pyresult = PyEval_CallObject(pyfunc,pyarglist); // Call Python |
75 |
Py_DECREF(pyarglist); // Trash arglist |
Py_DECREF(pyarglist); // Trash arglist |
81 |
}else{ |
}else{ |
82 |
//cerr << "pyresult = 0"<< endl; |
//cerr << "pyresult = 0"<< endl; |
83 |
} |
} |
84 |
|
|
85 |
Py_XDECREF(pyresult); |
Py_XDECREF(pyresult); |
86 |
return res; |
return res; |
87 |
} |
} |
88 |
|
|
89 |
void |
void |