diff options
author | Enrico Granata <granata.enrico@gmail.com> | 2011-07-26 21:02:56 +0000 |
---|---|---|
committer | Enrico Granata <granata.enrico@gmail.com> | 2011-07-26 21:02:56 +0000 |
commit | 0efa71aeb6e19c058ea0028d321dcdda1fd01232 (patch) | |
tree | 51e4bbee890e3673dbfd4784225c3be2f9a01677 /lldb/scripts/Python/python-wrapper.swig | |
parent | 2833ad13f0b89d5d9d143894b6b81ecc4bed938a (diff) | |
download | bcm5719-llvm-0efa71aeb6e19c058ea0028d321dcdda1fd01232.tar.gz bcm5719-llvm-0efa71aeb6e19c058ea0028d321dcdda1fd01232.zip |
adding required utility function to SWIG interface
llvm-svn: 136147
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r-- | lldb/scripts/Python/python-wrapper.swig | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig index 28fd1006913..35aa7514e4c 100644 --- a/lldb/scripts/Python/python-wrapper.swig +++ b/lldb/scripts/Python/python-wrapper.swig @@ -508,6 +508,49 @@ LLDBSwigPython_GetIndexOfChildWithName 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 ( |