[Lldb-commits] [lldb] r218812 - Add an accessor to PyCallable that allows one to determine the count of arguments that a Python function allows, and whether varargs/kwargs are also accepted by the same function
Enrico Granata
egranata at apple.com
Wed Oct 1 13:51:50 PDT 2014
Author: enrico
Date: Wed Oct 1 15:51:50 2014
New Revision: 218812
URL: http://llvm.org/viewvc/llvm-project?rev=218812&view=rev
Log:
Add an accessor to PyCallable that allows one to determine the count of arguments that a Python function allows, and whether varargs/kwargs are also accepted by the same function
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=218812&r1=218811&r2=218812&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-wrapper.swig (original)
+++ lldb/trunk/scripts/Python/python-wrapper.swig Wed Oct 1 15:51:50 2014
@@ -105,7 +105,32 @@ FindSessionDictionary(const char *sessio
class PyCallable
{
public:
-
+ struct argc {
+ size_t num_args;
+ bool varargs : 1;
+ bool kwargs : 1;
+ };
+
+ argc
+ GetNumArguments ()
+ {
+ if (m_callable && PyFunction_Check(m_callable))
+ {
+ PyCodeObject* code = (PyCodeObject*)PyFunction_GET_CODE(m_callable);
+ if (code)
+ {
+ size_t args = code->co_argcount;
+ bool va=false,kw=false;
+ if ((code->co_flags & 4) == 4)
+ va = true;
+ if ((code->co_flags & 8) == 8)
+ kw = true;
+ return {args,va,kw};
+ }
+ }
+ return {SIZE_MAX,false,false};
+ }
+
operator
bool ()
{
More information about the lldb-commits
mailing list