[Lldb-commits] [lldb] r136147 - /lldb/trunk/scripts/Python/python-wrapper.swig

Enrico Granata granata.enrico at gmail.com
Tue Jul 26 14:02:56 PDT 2011


Author: enrico
Date: Tue Jul 26 16:02:56 2011
New Revision: 136147

URL: http://llvm.org/viewvc/llvm-project?rev=136147&view=rev
Log:
adding required utility function to SWIG interface

Modified:
    lldb/trunk/scripts/Python/python-wrapper.swig

Modified: lldb/trunk/scripts/Python/python-wrapper.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-wrapper.swig?rev=136147&r1=136146&r2=136147&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-wrapper.swig (original)
+++ lldb/trunk/scripts/Python/python-wrapper.swig Tue Jul 26 16:02:56 2011
@@ -508,6 +508,49 @@
     return 0;
 }
 
+SWIGEXPORT void
+LLDBSwigPython_UpdateSynthProviderInstance
+(
+    PyObject *implementor
+)
+{
+    static char callee_name[] = "update";
+
+    if (implementor == NULL || implementor == Py_None)
+        return;
+
+    // all this code is here because update is optional, so we don't want to bother trying to call it unless it's been def:ined for us
+    // other synth provider calls are mandatory, so we want to fail in a very obvious way if they are missing!
+    PyObject* pmeth  = PyObject_GetAttrString(implementor, callee_name);
+
+    if (pmeth == NULL || pmeth == Py_None)
+    {
+        Py_XDECREF(pmeth);
+        return;
+    }
+
+    if (PyCallable_Check(pmeth) == 0)
+    {
+        Py_XDECREF(pmeth);
+        return;
+    }
+
+    Py_XDECREF(pmeth);
+
+    // right now we know this function exists and is callable..
+    PyObject* py_return = PyObject_CallMethod(implementor, callee_name, NULL);
+    
+    // if it fails, print the error but otherwise go on
+    if (PyErr_Occurred())
+    {
+        PyErr_Print();
+        PyErr_Clear();
+    }
+
+    Py_XDECREF(py_return);
+
+}
+
 SWIGEXPORT lldb::SBValue*
 LLDBSWIGPython_CastPyObjectToSBValue
 (





More information about the lldb-commits mailing list