summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/python-wrapper.swig
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2014-10-08 18:27:36 +0000
committerEnrico Granata <egranata@apple.com>2014-10-08 18:27:36 +0000
commitd07cfd3ae4c6a99d06c67549d7a946a870ce228a (patch)
treec684371dc7d2ea6d6cab1835ebb1a4d32bb1a652 /lldb/scripts/Python/python-wrapper.swig
parentef9bc3d85761d560b36990d5acf74e4e466c64b0 (diff)
downloadbcm5719-llvm-d07cfd3ae4c6a99d06c67549d7a946a870ce228a.tar.gz
bcm5719-llvm-d07cfd3ae4c6a99d06c67549d7a946a870ce228a.zip
Extend synthetic children to produce synthetic values (as in, those that GetValueAsUnsigned(), GetValueAsCString() would return)
The way to do this is to write a synthetic child provider for your type, and have it vend the (optional) get_value function. If get_value is defined, and it returns a valid SBValue, that SBValue's value (as in lldb_private::Value) will be used as the synthetic ValueObject's Value The rationale for doing things this way is twofold: - there are many possible ways to define a "value" (SBData, a Python number, ...) but SBValue seems general enough as a thing that stores a "value", so we just trade values that way and that keeps our currency trivial - we could introduce a new level of layering (ValueObjectSyntheticValue), a new kind of formatter (synthetic value producer), but that would complicate the model (can I have a dynamic with no synthetic children but synthetic value? synthetic value with synthetic children but no dynamic?), and I really couldn't see much benefit to be reaped from this added complexity in the matrix On the other hand, just defining a synthetic child provider with a get_value but returning no actual children is easy enough that it's not a significant road-block to adoption of this feature Comes with a test case llvm-svn: 219330
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r--lldb/scripts/Python/python-wrapper.swig28
1 files changed, 28 insertions, 0 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig
index bf22198f4e4..9f9ebaded9d 100644
--- a/lldb/scripts/Python/python-wrapper.swig
+++ b/lldb/scripts/Python/python-wrapper.swig
@@ -723,6 +723,34 @@ LLDBSwigPython_MightHaveChildrenSynthProviderInstance
return ret_val;
}
+SWIGEXPORT PyObject*
+LLDBSwigPython_GetValueSynthProviderInstance
+(
+ PyObject *implementor
+)
+{
+ PyObject* ret_val = nullptr;
+
+ static char callee_name[] = "get_value";
+
+ PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name, Py_None);
+
+ if (py_return == Py_None || py_return == nullptr)
+ ret_val = nullptr;
+
+ lldb::SBValue* sbvalue_ptr = NULL;
+
+ if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1)
+ ret_val = nullptr;
+ else if (sbvalue_ptr == NULL)
+ ret_val = nullptr;
+ else
+ ret_val = py_return;
+
+ Py_XDECREF(py_return);
+ return ret_val;
+}
+
SWIGEXPORT void*
LLDBSWIGPython_CastPyObjectToSBValue
(
OpenPOWER on IntegriCloud