blob: 103ee020605a01c3c4a11a8445285ac192b90b50 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001/*
2 lldb.swig
3
Chris Lattner30fdc8d2010-06-08 16:52:24 +00004 This is the input file for SWIG, to create the appropriate C++ wrappers and
5 functions for various scripting languages, to enable them to call the
6 liblldb Script Bridge functions.
Chris Lattner30fdc8d2010-06-08 16:52:24 +00007*/
8
Johnny Chenee481782011-06-30 21:29:50 +00009/* Define our module docstring. */
10%define DOCSTRING
11"The lldb module contains the public APIs for Python binding.
Chris Lattner30fdc8d2010-06-08 16:52:24 +000012
Johnny Chenee481782011-06-30 21:29:50 +000013Some of the important classes are describe here:
14
15o SBTarget: Represents the target program running under the debugger.
16o SBProcess: Represents the process associated with the target program.
17o SBThread: Represents a thread of execution. SBProcess contains SBThread(s).
18o SBFrame: Represents one of the stack frames associated with a thread. SBThread
19 contains SBFrame(s).
20o SBSymbolContext: A container that stores various debugger related info.
21o SBValue: Represents the value of a variable, a register, or an expression.
22o SBModule: Represents an executable image and its associated object and symbol
Johnny Chen4036b582011-07-14 21:32:11 +000023 files. SBTarget conatins SBModule(s).
24o SBBreakpoint: Represents a logical breakpoint and its associated settings.
25 SBTarget conatins SBBreakpoint(s).
Johnny Chen993f2b62011-07-14 21:23:24 +000026o SBSymbol: Represents the symbol possibly associated with a stack frame.
Johnny Chenee481782011-06-30 21:29:50 +000027o SBCompileUnit: Represents a compilation unit, or compiled source file.
28o SBFunction: Represents a generic function, which can be inlined or not.
29o SBBlock: Represents a lexical block. SBFunction contains SBBlock(s).
30o SBLineEntry: Specifies an association with a contiguous range of instructions
Johnny Chen61abb2a2011-07-01 18:39:47 +000031 and a source file location. SBCompileUnit contains SBLineEntry(s)."
Johnny Chenee481782011-06-30 21:29:50 +000032%enddef
33
Johnny Chen9ffc9f72011-07-16 21:27:36 +000034// The name of the module to be created.
Johnny Chenee481782011-06-30 21:29:50 +000035%module(docstring=DOCSTRING) lldb
36
Johnny Chen9ffc9f72011-07-16 21:27:36 +000037// Parameter types will be used in the autodoc string.
38%feature("autodoc", "1");
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039
Chris Lattner30fdc8d2010-06-08 16:52:24 +000040/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */
41
42%typemap(in) char ** {
43 /* Check if is a list */
44 if (PyList_Check($input)) {
45 int size = PyList_Size($input);
46 int i = 0;
Greg Claytonca512b32011-01-14 04:54:56 +000047 $1 = (char **) malloc((size+1) * sizeof(char*));
Chris Lattner30fdc8d2010-06-08 16:52:24 +000048 for (i = 0; i < size; i++) {
49 PyObject *o = PyList_GetItem($input,i);
50 if (PyString_Check(o))
Greg Claytonca512b32011-01-14 04:54:56 +000051 $1[i] = PyString_AsString(o);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000052 else {
53 PyErr_SetString(PyExc_TypeError,"list must contain strings");
54 free($1);
55 return NULL;
56 }
57 }
58 $1[i] = 0;
Caroline Ticeebc1bb22010-06-30 16:22:25 +000059 } else if ($input == Py_None) {
60 $1 = NULL;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000061 } else {
62 PyErr_SetString(PyExc_TypeError,"not a list");
63 return NULL;
64 }
65}
66
67%typemap(freearg) char** {
68 free((char *) $1);
69}
70
71%typemap(out) char** {
72 int len;
73 int i;
74 len = 0;
75 while ($1[len]) len++;
76 $result = PyList_New(len);
77 for (i = 0; i < len; i++) {
78 PyList_SetItem($result, i, PyString_FromString($1[i]));
79 }
80}
81
Johnny Chen2f6f7ba2011-03-07 21:28:57 +000082/* Typemap definitions to allow SWIG to properly handle char buffer. */
83
84// typemap for a char buffer
85// See also SBThread::GetStopDescription.
86%typemap(in) (char *dst, size_t dst_len) {
87 if (!PyInt_Check($input)) {
88 PyErr_SetString(PyExc_ValueError, "Expecting an integer");
89 return NULL;
90 }
91 $2 = PyInt_AsLong($input);
Johnny Chende8241c2011-03-23 00:26:08 +000092 if ($2 <= 0) {
Johnny Chen2f6f7ba2011-03-07 21:28:57 +000093 PyErr_SetString(PyExc_ValueError, "Positive integer expected");
94 return NULL;
95 }
96 $1 = (char *) malloc($2);
97}
98
99// Return the char buffer. Discarding any previous return result
100// See also SBThread::GetStopDescription.
101%typemap(argout) (char *dst, size_t dst_len) {
102 Py_XDECREF($result); /* Blow away any previous result */
103 $result = PyString_FromStringAndSize(($1),result);
104 free($1);
105}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000106
Greg Claytonca512b32011-01-14 04:54:56 +0000107
108// typemap for an outgoing buffer
Johnny Chen3a709ac2011-07-08 23:02:33 +0000109// See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len).
110%typemap(in) (const char *cstr, uint32_t cstr_len) {
111 if (!PyString_Check($input)) {
112 PyErr_SetString(PyExc_ValueError, "Expecting a string");
113 return NULL;
114 }
115 $1 = (char *) PyString_AsString($input);
116 $2 = PyString_Size($input);
117}
118// And SBProcess::WriteMemory.
Johnny Chen37f99fd2011-03-01 02:20:14 +0000119%typemap(in) (const void *buf, size_t size) {
Greg Claytonca512b32011-01-14 04:54:56 +0000120 if (!PyString_Check($input)) {
121 PyErr_SetString(PyExc_ValueError, "Expecting a string");
122 return NULL;
123 }
124 $1 = (void *) PyString_AsString($input);
125 $2 = PyString_Size($input);
126}
127
128// typemap for an incoming buffer
Johnny Chen2f6f7ba2011-03-07 21:28:57 +0000129// See also SBProcess::ReadMemory.
Johnny Chen37f99fd2011-03-01 02:20:14 +0000130%typemap(in) (void *buf, size_t size) {
Greg Claytonca512b32011-01-14 04:54:56 +0000131 if (!PyInt_Check($input)) {
132 PyErr_SetString(PyExc_ValueError, "Expecting an integer");
133 return NULL;
134 }
135 $2 = PyInt_AsLong($input);
Johnny Chende8241c2011-03-23 00:26:08 +0000136 if ($2 <= 0) {
Greg Claytonca512b32011-01-14 04:54:56 +0000137 PyErr_SetString(PyExc_ValueError, "Positive integer expected");
138 return NULL;
139 }
140 $1 = (void *) malloc($2);
141}
142
143// Return the buffer. Discarding any previous return result
Johnny Chen2f6f7ba2011-03-07 21:28:57 +0000144// See also SBProcess::ReadMemory.
Johnny Chen37f99fd2011-03-01 02:20:14 +0000145%typemap(argout) (void *buf, size_t size) {
Greg Claytonca512b32011-01-14 04:54:56 +0000146 Py_XDECREF($result); /* Blow away any previous result */
Johnny Chen37f99fd2011-03-01 02:20:14 +0000147 $result = PyString_FromStringAndSize(static_cast<const char*>($1),result);
Greg Claytonca512b32011-01-14 04:54:56 +0000148 free($1);
149}
150
Greg Claytonc0cc73e2010-06-12 15:34:20 +0000151/* The liblldb header files to be included. */
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000152
153%{
Greg Claytone0d378b2011-03-24 21:19:54 +0000154#include "lldb/lldb-public.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000155#include "lldb/API/SBAddress.h"
156#include "lldb/API/SBBlock.h"
157#include "lldb/API/SBBreakpoint.h"
158#include "lldb/API/SBBreakpointLocation.h"
159#include "lldb/API/SBBroadcaster.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000160#include "lldb/API/SBCommandInterpreter.h"
161#include "lldb/API/SBCommandReturnObject.h"
Greg Clayton05faeb72010-10-07 04:19:01 +0000162#include "lldb/API/SBCommunication.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000163#include "lldb/API/SBCompileUnit.h"
164#include "lldb/API/SBDebugger.h"
165#include "lldb/API/SBError.h"
166#include "lldb/API/SBEvent.h"
Johnny Chen23fd10c2010-08-27 22:35:26 +0000167#include "lldb/API/SBFileSpec.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000168#include "lldb/API/SBFrame.h"
169#include "lldb/API/SBFunction.h"
Greg Clayton05faeb72010-10-07 04:19:01 +0000170#include "lldb/API/SBHostOS.h"
171#include "lldb/API/SBInputReader.h"
Greg Clayton1d273162010-10-06 03:09:58 +0000172#include "lldb/API/SBInstruction.h"
173#include "lldb/API/SBInstructionList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000174#include "lldb/API/SBLineEntry.h"
175#include "lldb/API/SBListener.h"
176#include "lldb/API/SBModule.h"
177#include "lldb/API/SBProcess.h"
178#include "lldb/API/SBSourceManager.h"
Caroline Ticedde9cff2010-09-20 05:20:02 +0000179#include "lldb/API/SBStream.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000180#include "lldb/API/SBStringList.h"
181#include "lldb/API/SBSymbol.h"
182#include "lldb/API/SBSymbolContext.h"
Greg Clayton05faeb72010-10-07 04:19:01 +0000183#include "lldb/API/SBSymbolContextList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000184#include "lldb/API/SBTarget.h"
185#include "lldb/API/SBThread.h"
186#include "lldb/API/SBType.h"
187#include "lldb/API/SBValue.h"
Caroline Tice77404122010-09-22 16:41:52 +0000188#include "lldb/API/SBValueList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000189%}
190
191/* Various liblldb typedefs that SWIG needs to know about. */
Johnny Chen4b332092010-12-16 00:01:06 +0000192#define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */
Greg Clayton05faeb72010-10-07 04:19:01 +0000193%include <stdint.h>
194%include "lldb/lldb-defines.h"
195%include "lldb/lldb-enumerations.h"
196%include "lldb/lldb-forward.h"
197%include "lldb/lldb-forward-rtti.h"
198%include "lldb/lldb-types.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000199%include "lldb/API/SBAddress.h"
200%include "lldb/API/SBBlock.h"
201%include "lldb/API/SBBreakpoint.h"
202%include "lldb/API/SBBreakpointLocation.h"
203%include "lldb/API/SBBroadcaster.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000204%include "lldb/API/SBCommandInterpreter.h"
205%include "lldb/API/SBCommandReturnObject.h"
Greg Clayton05faeb72010-10-07 04:19:01 +0000206%include "lldb/API/SBCommunication.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000207%include "lldb/API/SBCompileUnit.h"
208%include "lldb/API/SBDebugger.h"
209%include "lldb/API/SBError.h"
210%include "lldb/API/SBEvent.h"
Johnny Chen23fd10c2010-08-27 22:35:26 +0000211%include "lldb/API/SBFileSpec.h"
Johnny Chen357033b2011-07-18 20:13:38 +0000212%include "./Python/interface/SBFrame.i"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000213%include "lldb/API/SBFunction.h"
Greg Clayton05faeb72010-10-07 04:19:01 +0000214%include "lldb/API/SBHostOS.h"
215%include "lldb/API/SBInputReader.h"
Greg Clayton1d273162010-10-06 03:09:58 +0000216%include "lldb/API/SBInstruction.h"
217%include "lldb/API/SBInstructionList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000218%include "lldb/API/SBLineEntry.h"
219%include "lldb/API/SBListener.h"
220%include "lldb/API/SBModule.h"
Johnny Chen357033b2011-07-18 20:13:38 +0000221%include "./Python/interface/SBProcess.i"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000222%include "lldb/API/SBSourceManager.h"
Caroline Ticedde9cff2010-09-20 05:20:02 +0000223%include "lldb/API/SBStream.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000224%include "lldb/API/SBStringList.h"
225%include "lldb/API/SBSymbol.h"
226%include "lldb/API/SBSymbolContext.h"
Greg Clayton05faeb72010-10-07 04:19:01 +0000227%include "lldb/API/SBSymbolContextList.h"
Johnny Chendc7d3c12011-07-16 21:15:39 +0000228%include "./Python/interface/SBTarget.i"
Johnny Chen357033b2011-07-18 20:13:38 +0000229%include "./Python/interface/SBThread.i"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000230%include "lldb/API/SBType.h"
Johnny Chen67ae7bd2011-07-18 19:08:30 +0000231%include "./Python/interface/SBValue.i"
232%include "./Python/interface/SBValueList.i"
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000233
Caroline Ticedac97f32010-09-22 23:01:29 +0000234%include "./Python/python-extensions.swig"
Caroline Tice18474c92010-09-27 18:00:20 +0000235
236
237%wrapper %{
238
Greg Claytonc6ed5422010-10-07 17:14:24 +0000239// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...)
240// and is used when a script command is attached to a breakpoint for execution.
Caroline Tice18474c92010-09-27 18:00:20 +0000241
Greg Claytonc6ed5422010-10-07 17:14:24 +0000242SWIGEXPORT bool
Greg Claytonfc36f7912011-03-22 01:14:58 +0000243LLDBSwigPythonBreakpointCallbackFunction
Greg Clayton05faeb72010-10-07 04:19:01 +0000244(
Greg Claytonc6ed5422010-10-07 17:14:24 +0000245 const char *python_function_name,
Caroline Tice2f88aad2011-01-14 00:29:16 +0000246 const char *session_dictionary_name,
Greg Claytonfc36f7912011-03-22 01:14:58 +0000247 const lldb::StackFrameSP& frame_sp,
248 const lldb::BreakpointLocationSP& bp_loc_sp
Greg Clayton05faeb72010-10-07 04:19:01 +0000249)
Caroline Tice18474c92010-09-27 18:00:20 +0000250{
Greg Claytonfc36f7912011-03-22 01:14:58 +0000251 lldb::SBFrame sb_frame (frame_sp);
252 lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp);
253
Greg Claytonc6ed5422010-10-07 17:14:24 +0000254 bool stop_at_breakpoint = true;
255 PyObject *Frame_PyObj = SWIG_NewPointerObj((void *) &sb_frame, SWIGTYPE_p_lldb__SBFrame, 0);
256 PyObject *Bp_Loc_PyObj = SWIG_NewPointerObj ((void *) &sb_bp_loc, SWIGTYPE_p_lldb__SBBreakpointLocation, 0);
Caroline Tice18474c92010-09-27 18:00:20 +0000257
Greg Claytonc6ed5422010-10-07 17:14:24 +0000258 if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL)
259 return stop_at_breakpoint;
Caroline Tice2f88aad2011-01-14 00:29:16 +0000260
261 if (!python_function_name || !session_dictionary_name)
262 return stop_at_breakpoint;
Greg Claytonc6ed5422010-10-07 17:14:24 +0000263
Caroline Tice2f88aad2011-01-14 00:29:16 +0000264 PyObject *pmodule, *main_dict, *session_dict, *pfunc;
Greg Claytonc6ed5422010-10-07 17:14:24 +0000265 PyObject *pargs, *pvalue;
Caroline Tice18474c92010-09-27 18:00:20 +0000266
Greg Claytonc6ed5422010-10-07 17:14:24 +0000267 pmodule = PyImport_AddModule ("__main__");
268 if (pmodule != NULL)
Caroline Tice18474c92010-09-27 18:00:20 +0000269 {
Caroline Tice2f88aad2011-01-14 00:29:16 +0000270 main_dict = PyModule_GetDict (pmodule);
271 if (main_dict != NULL)
Caroline Tice18474c92010-09-27 18:00:20 +0000272 {
Caroline Tice2f88aad2011-01-14 00:29:16 +0000273 PyObject *key, *value;
274 Py_ssize_t pos = 0;
275
276 // Find the current session's dictionary in the main module's dictionary.
277
278 if (PyDict_Check (main_dict))
279
280 {
281 session_dict = NULL;
282 while (PyDict_Next (main_dict, &pos, &key, &value))
283 {
284 // We have stolen references to the key and value objects in the dictionary; we need to increment
285 // them now so that Python's garbage collector doesn't collect them out from under us.
286 Py_INCREF (key);
287 Py_INCREF (value);
288 if (strcmp (PyString_AsString (key), session_dictionary_name) == 0)
289 {
290 session_dict = value;
291 break;
292 }
293 }
294 }
295
296 if (!session_dict || !PyDict_Check (session_dict))
297 return stop_at_breakpoint;
298
299 // Find the function we need to call in the current session's dictionary.
300
301 pos = 0;
302 pfunc = NULL;
303 while (PyDict_Next (session_dict, &pos, &key, &value))
304 {
305 if (PyString_Check (key))
306 {
307 // We have stolen references to the key and value objects in the dictionary; we need to increment
308 // them now so that Python's garbage collector doesn't collect them out from under us.
309 Py_INCREF (key);
310 Py_INCREF (value);
311 if (strcmp (PyString_AsString (key), python_function_name) == 0)
312 {
313 pfunc = value;
314 break;
315 }
316 }
317 }
318
319 // Set up the arguments and call the function.
320
Greg Claytonc6ed5422010-10-07 17:14:24 +0000321 if (pfunc && PyCallable_Check (pfunc))
Caroline Tice18474c92010-09-27 18:00:20 +0000322 {
Caroline Tice2f88aad2011-01-14 00:29:16 +0000323 pargs = PyTuple_New (3);
Greg Claytonc6ed5422010-10-07 17:14:24 +0000324 if (pargs == NULL)
Caroline Tice18474c92010-09-27 18:00:20 +0000325 {
Greg Claytonc6ed5422010-10-07 17:14:24 +0000326 if (PyErr_Occurred())
Caroline Tice18474c92010-09-27 18:00:20 +0000327 PyErr_Clear();
Greg Claytonc6ed5422010-10-07 17:14:24 +0000328 return stop_at_breakpoint;
Caroline Tice18474c92010-09-27 18:00:20 +0000329 }
Greg Claytonc6ed5422010-10-07 17:14:24 +0000330
331 PyTuple_SetItem (pargs, 0, Frame_PyObj); // This "steals" a reference to Frame_PyObj
332 PyTuple_SetItem (pargs, 1, Bp_Loc_PyObj); // This "steals" a reference to Bp_Loc_PyObj
Caroline Tice2f88aad2011-01-14 00:29:16 +0000333 PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict
Greg Claytonc6ed5422010-10-07 17:14:24 +0000334 pvalue = PyObject_CallObject (pfunc, pargs);
335 Py_DECREF (pargs);
336
337 if (pvalue != NULL)
338 {
339 Py_DECREF (pvalue);
340 }
341 else if (PyErr_Occurred ())
Caroline Tice18474c92010-09-27 18:00:20 +0000342 {
343 PyErr_Clear();
344 }
Caroline Tice2f88aad2011-01-14 00:29:16 +0000345 Py_INCREF (session_dict);
Caroline Tice18474c92010-09-27 18:00:20 +0000346 }
347 else if (PyErr_Occurred())
348 {
349 PyErr_Clear();
350 }
351 }
Greg Claytonc6ed5422010-10-07 17:14:24 +0000352 else if (PyErr_Occurred())
Caroline Tice18474c92010-09-27 18:00:20 +0000353 {
Greg Claytonc6ed5422010-10-07 17:14:24 +0000354 PyErr_Clear();
Caroline Tice18474c92010-09-27 18:00:20 +0000355 }
356 }
Greg Claytonc6ed5422010-10-07 17:14:24 +0000357 else if (PyErr_Occurred ())
358 {
359 PyErr_Clear ();
360 }
361 return stop_at_breakpoint;
Caroline Tice18474c92010-09-27 18:00:20 +0000362}
363
Enrico Granataf2bbf712011-07-15 02:26:42 +0000364SWIGEXPORT std::string
365LLDBSwigPythonCallTypeScript
366(
367 const char *python_function_name,
368 const char *session_dictionary_name,
369 const lldb::ValueObjectSP& valobj_sp
370)
371{
372 lldb::SBValue sb_value (valobj_sp);
373
374 std::string retval = "";
375
376 PyObject *ValObj_PyObj = SWIG_NewPointerObj((void *) &valobj_sp, SWIGTYPE_p_lldb__SBValue, 0);
377
378 if (ValObj_PyObj == NULL)
379 return retval;
380
381 if (!python_function_name || !session_dictionary_name)
382 return retval;
383
384 PyObject *pmodule, *main_dict, *session_dict, *pfunc;
385 PyObject *pargs, *pvalue;
386
387 pmodule = PyImport_AddModule ("__main__");
388 if (pmodule != NULL)
389 {
390 main_dict = PyModule_GetDict (pmodule);
391 if (main_dict != NULL)
392 {
393 PyObject *key, *value;
394 Py_ssize_t pos = 0;
395
396 // Find the current session's dictionary in the main module's dictionary.
397
398 if (PyDict_Check (main_dict))
399
400 {
401 session_dict = NULL;
402 while (PyDict_Next (main_dict, &pos, &key, &value))
403 {
404 // We have stolen references to the key and value objects in the dictionary; we need to increment
405 // them now so that Python's garbage collector doesn't collect them out from under us.
406 Py_INCREF (key);
407 Py_INCREF (value);
408 if (strcmp (PyString_AsString (key), session_dictionary_name) == 0)
409 {
410 session_dict = value;
411 break;
412 }
413 }
414 }
415
416 if (!session_dict || !PyDict_Check (session_dict))
417 return retval;
418
419 // Find the function we need to call in the current session's dictionary.
420
421 pos = 0;
422 pfunc = NULL;
423 while (PyDict_Next (session_dict, &pos, &key, &value))
424 {
425 if (PyString_Check (key))
426 {
427 // We have stolen references to the key and value objects in the dictionary; we need to increment
428 // them now so that Python's garbage collector doesn't collect them out from under us.
429 Py_INCREF (key);
430 Py_INCREF (value);
431 if (strcmp (PyString_AsString (key), python_function_name) == 0)
432 {
433 pfunc = value;
434 break;
435 }
436 }
437 }
438
439 // Set up the arguments and call the function.
440
441 if (pfunc && PyCallable_Check (pfunc))
442 {
443 pargs = PyTuple_New (2);
444 if (pargs == NULL)
445 {
446 if (PyErr_Occurred())
447 PyErr_Clear();
448 return retval;
449 }
450
451 PyTuple_SetItem (pargs, 0, ValObj_PyObj); // This "steals" a reference to ValObj_PyObj
452 PyTuple_SetItem (pargs, 1, session_dict); // This "steals" a reference to session_dict
453 pvalue = PyObject_CallObject (pfunc, pargs);
454 Py_DECREF (pargs);
455
456 if (pvalue != NULL)
457 {
458 if (pvalue != Py_None)
459 retval = std::string(PyString_AsString(pvalue));
460 else
461 retval = "None";
462 Py_DECREF (pvalue);
463 }
464 else if (PyErr_Occurred ())
465 {
Enrico Granata03f16a02011-07-18 16:24:10 +0000466 PyErr_Print();
Enrico Granataf2bbf712011-07-15 02:26:42 +0000467 PyErr_Clear();
468 }
469 Py_INCREF (session_dict);
470 }
471 else if (PyErr_Occurred())
472 {
Enrico Granata03f16a02011-07-18 16:24:10 +0000473 PyErr_Print();
Enrico Granataf2bbf712011-07-15 02:26:42 +0000474 PyErr_Clear();
475 }
476 }
477 else if (PyErr_Occurred())
478 {
Enrico Granata03f16a02011-07-18 16:24:10 +0000479 PyErr_Print();
Enrico Granataf2bbf712011-07-15 02:26:42 +0000480 PyErr_Clear();
481 }
482 }
483 else if (PyErr_Occurred ())
484 {
Enrico Granata03f16a02011-07-18 16:24:10 +0000485 PyErr_Print();
Enrico Granataf2bbf712011-07-15 02:26:42 +0000486 PyErr_Clear ();
487 }
488 return retval;
489}
490
491
Caroline Tice18474c92010-09-27 18:00:20 +0000492%}