lldb.swig revision 3cfd5e89ce6b66f271727032b36afb635287a24b
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) lldb.swig 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) This is the input file for SWIG, to create the appropriate C++ wrappers and 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) functions for various scripting languages, to enable them to call the 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) liblldb Script Bridge functions. 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Define our module docstring. */ 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%define DOCSTRING 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)"The lldb module contains the public APIs for Python binding. 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)Some of the important classes are describe here: 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBTarget: Represents the target program running under the debugger. 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBProcess: Represents the process associated with the target program. 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBThread: Represents a thread of execution. SBProcess contains SBThread(s). 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBFrame: Represents one of the stack frames associated with a thread. SBThread 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) contains SBFrame(s). 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBSymbolContext: A container that stores various debugger related info. 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBValue: Represents the value of a variable, a register, or an expression. 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBModule: Represents an executable image and its associated object and symbol 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) files. SBTarget conatins SBModule(s). 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBBreakpoint: Represents a logical breakpoint and its associated settings. 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SBTarget conatins SBBreakpoint(s). 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBSymbol: Represents the symbol possibly associated with a stack frame. 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBCompileUnit: Represents a compilation unit, or compiled source file. 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBFunction: Represents a generic function, which can be inlined or not. 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBBlock: Represents a lexical block. SBFunction contains SBBlock(s). 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)o SBLineEntry: Specifies an association with a contiguous range of instructions 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) and a source file location. SBCompileUnit contains SBLineEntry(s)." 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%enddef 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The name of the module to be created. 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%module(docstring=DOCSTRING) lldb 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Parameter types will be used in the autodoc string. 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%feature("autodoc", "1"); 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */ 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%typemap(in) char ** { 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /* Check if is a list */ 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (PyList_Check($input)) { 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int size = PyList_Size($input); 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int i = 0; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $1 = (char **) malloc((size+1) * sizeof(char*)); 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) for (i = 0; i < size; i++) { 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PyObject *o = PyList_GetItem($input,i); 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (PyString_Check(o)) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $1[i] = PyString_AsString(o); 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) else { 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PyErr_SetString(PyExc_TypeError,"list must contain strings"); 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) free($1); 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return NULL; 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $1[i] = 0; 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else if ($input == Py_None) { 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $1 = NULL; 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PyErr_SetString(PyExc_TypeError,"not a list"); 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return NULL; 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%typemap(freearg) char** { 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) free((char *) $1); 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%typemap(out) char** { 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int len; 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int i; 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) len = 0; 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) while ($1[len]) len++; 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $result = PyList_New(len); 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) for (i = 0; i < len; i++) { 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PyList_SetItem($result, i, PyString_FromString($1[i])); 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Typemap definitions to allow SWIG to properly handle char buffer. */ 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// typemap for a char buffer 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// See also SBThread::GetStopDescription. 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%typemap(in) (char *dst, size_t dst_len) { 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!PyInt_Check($input)) { 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PyErr_SetString(PyExc_ValueError, "Expecting an integer"); 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return NULL; 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $2 = PyInt_AsLong($input); 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if ($2 <= 0) { 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PyErr_SetString(PyExc_ValueError, "Positive integer expected"); 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return NULL; 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $1 = (char *) malloc($2); 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Return the char buffer. Discarding any previous return result 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// See also SBThread::GetStopDescription. 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)%typemap(argout) (char *dst, size_t dst_len) { 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Py_XDECREF($result); /* Blow away any previous result */ 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) $result = PyString_FromStringAndSize(($1),result); 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) free($1); 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 107 108// typemap for an outgoing buffer 109// 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. 119%typemap(in) (const void *buf, size_t size) { 120 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 129// See also SBProcess::ReadMemory. 130%typemap(in) (void *buf, size_t size) { 131 if (!PyInt_Check($input)) { 132 PyErr_SetString(PyExc_ValueError, "Expecting an integer"); 133 return NULL; 134 } 135 $2 = PyInt_AsLong($input); 136 if ($2 <= 0) { 137 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 144// See also SBProcess::ReadMemory. 145%typemap(argout) (void *buf, size_t size) { 146 Py_XDECREF($result); /* Blow away any previous result */ 147 $result = PyString_FromStringAndSize(static_cast<const char*>($1),result); 148 free($1); 149} 150 151/* The liblldb header files to be included. */ 152 153%{ 154#include "lldb/lldb-public.h" 155#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" 160#include "lldb/API/SBCommandInterpreter.h" 161#include "lldb/API/SBCommandReturnObject.h" 162#include "lldb/API/SBCommunication.h" 163#include "lldb/API/SBCompileUnit.h" 164#include "lldb/API/SBDebugger.h" 165#include "lldb/API/SBError.h" 166#include "lldb/API/SBEvent.h" 167#include "lldb/API/SBFileSpec.h" 168#include "lldb/API/SBFrame.h" 169#include "lldb/API/SBFunction.h" 170#include "lldb/API/SBHostOS.h" 171#include "lldb/API/SBInputReader.h" 172#include "lldb/API/SBInstruction.h" 173#include "lldb/API/SBInstructionList.h" 174#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" 179#include "lldb/API/SBStream.h" 180#include "lldb/API/SBStringList.h" 181#include "lldb/API/SBSymbol.h" 182#include "lldb/API/SBSymbolContext.h" 183#include "lldb/API/SBSymbolContextList.h" 184#include "lldb/API/SBTarget.h" 185#include "lldb/API/SBThread.h" 186#include "lldb/API/SBType.h" 187#include "lldb/API/SBValue.h" 188#include "lldb/API/SBValueList.h" 189%} 190 191/* Various liblldb typedefs that SWIG needs to know about. */ 192#define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */ 193%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" 199%include "./Python/interface/SBAddress.i" 200%include "./Python/interface/SBBlock.i" 201%include "./Python/interface/SBBreakpoint.i" 202%include "./Python/interface/SBBreakpointLocation.i" 203%include "lldb/API/SBBroadcaster.h" 204%include "lldb/API/SBCommandInterpreter.h" 205%include "lldb/API/SBCommandReturnObject.h" 206%include "lldb/API/SBCommunication.h" 207%include "lldb/API/SBCompileUnit.h" 208%include "lldb/API/SBDebugger.h" 209%include "lldb/API/SBError.h" 210%include "lldb/API/SBEvent.h" 211%include "lldb/API/SBFileSpec.h" 212%include "./Python/interface/SBFrame.i" 213%include "lldb/API/SBFunction.h" 214%include "lldb/API/SBHostOS.h" 215%include "lldb/API/SBInputReader.h" 216%include "lldb/API/SBInstruction.h" 217%include "lldb/API/SBInstructionList.h" 218%include "lldb/API/SBLineEntry.h" 219%include "lldb/API/SBListener.h" 220%include "lldb/API/SBModule.h" 221%include "./Python/interface/SBProcess.i" 222%include "lldb/API/SBSourceManager.h" 223%include "lldb/API/SBStream.h" 224%include "lldb/API/SBStringList.h" 225%include "lldb/API/SBSymbol.h" 226%include "lldb/API/SBSymbolContext.h" 227%include "lldb/API/SBSymbolContextList.h" 228%include "./Python/interface/SBTarget.i" 229%include "./Python/interface/SBThread.i" 230%include "lldb/API/SBType.h" 231%include "./Python/interface/SBValue.i" 232%include "./Python/interface/SBValueList.i" 233 234%include "./Python/python-extensions.swig" 235 236 237%wrapper %{ 238 239// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...) 240// and is used when a script command is attached to a breakpoint for execution. 241 242SWIGEXPORT bool 243LLDBSwigPythonBreakpointCallbackFunction 244( 245 const char *python_function_name, 246 const char *session_dictionary_name, 247 const lldb::StackFrameSP& frame_sp, 248 const lldb::BreakpointLocationSP& bp_loc_sp 249) 250{ 251 lldb::SBFrame sb_frame (frame_sp); 252 lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp); 253 254 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); 257 258 if (Frame_PyObj == NULL || Bp_Loc_PyObj == NULL) 259 return stop_at_breakpoint; 260 261 if (!python_function_name || !session_dictionary_name) 262 return stop_at_breakpoint; 263 264 PyObject *pmodule, *main_dict, *session_dict, *pfunc; 265 PyObject *pargs, *pvalue; 266 267 pmodule = PyImport_AddModule ("__main__"); 268 if (pmodule != NULL) 269 { 270 main_dict = PyModule_GetDict (pmodule); 271 if (main_dict != NULL) 272 { 273 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 321 if (pfunc && PyCallable_Check (pfunc)) 322 { 323 pargs = PyTuple_New (3); 324 if (pargs == NULL) 325 { 326 if (PyErr_Occurred()) 327 PyErr_Clear(); 328 return stop_at_breakpoint; 329 } 330 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 333 PyTuple_SetItem (pargs, 2, session_dict); // This "steals" a reference to session_dict 334 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 ()) 342 { 343 PyErr_Clear(); 344 } 345 Py_INCREF (session_dict); 346 } 347 else if (PyErr_Occurred()) 348 { 349 PyErr_Clear(); 350 } 351 } 352 else if (PyErr_Occurred()) 353 { 354 PyErr_Clear(); 355 } 356 } 357 else if (PyErr_Occurred ()) 358 { 359 PyErr_Clear (); 360 } 361 return stop_at_breakpoint; 362} 363 364SWIGEXPORT 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 { 466 PyErr_Print(); 467 PyErr_Clear(); 468 } 469 Py_INCREF (session_dict); 470 } 471 else if (PyErr_Occurred()) 472 { 473 PyErr_Print(); 474 PyErr_Clear(); 475 } 476 } 477 else if (PyErr_Occurred()) 478 { 479 PyErr_Print(); 480 PyErr_Clear(); 481 } 482 } 483 else if (PyErr_Occurred ()) 484 { 485 PyErr_Print(); 486 PyErr_Clear (); 487 } 488 return retval; 489} 490 491 492%} 493